@nexconn/call 26.1.0 → 26.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,n,r,i=require("@nexconn/chat"),a=require("@nexconn/engine");function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t,n){return t=h(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,p()?Reflect.construct(t,n||[],h(e).constructor):t.apply(e,n))}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,L(r.key),r)}}function l(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=y(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=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=n.call(e)},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 d(e,t,n){return(t=L(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},f.apply(null,arguments)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&T(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function E(){
2
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
- var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function a(n,r,i,a){var c=r&&r.prototype instanceof s?r:s,u=Object.create(c.prototype);return v(u,"_invoke",function(n,r,i){var a,s,c,u=0,l=i||[],_=!1,d={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return a=t,s=0,c=e,d.n=n,o}};function f(n,r){for(s=n,c=r,t=0;!_&&u&&!i&&t<l.length;t++){var i,a=l[t],f=d.p,h=a[2];n>3?(i=h===r)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=f&&((i=n<2&&f<a[1])?(s=0,d.v=r,d.n=a[1]):f<h&&(i=n<3||a[0]>r||r>h)&&(a[4]=n,a[5]=r,d.n=h,s=0))}if(i||n>1)return o;throw _=!0,r}return function(i,l,h){if(u>1)throw TypeError("Generator is already running");for(_&&1===l&&f(l,h),s=l,c=h;(t=s<2?e:c)||!_;){a||(s?s<3?(s>1&&(d.n=-1),f(s,c)):d.n=c:d.v=c);try{if(u=2,a){if(s||(i="next"),t=a[i]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=a.return)&&t.call(a),s<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=e}else if((t=(_=d.n<0)?c:n.call(r,d))!==o)break}catch(t){a=e,s=1,c=t}finally{u=1}}return{value:t,done:_}}}(n,i,a),!0),u}var o={};function s(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(v(t={},r,function(){return this}),t),_=u.prototype=s.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,v(e,i,"GeneratorFunction")),e.prototype=Object.create(_),e}return c.prototype=u,v(_,"constructor",u),v(u,"constructor",c),c.displayName="GeneratorFunction",v(u,i,"GeneratorFunction"),v(_),v(_,i,"Generator"),v(_,r,function(){return this}),v(_,"toString",function(){return"[object Generator]"}),(E=function(){return{w:a,m:d}})()}function v(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}v=function(e,t,n,r){function a(t,n){v(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},v(e,t,n,r)}function m(e){var t=Object(e),n=[];for(var r in t)n.unshift(r);return function e(){for(;n.length;)if((r=n.pop())in t)return e.value=r,e.done=!1,e;return e.done=!0,e}}function R(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function T(e,t){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},T(e,t)}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],c=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t,n,r){var i=f(h(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function C(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(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 L(e){var t=function(e,t){if("object"!=typeof e||!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:t+""}function O(e){return O="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},O(e)}function y(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.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)?o(e,t):void 0}}function b(e){var t="function"==typeof Map?new Map:void 0;return b=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(p())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&T(i,n.prototype),i}(e,arguments,h(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),T(n,e)},b(e)}!function(e){e[e.PRIVATE=1]="PRIVATE",e[e.GROUP=2]="GROUP",e[e.SYSTEM=3]="SYSTEM",e[e.CUSTOM=4]="CUSTOM",e[e.RTC_ROOM=7]="RTC_ROOM"}(e||(e={})),function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED",e[e.SUSPENDED=3]="SUSPENDED"}(t||(t={})),function(e){e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error",e[e.STATISTICS=6]="STATISTICS"}(n||(n={})),function(e){e.RTC="RTC",e.CallPlus="CallPlus"}(r||(r={}));var A=function(){return l(function e(t){c(this,e),Object.defineProperty(this,"_writer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:0})},[{key:"debug",value:function(e,t,r){this._writer.writeLog(n.Debug,e,null!=t?t:"",r)}},{key:"info",value:function(e,t,r){this._writer.writeLog(n.Info,e,null!=t?t:"",r)}},{key:"warn",value:function(e,t,r){this._writer.writeLog(n.Warn,e,null!=t?t:"",r)}},{key:"error",value:function(e,t,r){this._writer.writeLog(n.Error,e,null!=t?t:"",r)}},{key:"createTraceId",value:function(){return"".concat(++this._traceId)}},{key:"setOutputLevel",value:function(e){this._writer.setOutputLevel(e)}},{key:"__statistics",value:function(e,t,r){this._writer.writeLog(n.STATISTICS,e,null!=t?t:"",r)}}])}(),N=d(d(d(d(d(d({},a.ConversationType.PRIVATE,e.PRIVATE),a.ConversationType.GROUP,e.GROUP),a.ConversationType.SYSTEM,e.SYSTEM),a.ConversationType.CHATROOM,e.CUSTOM),a.ConversationType.APP_PUBLIC_SERVICE,e.RTC_ROOM),a.ConversationType.RTC_ROOM,e.RTC_ROOM),k=d(d(d(d(d({},e.PRIVATE,a.ConversationType.PRIVATE),e.GROUP,a.ConversationType.GROUP),e.SYSTEM,a.ConversationType.SYSTEM),e.CUSTOM,a.ConversationType.CHATROOM),e.RTC_ROOM,a.ConversationType.APP_PUBLIC_SERVICE),P={toCommon:function(e){var t;return null!==(t=N[e])&&void 0!==t?t:e},toNative:function(e){var t;return null!==(t=k[e])&&void 0!==t?t:e}},U=d(d(d(d({},a.RCConnectionStatus.CONNECTED,t.CONNECTED),a.RCConnectionStatus.CONNECTING,t.CONNECTING),a.RCConnectionStatus.DISCONNECTED,t.DISCONNECTED),a.RCConnectionStatus.SUSPENDED,t.SUSPENDED),w=d(d(d(d({},t.DISCONNECTED,a.RCConnectionStatus.DISCONNECTED),t.CONNECTING,a.RCConnectionStatus.CONNECTING),t.CONNECTED,a.RCConnectionStatus.CONNECTED),t.SUSPENDED,a.RCConnectionStatus.SUSPENDED),D={toNative:function(e){return Object.assign({},e)}},M={toCommon:function(e){return e},toNative:function(e){return e}},x=P,V={toCommon:function(e){var t;return null!==(t=U[e])&&void 0!==t?t:e},toNative:function(e){var t;return null!==(t=w[e])&&void 0!==t?t:e}},B=D,G={toCommon:function(e){return e}},j={toCommon:function(e){var t,n,r;return{voipCallInfo:null!==(t=e.voipCallInfo)&&void 0!==t?t:void 0,rtcAISwitch:e.rtcAISwitch,jwtToken:null!==(n=e.jwtToken)&&void 0!==n?n:e.jwt,logServer:e.logServer,dataCenter:null!==(r=e.dataCenter)&&void 0!==r?r:e.dc,openGzip:e.openGzip,ipType:e.ipType}}};function F(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})}function H(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function J(e){var t,i=this,a={logger:(r.RTC,t=e.createLogger("NCCall","RTC"),new A({writeLog:function(e,r,i,a){switch(e){case n.Debug:t.debug(r,i,a);break;case n.Info:t.info(r,i,a);break;case n.Warn:t.warn(r,i,a);break;case n.Error:t.error(r,i,a);break;case n.STATISTICS:t.__statistics(r,i,a);break;default:t.info(r,i,a)}},setOutputLevel:function(e){t.setOutputLevel(e)}})),rtcSignaling:function(t,n,r,i){return F(this,void 0,void 0,E().m(function a(){var o;return E().w(function(a){for(;;)switch(a.n){case 0:return a.n=1,e.rtcSignaling(t,n,r,i);case 1:return o=a.v,a.a(2,{code:M.toCommon(null==o?void 0:o.code),buffer:null==o?void 0:o.buffer})}},a)}))},registerRTCSignalListener:function(t){e.registerRTCSignalListener(t)},sendGroupCallSignalInfo:function(t,n,r){return F(this,void 0,void 0,E().m(function i(){var a;return E().w(function(i){for(;;)switch(i.n){case 0:return i.n=1,e.setCallInfo(t,n,r);case 1:return a=i.v,i.a(2,{code:M.toCommon(a.code),data:a.data})}},i)}))},registerGroupCallSignalInfoListener:function(t){e.onCallInfo=function(e){t(e)}},setOnnavidatachange:function(t){var n=t?function(e){var n=j.toCommon(e);t(n)}:void 0;e.onnavidatachange=n},refetchNaviInfo:e.refetchNaviInfo?function(){return F(i,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.refetchNaviInfo();case 1:return t.a(2)}},t)}))}:void 0,registerConnectionStateChangeListener:function(t){e.onconnectionstatechange=function(e,n){t(V.toCommon(e),M.toCommon(null!=n?n:0))}},registerDisconnectListener:function(t){e.ondisconnect=t},registerDestroyListener:function(t){e.ondestroy=t},registerMessageListener:function(t){var n=t?function(e){return t(G.toCommon(e))}:void 0;e.onmessage=n},sendMessage:function(t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s;return E().w(function(i){for(;;)switch(i.n){case 0:return a=x.toNative(t),o=B.toNative(r),i.n=1,e.sendMessage(a,n,o);case 1:return s=i.v,i.a(2,{code:M.toCommon(s.code),data:void 0!==s.data?G.toCommon(s.data):void 0})}},i)}))},getCurrentId:function(){return e.getCurrentId()},getNaviInfo:function(){var t=e.getNaviInfo();return null!=t?j.toCommon(t):null},getConnectionStatus:function(){return V.toCommon(e.getConnectionStatus())},getAppkey:function(){return e.getAppkey()},getCoreVersion:function(){return e.getCoreVersion()},registerMessageType:function(t,n,r,i){e.registerMessageType(t,n,r,i)}};return e.rtcPingResVersion&&(a.rtcPingResVersion=function(t,n,r){return F(i,void 0,void 0,E().m(function i(){var a;return E().w(function(i){for(;;)switch(i.n){case 0:return i.n=1,e.rtcPingResVersion(t,n,r);case 1:return a=i.v,i.a(2,{code:M.toCommon(a.code),data:a.data})}},i)}))}),a}"function"==typeof SuppressedError&&SuppressedError;var K,Y=function(e){return"string"==typeof e},q=function(e){return"boolean"==typeof e},W=function(e){return"number"==typeof e&&!Number.isNaN(e)},z=function(e){return-1!==Object.prototype.toString.call(e).indexOf("Array")},Q=function(e){return Y(e)&&e.length>0},Z=function(e){return z(e)&&e.length>0},X=function(e){return"[object Object]"===Object.prototype.toString.call(e)},$=function(e){return"function"==typeof e},ee=function(e){return void 0===e||"[object Undefined]"===Object.prototype.toString.call(e)},te=function(e){return Y(e)&&/https?:\/\//.test(e)};!function(e){e[e.STRING=0]="STRING",e[e.ONLY_STRING=1]="ONLY_STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.OBJECT=4]="OBJECT",e[e.ARRAY=5]="ARRAY",e[e.CALLBACK=6]="CALLBACK"}(K||(K={}));var ne,re,ie,ae=d(d(d(d(d(d(d({},K.STRING,Q),K.ONLY_STRING,Y),K.NUMBER,W),K.BOOLEAN,function(e){return"boolean"==typeof e}),K.OBJECT,X),K.ARRAY,z),K.CALLBACK,function(e){var t=!0;return X(e)||(t=!1),(e=e||{}).onSuccess&&!$(e.onSuccess)&&(t=!1),e.onError&&!$(e.onError)&&(t=!1),t}),oe=function(){function e(t){var n;return c(this,e),(n=s(this,e,[t])).name="RCAssertError",n}return g(e,b(Error)),l(e)}(),se=function(e,t,n){if(!ce(e,t,n,arguments.length>3&&void 0!==arguments[3]&&arguments[3]))throw new oe("'".concat(e,"' is invalid: ").concat(JSON.stringify(t)))},ce=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];n=ae[n]||n;var i=r?n(t):ee(t)||null==t||n(t);return i||null===console||void 0===console||console.error("'".concat(e,"' is invalid: ").concat(JSON.stringify(t))),i},ue=function(){return l(function e(){c(this,e),Object.defineProperty(this,"_map",{enumerable:!0,configurable:!0,writable:!0,value:{}})},[{key:"on",value:function(e,t,n){var r=this._map[e]||(this._map[e]=[]);r.some(function(e){return e.listener===t&&e.target===n})||r.push({listener:t,target:n})}},{key:"once",value:function(e,t,n){var r=this._map[e]||(this._map[e]=[]);r.some(function(e){return e.listener===t&&e.target===n})||r.push({listener:t,target:n,once:!0})}},{key:"off",value:function(e,t,n){var r=this._map[e];r&&((r=r.filter(function(e){return e.listener!==t||e.target!==n})).length?this._map[e]=r:delete this._map[e])}},{key:"emit",value:function(e){var t=this._map[e];if(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];for(var a=0;a<t.length;a+=1){var o=t[a],s=o.target,c=o.once,u=o.listener;c&&(t.splice(a,1),a-=1);try{u.call.apply(u,[s].concat(r))}catch(e){null===console||void 0===console||console.error(e)}}}}},{key:"removeAll",value:function(e){delete this._map[e]}},{key:"clear",value:function(){Object.keys(this._map).forEach(this.removeAll,this)}}])}();function le(e,t){var n;if(!e)return"";var r="undefined"!=typeof window&&"https:"===(null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.protocol);return/^https?:\/\//.test(e)?r?e.replace(/^https?:\/\//i,"https://"):e:t!==ie.HTTP||r?"https://".concat(e):"http://".concat(e)}!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT"}(ne||(ne={})),function(e){e.WIFI="wifi",e.FOUR_G="4g",e.THREE_G="3g",e.TWO_G="2g",e.FIVE_G="2g",e.THREE_GENT="3gnet",e.UNKONWN="unknown"}(re||(re={})),function(e){e[e.RMTP=1]="RMTP",e[e.TLS=2]="TLS",e[e.RPP=3]="RPP",e[e.QUIC=4]="QUIC",e[e.WS=5]="WS",e[e.WSS=6]="WSS",e[e.HTTP=11]="HTTP",e[e.HTTPS=12]="HTTPS"}(ie||(ie={}));var _e,de=function(e,t,n){var r=null==n?void 0:n.isReverse;X(e)&&function(){for(var n in e)t(e[n],n,e)}(),(z(e)||Y(e))&&function(){if(r)for(var n=e.length-1;n>=0;n--)t(e[n],n);else for(var i=0,a=e.length;i<a;i++)t(e[i],i)}()};!function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE",e[e.SIP=4]="SIP",e[e.CALL=5]="CALL",e[e.MEETING=6]="MEETING",e[e.CROSS_MUTI=7]="CROSS_MUTI",e[e.CROSS_LIVE=8]="CROSS_LIVE"}(_e||(_e={}));var fe=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.floor(36*Math.random());return("x"===e?t:3&t|8).toString(36)})},he=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:22,n=Date.now(),r=n.toString(36),i=Math.floor(Math.random()*n).toString(36),a=t-r.length-i.length;return[i,r,a>0?(e=a,Array.from({length:e}).map(function(){return Math.floor(36*Math.random()).toString(36)}).join("")):""].join("").slice(0,t)},ge=function(){return l(function e(t,n){var r=this;c(this,e),Object.defineProperty(this,"_promise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_resolve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_onCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._promise=new Promise(function(e){r._resolve=e,t(r._onResolve.bind(r))}),this._onCancel=n},[{key:"_onResolve",value:function(e){this._resolve(e)}},{key:"result",value:function(){return this._promise}},{key:"abort",value:function(){this._onCancel(this._onResolve.bind(this))}}])}();function pe(e){var t=e.method||ne.GET,n=e.timeout||6e4,r=e.headers,i=e.query,a=e.body,o=e.onProgress,s=function(e,t){if(e=e.replace(/\?$/,""),!t)return e;var n=Object.keys(t).map(function(e){return"".concat(e,"=").concat(t[e])}).filter(function(e){return!!e});return n.length?[e,n.join("&")].join("?"):e}(e.url,i),c=new XMLHttpRequest;if(c.open(t,s),r&&c.setRequestHeader)for(var u in r)c.setRequestHeader(u,r[u]);return function(e,t,n,r){return new ge(function(i){e.onreadystatechange=function(){4===e.readyState&&i({data:e.responseText,status:e.status,xhr:e})},e.onerror=function(){i({status:e.status})},r&&(e.upload.onprogress=function(e){return r(e)}),0!==t&&setTimeout(function(){e.abort(),i({status:e.status})},t),e.send(n)},function(t){e.abort(),t({status:-1})})}(c,n,a,o)}var Ee,ve,me,Re=function(){return l(function e(t,n,r){c(this,e),Object.defineProperty(this,"isOk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"msg",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isOk=0===t,this.code=t,this.msg=n,this.data=r},[{key:"next",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)switch(t.n){case 0:if(!this.isOk){t.n=1;break}return t.a(2,e(this.data));case 1:return t.a(2,this.wipe())}},t,this)}))}},{key:"or",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)switch(t.n){case 0:if(!this.isOk){t.n=1;break}return t.a(2,this);case 1:return t.a(2,e(this.code))}},t,this)}))}},{key:"orSync",value:function(e){return this.isOk?this:e(this.code)}},{key:"trans",value:function(e){return this.isOk?Te(e(this.data)):this.wipe()}},{key:"tryTrans",value:function(e){return this.isOk?e(this.data):this.wipe()}},{key:"errmsg",value:function(){return JSON.stringify({code:this.code,msg:this.msg})}},{key:"wipe",value:function(){return this.isOk?Te(void 0,this.msg):Ie(this.code,this.msg)}}])}(),Te=function(e,t){return new Re(0,t||"success",e)},Ie=function(e,t,n){return new Re(e,t||"fail: ".concat(e),n)},Se=function(){var e,t=new Promise(function(t){e=t});return{resolve:e,promise:t}},Ce=function(){return l(function e(t){c(this,e),Ee.add(this),ve.set(this,void 0),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),function(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===r?i.call(e,n):i?i.value=n:t.set(e,n)}(this,ve,t,"f"),this._logger=t.logger},[{key:"open",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)if(0===t.n)return e=e.sort(function(e,t){return t.weight-e.weight}),t.a(2,H(this,Ee,"m",me).call(this,e,H(this,ve,"f")))},t,this)}))}}])}();ve=new WeakMap,Ee=new WeakSet,me=function e(t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s=this;return E().w(function(r){for(;;)switch(r.n){case 0:if(0!==t.length){r.n=1;break}return r.a(2,Ie(39005,"All addrs failed"));case 1:return i=t.shift(),a=le(i.addr,i.protocol),a="".concat(a,"/v3/message/get_stream.json?sdkVersion=","26.1.0","&platform=Websocket&messageUID=").concat(n.msgUId),this._logger.info("L-req_stream_msg_content-O","try open -> ".concat(a)),r.n=2,this._openHandler(a,n);case 2:return o=r.v,r.a(2,o.or(function(r){return F(s,void 0,void 0,E().m(function i(){return E().w(function(i){for(;;)switch(i.n){case 0:if(-1!==r){i.n=1;break}return i.a(2,H(this,Ee,"m",e).call(this,t,n));case 1:return i.a(2,o)}},i,this)}))}))}},r,this)}))};var Le=function(){function e(){return c(this,e),s(this,e,arguments)}return g(e,Ce),l(e,[{key:"_openHandler",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s=this;return E().w(function(n){for(;;)if(0===n.n)return r=Se(),i=r.resolve,a=r.promise,(o=new XMLHttpRequest).open("GET",e,!0),o.timeout=t.timeout,o.ontimeout=function(){s._logger.warn("L-req_stream_msg_content-E","timeout -> ".concat(e)),i(Ie(-1,"timeout"))},o.onreadystatechange=function(n){if(o.readyState===XMLHttpRequest.HEADERS_RECEIVED){var r=o.getResponseHeader("Content-Type"),a=null==r?void 0:r.startsWith("text/event-stream");if(200===o.status&&a){i(Te());var c=0;o.onprogress=function(e){var n=o.response.slice(c);c=o.response.length,t.onRawContent(n)},o.onerror=function(n){s._logger.warn("L-req_stream_msg_content-E","network error in transit -> ".concat(e)),o.onprogress=null,o.abort(),t.onNetworkError(39005)}}else o.onloadend=function(){var e=JSON.parse(o.response);i(Ie(e.code,e.message))}}},o.onerror=function(t){s._logger.warn("L-req_stream_msg_content-E","req fail -> ".concat(e)),i(Ie(-1))},o.setRequestHeader("Content-Type","application/json;charset=UTF-8"),o.setRequestHeader("App-Key",t.appkey),o.setRequestHeader("Authorization","Bearer ".concat(t.token)),o.send(),n.a(2,a)},n)}))}}])}(),Oe=!("undefined"==typeof uni||!function(e){for(var t=["request","getSystemInfo"],n=0,r=t.length;n<r;n++)if(!e[t[n]])return!1;return!0}(uni));var ye=null,be=function(e){return F(void 0,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,Pe.getNetworkType();case 1:n=t.v,ye({status:"online"===e.type,type:n});case 2:return t.a(2)}},t)}))};var Ae,Ne,ke,Pe={tag:"browser",httpReq:function(e){return pe(e).result()},localStorage:null===window||void 0===window?void 0:window.localStorage,sessionStorage:null===window||void 0===window?void 0:window.sessionStorage,useNavi:!0,connectPlatform:"",isFromUniapp:Oe,createWebSocket:function(e,t){var n=new WebSocket(e,t);return n.binaryType="arraybuffer",Promise.resolve(Te({id:Date.now(),onClose:function(e){n.onclose=function(t){var n=t.code,r=t.reason;e(n,r)}},onError:function(e){n.onerror=e},onMessage:function(e){n.onmessage=function(t){e(t.data)}},onOpen:function(e){n.onopen=e},send:function(e){n.send(e)},close:function(e,t){n.close()}}))},getNetworkType:function(){var e=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{effectiveType:re.UNKONWN},t=e.type,n=e.effectiveType,r=t||n||re.UNKONWN;return Promise.resolve(r)},setNetworkStatusListener:function(e){ye=e,"undefined"!=typeof window&&window&&(window.addEventListener("offline",be),window.addEventListener("online",be))},removeNetworkStatusListener:function(){"undefined"!=typeof window&&window&&(window.removeEventListener("offline",be),window.removeEventListener("online",be)),ye=null},createSSEClient:function(e){return Te(new Le(e))},getApiVer:function(){var e=Pe.runtimeInfo,t=e.type,n=e.version;return"|".concat(t,"|").concat(n)},get runtimeInfo(){var e,t,n=navigator.userAgent,r={IE:/rv:([\d.]+)\) like Gecko|MSIE ([\d.]+)/,Edge:/Edge\/([\d.]+)/,Firefox:/Firefox\/([\d.]+)/,Opera:/(?:OPERA|OPR).([\d.]+)/,WeChat:/MicroMessenger\/([\d.]+)/,QQBrowser:/QQBrowser\/([\d.]+)/,Chrome:/Chrome\/([\d.]+)/,Safari:/Version\/([\d.]+).*Safari/,iOSChrome:/Mobile\/([\d.]+).*Safari/};for(var i in r)if(r.hasOwnProperty(i)){var a=n.match(r[i]);if(a){t=i,e=a[1]||a[2];break}}return{type:t||"Unknown",version:e||"Unknown"}}},Ue=Pe,we=0,De=2,Me=-1,xe=30001,Ve=30002,Be=30003;!function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.PB_ERROR=40001]="PB_ERROR",e[e.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",e[e.PARAMS_ERROR=50001]="PARAMS_ERROR",e[e.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",e[e.NOT_IN_ROOM=50003]="NOT_IN_ROOM",e[e.SERVICE_INVALID=50004]="SERVICE_INVALID",e[e.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",e[e.ASR_NOT_AVAILABLE=50034]="ASR_NOT_AVAILABLE",e[e.ASR_NOT_START=50035]="ASR_NOT_START",e[e.SIGNAL_ERROR=53001]="SIGNAL_ERROR",e[e.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",e[e.REQUEST_FAILED=53004]="REQUEST_FAILED",e[e.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",e[e.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",e[e.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",e[e.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",e[e.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",e[e.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",e[e.BROWSER_PERMISSION_DENIED=53012]="BROWSER_PERMISSION_DENIED",e[e.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",e[e.INVALID_TAGS=53014]="INVALID_TAGS",e[e.INVALID_USER_ID=53015]="INVALID_USER_ID",e[e.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",e[e.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",e[e.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",e[e.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",e[e.TRACK_NOT_READY=53020]="TRACK_NOT_READY",e[e.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",e[e.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",e[e.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",e[e.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",e[e.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",e[e.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",e[e.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",e[e.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",e[e.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",e[e.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM",e[e.SOME_TRACKS_PUBLISH_FAILED=53031]="SOME_TRACKS_PUBLISH_FAILED",e[e.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO=53032]="MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO",e[e.JWT_TIME_OUT=1004]="JWT_TIME_OUT",e[e.SYSTEM_PERMISSION_DENIED=53033]="SYSTEM_PERMISSION_DENIED",e[e.PUBLISH_TRACKS_IS_INVALID=53034]="PUBLISH_TRACKS_IS_INVALID",e[e.TRACK_READYSTATE_IS_ENDED=53035]="TRACK_READYSTATE_IS_ENDED",e[e.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH=53036]="APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH",e[e.LOAD_3A_MODULE_FAILED=53037]="LOAD_3A_MODULE_FAILED"}(Ae||(Ae={})),function(e){e.L_INDEX_INSTALL_RTC_PLUGIN_O="L-index_install_rtc_plugin-O",e.L_RTC_CLIENT_IM_CONNECTION_STATE_S="L-rtc_client_im_connection_state-S",e.L_RTC_CLIENT_MESSAGE_O="L-rtc_client_message-O",e.L_RTC_CLIENT_DESTROY_S="L-rtc_client_destroy-S",e.L_RTC_CLIENT_JOIN_RTC_ROOM_T="L-rtc_client_join_rtc_room-T",e.L_RTC_CLIENT_JOIN_RTC_ROOM_O="L-rtc_client_join_rtc_room-O",e.L_RTC_CLIENT_JOIN_RTC_ROOM_R="L-rtc_client_join_rtc_room-R",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_T="L-rtc_client_join_living_room-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_R="L-rtc_client_join_living_room-R",e.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O="L-rtc_client_get_audience_client-O",e.L_RTC_CLIENT_LEAVE_ROOM_T="L-rtc_client_leave_room-T",e.L_RTC_CLIENT_LEAVE_ROOM_R="L-rtc_client_leave_room-R",e.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O="L-rtc_client_create_microphone_audio_track-O",e.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O="L-rtc_client_create_camera_video_track-O",e.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O="L-rtc_client_create_microphone_and_camera_tracks-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O="L-rtc_client_create_screen_video_track-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O="L-rtc_client_create_screen_video_and_audio_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O="L-rtc_client_create_local_audio_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O="L-rtc_client_create_local_video_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O="L-rtc_client_create_local_file_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O="L-rtc_client_create_local_tracks-O",e.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O="L-rtc_client_apply_video_aspect_ratio-O",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_join_living_room_as_audience-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_join_living_room_as_audience_R",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_leave_living_room_as_audience-T",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_leave_living_room_as_audience-R",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T="L-rtc_client_upgrade_to_anchor_room-T",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R="L-rtc_client_upgrade_to_anchor_room-R",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T="L-rtc_client_downgrade_to_audience_room-T",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R="L-rtc_client_downgrade_to_audience_room-R",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T="L-rtc_client_get_joined_room_info-T",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R="L-rtc_client_get_joined_room_info-R",e.L_RTC_CLIENT_GENERATE_SUMMARIZATION_T="L-rtc_client_generate_summarization-T",e.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R="L-rtc_client_generate_summarization-R",e.L_RTC_CLIENT_GET_ASR_CONTENT_T="L-rtc_client_get_asr_content-T",e.L_RTC_CLIENT_GET_ASR_CONTENT_R="L-rtc_client_get_asr_content-R",e.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O="L-audinence_client_call_onTrackReady-O",e.L_AUDIENCE_CLIENT_SUBSCRIBE_T="L-audinence_client_subscribe-T",e.L_AUDIENCE_CLIENT_SUBSCRIBE_R="L-audinence_client_subscribe-R",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T="L-audinence_client_unsubscribe-T",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R="L-audinence_client_unsubscribe-R",e.L_PINGER_START_O="L-pinger_start-O",e.L_PINGER_STOP_O="L-pinger_stop-O",e.L_PINGER_SEND_RTCPING_E="L-pinger_send_rtcping-E",e.L_ABSTRACT_ROOM_SEND_MESSAGE_T="L-abstract_room_send_message-T",e.L_ABSTRACT_ROOM_SEND_MESSAGE_R="L-abstract_room_send_message-R",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T="L-abstract_room_set_room_attribute-T",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R="L-abstract_room_set_room_attribute_R",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T="L-abstract_room_delete_room_attribute_T",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R="L-abstract_room_delete_room_attribute_R",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T="L-abstract_room_get_room_attribute_T",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R="L-abstract_room_get_room_attribute_R",e.L_ABSTRACT_ROOM_PUBLISH_T="L-abstract_room_publish-T",e.L_ABSTRACT_ROOM_PUBLISH_R="L-abstract_room_publish-R",e.L_ABSTRACT_ROOM_PUBLISH_E="L-abstract_room_publish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_T="L-abstract_room_unpublish-T",e.L_ABSTRACT_ROOM_UNPUBLISH_R="L-abstract_room_unpublish-R",e.L_ABSTRACT_ROOM_UNPUBLISH_E="L-abstract_room_unpublish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_P="L-abstract_room_unpublish-P",e.L_ABSTRACT_ROOM_SUBSCRIBE_T="L-abstract_room_subscribe-T",e.L_ABSTRACT_ROOM_SUBSCRIBE_R="L-abstract_room_subscribe-R",e.L_ABSTRACT_ROOM_SUBSCRIBE_E="L-abstract_room_subscribe-E",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_T="L-abstract_room_unsubscribe-T",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_R="L-abstract_room_unsubscribe-R",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_E="L-abstract_room_unsubscribe-E",e.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_T="L-abstract_room_set_src_language-T",e.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_R="L-abstract_room_set_src_language-R",e.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T="L-abstract_room_operate_asr_status-T",e.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R="L-abstract_room_operate_asr_status-R",e.L_ABSTRACT_ROOM_SET_ENABLE_ASR_T="L-abstract_room_set_enable_asr-T",e.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R="L-abstract_room_set_enable_asr-R",e.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_T="L-abstract_room_operate_realtime_translation-T",e.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R="L-abstract_room_operate_realtime_translation-R",e.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_T="L-abstract_room_operate_summarization-T",e.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R="L-abstract_room_operate_summarization-R",e.L_APP_CALL_UNSUBSCRIBE_O="L-app_call_unsubscribe-O",e.L_USER_LEFT_UNSUBSCRIBE_O="L-user_left_unsubscribe-O",e.L_RES_UNPUB_UNSUBSCRIBE_O="L-res_unpub_unsubscribe-O",e.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O="L-abstract_room_register_room_event_listener-O",e.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O="L-abstract_room_register_report_listener-O",e.L_ABSTRACT_ROOM_AUDIO_LEVEL_O="L-abstract_room_audio_level-O",e.L_ABSTRACT_ROOM_IM_RECONNECTED_T="L-abstract_room_im_reconnected-T",e.L_ABSTRACT_ROOM_IM_RECONNECTED_R="L-abstract_room_im_reconnected-R",e.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O="L-abstract_room_call_app_listener-O",e.L_ABSTRACT_ROOM_SETBITRATE_O="L-abstract_room_setBitrate-O",e.L_ABSTRACT_ROOM_ONTRACKREADY_O="L-abstract_room_onTrackReady-O",e.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O="L-abstract_room_receive_message-O",e.L_ABSTRACT_ROOM_ONKICKOFF_O="L-abstract_room_onKickoff-O",e.L_LIVING_ROOM_RECONNECTED_T="L-living_room_reconnected-T",e.L_LIVING_ROOM_RECONNECTED_R="L-living_room_reconnected-R",e.L_LIVING_ROOM_ENABLE_INNER_CDN_T="L-living_room_enable_inner_cdn-T",e.L_LIVING_ROOM_ENABLE_INNER_CDN_R="L-living_room_enable_inner_cdn-R",e.L_LIVING_ROOM_SPREAD_CDN_INFO_T="L-living_room_spread_cdn_info-T",e.L_LIVING_ROOM_SPREAD_CDN_INFO_R="L-living_room_spread_cdn_info-R",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T="L-living_room_set_room_cdn_info-T",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R="L-living_room_set_room_cdn_info-R",e.L_LIVING_ROOM_JOINED_PK_ROOM_T="L-living_room_joined_pk_room-T",e.L_LIVING_ROOM_JOINED_PK_ROOM_R="L-living_room_joined_pk_room-R",e.L_LIVING_ROOM_LEAVE_PK_ROOM_T="L-living_room_leave_pk_room-T",e.L_LIVING_ROOM_LEAVE_PK_ROOM_R="L-living_room_leave_pk_room-R",e.L_APP_CALL_LEAVE_PK_ROOM_O="L-app_call_leave_pk_room-O",e.L_QUIT_PK_LEAVE_PK_ROOM_O="L-quit_pk_leave_pk_room-O",e.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O="L-living_room_get_room_pk_handler-O",e.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O="L-living_room_get_mcu_config_builder-O",e.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O="L-living_room_quit_all_pk_room-O",e.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O="L-living_pk_handler_register_room_pk_event_listener-O",e.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O="L-living_pk_handler_call_app_listener-O",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_request_join_other_room-T",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_request_join_other_room-R",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_cancel_request_join_other_room-T",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_cancel_request_join_other_room-R",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T="L-living_pk_handler_response_join_other_room-T",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R="L-living_pk_handler_response_join_other_room-R",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T="L-living_pk_handler_join_other_room-T",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R="L-living_pk_handler_join_other_room-R",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_T="L-living_pk_handler_leave_other_room-T",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_R="L-living_pk_handler_leave_other_room-R",e.L_QUIT_PK_T="L-quit_pk-T",e.L_QUIT_PK_R="L-quit_pk-R",e.L_EXCHANGE_WITH_PUSHOTHERROOM_T="L-exchange_with_pushotherroom-T",e.L_EXCHANGE_WITH_PUSHOTHERROOM_R="L-exchange_with_pushotherroom-R",e.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O="L-audience_living_room_call_app_listener-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_O="L-audience_living_room_pull_kvEntries-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R",e.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P="L-audience_living_room_singal_data_change-P",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T="L-audience_living_room_get_cdn_play_url-T",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R="L-audience_living_room_get_cdn_play_url-R",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T="L-audience_living_room_subscribe-T",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R="L-audience_living_room_subscribe-R",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T="L-audience_living_room_unsubscribe-T",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R="L-audience_living_room_unsubscribe-R",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T="L-audience_living_room_update_subscribeList-T",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R="L-audience_living_room_update_subscribeList-R",e.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O="L-audience_living_room_onTrackReady-O",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R="L-audience_living_room_im_reconnected-R",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T="L-audience_living_room_im_reconnected-T",e.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O="L-mcu_config_builder_set_host_video_track-O",e.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O="L-mcu_config_builder_set_mix_layout_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O="L-mcu_config_builder_set_output_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_tiny_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O="L-mcu_config_builder_set_output_tiny_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_tiny_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O="L-mcu_config_builder_set_output_video_render_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O="L-mcu_config_builder_set_output_audio_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O="L-mcu_config_builder_set_output_background_color-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_add_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_remove_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_clear_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O="L-mcu_config_builder_set_output_background_picture-fill-mode-O",e.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_add_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_remove_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_clear_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_add_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_remove_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_clear_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_set_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_add_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_remove_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_clear_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_RESET_O="L-mcu_config_builder_reset-O",e.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O="L-mcu_config_builder_add_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O="L-mcu_config_builder_remove_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_CLEAR_SINGLE_WATER_MARK_O="L-mcu_config_builder_clear_single_water_mark-O",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_T="L-media_service_set_mcu_config-T",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_R="L-media_service_set_mcu_config-R",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T="L-media_service_get_cnd_resource_info-T",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R="L-media_service_get_cnd_resource_info-R",e.L_MEDIA_SERVICE_MSLIST_CHANGE_O="L-media_service_msList_change-O",e.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O="L-media_service_parse_navi_callvoip_info-O",e.L_MEDIA_SERVICE_REQUEST_T="L-media_service_request-T",e.L_MEDIA_SERVICE_REQUEST_R="L-media_service_request-R",e.L_LOCAL_TRACK_DESTROY_O="L-loacl_track_destroy-O",e.L_LOCAL_TRACK_SET_BITRATE_O="L-loacl_track_set_bitrate-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_O="L-loacl_track_set_local_muted-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T="L-loacl_track_set_local_muted_spread-T",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R="L-loacl_track_set_local_muted_spread-R",e.L_TRACK_PLAY_O="L-track_play-O",e.L_TRACK_PLAY_E="L-track_play-E",e.L_TRACK_LOAD_START_O="L-track_load_start-O",e.L_TRACK_DURATION_CHANGE_O="L-track_duration_change-O",e.L_TRACK_LOADED_META_DATA_O="L-track_loaded_meta_data-O",e.L_TRACK_LOADED_DATA_O="L-track_loaded_data-O",e.L_TRACK_ABORT_O="L-track_abort-O",e.L_TRACK_VOLUME_CHANGE_O="L-track_volume_change-O",e.L_TRACK_CANPLAY_O="L-track_canplay-O",e.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O="L-abstract_stat_parser_format_rtc_state_report-O",e.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O="L-a_sdp_strategy_set_sdp_semantics-O",e.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O="L-a_sdp_strategy_set_remote_answer-O",e.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O="L-rtc_peer_connection_add_local_track-O",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S="L-rtc_peer_connection_ice_connection_state-S",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R="L-rtc_peer_connection_ice_connection_state_report-R",e.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S="L-rtc_peer_connection_connection_state-S",e.L_RTC_PEER_CONNECTION_SET_BITRATE_O="L-rtc_peer_connection_set_bitrate-O",e.L_RTC_PEER_CONNECTION_CREATE_OFFER_O="L-rtc_peer_connection_create_offer-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O="L-rtc_peer_connection_remove_local_track_by_id-O",e.L_RTC_PEER_CONNECTION_REMOVE_ALL_LOCAL_TRACK_O="L-rtc_peer_connection_remove_all_local_track-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O="L-rtc_peer_connection_remove_local_track-O",e.L_RTC_PEER_CONNECTION_DESTROY_O="L-rtc_peer_connection_destroy-O",e.L_RTC_SET_RECOMMEND_BITRATE_O="L_rtc_set_recommend_bitrate_O",e.L_RTC_3ANOISE_NODE_O="L_RTC_AAAnoiseNode_O",e.L_RTC_3ANOISE_NODE_E="L_RTC_AAAnoiseNode_E",e.L_RTC_3ANOISE_NODE_STOP_O="L_RTC_AAAnoiseNode_Stop_O",e.L_QS_JOIN_ROOM_S="RTC-joinRoomRtc-S",e.L_QS_SUBSCRIBE_S="RTC-subscribe-S",e.L_QS_UNSUBSCRIBE_S="RTC-unsubscribe-S",e.L_QS_PUBLISH_S="RTC-publishRtc-S",e.L_QS_UNPUBLISH_S="RTC-unpublishRtc-S",e.L_QS_ICE_STATUS_S="RTC-iceStatus-S",e.L_QS_KICKED_S="RTC-forcedOffline-S",e.L_QS_PUB_ICE_STATUS_S="RTC-pubIceConnected-S",e.L_QS_SUB_ICE_STATUS_S="RTC-subIceConnected-S",e.L_QS_RECV_PUB_MSG_S="RTC-recvPubMsg-S",e.L_SET_ENCODER_PREFERENCES_S="RTC-set_Encoder_Preferences-S",e.L_RTCNTF_PULL_ROOM_STATUS_O="L-rtcntf_pull_room_status-O",e.L_RTCPING_PULL_ROOM_STATUS_O="L-rtcping_pull_room_status-O",e.L_PULL_ROOM_STATUS_T="L-pull_room_status-T",e.L_PULL_ROOM_STATUS_R="L-pull_room_status-R",e.L_OLD_DAILY_RECORD_O="L-old_daily_record-O",e.L_REMOTE_USER_JOINED_RESOURCES_O="L-remote_user_joined_resources-O",e.L_REMOTE_USER_STATE_HANDLE_O="L-remote_user_state_handle-O",e.L_UPDATE_SUBSCRIBELIST_COMMAND_T="L-update_subscribeList_command-T",e.L_UPDATE_SUBSCRIBELIST_COMMAND_P="L-update_subscribeList_command-P",e.L_UPDATE_SUBSCRIBELIST_COMMAND_R="L-update_subscribeList_command-R",e.L_RTC_CLIENT_NAVI_CHANGE_O="L-rtc_client_navi_change-O",e.L_UNPUBLISH_PREV_COMMAND_T="L-unpublish_prev_command-T",e.L_UNPUBLISH_PREV_COMMAND_R="L-unpublish_prev_command-R",e.L_RETRY_EXCHANGE_COMMAND_T="L-retry_exchange_command-T",e.L_RETRY_EXCHANGE_SPREAD_T="L-retry_exchange_spread-T",e.L_RETRY_EXCHANGE_SPREAD_R="L-retry_exchange_spread-R",e.L_PARSE_USERSTATE_COMMAND_R="L-parse_userstate_command-R",e.L_RESUB_REPUB_RES_R="L-resub_repub_res-R",e.L_PARSE_ROOMDATA_URIS_R="L-parse_roomdata_uris-R",e.L_SET_AUDIO_CONSTRAINTS_O="L-set_audio_constraints-O",e.L_FUNCTION_IS_UNAVAILABLE="L-function_is_unavailable",e.L_CLEAR_UNSUBSCRIBE_LIST_O="L-clear_unsubscribe_list-O",e.L_INVOKER_PUSH_O="L-invoker_push-O",e.L_INVOKER_EXECUTE_T="L-invoker_execute-T",e.L_INVOKER_EXECUTE_R="L-invoker_execute-R",e.L_INVOKER_DESTROY_O="L-invoker_destroy-R",e.L_PARSE_VOIP_SERVER_CONF_E="L_PARSE_VOIP_SERVER_CONF_E",e.L_GET_MEDIA_STREAM_E="L_GET_MEDIA_STREAM_E",e.L_INNER_SET_TRACK_O="L_INNER_SET_TRACK_O",e.A_APPLY_3A_NOISE_WORKLET_T="A-apply_3a_noise_worklet-T",e.A_APPLY_3A_NOISE_WORKLET_R="A-apply_3a_noise_worklet-R",e.L_ENCRYPTOR_ENCODE_E="L-encryptor_encode-E",e.L_ENCRYPTOR_DECODE_E="L-encryptor_decode-E",e.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T="L-rtc_client_change_media_device-T",e.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R="L-rtc_client_change_media_device-R"}(Ne||(Ne={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(ke||(ke={}));let Ge=!0,je=!0;function Fe(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function He(e,t,n){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);const a=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,a),i.apply(this,[e,a])};const a=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return a.apply(this,arguments);if(!this._eventMap[t].has(n))return a.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,a.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function Je(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(Ge=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Ke(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(je=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Ye(){if("object"==typeof window){if(Ge)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function qe(e,t){je&&console.warn(e+" is deprecated, please use "+t+" instead.")}function We(e){return"[object Object]"===Object.prototype.toString.call(e)}function ze(e){return We(e)?Object.keys(e).reduce(function(t,n){const r=We(e[n]),i=r?ze(e[n]):e[n],a=r&&!Object.keys(i).length;return void 0===i||a?t:Object.assign(t,{[n]:i})},{}):e}function Qe(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach(r=>{r.endsWith("Id")?Qe(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach(t=>{Qe(e,e.get(t),n)})}))}function Ze(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const a=[];return e.forEach(e=>{"track"===e.type&&e.trackIdentifier===t.id&&a.push(e)}),a.forEach(t=>{e.forEach(n=>{n.type===r&&n.trackId===t.id&&Qe(e,n,i)})}),i}const Xe=Ye;function $e(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[i("min",n)]=r.ideal,t.optional.push(e),e={},e[i("max",n)]=r.ideal,t.optional.push(e)):(e[i("",n)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let a=e.video.facingMode;a=a&&("object"==typeof a?a:{ideal:a});const o=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||o)){let t;if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?t=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then(n=>{let o=(n=n.filter(e=>"videoinput"===e.kind)).find(e=>t.some(t=>e.label.toLowerCase().includes(t)));return!o&&n.length&&t.includes("back")&&(o=n[n.length-1]),o&&(e.video.deviceId=a.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=r(e.video),Xe("chrome: "+JSON.stringify(e)),i(e)})}e.video=r(e.video)}return Xe("chrome: "+JSON.stringify(e)),i(e)},a=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,e=>{n.webkitGetUserMedia(e,t,e=>{r&&r(a(e))})})}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return e},e=>Promise.reject(a(e))))}}}function et(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function tt(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===n.track.id):{track:n.track};const i=new Event("track");i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}),t.stream.getTracks().forEach(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===n.id):{track:n};const i=new Event("track");i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else He(e,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function nt(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{const t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function rt(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const i=function(e){const t={};return e.result().forEach(e=>{const n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(t=>{n[t]=e.stat(t)}),t[n.id]=n}),t},a=function(e){return new Map(Object.keys(e).map(t=>[t,e[t]]))};if(arguments.length>=2){const r=function(e){n(a(i(e)))};return t.apply(this,[r,e])}return new Promise((e,n)=>{t.apply(this,[function(t){e(a(i(t)))},n])}).then(n,r)}}function it(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>Ze(t,e.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),He(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>Ze(t,e.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,n,r;return this.getSenders().forEach(n=>{n.track===e&&(t?r=!0:t=n)}),this.getReceivers().forEach(t=>(t.track===e&&(n?r=!0:n=t),t.track===e)),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function at(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")});const t=this.getSenders();n.apply(this,arguments);const r=this.getSenders().filter(e=>-1===t.indexOf(e));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{const n=this._shimmedLocalStreams[t].indexOf(e);-1!==n&&this._shimmedLocalStreams[t].splice(n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]}),i.apply(this,arguments)}}function ot(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return at(e);const n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){const n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function a(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find(e=>e===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(e=>e.track===t))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[n.id];if(i)i.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const r=new e.MediaStream([t]);this._streams[n.id]=r,this._reverseStreams[r.id]=n,this.addStream(r)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[t=>{const n=a(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then(e=>a(this,e))}};e.RTCPeerConnection.prototype[t]=r[t]});const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};const s=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=s.get.apply(this);return""===e.type?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(n=>{this._streams[n].getTracks().find(t=>e.track===t)&&(t=this._streams[n])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function st(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]})}function ct(e,t){He(e,"negotiationneeded",e=>{const n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e})}var ut=Object.freeze({__proto__:null,shimMediaStream:et,shimOnTrack:tt,shimGetSendersWithDtmf:nt,shimGetStats:rt,shimSenderReceiverGetStats:it,shimAddTrackRemoveTrackWithNative:at,shimAddTrackRemoveTrack:ot,shimPeerConnection:st,fixNegotiationNeeded:ct,shimGetUserMedia:$e,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then(t=>{const r=n.video&&n.video.width,i=n.video&&n.video.height,a=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:a||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});var lt,_t,dt=(lt=function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},t.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},t.getDescription=function(e){var n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){var n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter(function(e){return 0===e.indexOf(n)})},t.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},t.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},t.getMid=function(e){var n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){var r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" "),i=3;i<r.length;i++){var a=r[i],o=t.matchPrefix(e,"a=rtpmap:"+a+" ")[0];if(o){var s=t.parseRtpMap(o),c=t.matchPrefix(e,"a=fmtp:"+a+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+a+" ").map(t.parseRtcpFb),n.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(s.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach(function(e){n.headerExtensions.push(t.parseExtmap(e))}),n},t.writeRtpDescription=function(e,n){var r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=n.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach(function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)});var i=0;return n.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",n.headerExtensions&&n.headerExtensions.forEach(function(e){r+=t.writeExtmap(e)}),r},t.parseRtpEncodingParameters=function(e){var n,r=[],i=t.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===c&&(n=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&n&&(t.rtx={ssrc:n}),r.push(t),a&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},r.push(t))}}),0===r.length&&c&&r.push({ssrc:c});var l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substr(5),10)*.95-16e3:void 0,r.forEach(function(e){e.maxBitrate=l})),r},t.parseRtcpParameters=function(e){var n={},r=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;var a=t.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},t.parseMsid=function(e){var n,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(n=r[0].substr(7).split(" "))[0],track:n[1]};var i=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(n=i[0].value.split(" "))[0],track:n[1]}:void 0},t.parseSctpDescription=function(e){var n,r=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(n=parseInt(i[0].substr(19),10)),isNaN(n)&&(n=65536);var a=t.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:r.fmt,maxMessageSize:n};if(t.matchPrefix(e,"a=sctpmap:").length>0){var o=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,n,r){var i=void 0!==n?n:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,n,r,i){var a=t.writeRtpDescription(e.kind,n);if(a+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),a+="a=mid:"+e.mid+"\r\n",e.direction?a+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+o,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),a},t.getDirection=function(e,n){for(var r=t.splitLines(e),i=0;i<r.length;i++)switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substr(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var n=t.splitLines(e)[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var n=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var n=t.splitLines(e),r=0;r<n.length;r++)if(n[r].length<2||"="!==n[r].charAt(1))return!1;return!0},e.exports=t},lt(_t={exports:{}},_t.exports),_t.exports);function ft(e,t,n,r,i){var a=dt.writeRtpDescription(e.kind,t);if(a+=dt.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=dt.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":i||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var s="msid:"+(r?r.id:"-")+" "+o+"\r\n";a+="a="+s,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+dt.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+dt.localCName+"\r\n"),a}function ht(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var a=r(e.parameters.apt,n),o=r(t.parameters.apt,i);return a&&o&&a.name.toLowerCase()===o.name.toLowerCase()};return e.codecs.forEach(function(r){for(var a=0;a<t.codecs.length;a++){var o=t.codecs[a];if(r.name.toLowerCase()===o.name.toLowerCase()&&r.clockRate===o.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&o.parameters.apt&&!i(r,o,e.codecs,t.codecs))continue;(o=JSON.parse(JSON.stringify(o))).numChannels=Math.min(r.numChannels,o.numChannels),n.codecs.push(o),o.rtcpFeedback=o.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n}function gt(e,t,n){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)}function pt(e,t){var n=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});return n||e.addRemoteCandidate(t),!n}function Et(e,t){var n=new Error(t);return n.name=e,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],n}var vt=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function r(t,n,r,i){var a=new Event("track");a.track=n,a.receiver=r,a.transceiver={receiver:r},a.streams=i,e.setTimeout(function(){t._dispatchEvent("track",a)})}var i=function(n){var r=this,i=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){r[e]=i[e].bind(i)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw Et("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}})}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var a=n.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=dt.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},i.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},i.prototype.addTrack=function(t,n){if(this._isClosed)throw Et("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find(function(e){return e.track===t}))throw Et("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},i.prototype.addStream=function(e){var n=this;if(t>=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},i.prototype.removeTrack=function(t){if(this._isClosed)throw Et("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find(function(e){return e.rtpSender===t});if(!n)throw Et("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var n=t.getSenders().find(function(t){return t.track===e});n&&t.removeTrack(n)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},i.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},i.prototype._gather=function(t,n){var r=this,i=this.transceivers[n].iceGatherer;if(!i.onlocalcandidate){var a=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,i.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),i.onlocalcandidate=function(e){if(!(r.usingBundle&&n>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:n};var o=e.candidate,s=!o||0===Object.keys(o).length;if(s)"new"!==i.state&&"gathering"!==i.state||(i.state="completed");else{"new"===i.state&&(i.state="gathering"),o.component=1,o.ufrag=i.getLocalParameters().usernameFragment;var c=dt.writeCandidate(o);a.candidate=Object.assign(a.candidate,dt.parseCandidate(c)),a.candidate.candidate=c,a.candidate.toJSON=function(){return{candidate:a.candidate.candidate,sdpMid:a.candidate.sdpMid,sdpMLineIndex:a.candidate.sdpMLineIndex,usernameFragment:a.candidate.usernameFragment}}}var u=dt.getMediaSections(r._localDescription.sdp);u[a.candidate.sdpMLineIndex]+=s?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",r._localDescription.sdp=dt.getDescription(r._localDescription.sdp)+u.join("");var l=r.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==r.iceGatheringState&&(r.iceGatheringState="gathering",r._emitGatheringStateChange()),s||r._dispatchEvent("icecandidate",a),l&&(r._dispatchEvent("icecandidate",new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},e.setTimeout(function(){a.forEach(function(e){i.onlocalcandidate(e)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},i.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},i.prototype._transceive=function(e,n,r){var i=ht(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:dt.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),r&&e.rtpReceiver&&i.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?i.encodings=e.recvEncodingParameters:i.encodings=[{}],i.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(i.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},i.prototype.setLocalDescription=function(e){var t,n,r=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(Et("TypeError",'Unsupported type "'+e.type+'"'));if(!gt("setLocalDescription",e.type,r.signalingState)||r._isClosed)return Promise.reject(Et("InvalidStateError","Can not set local "+e.type+" in state "+r.signalingState));if("offer"===e.type)t=dt.splitSections(e.sdp),n=t.shift(),t.forEach(function(e,t){var n=dt.parseRtpParameters(e);r.transceivers[t].localCapabilities=n}),r.transceivers.forEach(function(e,t){r._gather(e.mid,t)});else if("answer"===e.type){t=dt.splitSections(r._remoteDescription.sdp),n=t.shift();var i=dt.matchPrefix(n,"a=ice-lite").length>0;t.forEach(function(e,t){var a=r.transceivers[t],o=a.iceGatherer,s=a.iceTransport,c=a.dtlsTransport,u=a.localCapabilities,l=a.remoteCapabilities;if(!(dt.isRejected(e)&&0===dt.matchPrefix(e,"a=bundle-only").length)&&!a.rejected){var _=dt.getIceParameters(e,n),d=dt.getDtlsParameters(e,n);i&&(d.role="server"),r.usingBundle&&0!==t||(r._gather(a.mid,t),"new"===s.state&&s.start(o,_,i?"controlling":"controlled"),"new"===c.state&&c.start(d));var f=ht(u,l);r._transceive(a,f.codecs.length>0,!1)}})}return r._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?r._updateSignalingState("have-local-offer"):r._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(i){var a=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(Et("TypeError",'Unsupported type "'+i.type+'"'));if(!gt("setRemoteDescription",i.type,a.signalingState)||a._isClosed)return Promise.reject(Et("InvalidStateError","Can not set remote "+i.type+" in state "+a.signalingState));var o={};a.remoteStreams.forEach(function(e){o[e.id]=e});var s=[],c=dt.splitSections(i.sdp),u=c.shift(),l=dt.matchPrefix(u,"a=ice-lite").length>0,_=dt.matchPrefix(u,"a=group:BUNDLE ").length>0;a.usingBundle=_;var d=dt.matchPrefix(u,"a=ice-options:")[0];return a.canTrickleIceCandidates=!!d&&d.substr(14).split(" ").indexOf("trickle")>=0,c.forEach(function(r,c){var d=dt.splitLines(r),f=dt.getKind(r),h=dt.isRejected(r)&&0===dt.matchPrefix(r,"a=bundle-only").length,g=d[0].substr(2).split(" ")[2],p=dt.getDirection(r,u),E=dt.parseMsid(r),v=dt.getMid(r)||dt.generateIdentifier();if(h||"application"===f&&("DTLS/SCTP"===g||"UDP/DTLS/SCTP"===g))a.transceivers[c]={mid:v,kind:f,protocol:g,rejected:!0};else{var m,R,T,I,S,C,L,O,y;!h&&a.transceivers[c]&&a.transceivers[c].rejected&&(a.transceivers[c]=a._createTransceiver(f,!0));var b,A,N=dt.parseRtpParameters(r);h||(b=dt.getIceParameters(r,u),(A=dt.getDtlsParameters(r,u)).role="client"),L=dt.parseRtpEncodingParameters(r);var k=dt.parseRtcpParameters(r),P=dt.matchPrefix(r,"a=end-of-candidates",u).length>0,U=dt.matchPrefix(r,"a=candidate:").map(function(e){return dt.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===i.type||"answer"===i.type)&&!h&&_&&c>0&&a.transceivers[c]&&(a._disposeIceAndDtlsTransports(c),a.transceivers[c].iceGatherer=a.transceivers[0].iceGatherer,a.transceivers[c].iceTransport=a.transceivers[0].iceTransport,a.transceivers[c].dtlsTransport=a.transceivers[0].dtlsTransport,a.transceivers[c].rtpSender&&a.transceivers[c].rtpSender.setTransport(a.transceivers[0].dtlsTransport),a.transceivers[c].rtpReceiver&&a.transceivers[c].rtpReceiver.setTransport(a.transceivers[0].dtlsTransport)),"offer"!==i.type||h){if("answer"===i.type&&!h){R=(m=a.transceivers[c]).iceGatherer,T=m.iceTransport,I=m.dtlsTransport,S=m.rtpReceiver,C=m.sendEncodingParameters,O=m.localCapabilities,a.transceivers[c].recvEncodingParameters=L,a.transceivers[c].remoteCapabilities=N,a.transceivers[c].rtcpParameters=k,U.length&&"new"===T.state&&(!l&&!P||_&&0!==c?U.forEach(function(e){pt(m.iceTransport,e)}):T.setRemoteCandidates(U)),_&&0!==c||("new"===T.state&&T.start(R,b,"controlling"),"new"===I.state&&I.start(A)),!ht(m.localCapabilities,m.remoteCapabilities).codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&m.sendEncodingParameters[0].rtx&&delete m.sendEncodingParameters[0].rtx,a._transceive(m,"sendrecv"===p||"recvonly"===p,"sendrecv"===p||"sendonly"===p),!S||"sendrecv"!==p&&"sendonly"!==p?delete m.rtpReceiver:(y=S.track,E?(o[E.stream]||(o[E.stream]=new e.MediaStream),n(y,o[E.stream]),s.push([y,S,o[E.stream]])):(o.default||(o.default=new e.MediaStream),n(y,o.default),s.push([y,S,o.default])))}}else{(m=a.transceivers[c]||a._createTransceiver(f)).mid=v,m.iceGatherer||(m.iceGatherer=a._createIceGatherer(c,_)),U.length&&"new"===m.iceTransport.state&&(!P||_&&0!==c?U.forEach(function(e){pt(m.iceTransport,e)}):m.iceTransport.setRemoteCandidates(U)),O=e.RTCRtpReceiver.getCapabilities(f),t<15019&&(O.codecs=O.codecs.filter(function(e){return"rtx"!==e.name})),C=m.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var w,D=!1;if("sendrecv"===p||"sendonly"===p){if(D=!m.rtpReceiver,S=m.rtpReceiver||new e.RTCRtpReceiver(m.dtlsTransport,f),D)y=S.track,E&&"-"===E.stream||(E?(o[E.stream]||(o[E.stream]=new e.MediaStream,Object.defineProperty(o[E.stream],"id",{get:function(){return E.stream}})),Object.defineProperty(y,"id",{get:function(){return E.track}}),w=o[E.stream]):(o.default||(o.default=new e.MediaStream),w=o.default)),w&&(n(y,w),m.associatedRemoteMediaStreams.push(w)),s.push([y,S,w])}else m.rtpReceiver&&m.rtpReceiver.track&&(m.associatedRemoteMediaStreams.forEach(function(t){var n=t.getTracks().find(function(e){return e.id===m.rtpReceiver.track.id});n&&function(t,n){n.removeTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(n,t)}),m.associatedRemoteMediaStreams=[]);m.localCapabilities=O,m.remoteCapabilities=N,m.rtpReceiver=S,m.rtcpParameters=k,m.sendEncodingParameters=C,m.recvEncodingParameters=L,a._transceive(a.transceivers[c],!1,D)}}}),void 0===a._dtlsRole&&(a._dtlsRole="offer"===i.type?"active":"passive"),a._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?a._updateSignalingState("have-remote-offer"):a._updateSignalingState("stable"),Object.keys(o).forEach(function(t){var n=o[t];if(n.getTracks().length){if(-1===a.remoteStreams.indexOf(n)){a.remoteStreams.push(n);var i=new Event("addstream");i.stream=n,e.setTimeout(function(){a._dispatchEvent("addstream",i)})}s.forEach(function(e){var t=e[0],i=e[1];n.id===e[2].id&&r(a,t,i,[n])})}}),s.forEach(function(e){e[2]||r(a,e[0],e[1],[])}),e.setTimeout(function(){a&&a.transceivers&&a.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},i.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},i.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++}),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},i.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},i.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(Et("InvalidStateError","Can not call createOffer after close"));var r=n.transceivers.filter(function(e){return"audio"===e.kind}).length,i=n.transceivers.filter(function(e){return"video"===e.kind}).length,a=arguments[0];if(a){if(a.mandatory||a.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==a.offerToReceiveAudio&&(r=!0===a.offerToReceiveAudio?1:!1===a.offerToReceiveAudio?0:a.offerToReceiveAudio),void 0!==a.offerToReceiveVideo&&(i=!0===a.offerToReceiveVideo?1:!1===a.offerToReceiveVideo?0:a.offerToReceiveVideo)}for(n.transceivers.forEach(function(e){"audio"===e.kind?--r<0&&(e.wantReceive=!1):"video"===e.kind&&--i<0&&(e.wantReceive=!1)});r>0||i>0;)r>0&&(n._createTransceiver("audio"),r--),i>0&&(n._createTransceiver("video"),i--);var o=dt.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach(function(r,i){var a=r.track,o=r.kind,s=r.mid||dt.generateIdentifier();r.mid=s,r.iceGatherer||(r.iceGatherer=n._createIceGatherer(i,n.usingBundle));var c=e.RTCRtpSender.getCapabilities(o);t<15019&&(c.codecs=c.codecs.filter(function(e){return"rtx"!==e.name})),c.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),r.remoteCapabilities&&r.remoteCapabilities.codecs&&r.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),c.headerExtensions.forEach(function(e){(r.remoteCapabilities&&r.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var u=r.sendEncodingParameters||[{ssrc:1001*(2*i+1)}];a&&t>=15019&&"video"===o&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),r.wantReceive&&(r.rtpReceiver=new e.RTCRtpReceiver(r.dtlsTransport,o)),r.localCapabilities=c,r.sendEncodingParameters=u}),"max-compat"!==n._config.bundlePolicy&&(o+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),o+="a=ice-options:trickle\r\n",n.transceivers.forEach(function(e,t){o+=ft(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),o+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,o+="a="+dt.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(o+="a=end-of-candidates\r\n"))});var s=new e.RTCSessionDescription({type:"offer",sdp:o});return Promise.resolve(s)},i.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(Et("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(Et("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var r=dt.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(r+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),r+="a=ice-options:trickle\r\n";var i=dt.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach(function(e,a){if(!(a+1>i)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?r+="m=application 0 DTLS/SCTP 5000\r\n":r+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?r+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(r+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(r+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var o;if(e.stream)"audio"===e.kind?o=e.stream.getAudioTracks()[0]:"video"===e.kind&&(o=e.stream.getVideoTracks()[0]),o&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var s=ht(e.localCapabilities,e.remoteCapabilities);!s.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,r+=ft(e,s,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(r+="a=rtcp-rsize\r\n")}});var a=new e.RTCSessionDescription({type:"answer",sdp:r});return Promise.resolve(a)},i.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(r,i){if(!n._remoteDescription)return i(Et("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid)for(var o=0;o<n.transceivers.length;o++)if(n.transceivers[o].mid===e.sdpMid){a=o;break}var s=n.transceivers[a];if(!s)return i(Et("OperationError","Can not add ICE candidate"));if(s.rejected)return r();var c=Object.keys(e.candidate).length>0?dt.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return r();if(c.component&&1!==c.component)return r();if((0===a||a>0&&s.iceTransport!==n.transceivers[0].iceTransport)&&!pt(s.iceTransport,c))return i(Et("OperationError","Can not add ICE candidate"));var u=e.candidate.trim();0===u.indexOf("a=")&&(u=u.substr(2)),(t=dt.getMediaSections(n._remoteDescription.sdp))[a]+="a="+(c.type?u:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=dt.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var l=0;l<n.transceivers.length&&(n.transceivers[l].rejected||(n.transceivers[l].iceTransport.addRemoteCandidate({}),(t=dt.getMediaSections(n._remoteDescription.sdp))[l]+="a=end-of-candidates\r\n",n._remoteDescription.sdp=dt.getDescription(n._remoteDescription.sdp)+t.join(""),!n.usingBundle));l++);r()})},i.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var n=null;if(this.transceivers.forEach(function(e){e.rtpSender&&e.rtpSender.track===t?n=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(n=e.rtpReceiver)}),!n)throw Et("InvalidAccessError","Invalid selector.");return n.getStats()}var r=[];return this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){e[t]&&r.push(e[t].getStats())})}),Promise.all(r).then(function(e){var t=new Map;return e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})}),t})};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(t){var n=e[t];if(n&&n.prototype&&n.prototype.getStats){var r=n.prototype.getStats;n.prototype.getStats=function(){return r.apply(this).then(function(e){var t=new Map;return Object.keys(e).forEach(function(n){var r;e[n].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[n]).type]||r.type,t.set(n,e[n])}),t})}}});var a=["createOffer","createAnswer"];return a.forEach(function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then(function(t){"function"==typeof e[0]&&e[0].apply(null,[t])},function(t){"function"==typeof e[1]&&e[1].apply(null,[t])}):t.apply(this,arguments)}}),(a=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)},function(t){"function"==typeof e[2]&&e[2].apply(null,[t])}):t.apply(this,arguments)}}),["getStats"].forEach(function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)}):t.apply(this,arguments)}}),i};function mt(e){const t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch(e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e)))}}function Rt(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function Tt(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const n=new Event("enabled");n.enabled=e,this.dispatchEvent(n)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const n=vt(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e){let t=!1;return(e=JSON.parse(JSON.stringify(e))).filter(e=>{if(e&&(e.urls||e.url)){let n=e.urls||e.url;e.url&&!e.urls&&qe("RTCIceServer.url","RTCIceServer.urls");const r="string"==typeof n;return r&&(n=[n]),n=n.filter(e=>{if(0===e.indexOf("stun:"))return!1;const n=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return n&&!t?(t=!0,!0):n&&!t}),delete e.url,e.urls=r?n[0]:n,!!n.length}})}(e.iceServers,t.version),Ye("ICE servers after filtering:",e.iceServers)),new n(e)},e.RTCPeerConnection.prototype=n.prototype}function It(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var St=Object.freeze({__proto__:null,shimPeerConnection:Tt,shimReplaceTrack:It,shimGetUserMedia:mt,shimGetDisplayMedia:Rt});function Ct(e,t){const n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){qe("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return"object"==typeof n&&"object"==typeof n.audio&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,"autoGainControl","mozAutoGainControl"),e(n.audio,"noiseSuppression","mozNoiseSuppression")),t(n)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const n=t.apply(this,arguments);return e(n,"mozAutoGainControl","autoGainControl"),e(n,"mozNoiseSuppression","noiseSuppression"),n}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(n){return"audio"===this.kind&&"object"==typeof n&&(n=JSON.parse(JSON.stringify(n)),e(n,"autoGainControl","mozAutoGainControl"),e(n,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[n])}}}}function Lt(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ot(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]});const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,a]=arguments;return r.apply(this,[e||null]).then(e=>{if(t.version<53&&!i)try{e.forEach(e=>{e.type=n[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,r)=>{e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))})}return e}).then(i,a)}}function yt(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function bt(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),He(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function At(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){qe("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Nt(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function kt(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],n=e&&"sendEncodings"in e;n&&e.sendEncodings.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const r=t.apply(this,arguments);if(n){const{sender:t}=r,n=t.getParameters();(!("encodings"in n)||1===n.encodings.length&&0===Object.keys(n.encodings[0]).length)&&(n.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(n).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return r})}function Pt(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Ut(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function wt(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}var Dt=Object.freeze({__proto__:null,shimOnTrack:Lt,shimPeerConnection:Ot,shimSenderGetStats:yt,shimReceiverGetStats:bt,shimRemoveStream:At,shimRTCDataChannel:Nt,shimAddTransceiver:kt,shimGetParameters:Pt,shimCreateOffer:Ut,shimCreateAnswer:wt,shimGetUserMedia:Ct,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});function Mt(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(n=>t.call(this,n,e)),e.getVideoTracks().forEach(n=>t.call(this,n,e))},e.RTCPeerConnection.prototype.addTrack=function(e,...n){return n&&n.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach(e=>{n.includes(e.track)&&this.removeTrack(e)})})}}function xt(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)})})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const n=new Event("addstream");n.stream=t,e.dispatchEvent(n)})}),t.apply(e,arguments)}}}function Vt(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,a=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,n){const r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){const r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){const r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}function Bt(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n(Gt(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function Gt(e){return e&&void 0!==e.video?Object.assign({},e,{video:ze(e.video)}):e}function jt(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){const t=[];for(let n=0;n<e.iceServers.length;n++){let r=e.iceServers[n];!r.hasOwnProperty("urls")&&r.hasOwnProperty("url")?(qe("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[n])}e.iceServers=t}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function Ft(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ht(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const n=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video")}return t.apply(this,arguments)}}function Jt(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Kt=Object.freeze({__proto__:null,shimLocalStreamsAPI:Mt,shimRemoteStreamsAPI:xt,shimCallbacksAPI:Vt,shimGetUserMedia:Bt,shimConstraints:Gt,shimRTCIceServerUrls:jt,shimTrackEventTransceiver:Ft,shimCreateOfferLegacy:Ht,shimAudioContext:Jt});function Yt(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const n=new t(e),r=dt.parseCandidate(e.candidate),i=Object.assign(n,r);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,He(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function qt(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=dt.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=dt.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),n=function(e){let n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n}(e),r=function(e,n){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const i=dt.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?r=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r}(arguments[0],e);let i;i=0===n&&0===r?Number.POSITIVE_INFINITY:0===n||0===r?Math.max(n,r):Math.min(n,r);const a={};Object.defineProperty(a,"maxMessageSize",{get:()=>i}),this._sctp=a}return n.apply(this,arguments)}}function Wt(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const n=e.send;e.send=function(){const r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return t(e,this),e},He(e,"datachannel",e=>(t(e.channel,e.target),e))}function zt(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function Qt(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const n=t.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function Zt(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var Xt=Object.freeze({__proto__:null,shimRTCIceCandidate:Yt,shimMaxMessageSize:qt,shimSendThrowTypeError:Wt,shimConnectionState:zt,removeExtmapAllowMixed:Qt,shimAddIceCandidateNullOrEmpty:Zt});const $t=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const n=Ye,r=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:n}=e;if(n.mozGetUserMedia)t.browser="firefox",t.version=Fe(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=Fe(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.mediaDevices&&n.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=Fe(n.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=Fe(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:r,commonShim:Xt,extractVersion:Fe,disableLog:Je,disableWarnings:Ke};switch(r.browser){case"chrome":if(!ut||!st||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(null===r.version)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=ut,Zt(e,r),$e(e,r),et(e),st(e,r),tt(e),ot(e,r),nt(e),rt(e),it(e),ct(e,r),Yt(e),zt(e),qt(e,r),Wt(e),Qt(e,r);break;case"firefox":if(!Dt||!Ot||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=Dt,Zt(e,r),Ct(e,r),Ot(e,r),Lt(e),At(e),yt(e),bt(e),Nt(e),kt(e),Pt(e),Ut(e),wt(e),Yt(e),zt(e),qt(e,r),Wt(e);break;case"edge":if(!St||!Tt||!t.shimEdge)return n("MS edge shim is not included in this adapter release."),i;n("adapter.js shimming edge."),i.browserShim=St,mt(e),Rt(e),Tt(e,r),It(e),qt(e,r),Wt(e);break;case"safari":if(!Kt||!t.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=Kt,Zt(e,r),jt(e),Ht(e),Vt(e),Mt(e),xt(e),Ft(e),Bt(e),Jt(e),Yt(e),qt(e,r),Wt(e),Qt(e,r);break;default:n("Unsupported browser!")}return i}({window:"undefined"==typeof window?void 0:window});var en,tn,nn,rn;exports.NCCallVideoFrameRate=void 0,(en=exports.NCCallVideoFrameRate||(exports.NCCallVideoFrameRate={})).FPS_10="FPS_10",en.FPS_15="FPS_15",en.FPS_24="FPS_24",en.FPS_30="FPS_30",exports.NCCallVideoResolution=void 0,(tn=exports.NCCallVideoResolution||(exports.NCCallVideoResolution={})).W176_H132="W176_H132",tn.W176_H144="W176_H144",tn.W180_H180="W180_H180",tn.W240_H180="W240_H180",tn.W240_H240="W240_H240",tn.W256_H144="W256_H144",tn.W320_H180="W320_H180",tn.W320_H240="W320_H240",tn.W360_H360="W360_H360",tn.W480_H360="W480_H360",tn.W480_H480="W480_H480",tn.W640_H360="W640_H360",tn.W640_H480="W640_H480",tn.W720_H480="W720_H480",tn.W848_H480="W848_H480",tn.W960_H720="W960_H720",tn.W1280_H720="W1280_H720",tn.W1920_H1080="W1920_H1080",tn.W144_H176="W144_H176",tn.W144_H256="W144_H256",tn.W180_H240="W180_H240",tn.W180_H320="W180_H320",tn.W240_H320="W240_H320",tn.W360_H480="W360_H480",tn.W360_H640="W360_H640",tn.W480_H640="W480_H640",tn.W480_H720="W480_H720",tn.W480_H848="W480_H848",tn.W720_H1280="W720_H1280",tn.W720_H960="W720_H960",tn.W1080_H1920="W1080_H1920",function(e){e[e.AUDIO_ONLY=0]="AUDIO_ONLY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(nn||(nn={}));var an,on=(d(d(d(d(d(d(d(d(d(d(rn={},exports.NCCallVideoResolution.W176_H132,{width:176,height:132,maxBitrate:150,minBitrate:80}),exports.NCCallVideoResolution.W176_H144,{width:176,height:144,maxBitrate:150,minBitrate:80}),exports.NCCallVideoResolution.W180_H180,{width:180,height:180,maxBitrate:200,minBitrate:100}),exports.NCCallVideoResolution.W240_H180,{width:240,height:180,maxBitrate:240,minBitrate:120}),exports.NCCallVideoResolution.W240_H240,{width:240,height:240,maxBitrate:280,minBitrate:120}),exports.NCCallVideoResolution.W256_H144,{width:256,height:144,maxBitrate:240,minBitrate:120}),exports.NCCallVideoResolution.W320_H180,{width:320,height:180,maxBitrate:280,minBitrate:120}),exports.NCCallVideoResolution.W320_H240,{width:320,height:240,maxBitrate:400,minBitrate:120}),exports.NCCallVideoResolution.W360_H360,{width:360,height:360,maxBitrate:520,minBitrate:140}),exports.NCCallVideoResolution.W480_H360,{width:480,height:360,maxBitrate:650,minBitrate:150}),d(d(d(d(d(d(d(d(d(d(rn,exports.NCCallVideoResolution.W480_H480,{width:480,height:480,maxBitrate:800,minBitrate:180}),exports.NCCallVideoResolution.W640_H360,{width:640,height:360,maxBitrate:800,minBitrate:180}),exports.NCCallVideoResolution.W640_H480,{width:640,height:480,maxBitrate:900,minBitrate:200}),exports.NCCallVideoResolution.W720_H480,{width:720,height:480,maxBitrate:1e3,minBitrate:200}),exports.NCCallVideoResolution.W848_H480,{width:848,height:480,maxBitrate:1860,minBitrate:200}),exports.NCCallVideoResolution.W960_H720,{width:960,height:720,maxBitrate:2e3,minBitrate:250}),exports.NCCallVideoResolution.W1280_H720,{width:1280,height:720,maxBitrate:2200,minBitrate:250}),exports.NCCallVideoResolution.W1920_H1080,{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}),exports.NCCallVideoResolution.W144_H176,{width:144,height:176,maxBitrate:150,minBitrate:80}),exports.NCCallVideoResolution.W144_H256,{width:144,height:256,maxBitrate:240,minBitrate:120}),d(d(d(d(d(d(d(d(d(d(rn,exports.NCCallVideoResolution.W180_H240,{width:180,height:240,maxBitrate:240,minBitrate:120}),exports.NCCallVideoResolution.W180_H320,{width:180,height:320,maxBitrate:280,minBitrate:120}),exports.NCCallVideoResolution.W240_H320,{width:240,height:320,maxBitrate:400,minBitrate:120}),exports.NCCallVideoResolution.W360_H480,{width:360,height:480,maxBitrate:650,minBitrate:150}),exports.NCCallVideoResolution.W360_H640,{width:360,height:640,maxBitrate:800,minBitrate:180}),exports.NCCallVideoResolution.W480_H640,{width:480,height:640,maxBitrate:900,minBitrate:200}),exports.NCCallVideoResolution.W480_H720,{width:480,height:720,maxBitrate:1e3,minBitrate:200}),exports.NCCallVideoResolution.W480_H848,{width:480,height:848,maxBitrate:1860,minBitrate:930}),exports.NCCallVideoResolution.W720_H1280,{width:720,height:1280,maxBitrate:2200,minBitrate:250}),exports.NCCallVideoResolution.W720_H960,{width:720,height:960,maxBitrate:2760,minBitrate:910}),d(rn,exports.NCCallVideoResolution.W1080_H1920,{width:1080,height:1920,maxBitrate:4e3,minBitrate:400})),sn=function(e){var t={192:180,368:360,1088:1080};return t[e]?t[e]:e},cn=function(e,t){e=sn(e),t=sn(t);var n=on["W".concat(e,"_H").concat(t)];if(n)return n;var r=e*t;return Object.keys(on).map(function(e){return on[e]}).sort(function(e,t){return e.height*e.width-t.width*t.height}).filter(function(e){return e.height*e.width>=r})[0]||on.W1920_H1080},un={10:1,15:1,24:1.5,30:1.5},ln=function(e){var t=Number.MAX_VALUE,n=1;for(var r in un){var i=Math.abs(e-parseInt(r));i<t&&(t=i,n=un[r])}return n},_n=function(){return F(void 0,void 0,void 0,E().m(function e(){var t;return E().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,navigator.mediaDevices.enumerateDevices();case 1:return t=e.v,e.a(2,t.filter(function(e){return"videoinput"===e.kind}))}},e)}))},dn=function(){return F(void 0,void 0,void 0,E().m(function e(){var t;return E().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,navigator.mediaDevices.enumerateDevices();case 1:return t=e.v,e.a(2,t.filter(function(e){return"audioinput"===e.kind}))}},e)}))},fn=function(){return F(void 0,void 0,void 0,E().m(function e(){var t;return E().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,navigator.mediaDevices.enumerateDevices();case 1:return t=e.v,e.a(2,t.filter(function(e){return"audiooutput"===e.kind}))}},e)}))};!function(e){e.AUDIO="audio",e.VIDEO="video"}(an||(an={}));var hn,gn=function(){function e(t,n,r,i,a,o){var u;return c(this,e),u=s(this,e),Object.defineProperty(u,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(u,"_tag",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(u,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(u,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(u,"_isLocalTrack",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(u,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(u,"_localMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_remoteMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_streamId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_msTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_msStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"DataTrackId",{enumerable:!0,configurable:!0,writable:!0,value:"data-track-id"}),Object.defineProperty(u,"_element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._streamId=[u._userId||u._roomId,u._tag].join("_"),u._id=[u._streamId,u.isAudioTrack()?0:1].join("_"),u}return g(e,ue),l(e,[{key:"getStreamId",value:function(){return this._streamId}},{key:"getTrackId",value:function(){return this._id}},{key:"getUserId",value:function(){return this._userId}},{key:"__innerGetMediaStreamTrack",value:function(){return this._msTrack}},{key:"streamTrack",get:function(){return this._msTrack}},{key:"getTag",value:function(){return this._tag}},{key:"isLocalTrack",value:function(){return this._isLocalTrack}},{key:"isVideoTrack",value:function(){return"video"===this._kind}},{key:"isAudioTrack",value:function(){return"audio"===this._kind}},{key:"isReady",value:function(){var e;return"live"===(null===(e=this._msTrack)||void 0===e?void 0:e.readyState)}},{key:"__innerSetMediaStreamTrack",value:function(e){this._msTrack=e,this._setLocalMuted(this._localMuted);var t=this._msStream=this._msStream||new MediaStream,n=t.getTracks()[0];n&&t.removeTrack(n),this._isLocalTrack||this._logger.warn(Ne.L_INNER_SET_TRACK_O,"trackId: ".concat(this._id,", track: ").concat(e?e.id:"undefined")),e?t.addTrack(e):this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.pause(),this._element.srcObject=null)}},{key:"_setLocalMuted",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)if(0===t.n)return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,t.a(2,Ae.SUCCESS)},t,this)}))}},{key:"mute",value:function(){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return e.a(2,this._setLocalMuted(!0))},e,this)}))}},{key:"unmute",value:function(){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return e.a(2,this._setLocalMuted(!1))},e,this)}))}},{key:"isLocalMuted",value:function(){return this._localMuted}},{key:"isMCUTrack",value:function(){return Boolean(this._roomId)}},{key:"isOwnerMuted",value:function(){return this._remoteMuted}},{key:"_validateVolume",value:function(e){if(null==e?void 0:e.volume){if(!W(null==e?void 0:e.volume))return this._logger.error(Ne.L_TRACK_PLAY_E,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:Ae.PARAMS_ERROR};(null==e?void 0:e.volume)<0&&(e.volume=0,this._logger.warn(Ne.L_TRACK_PLAY_E,JSON.stringify({status:ke.FAILED,msg:"params error -> options.volume < 0",tips:"the valid range of options.volume is 0-100, the value of volume has been set 0"}))),(null==e?void 0:e.volume)>100&&(e.volume=100,this._logger.warn(Ne.L_TRACK_PLAY_E,JSON.stringify({status:ke.FAILED,msg:"params error -> options.volume > 100",tips:"the valid range of options.volume is 0-100, the value of volume has been set 100"})))}}},{key:"_validatePlayOptions",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._msTrack){n.n=1;break}return this._logger.error(Ne.L_TRACK_PLAY_E,JSON.stringify({status:ke.FAILED,code:Ae.TRACK_NOT_READY,kind:this._kind,msg:"the track is not ready to play -> id: ".concat(this._id)})),n.a(2,{code:Ae.TRACK_NOT_READY});case 1:if("ended"===this._msTrack.readyState&&this._logger.warn(Ne.L_TRACK_PLAY_E,"track readyState is ended -> id: ".concat(this._id)),!(r=this._validateVolume(t))){n.n=2;break}return n.a(2,r);case 2:if(!(null==t?void 0:t.audioDeviceId)){n.n=4;break}return n.n=3,fn();case 3:if(i=n.v.map(function(e){return e.deviceId}),i.includes(t.audioDeviceId)){n.n=4;break}return this._logger.error(Ne.L_TRACK_PLAY_E,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),n.a(2,{code:Ae.PARAMS_ERROR});case 4:if(!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))){n.n=5;break}return this._logger.error(Ne.L_TRACK_PLAY_E,JSON.stringify({status:ke.FAILED,code:Ae.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),n.a(2,{code:Ae.VIDEO_TRACK_MISS_MEDIA_ELEMENT});case 5:return n.a(2)}},n,this)}))}},{key:"_setPlayAttrs",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r;return E().w(function(n){for(;;)switch(n.n){case 0:if(e&&(this._element.playsInline=!0,this._element.x5PlaysInline=!0,this._element.webkitPlaysInline=!0),!(null==t?void 0:t.audioDeviceId)||e){n.n=1;break}return n.n=1,this._element.setSinkId(t.audioDeviceId);case 1:e||!(null==t?void 0:t.volume)&&0!==(null==t?void 0:t.volume)||(this._element.volume=t.volume/100),null===(r=this._element)||void 0===r||r.setAttribute(this.DataTrackId,this.getTrackId());case 2:return n.a(2)}},n,this)}))}},{key:"play",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a=this;return E().w(function(n){for(;;)switch(n.n){case 0:return this._logger.info(Ne.L_TRACK_PLAY_O,JSON.stringify({elementId:null==e?void 0:e.id,trackId:this._id,kind:this._kind,options:t?{volume:null==t?void 0:t.volume,audioDeviceId:t.audioDeviceId}:void 0})),n.n=1,this._validatePlayOptions(e,t);case 1:if(!(r=n.v)){n.n=2;break}return n.a(2,r);case 2:return i=this.isVideoTrack(),this._element=i?e:this._element||new Audio,this._localMuted&&this._setLocalMuted(!1),this._element.srcObject&&this._element.srcObject===this._msStream||this._element.pause(),this._element.onloadstart=function(e){var t;a._logger.info(Ne.L_TRACK_LOAD_START_O,JSON.stringify({status:ke.INFO,kind:a._kind,msg:"HTMLMediaElement onloadstart -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.ondurationchange=function(e){var t;a._logger.info(Ne.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:ke.INFO,kind:a._kind,msg:"HTMLMediaElement ondurationchange -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onloadedmetadata=function(e){var t;a._logger.info(Ne.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:ke.INFO,kind:a._kind,msg:"HTMLMediaElement onloadedmetadata -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onloadeddata=function(e){var t;a._logger.info(Ne.L_TRACK_LOADED_DATA_O,JSON.stringify({status:ke.INFO,kind:a._kind,msg:"HTMLMediaElement onloadeddata -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onabort=function(e){var t;a._logger.info(Ne.L_TRACK_ABORT_O,JSON.stringify({status:ke.INFO,kind:a._kind,msg:"HTMLMediaElement onabort -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.oncanplay=function(e){return F(a,void 0,void 0,E().m(function n(){var r,a,o;return E().w(function(n){for(;;)switch(n.p=n.n){case 0:if(this._logger.info(Ne.L_TRACK_CANPLAY_O,JSON.stringify({status:ke.INFO,kind:this._kind,msg:"HTMLMediaElement oncanplay -> id: ".concat(null===(r=e.target)||void 0===r?void 0:r.id,", trackId: ").concat(this._id)})),n.p=1,!(null==t?void 0:t.audioDeviceId)||i){n.n=2;break}return n.n=2,this._element.setSinkId(t.audioDeviceId);case 2:return n.n=3,null===(a=this._element)||void 0===a?void 0:a.play();case 3:n.n=6;break;case 4:if(n.p=4,"No permission to use requested device"!==(o=n.v).message){n.n=5;break}return this._logger.error(Ne.L_TRACK_PLAY_E,JSON.stringify({status:ke.FAILED,kind:this._kind,code:Ae.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:"setSinkId failed, error msg: ".concat(o.message)})),n.a(2);case 5:this._logger.error(Ne.L_TRACK_PLAY_E,JSON.stringify({status:ke.FAILED,code:Ae.TRACK_PLAY_ERROR,kind:this._kind,msg:"play error, error msg: ".concat(o.message)}));case 6:return n.a(2)}},n,this,[[1,4]])}))},this._element.onvolumechange=function(e){var t,n,r=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));a._logger.info(Ne.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:ke.INFO,msg:"HTMLMediaElement onvolumechange -> id: ".concat(null===(n=e.target)||void 0===n?void 0:n.id,", volume: ").concat(r,", trackId: ").concat(a._id)}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,n.n=3,this._setPlayAttrs(i,t);case 3:return n.a(2,{code:Ae.SUCCESS})}},n,this)}))}},{key:"__innerDestroy",value:function(){this.__innerSetMediaStreamTrack(void 0)}},{key:"__releaseMediaElement",value:function(){this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.remove(),this._element.srcObject=null)}},{key:"_validateVideoNodeName",value:function(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()}}])}();!function(e){e.Speech="Speech",e.Music="Music",e.MusicHigh="MusicHigh"}(hn||(hn={}));var pn,En=d(d(d({},hn.Music,{max:64,min:64}),hn.MusicHigh,{max:128,min:128}),hn.Speech,{max:32,min:32});!function(e){e.LEVEL0="LEVEL0",e.LEVEL1="LEVEL1",e.LEVEL2="LEVEL2",e.LEVEL3="LEVEL3",e.LEVEL4="LEVEL4",e.LEVEL5="LEVEL5"}(pn||(pn={}));var vn=d(d(d(d(d(d({},pn.LEVEL0,{max:150,min:80}),pn.LEVEL1,{max:280,min:120}),pn.LEVEL2,{max:650,min:150}),pn.LEVEL3,{max:1e3,min:200}),pn.LEVEL4,{max:2200,min:250}),pn.LEVEL5,{max:4e3,min:400}),mn=function(){function e(){c(this,e)}return l(e,null,[{key:"apply3ANoiseWorklet",value:function(t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u;return E().w(function(n){for(;;)switch(n.p=n.n){case 0:return r=new AudioContext({sampleRate:44100}),n.p=1,n.n=2,r.audioWorklet.addModule(e.SCRIPT_URL);case 2:return n.n=3,fetch(e.WASM_URL,{cache:"force-cache",credentials:"same-origin"});case 3:return a=n.v,n.n=4,a.arrayBuffer();case 4:i=n.v,n.n=6;break;case 5:return n.p=5,n.v,n.a(2,{code:Ae.LOAD_3A_MODULE_FAILED});case 6:return o=r.createMediaStreamSource(new MediaStream([t])),s=new AudioWorkletNode(r,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:i}}),c=r.createMediaStreamDestination(),o.connect(s).connect(c),u=c.stream.getAudioTracks()[0],e._maps.set(t.id,r),n.a(2,{code:Ae.SUCCESS,track:u})}},n,null,[[1,5]])}))}},{key:"release3ANoiseWorklet",value:function(t){var n=e._maps.get(t.id);n&&(n.close(),e._maps.delete(t.id))}}])}();Object.defineProperty(mn,"WASM_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(mn,"SCRIPT_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(mn,"_maps",{enumerable:!0,configurable:!0,writable:!0,value:new Map});var Rn=function(){function e(t,n,r,i,a){var o;return c(this,e),o=s(this,e,[t,n,r,i,!0]),Object.defineProperty(o,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_isPublished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_bitrateInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),o.__innerSetMediaStreamTrack(a),a.onended=function(){a.onended=null,o._onTrackEnded()},o}return g(e,gn),l(e,[{key:"_onTrackEnded",value:function(){this.emit(e.EVENT_LOCAL_TRACK_END,this),this.removeAll(e.EVENT_LOCAL_TRACK_END)}},{key:"_setLocalMuted",value:function(t){var n=this;return new Promise(function(r){var i=n._localMuted!==t;S(e,"_setLocalMuted",n,3)([t]),n._remoteMuted=n._localMuted,i&&n._isPublished?n.emit(e.__INNER_EVENT_MUTED_CHANGE__,n,r):r(Ae.SUCCESS),n._logger.info(Ne.L_LOCAL_TRACK_SET_LOCAL_MUTED_O,JSON.stringify({enable:t,trackId:n._id}))})}},{key:"__innerSetPublished",value:function(e){this._isPublished=e}},{key:"isPublished",value:function(){return this._isPublished}},{key:"destroy",value:function(){var t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._isDestroyed||(this._logger.info(Ne.L_LOCAL_TRACK_DESTROY_O,this._id),this._isDestroyed=!0,null===(t=this._msTrack)||void 0===t||t.stop(),S(e,"__innerDestroy",this,3)([]),this.isAudioTrack()&&S(e,"__releaseMediaElement",this,3)([]),this._isPublished&&n&&this.emit(e.__INNER_EVENT_DESTROY__,this))}},{key:"isDestroyed",value:function(){return this._isDestroyed}},{key:"setBitrate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;!W(e)||!W(t)||!W(n)||e<=0||t<=0||e<t?this._logger.error(Ne.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> max: ".concat(e,",min: ").concat(t,", start: ").concat(n),trackId:this._id})):(this._logger.info(Ne.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:ke.SUCCESSED,max:e,min:t,start:n,trackId:this._id})),this._bitrateInfo={max:e,min:t,start:n})}},{key:"getBitrate",value:function(){var e,t,n,r,i,a,o,s=0,c=0,u=0;if((null===(e=this._msTrack)||void 0===e?void 0:e.kind)===an.VIDEO){var l=Gn(this._msTrack);s=l.min,c=l.max}else if((null===(t=this._msTrack)||void 0===t?void 0:t.kind)===an.AUDIO){var _={min:32,max:32};s=_.min,c=_.max}return(null===(n=this._bitrateInfo)||void 0===n?void 0:n.max)&&(u=.7*(null===(r=this._bitrateInfo)||void 0===r?void 0:r.max)),{min:(null===(i=this._bitrateInfo)||void 0===i?void 0:i.min)||s,max:(null===(a=this._bitrateInfo)||void 0===a?void 0:a.max)||c,start:(null===(o=this._bitrateInfo)||void 0===o?void 0:o.start)||u}}},{key:"getSettings",value:function(){var e;return null===(e=this._msTrack)||void 0===e?void 0:e.getSettings()}}])}();Object.defineProperty(Rn,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(Rn,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(Rn,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"});var Tn=function(){function e(t,n,r,i){return c(this,e),s(this,e,[t,n,r,"audio",i])}return g(e,Rn),l(e,[{key:"setRecommendBitrate",value:function(e){if(ce("audioBitrate",e,function(e){return e in hn})){var t=En[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}else this._logger.warn(Ne.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> params type is RCAudioBitrate"}))}},{key:"setBitrate",value:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var a=r[0],o=void 0===a?1:a,s=r[1],c=void 0===s?.7*t||1:s;S(e,"setBitrate",this,3)([t,o,c])}}])}(),In=function(){function e(t,n,r,i){var a,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return c(this,e),a=s(this,e,[t,n,r,"video",i]),Object.defineProperty(a,"_isTiny",{enumerable:!0,configurable:!0,writable:!0,value:o}),a}return g(e,Rn),l(e,[{key:"__isTiny",value:function(){return this._isTiny}},{key:"getStreamId",value:function(){var t=S(e,"getStreamId",this,3)([]);return this._isTiny?"".concat(t,"_tiny"):t}},{key:"getTrackId",value:function(){var t=S(e,"getTrackId",this,3)([]);return this._isTiny?"".concat(t,"_tiny"):t}},{key:"setRecommendBitrate",value:function(e){if(ce("videoBitrate",e,function(e){return e in pn})){var t=vn[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}else this._logger.warn(Ne.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> params type is RCVideoBitrate"}))}},{key:"setBitrate",value:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var a=r[0],o=void 0===a?1:a,s=r[1],c=void 0===s?.7*t||1:s;S(e,"setBitrate",this,3)([t,o,c])}}])}(),Sn=function(){function e(t,n,r,i,a,o){var u;return c(this,e),u=s(this,e,[t,n,r,i,a]),Object.defineProperty(u,"_resource",{enumerable:!0,configurable:!0,writable:!0,value:o}),e._innerSetMapping(u.getTrackId(),o),u}return g(e,Rn),l(e,[{key:"destroy",value:function(){this.isAudioTrack()&&this.mute(),e._innerRemoveMapping(this.getTrackId(),this._resource),S(e,"destroy",this,3)([])}}],[{key:"_innerSetMapping",value:function(e,t){var n=this._mapping.get(t)||[];n.push(e),this._mapping.set(t,n)}},{key:"_innerRemoveMapping",value:function(e,t){var n,r,i=null===(n=this._mapping.get(t))||void 0===n?void 0:n.filter(function(t){return t!==e});i&&i.length>0?this._mapping.set(t,i):(this._mapping.delete(t),t.pause(),t.src="",null===(r=t.parentNode)||void 0===r||r.removeChild(t))}}])}();Object.defineProperty(Sn,"_mapping",{enumerable:!0,configurable:!0,writable:!0,value:new Map});var Cn,Ln=function(){function e(t,n,r,i,a){return c(this,e),s(this,e,[t,n,r,"video",i,a])}return g(e,Sn),l(e)}(),On=function(){function e(t,n,r,i,a){return c(this,e),s(this,e,[t,n,r,"audio",i,a])}return g(e,Sn),l(e,[{key:"_setLocalMuted",value:function(t){var n=this,r=Object.create(null,{_setLocalMuted:{get:function(){return S(e,"_setLocalMuted",n,1)}}});return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return this._resource&&(this._resource.muted=t),e.a(2,r._setLocalMuted.call(this,t))},e,this)}))}},{key:"play",value:function(){return F(this,void 0,void 0,E().m(function e(){var t;return E().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this._setLocalMuted(!1);case 1:return t=e.v,e.a(2,{code:t})}},e,this)}))}}])}(),yn=function(){function e(){var t;return c(this,e),t=s(this,e,arguments),Object.defineProperty(t,"_originTrack",{enumerable:!0,configurable:!0,writable:!0,value:null}),t}return g(e,Tn),l(e,[{key:"apply3ANoiseWorklet",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r;return E().w(function(e){for(;;)switch(e.n){case 0:if(this._logger.info(Ne.A_APPLY_3A_NOISE_WORKLET_T),!this._originTrack){e.n=1;break}return this._logger.warn(Ne.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ke.FAILED,msg:"3A noise module already applied"})),e.a(2,{code:Ae.SUCCESS});case 1:if(this._msTrack&&!this.isDestroyed()){e.n=2;break}return this._logger.warn(Ne.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ke.FAILED,msg:"track not ready"})),e.a(2,{code:Ae.TRACK_NOT_READY});case 2:if(!this.isPublished()){e.n=3;break}return this._logger.warn(Ne.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ke.FAILED,msg:"track already published"})),e.a(2,{code:Ae.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH});case 3:return e.n=4,mn.apply3ANoiseWorklet(this._msTrack);case 4:if(t=e.v,n=t.code,r=t.track,n===Ae.SUCCESS&&r){e.n=5;break}return this._logger.warn(Ne.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ke.FAILED,msg:"apply 3A noise module failed: ".concat(n),SCRIPT_URL:mn.SCRIPT_URL,WASM_URL:mn.WASM_URL})),e.a(2,{code:n});case 5:return this._originTrack=this._msTrack,this._msTrack=r,this._logger.info(Ne.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ke.SUCCESSED})),e.a(2,{code:Ae.SUCCESS})}},e,this)}))}},{key:"__innerSetMediaStreamTrack",value:function(t){!t&&this._originTrack&&(mn.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),S(e,"__innerSetMediaStreamTrack",this,3)([t])}},{key:"replaceInnerTrack",value:function(e){}}])}(),bn=function(){function e(t,n,r,i){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return c(this,e),s(this,e,[t,n,r,i,a])}return g(e,In),l(e,[{key:"replaceInnerTrack",value:function(e){}}])}(),An=function(){function e(){return c(this,e),s(this,e,arguments)}return g(e,In),l(e,[{key:"_onTrackEnded",value:function(){S(e,"_onTrackEnded",this,3)([]),this.isPublished()&&this.emit(Rn.__INNER_EVENT_DESTROY__,this)}}])}(),Nn=function(){function e(){return c(this,e),s(this,e,arguments)}return g(e,Tn),l(e,[{key:"_onTrackEnded",value:function(){S(e,"_onTrackEnded",this,3)([]),this.isPublished()&&this.emit(Rn.__INNER_EVENT_DESTROY__,this)}}])}(),kn=function(){function e(t,n,r,i,a){var o;return c(this,e),o=s(this,e,[t,n,r,i,!1,a]),Object.defineProperty(o,"_isSubscribed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),o}return g(e,gn),l(e,[{key:"__innerSetRemoteMuted",value:function(e){this._remoteMuted=e}},{key:"__innerSetSubscribed",value:function(e){this._isSubscribed=e}},{key:"isSubscribed",value:function(){return this._isSubscribed}}])}(),Pn=function(){function e(t,n,r,i){return c(this,e),s(this,e,[t,n,r,"audio",i])}return g(e,kn),l(e,[{key:"_setLocalMuted",value:function(t){var n=Zn.browser,r=Zn.version;return this._element&&r&&/chrome/i.test(n)&&r>=130&&(this._element.muted=t),S(e,"_setLocalMuted",this,3)([t])}},{key:"getVolume",value:function(){var e;return 100*((null===(e=this._element)||void 0===e?void 0:e.volume)||0)}}])}(),Un=function(){function e(t,n,r,i){var a;return c(this,e),a=s(this,e,[t,n,r,"video",i]),Object.defineProperty(a,"_isSubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),a}return g(e,kn),l(e,[{key:"__innerSetIsTinyTrack",value:function(e){this._isSubTiny=e}},{key:"isSubTiny",value:function(){return this._isSubTiny}}])}();!function(e){e[e.MARK_DOWN=0]="MARK_DOWN",e[e.JSON=1]="JSON"}(Cn||(Cn={}));var wn,Dn=function(e,t){return{name:e,content:JSON.stringify({uris:t,ignore:!0})}},Mn=function(e){return JSON.stringify(e)},xn=function(e){return/^[a-zA-Z\d-=]+$/g.test(e)},Vn=function(e){if(void 0===e)return 0;if(W(e))return e;var t=e;return t.exact||t.ideal||t.max||0},Bn=function(e){var t=e.getSettings(),n=e.getConstraints();return{width:Vn(n.width)||t.width||0,height:Vn(n.height)||t.height||0,frameRate:t.frameRate||Vn(n.frameRate)}},Gn=function(e){var t=Bn(e),n=t.width,r=t.height,i=t.frameRate,a=cn(n||1920,r||1080),o=ln(i);return{min:a.minBitrate*o,max:a.maxBitrate*o}},jn=function(e){return[e.msid,e.mediaType].join("_")},Fn=function(e){var t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},Hn=function(e,t){return[e,t].join("_")},Jn=function(e){return e.map(function(e){return Object.assign({},e)})},Kn=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e=e.slice();var r=[],i=[],a=[];return t.forEach(function(t){var i=jn(t),o=e.findIndex(function(e){return jn(e)===i});if(n&&(o=e.findIndex(function(e){return e.uri===t.uri})),-1!==o){var s=e[o];s.uri!==t.uri?r.push(t):s.state!==t.state&&a.push(t),e.splice(o,1)}else r.push(t)}),i.push.apply(i,C(e)),{publishedList:r,unpublishedList:i,modifiedList:a}},Yn=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return e="".concat(e.replace(/-/g,""),"0"),(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),n=t.length+1,r=+e,i=[];do{var a=r%n;r=(r-a)/n,i.unshift(t[a])}while(r);return i.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},qn=function(e){if(on[e]){var t=on[e];return{width:t.width,height:t.height}}var n=I(e.split("_").map(function(e){return parseInt(e.replace(/[^\d]/g,""))}),2);return{width:n[0],height:n[1]}},Wn=function(e){return!!exports.NCCallVideoResolution[e]},zn=function(e){return!!exports.NCCallVideoFrameRate[e]},Qn=function(e){return parseInt(e.replace("FPS_",""))},Zn={browser:(wn=$t.browserDetails).browser,version:wn.version,supportsUnifiedPlan:!1!==wn.supportsUnifiedPlan};function Xn(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function $n(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}var er,tr,nr=function(e){return"[object Null]"===Object.prototype.toString.call(e)},rr=function(e){return 1===e.type},ir=function(e,t){var n=0;return e.forEach(function(e){var r=e instanceof Rn?e.getTrackId():e.track.getTrackId();t.getLocalTrack(r)||(e instanceof Rn?n++:e.pubTiny&&e.track.isVideoTrack()&&(n+=2))}),n},ar=function(e,t,n,r){var i={},a=Object.keys(e.users);return a.length&&a.forEach(function(a){var o=[],s=e.users[a];if(s.extra){var c=JSON.parse(s.extra).roomId;if(t!==c)return}if(s.uris)try{o.push.apply(o,C(JSON.parse(s.uris)))}catch(e){n.warn(Ne.L_PARSE_ROOMDATA_URIS_R,"invalid user data -> userId: ".concat(a,", userData: ").concat(s),r)}i[a]=o}),i},or=function(e,t){for(var n=!1,r=0,i=0;i<t.length;i++){var a=t[i];if("".concat(e.msid,"_").concat(e.mediaType)==="".concat(a.msid,"_").concat(a.mediaType)){n=!0,r=i;break}}return{isInclude:n,index:r}},sr=function(e){return e instanceof gn?e.getTrackId():e.track.getTrackId()},cr=function(e){if(!X(e)||void 0===e.low||void 0===e.high)return e;var t=e.low;return t<0&&(t+=4294967296),t=t.toString(16),parseInt(e.high.toString(16)+"00000000".replace(new RegExp("0{".concat(t.length,"}$")),t),16)},ur=function(e){if("destLang"in e&&!Y(e.destLang))return{isValid:!1,key:"destLang"};if("customPrompt"in e&&!Y(e.customPrompt))return{isValid:!1,key:"customPrompt"};if("enableSummarization"in e&&!q(e.enableSummarization))return{isValid:!1,key:"enableSummarization"};if("enableSummarizationDetails"in e&&!q(e.enableSummarizationDetails))return{isValid:!1,key:"enableSummarizationDetails"};if("enableChapterSummary"in e&&!q(e.enableChapterSummary))return{isValid:!1,key:"enableChapterSummary"};if("enableTodoList"in e&&!q(e.enableTodoList))return{isValid:!1,key:"enableTodoList"};if("enableHashtag"in e&&!q(e.enableHashtag))return{isValid:!1,key:"enableHashtag"};if("format"in e&&void 0===Cn[e.format])return{isValid:!1,key:"format"};var t=e.enableSummarization||e.enableSummarizationDetails||e.enableChapterSummary||e.enableTodoList||e.enableHashtag;return e.customPrompt||t?{isValid:!0,key:""}:{isValid:!1,key:"at least one of the summary features must be enabled"}};!function(e){e.PUBLISH="RCRTC:PublishResource",e.UNPUBLISH="RCRTC:UnpublishResource",e.MODIFY="RCRTC:ModifyResource",e.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",e.STATE="RCRTC:state",e.ROOM_NOTIFY="RCRTC:RoomNtf",e.USER_NOTIFY="RCRTC:UserNtf",e.KICK="RCRTC:kick",e.PK_INVITE="RCRTC:invite",e.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",e.PK_CANCEL_INVITE="RCRTC:cancelInvite",e.PK_INVITE_ANSWER="RCRTC:answerInvite",e.PK_END="RCRTC:endInvite",e.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline",e.ROOM_TASK_FINISH="RCRTC:roomTaskFinish",e.ASR_STATUS="RCRTC:AsrStatus",e.ASR_SEI="RCRTC:PublishSeiAi",e.SUMMARIZATION_STATUS="RCRTC:Summarization"}(er||(er={})),function(e){e.SUCCESS="Success",e.FAIL="Fail"}(tr||(tr={}));var lr=function(){return l(function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;c(this,e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_roomMode",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_gap",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_latestTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onPingResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_started",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger},[{key:"start",value:function(e){this._started||(e<15e3&&(e=15e3),this._logger.info(Ne.L_PINGER_START_O,JSON.stringify({interval:this._gap,offlineKickTime:e})),this._started=!0,this._checkAlive(e))}},{key:"_sendPing",value:function(){var e=this;return new Promise(function(t){e._context.rtcPing(e._roomId,e._roomMode).then(t),setTimeout(t,5e3,{code:Me})})}},{key:"_checkAlive",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c=this;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this._context.logger,r=n.createTraceId(),t.n=1,this._sendPing();case 1:if(i=t.v,a=i.code,o=i.data,this._started){t.n=2;break}return t.a(2);case 2:if(s=Date.now(),a!==we){t.n=3;break}return this._latestTimestamp=s,this.onPingResult(tr.SUCCESS,o.version),this._timer=setTimeout(function(){return c._checkAlive(e)},this._gap),t.a(2);case 3:if(n.error(Ne.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:a}),r),this.onPingResult(tr.FAIL),!(40003===a||s-this._latestTimestamp>e)){t.n=4;break}return this.stop(),this.onFailed(40003===a),t.a(2);case 4:this._timer=setTimeout(function(){return c._checkAlive(e)},this._gap);case 5:return t.a(2)}},t,this)}))}},{key:"stop",value:function(){this._started&&(this._logger.info(Ne.L_PINGER_STOP_O),this._started=!1,this._timer&&(clearTimeout(this._timer),this._timer=null))}}])}();function _r(e){let t=e.length;for(;--t>=0;)e[t]=0}const dr=256,fr=286,hr=30,gr=15,pr=new Uint8Array([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]),Er=new Uint8Array([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]),vr=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),mr=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Rr=new Array(576);_r(Rr);const Tr=new Array(60);_r(Tr);const Ir=new Array(512);_r(Ir);const Sr=new Array(256);_r(Sr);const Cr=new Array(29);_r(Cr);const Lr=new Array(hr);function Or(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}let yr,br,Ar;function Nr(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}_r(Lr);const kr=e=>e<256?Ir[e]:Ir[256+(e>>>7)],Pr=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Ur=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,Pr(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},wr=(e,t,n)=>{Ur(e,n[2*t],n[2*t+1])},Dr=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Mr=(e,t,n)=>{const r=new Array(16);let i,a,o=0;for(i=1;i<=gr;i++)o=o+n[i-1]<<1,r[i]=o;for(a=0;a<=t;a++){let t=e[2*a+1];0!==t&&(e[2*a]=Dr(r[t]++,t))}},xr=e=>{let t;for(t=0;t<fr;t++)e.dyn_ltree[2*t]=0;for(t=0;t<hr;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},Vr=e=>{e.bi_valid>8?Pr(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Br=(e,t,n,r)=>{const i=2*t,a=2*n;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},Gr=(e,t,n)=>{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&Br(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Br(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},jr=(e,t,n)=>{let r,i,a,o,s=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+s++],r+=(255&e.pending_buf[e.sym_buf+s++])<<8,i=e.pending_buf[e.sym_buf+s++],0===r?wr(e,i,t):(a=Sr[i],wr(e,a+dr+1,t),o=pr[a],0!==o&&(i-=Cr[a],Ur(e,i,o)),r--,a=kr(r),wr(e,a,n),o=Er[a],0!==o&&(r-=Lr[a],Ur(e,r,o)))}while(s<e.sym_next);wr(e,256,t)},Fr=(e,t)=>{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems;let o,s,c,u=-1;for(e.heap_len=0,e.heap_max=573,o=0;o<a;o++)0!==n[2*o]?(e.heap[++e.heap_len]=u=o,e.depth[o]=0):n[2*o+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=u<2?++u:0,n[2*c]=1,e.depth[c]=0,e.opt_len--,i&&(e.static_len-=r[2*c+1]);for(t.max_code=u,o=e.heap_len>>1;o>=1;o--)Gr(e,n,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Gr(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[2*c]=n[2*o]+n[2*s],e.depth[c]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[2*o+1]=n[2*s+1]=c,e.heap[1]=c++,Gr(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,_,d,f,h,g=0;for(d=0;d<=gr;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,g++),n[2*l+1]=d,l>r||(e.bl_count[d]++,f=0,l>=s&&(f=o[l-s]),h=n[2*l],e.opt_len+=h*(d+f),a&&(e.static_len+=h*(i[2*l+1]+f)));if(0!==g){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,g-=2}while(g>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)_=e.heap[--u],_>r||(n[2*_+1]!==d&&(e.opt_len+=(d-n[2*_+1])*n[2*_],n[2*_+1]=d),l--)}})(e,t),Mr(n,u,e.bl_count)},Hr=(e,t,n)=>{let 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],++s<c&&i===o||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,a=i,0===o?(c=138,u=3):i===o?(c=6,u=3):(c=7,u=4))},Jr=(e,t,n)=>{let r,i,a=-1,o=t[1],s=0,c=7,u=4;for(0===o&&(c=138,u=3),r=0;r<=n;r++)if(i=o,o=t[2*(r+1)+1],!(++s<c&&i===o)){if(s<u)do{wr(e,i,e.bl_tree)}while(0!==--s);else 0!==i?(i!==a&&(wr(e,i,e.bl_tree),s--),wr(e,16,e.bl_tree),Ur(e,s-3,2)):s<=10?(wr(e,17,e.bl_tree),Ur(e,s-3,3)):(wr(e,18,e.bl_tree),Ur(e,s-11,7));s=0,a=i,0===o?(c=138,u=3):i===o?(c=6,u=3):(c=7,u=4)}};let Kr=!1;const Yr=(e,t,n,r)=>{Ur(e,0+(r?1:0),3),Vr(e),Pr(e,n),Pr(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var qr=(e,t,n,r)=>{let i,a,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<dr;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),Fr(e,e.l_desc),Fr(e,e.d_desc),o=(e=>{let t;for(Hr(e,e.dyn_ltree,e.l_desc.max_code),Hr(e,e.dyn_dtree,e.d_desc.max_code),Fr(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*mr[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,a<=i&&(i=a)):i=a=n+5,n+4<=i&&-1!==t?Yr(e,t,n,r):4===e.strategy||a===i?(Ur(e,2+(r?1:0),3),jr(e,Rr,Tr)):(Ur(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for(Ur(e,t-257,5),Ur(e,n-1,5),Ur(e,r-4,4),i=0;i<r;i++)Ur(e,e.bl_tree[2*mr[i]+1],3);Jr(e,e.dyn_ltree,t-1),Jr(e,e.dyn_dtree,n-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),jr(e,e.dyn_ltree,e.dyn_dtree)),xr(e),r&&Vr(e)},Wr={_tr_init:e=>{Kr||((()=>{let e,t,n,r,i;const a=new Array(16);for(n=0,r=0;r<28;r++)for(Cr[r]=n,e=0;e<1<<pr[r];e++)Sr[n++]=r;for(Sr[n-1]=r,i=0,r=0;r<16;r++)for(Lr[r]=i,e=0;e<1<<Er[r];e++)Ir[i++]=r;for(i>>=7;r<hr;r++)for(Lr[r]=i<<7,e=0;e<1<<Er[r]-7;e++)Ir[256+i++]=r;for(t=0;t<=gr;t++)a[t]=0;for(e=0;e<=143;)Rr[2*e+1]=8,e++,a[8]++;for(;e<=255;)Rr[2*e+1]=9,e++,a[9]++;for(;e<=279;)Rr[2*e+1]=7,e++,a[7]++;for(;e<=287;)Rr[2*e+1]=8,e++,a[8]++;for(Mr(Rr,287,a),e=0;e<hr;e++)Tr[2*e+1]=5,Tr[2*e]=Dr(e,5);yr=new Or(Rr,pr,257,fr,gr),br=new Or(Tr,Er,0,hr,gr),Ar=new Or(new Array(0),vr,0,19,7)})(),Kr=!0),e.l_desc=new Nr(e.dyn_ltree,yr),e.d_desc=new Nr(e.dyn_dtree,br),e.bl_desc=new Nr(e.bl_tree,Ar),e.bi_buf=0,e.bi_valid=0,xr(e)},_tr_stored_block:Yr,_tr_flush_block:qr,_tr_tally:(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Sr[n]+dr+1)]++,e.dyn_dtree[2*kr(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Ur(e,2,3),wr(e,256,Rr),(e=>{16===e.bi_valid?(Pr(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 zr=(e,t,n,r)=>{let i=65535&e,a=e>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{i=i+t[r++]|0,a=a+i|0}while(--o);i%=65521,a%=65521}return i|a<<16};const Qr=new Uint32Array((()=>{let e,t=[];for(var 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 Zr=(e,t,n,r)=>{const i=Qr,a=r+n;e^=-1;for(let n=r;n<a;n++)e=e>>>8^i[255&(e^t[n])];return-1^e},Xr={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"},$r={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ei,_tr_stored_block:ti,_tr_flush_block:ni,_tr_tally:ri,_tr_align:ii}=Wr,{Z_NO_FLUSH:ai,Z_PARTIAL_FLUSH:oi,Z_FULL_FLUSH:si,Z_FINISH:ci,Z_BLOCK:ui,Z_OK:li,Z_STREAM_END:_i,Z_STREAM_ERROR:di,Z_DATA_ERROR:fi,Z_BUF_ERROR:hi,Z_DEFAULT_COMPRESSION:gi,Z_FILTERED:pi,Z_HUFFMAN_ONLY:Ei,Z_RLE:vi,Z_FIXED:mi,Z_DEFAULT_STRATEGY:Ri,Z_UNKNOWN:Ti,Z_DEFLATED:Ii}=$r,Si=258,Ci=262,Li=42,Oi=113,yi=666,bi=(e,t)=>(e.msg=Xr[t],t),Ai=e=>2*e-(e>4?9:0),Ni=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ki=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let Pi=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask;const Ui=e=>{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,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))},wi=(e,t)=>{ni(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ui(e.strm)},Di=(e,t)=>{e.pending_buf[e.pending++]=t},Mi=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},xi=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=zr(e.adler,t,i,n):2===e.state.wrap&&(e.adler=Zr(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},Vi=(e,t)=>{let n,r,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-Ci?e.strstart-(e.w_size-Ci):0,u=e.window,l=e.w_mask,_=e.prev,d=e.strstart+Si;let f=u[a+o-1],h=u[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(n=t,u[n+o]===h&&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]&&a<d);if(r=Si-(d-a),a=d-Si,r>o){if(e.match_start=t,o=r,r>=s)break;f=u[a+o-1],h=u[a+o]}}}while((t=_[t&l])>c&&0!==--i);return o<=e.lookahead?o:e.lookahead},Bi=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Ci)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),ki(e),r+=t),0===e.strm.avail_in)break;if(n=xi(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Pi(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Pi(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<Ci&&0!==e.strm.avail_in)},Gi=(e,t)=>{let n,r,i,a=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,s=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_out<i)break;if(i=e.strm.avail_out-i,r=e.strstart-e.block_start,n>r+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n<a&&(0===n&&t!==ci||t===ai||n!==r+e.strm.avail_in))break;o=t===ci&&n===r+e.strm.avail_in?1:0,ti(e,0,0,o),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Ui(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(xi(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===o);return s-=e.strm.avail_in,s&&(s>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=s&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?4:t!==ai&&t!==ci&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(i=e.window_size-e.strstart,e.strm.avail_in>i&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(xi(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water<e.strstart&&(e.high_water=e.strstart),i=e.bi_valid+42>>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,a=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=a||(r||t===ci)&&t!==ai&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,o=t===ci&&0===e.strm.avail_in&&n===r?1:0,ti(e,e.block_start,n,o),e.block_start+=n,Ui(e.strm)),o?3:1)},ji=(e,t)=>{let n,r;for(;;){if(e.lookahead<Ci){if(Bi(e),e.lookahead<Ci&&t===ai)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=Pi(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-Ci&&(e.match_length=Vi(e,n)),e.match_length>=3)if(r=ri(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Pi(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!==--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Pi(e,e.ins_h,e.window[e.strstart+1]);else r=ri(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(wi(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===ci?(wi(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(wi(e,!1),0===e.strm.avail_out)?1:2},Fi=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<Ci){if(Bi(e),e.lookahead<Ci&&t===ai)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=Pi(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-Ci&&(e.match_length=Vi(e,n),e.match_length<=5&&(e.strategy===pi||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=ri(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=Pi(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!==--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(wi(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=ri(e,0,e.window[e.strstart-1]),r&&wi(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ri(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===ci?(wi(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(wi(e,!1),0===e.strm.avail_out)?1:2};function Hi(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const Ji=[new Hi(0,0,0,0,Gi),new Hi(4,4,8,4,ji),new Hi(4,5,16,8,ji),new Hi(4,6,32,32,ji),new Hi(4,4,16,16,Fi),new Hi(8,16,32,32,Fi),new Hi(8,16,128,128,Fi),new Hi(8,32,128,256,Fi),new Hi(32,128,258,1024,Fi),new Hi(32,258,258,4096,Fi)];function Ki(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ii,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Ni(this.dyn_ltree),Ni(this.dyn_dtree),Ni(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Ni(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Ni(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Yi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Li&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Oi&&t.status!==yi?1:0},qi=e=>{if(Yi(e))return bi(e,di);e.total_in=e.total_out=0,e.data_type=Ti;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Li:Oi,e.adler=2===t.wrap?0:1,t.last_flush=-2,ei(t),li},Wi=e=>{const t=qi(e);var n;return t===li&&((n=e.state).window_size=2*n.w_size,Ni(n.head),n.max_lazy_match=Ji[n.level].max_lazy,n.good_match=Ji[n.level].good_length,n.nice_match=Ji[n.level].nice_length,n.max_chain_length=Ji[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},zi=(e,t,n,r,i,a)=>{if(!e)return di;let o=1;if(t===gi&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>9||n!==Ii||r<8||r>15||t<0||t>9||a<0||a>mi||8===r&&1!==o)return bi(e,di);8===r&&(r=9);const s=new Ki;return e.state=s,s.strm=e,s.status=Li,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new Uint8Array(2*s.w_size),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=3*(s.lit_bufsize-1),s.level=t,s.strategy=a,s.method=n,Wi(e)};var Qi={deflateInit:(e,t)=>zi(e,t,Ii,15,8,Ri),deflateInit2:zi,deflateReset:Wi,deflateResetKeep:qi,deflateSetHeader:(e,t)=>Yi(e)||2!==e.state.wrap?di:(e.state.gzhead=t,li),deflate:(e,t)=>{if(Yi(e)||t>ui||t<0)return e?bi(e,di):di;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===yi&&t!==ci)return bi(e,0===e.avail_out?hi:di);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Ui(e),0===e.avail_out)return n.last_flush=-1,li}else if(0===e.avail_in&&Ai(t)<=Ai(r)&&t!==ci)return bi(e,hi);if(n.status===yi&&0!==e.avail_in)return bi(e,hi);if(n.status===Li&&0===n.wrap&&(n.status=Oi),n.status===Li){let t=Ii+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Ei||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Mi(n,t),0!==n.strstart&&(Mi(n,e.adler>>>16),Mi(n,65535&e.adler)),e.adler=1,n.status=Oi,Ui(e),0!==n.pending)return n.last_flush=-1,li}if(57===n.status)if(e.adler=0,Di(n,31),Di(n,139),Di(n,8),n.gzhead)Di(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Di(n,255&n.gzhead.time),Di(n,n.gzhead.time>>8&255),Di(n,n.gzhead.time>>16&255),Di(n,n.gzhead.time>>24&255),Di(n,9===n.level?2:n.strategy>=Ei||n.level<2?4:0),Di(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Di(n,255&n.gzhead.extra.length),Di(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Zr(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Di(n,0),Di(n,0),Di(n,0),Di(n,0),Di(n,0),Di(n,9===n.level?2:n.strategy>=Ei||n.level<2?4:0),Di(n,3),n.status=Oi,Ui(e),0!==n.pending)return n.last_flush=-1,li;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,Ui(e),0!==n.pending)return n.last_flush=-1,li;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-r,r)),Ui(e),0!==n.pending)return n.last_flush=-1,li;r=0}t=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,Di(n,t)}while(0!==t);n.gzhead.hcrc&&n.pending>r&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-r,r)),Ui(e),0!==n.pending)return n.last_flush=-1,li;r=0}t=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,Di(n,t)}while(0!==t);n.gzhead.hcrc&&n.pending>r&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Ui(e),0!==n.pending))return n.last_flush=-1,li;Di(n,255&e.adler),Di(n,e.adler>>8&255),e.adler=0}if(n.status=Oi,Ui(e),0!==n.pending)return n.last_flush=-1,li}if(0!==e.avail_in||0!==n.lookahead||t!==ai&&n.status!==yi){let r=0===n.level?Gi(n,t):n.strategy===Ei?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Bi(e),0===e.lookahead)){if(t===ai)return 1;break}if(e.match_length=0,n=ri(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(wi(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ci?(wi(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(wi(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===vi?((e,t)=>{let n,r,i,a;const o=e.window;for(;;){if(e.lookahead<=Si){if(Bi(e),e.lookahead<=Si&&t===ai)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+Si;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]&&i<a);e.match_length=Si-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=ri(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ri(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(wi(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ci?(wi(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(wi(e,!1),0===e.strm.avail_out)?1:2})(n,t):Ji[n.level].func(n,t);if(3!==r&&4!==r||(n.status=yi),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),li;if(2===r&&(t===oi?ii(n):t!==ui&&(ti(n,0,0,!1),t===si&&(Ni(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Ui(e),0===e.avail_out))return n.last_flush=-1,li}return t!==ci?li:n.wrap<=0?_i:(2===n.wrap?(Di(n,255&e.adler),Di(n,e.adler>>8&255),Di(n,e.adler>>16&255),Di(n,e.adler>>24&255),Di(n,255&e.total_in),Di(n,e.total_in>>8&255),Di(n,e.total_in>>16&255),Di(n,e.total_in>>24&255)):(Mi(n,e.adler>>>16),Mi(n,65535&e.adler)),Ui(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?li:_i)},deflateEnd:e=>{if(Yi(e))return di;const t=e.state.status;return e.state=null,t===Oi?bi(e,fi):li},deflateSetDictionary:(e,t)=>{let n=t.length;if(Yi(e))return di;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==Li||r.lookahead)return di;if(1===i&&(e.adler=zr(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(Ni(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Bi(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Pi(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,Bi(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,li},deflateInfo:"pako deflate (from Nodeca project)"};const Zi=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Xi=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Zi(n,t)&&(e[t]=n[t])}}return e},$i=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;const n=new Uint8Array(t);for(let t=0,r=0,i=e.length;t<i;t++){let i=e[t];n.set(i,r),r+=i.length}return n};let ea=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){ea=!1}const ta=new Uint8Array(256);for(let e=0;e<256;e++)ta[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ta[254]=ta[254]=1;var na=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,a,o=e.length,s=0;for(i=0;i<o;i++)n=e.charCodeAt(i),55296==(64512&n)&&i+1<o&&(r=e.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)n=e.charCodeAt(i),55296==(64512&n)&&i+1<o&&(r=e.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>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},ra=(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const a=new Array(2*n);for(i=0,r=0;r<n;){let t=e[r++];if(t<128){a[i++]=t;continue}let o=ta[t];if(o>4)a[i++]=65533,r+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&r<n;)t=t<<6|63&e[r++],o--;o>1?a[i++]=65533:t<65536?a[i++]=t:(t-=65536,a[i++]=55296|t>>10&1023,a[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&ea)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n})(a,i)},ia=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+ta[e[n]]>t?n:t};var aa=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};const oa=Object.prototype.toString,{Z_NO_FLUSH:sa,Z_SYNC_FLUSH:ca,Z_FULL_FLUSH:ua,Z_FINISH:la,Z_OK:_a,Z_STREAM_END:da,Z_DEFAULT_COMPRESSION:fa,Z_DEFAULT_STRATEGY:ha,Z_DEFLATED:ga}=$r;function pa(e){this.options=Xi({level:fa,method:ga,chunkSize:16384,windowBits:15,memLevel:8,strategy:ha},e||{});let 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 aa,this.strm.avail_out=0;let n=Qi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==_a)throw new Error(Xr[n]);if(t.header&&Qi.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?na(t.dictionary):"[object ArrayBuffer]"===oa.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Qi.deflateSetDictionary(this.strm,e),n!==_a)throw new Error(Xr[n]);this._dict_set=!0}}function Ea(e,t){const n=new pa(t);if(n.push(e,!0),n.err)throw n.msg||Xr[n.err];return n.result}pa.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,a;if(this.ended)return!1;for(a=t===~~t?t:!0===t?la:sa,"string"==typeof e?n.input=na(e):"[object ArrayBuffer]"===oa.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(a===ca||a===ua)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=Qi.deflate(n,a),i===da)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=Qi.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===_a;if(0!==n.avail_out){if(a>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},pa.prototype.onData=function(e){this.chunks.push(e)},pa.prototype.onEnd=function(e){e===_a&&(this.result=$i(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var va={Deflate:pa,deflate:Ea,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Ea(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Ea(e,t)},constants:$r};const ma=16209;var Ra=function(e,t){let n,r,i,a,o,s,c,u,l,_,d,f,h,g,p,E,v,m,R,T,I,S,C,L;const O=e.state;n=e.next_in,C=e.input,r=n+(e.avail_in-5),i=e.next_out,L=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=O.dmax,c=O.wsize,u=O.whave,l=O.wnext,_=O.window,d=O.hold,f=O.bits,h=O.lencode,g=O.distcode,p=(1<<O.lenbits)-1,E=(1<<O.distbits)-1;e:do{f<15&&(d+=C[n++]<<f,f+=8,d+=C[n++]<<f,f+=8),v=h[d&p];t:for(;;){if(m=v>>>24,d>>>=m,f-=m,m=v>>>16&255,0===m)L[i++]=65535&v;else{if(!(16&m)){if(64&m){if(32&m){O.mode=16191;break e}e.msg="invalid literal/length code",O.mode=ma;break e}v=h[(65535&v)+(d&(1<<m)-1)];continue t}for(R=65535&v,m&=15,m&&(f<m&&(d+=C[n++]<<f,f+=8),R+=d&(1<<m)-1,d>>>=m,f-=m),f<15&&(d+=C[n++]<<f,f+=8,d+=C[n++]<<f,f+=8),v=g[d&E];;){if(m=v>>>24,d>>>=m,f-=m,m=v>>>16&255,16&m){if(T=65535&v,m&=15,f<m&&(d+=C[n++]<<f,f+=8,f<m&&(d+=C[n++]<<f,f+=8)),T+=d&(1<<m)-1,T>s){e.msg="invalid distance too far back",O.mode=ma;break e}if(d>>>=m,f-=m,m=i-a,T>m){if(m=T-m,m>u&&O.sane){e.msg="invalid distance too far back",O.mode=ma;break e}if(I=0,S=_,0===l){if(I+=c-m,m<R){R-=m;do{L[i++]=_[I++]}while(--m);I=i-T,S=L}}else if(l<m){if(I+=c+l-m,m-=l,m<R){R-=m;do{L[i++]=_[I++]}while(--m);if(I=0,l<R){m=l,R-=m;do{L[i++]=_[I++]}while(--m);I=i-T,S=L}}}else if(I+=l-m,m<R){R-=m;do{L[i++]=_[I++]}while(--m);I=i-T,S=L}for(;R>2;)L[i++]=S[I++],L[i++]=S[I++],L[i++]=S[I++],R-=3;R&&(L[i++]=S[I++],R>1&&(L[i++]=S[I++]))}else{I=i-T;do{L[i++]=L[I++],L[i++]=L[I++],L[i++]=L[I++],R-=3}while(R>2);R&&(L[i++]=L[I++],R>1&&(L[i++]=L[I++]))}break}if(64&m){e.msg="invalid distance code",O.mode=ma;break e}v=g[(65535&v)+(d&(1<<m)-1)]}}break}}while(n<r&&i<o);R=f>>3,n-=R,f-=R<<3,d&=(1<<f)-1,e.next_in=n,e.next_out=i,e.avail_in=n<r?r-n+5:5-(n-r),e.avail_out=i<o?o-i+257:257-(i-o),O.hold=d,O.bits=f};const Ta=15,Ia=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Sa=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Ca=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),La=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Oa=(e,t,n,r,i,a,o,s)=>{const c=s.bits;let u,l,_,d,f,h,g=0,p=0,E=0,v=0,m=0,R=0,T=0,I=0,S=0,C=0,L=null;const O=new Uint16Array(16),y=new Uint16Array(16);let b,A,N,k=null;for(g=0;g<=Ta;g++)O[g]=0;for(p=0;p<r;p++)O[t[n+p]]++;for(m=c,v=Ta;v>=1&&0===O[v];v--);if(m>v&&(m=v),0===v)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(E=1;E<v&&0===O[E];E++);for(m<E&&(m=E),I=1,g=1;g<=Ta;g++)if(I<<=1,I-=O[g],I<0)return-1;if(I>0&&(0===e||1!==v))return-1;for(y[1]=0,g=1;g<Ta;g++)y[g+1]=y[g]+O[g];for(p=0;p<r;p++)0!==t[n+p]&&(o[y[t[n+p]]++]=p);if(0===e?(L=k=o,h=20):1===e?(L=Ia,k=Sa,h=257):(L=Ca,k=La,h=0),C=0,p=0,g=E,f=a,R=m,T=0,_=-1,S=1<<m,d=S-1,1===e&&S>852||2===e&&S>592)return 1;for(;;){b=g-T,o[p]+1<h?(A=0,N=o[p]):o[p]>=h?(A=k[o[p]-h],N=L[o[p]-h]):(A=96,N=0),u=1<<g-T,l=1<<R,E=l;do{l-=u,i[f+(C>>T)+l]=b<<24|A<<16|N}while(0!==l);for(u=1<<g-1;C&u;)u>>=1;if(0!==u?(C&=u-1,C+=u):C=0,p++,0===--O[g]){if(g===v)break;g=t[n+o[p]]}if(g>m&&(C&d)!==_){for(0===T&&(T=m),f+=E,R=g-T,I=1<<R;R+T<v&&(I-=O[R+T],!(I<=0));)R++,I<<=1;if(S+=1<<R,1===e&&S>852||2===e&&S>592)return 1;_=C&d,i[_]=m<<24|R<<16|f-a}}return 0!==C&&(i[f+C]=g-T<<24|64<<16),s.bits=m,0};const{Z_FINISH:ya,Z_BLOCK:ba,Z_TREES:Aa,Z_OK:Na,Z_STREAM_END:ka,Z_NEED_DICT:Pa,Z_STREAM_ERROR:Ua,Z_DATA_ERROR:wa,Z_MEM_ERROR:Da,Z_BUF_ERROR:Ma,Z_DEFLATED:xa}=$r,Va=16180,Ba=16190,Ga=16191,ja=16192,Fa=16194,Ha=16199,Ja=16200,Ka=16206,Ya=16209,qa=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Wa(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const za=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Va||t.mode>16211?1:0},Qa=e=>{if(za(e))return Ua;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Va,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Na},Za=e=>{if(za(e))return Ua;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Qa(e)},Xa=(e,t)=>{let n;if(za(e))return Ua;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ua:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Za(e))},$a=(e,t)=>{if(!e)return Ua;const n=new Wa;e.state=n,n.strm=e,n.window=null,n.mode=Va;const r=Xa(e,t);return r!==Na&&(e.state=null),r};let eo,to,no=!0;const ro=e=>{if(no){eo=new Int32Array(512),to=new Int32Array(32);let t=0;for(;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(Oa(1,e.lens,0,288,eo,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Oa(2,e.lens,0,32,to,0,e.work,{bits:5}),no=!1}e.lencode=eo,e.lenbits=9,e.distcode=to,e.distbits=5},io=(e,t,n,r)=>{let i;const a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(t.subarray(n-r,n-r+i),a.wnext),(r-=i)?(a.window.set(t.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0};var ao={inflateReset:Za,inflateReset2:Xa,inflateResetKeep:Qa,inflateInit:e=>$a(e,15),inflateInit2:$a,inflate:(e,t)=>{let n,r,i,a,o,s,c,u,l,_,d,f,h,g,p,E,v,m,R,T,I,S,C=0;const L=new Uint8Array(4);let O,y;const b=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(za(e)||!e.output||!e.input&&0!==e.avail_in)return Ua;n=e.state,n.mode===Ga&&(n.mode=ja),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,_=s,d=c,S=Na;e:for(;;)switch(n.mode){case Va:if(0===n.wrap){n.mode=ja;break}for(;l<16;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(2&n.wrap&&35615===u){0===n.wbits&&(n.wbits=15),n.check=0,L[0]=255&u,L[1]=u>>>8&255,n.check=Zr(n.check,L,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=Ya;break}if((15&u)!==xa){e.msg="unknown compression method",n.mode=Ya;break}if(u>>>=4,l-=4,I=8+(15&u),0===n.wbits&&(n.wbits=I),I>15||I>n.wbits){e.msg="invalid window size",n.mode=Ya;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=512&u?16189:Ga,u=0,l=0;break;case 16181:for(;l<16;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(n.flags=u,(255&n.flags)!==xa){e.msg="unknown compression method",n.mode=Ya;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=Ya;break}n.head&&(n.head.text=u>>8&1),512&n.flags&&4&n.wrap&&(L[0]=255&u,L[1]=u>>>8&255,n.check=Zr(n.check,L,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}n.head&&(n.head.time=u),512&n.flags&&4&n.wrap&&(L[0]=255&u,L[1]=u>>>8&255,L[2]=u>>>16&255,L[3]=u>>>24&255,n.check=Zr(n.check,L,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}n.head&&(n.head.xflags=255&u,n.head.os=u>>8),512&n.flags&&4&n.wrap&&(L[0]=255&u,L[1]=u>>>8&255,n.check=Zr(n.check,L,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}n.length=u,n.head&&(n.head.extra_len=u),512&n.flags&&4&n.wrap&&(L[0]=255&u,L[1]=u>>>8&255,n.check=Zr(n.check,L,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>s&&(f=s),f&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+f),I)),512&n.flags&&4&n.wrap&&(n.check=Zr(n.check,r,f,a)),s-=f,a+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===s)break e;f=0;do{I=r[a+f++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I))}while(I&&f<s);if(512&n.flags&&4&n.wrap&&(n.check=Zr(n.check,r,f,a)),s-=f,a+=f,I)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===s)break e;f=0;do{I=r[a+f++],n.head&&I&&n.length<65536&&(n.head.comment+=String.fromCharCode(I))}while(I&&f<s);if(512&n.flags&&4&n.wrap&&(n.check=Zr(n.check,r,f,a)),s-=f,a+=f,I)break e}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;l<16;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(4&n.wrap&&u!==(65535&n.check)){e.msg="header crc mismatch",n.mode=Ya;break}u=0,l=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Ga;break;case 16189:for(;l<32;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}e.adler=n.check=qa(u),u=0,l=0,n.mode=Ba;case Ba:if(0===n.havedict)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=u,n.bits=l,Pa;e.adler=n.check=1,n.mode=Ga;case Ga:if(t===ba||t===Aa)break e;case ja:if(n.last){u>>>=7&l,l-=7&l,n.mode=Ka;break}for(;l<3;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}switch(n.last=1&u,u>>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(ro(n),n.mode=Ha,t===Aa){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Ya}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",n.mode=Ya;break}if(n.length=65535&u,u=0,l=0,n.mode=Fa,t===Aa)break e;case Fa:n.mode=16195;case 16195:if(f=n.length,f){if(f>s&&(f=s),f>c&&(f=c),0===f)break e;i.set(r.subarray(a,a+f),o),s-=f,a+=f,c-=f,o+=f,n.length-=f;break}n.mode=Ga;break;case 16196:for(;l<14;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(n.nlen=257+(31&u),u>>>=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=Ya;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;l<3;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}n.lens[b[n.have++]]=7&u,u>>>=3,l-=3}for(;n.have<19;)n.lens[b[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,O={bits:n.lenbits},S=Oa(0,n.lens,0,19,n.lencode,0,n.work,O),n.lenbits=O.bits,S){e.msg="invalid code lengths set",n.mode=Ya;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;C=n.lencode[u&(1<<n.lenbits)-1],p=C>>>24,E=C>>>16&255,v=65535&C,!(p<=l);){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(v<16)u>>>=p,l-=p,n.lens[n.have++]=v;else{if(16===v){for(y=p+2;l<y;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(u>>>=p,l-=p,0===n.have){e.msg="invalid bit length repeat",n.mode=Ya;break}I=n.lens[n.have-1],f=3+(3&u),u>>>=2,l-=2}else if(17===v){for(y=p+3;l<y;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}u>>>=p,l-=p,I=0,f=3+(7&u),u>>>=3,l-=3}else{for(y=p+7;l<y;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}u>>>=p,l-=p,I=0,f=11+(127&u),u>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Ya;break}for(;f--;)n.lens[n.have++]=I}}if(n.mode===Ya)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Ya;break}if(n.lenbits=9,O={bits:n.lenbits},S=Oa(1,n.lens,0,n.nlen,n.lencode,0,n.work,O),n.lenbits=O.bits,S){e.msg="invalid literal/lengths set",n.mode=Ya;break}if(n.distbits=6,n.distcode=n.distdyn,O={bits:n.distbits},S=Oa(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,O),n.distbits=O.bits,S){e.msg="invalid distances set",n.mode=Ya;break}if(n.mode=Ha,t===Aa)break e;case Ha:n.mode=Ja;case Ja: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,Ra(e,d),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===Ga&&(n.back=-1);break}for(n.back=0;C=n.lencode[u&(1<<n.lenbits)-1],p=C>>>24,E=C>>>16&255,v=65535&C,!(p<=l);){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(E&&!(240&E)){for(m=p,R=E,T=v;C=n.lencode[T+((u&(1<<m+R)-1)>>m)],p=C>>>24,E=C>>>16&255,v=65535&C,!(m+p<=l);){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}u>>>=m,l-=m,n.back+=m}if(u>>>=p,l-=p,n.back+=p,n.length=v,0===E){n.mode=16205;break}if(32&E){n.back=-1,n.mode=Ga;break}if(64&E){e.msg="invalid literal/length code",n.mode=Ya;break}n.extra=15&E,n.mode=16201;case 16201:if(n.extra){for(y=n.extra;l<y;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}n.length+=u&(1<<n.extra)-1,u>>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[u&(1<<n.distbits)-1],p=C>>>24,E=C>>>16&255,v=65535&C,!(p<=l);){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(!(240&E)){for(m=p,R=E,T=v;C=n.distcode[T+((u&(1<<m+R)-1)>>m)],p=C>>>24,E=C>>>16&255,v=65535&C,!(m+p<=l);){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}u>>>=m,l-=m,n.back+=m}if(u>>>=p,l-=p,n.back+=p,64&E){e.msg="invalid distance code",n.mode=Ya;break}n.offset=v,n.extra=15&E,n.mode=16203;case 16203:if(n.extra){for(y=n.extra;l<y;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}n.offset+=u&(1<<n.extra)-1,u>>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Ya;break}n.mode=16204;case 16204:if(0===c)break e;if(f=d-c,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Ya;break}f>n.wnext?(f-=n.wnext,h=n.wsize-f):h=n.wnext-f,f>n.length&&(f=n.length),g=n.window}else g=i,h=o-n.offset,f=n.length;f>c&&(f=c),c-=f,n.length-=f;do{i[o++]=g[h++]}while(--f);0===n.length&&(n.mode=Ja);break;case 16205:if(0===c)break e;i[o++]=n.length,c--,n.mode=Ja;break;case Ka:if(n.wrap){for(;l<32;){if(0===s)break e;s--,u|=r[a++]<<l,l+=8}if(d-=c,e.total_out+=d,n.total+=d,4&n.wrap&&d&&(e.adler=n.check=n.flags?Zr(n.check,i,d,o-d):zr(n.check,i,d,o-d)),d=c,4&n.wrap&&(n.flags?u:qa(u))!==n.check){e.msg="incorrect data check",n.mode=Ya;break}u=0,l=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;l<32;){if(0===s)break e;s--,u+=r[a++]<<l,l+=8}if(4&n.wrap&&u!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=Ya;break}u=0,l=0}n.mode=16208;case 16208:S=ka;break e;case Ya:S=wa;break e;case 16210:return Da;default:return Ua}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=u,n.bits=l,(n.wsize||d!==e.avail_out&&n.mode<Ya&&(n.mode<Ka||t!==ya))&&io(e,e.output,e.next_out,d-e.avail_out),_-=e.avail_in,d-=e.avail_out,e.total_in+=_,e.total_out+=d,n.total+=d,4&n.wrap&&d&&(e.adler=n.check=n.flags?Zr(n.check,i,d,e.next_out-d):zr(n.check,i,d,e.next_out-d)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Ga?128:0)+(n.mode===Ha||n.mode===Fa?256:0),(0===_&&0===d||t===ya)&&S===Na&&(S=Ma),S},inflateEnd:e=>{if(za(e))return Ua;let t=e.state;return t.window&&(t.window=null),e.state=null,Na},inflateGetHeader:(e,t)=>{if(za(e))return Ua;const n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Na):Ua},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,a;return za(e)?Ua:(r=e.state,0!==r.wrap&&r.mode!==Ba?Ua:r.mode===Ba&&(i=1,i=zr(i,t,n,0),i!==r.check)?wa:(a=io(e,t,n,n),a?(r.mode=16210,Da):(r.havedict=1,Na)))},inflateInfo:"pako inflate (from Nodeca project)"};var oo=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const so=Object.prototype.toString,{Z_NO_FLUSH:co,Z_FINISH:uo,Z_OK:lo,Z_STREAM_END:_o,Z_NEED_DICT:fo,Z_STREAM_ERROR:ho,Z_DATA_ERROR:go,Z_MEM_ERROR:po}=$r;function Eo(e){this.options=Xi({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=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&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new aa,this.strm.avail_out=0;let n=ao.inflateInit2(this.strm,t.windowBits);if(n!==lo)throw new Error(Xr[n]);if(this.header=new oo,ao.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=na(t.dictionary):"[object ArrayBuffer]"===so.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ao.inflateSetDictionary(this.strm,t.dictionary),n!==lo)))throw new Error(Xr[n])}Eo.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let a,o,s;if(this.ended)return!1;for(o=t===~~t?t:!0===t?uo:co,"[object ArrayBuffer]"===so.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),a=ao.inflate(n,o),a===fo&&i&&(a=ao.inflateSetDictionary(n,i),a===lo?a=ao.inflate(n,o):a===go&&(a=fo));n.avail_in>0&&a===_o&&n.state.wrap>0&&0!==e[n.next_in];)ao.inflateReset(n),a=ao.inflate(n,o);switch(a){case ho:case go:case fo:case po:return this.onEnd(a),this.ended=!0,!1}if(s=n.avail_out,n.next_out&&(0===n.avail_out||a===_o))if("string"===this.options.to){let e=ia(n.output,n.next_out),t=n.next_out-e,i=ra(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(a!==lo||0!==s){if(a===_o)return a=ao.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Eo.prototype.onData=function(e){this.chunks.push(e)},Eo.prototype.onEnd=function(e){e===lo&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=$i(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:vo,deflate:mo,deflateRaw:Ro,gzip:To}=va;var Io=To;var So,Co=-1,Lo="RongCloudSEIAI",Oo=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},yo=function(e,t){return e+Math.floor(Math.random()*(t-e))},bo=function(){return{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:"web|".concat(Zn.browser,"|").concat(Zn.version),ClientVersion:"26.1.0","Client-Session-Id":Oo(),"Request-Id":Date.now().toString()}},Ao=function(e,t,n){return F(void 0,void 0,void 0,E().m(function r(){var i,a;return E().w(function(r){for(;;)if(0===r.n)return i=[],a=n.jwtToken||"",r.a(2,new Promise(function(n,r){e.forEach(function(e){return F(void 0,void 0,void 0,E().m(function r(){var o,s,c;return E().w(function(r){for(;;)switch(r.n){case 0:return o=e.detectorAddr.replace(/^(https?:\/\/)?/,"https://"),s="".concat(o,"/rtc/detector/ping?t=").concat(yo(1e3,9999)),c={jwt:a},r.n=1,t.httpReq({url:s,body:JSON.stringify(c),timeout:5e3,method:ne.POST});case 1:200===r.v.status&&i.push(e.clusterId),n(i);case 2:return r.a(2)}},r)}))})}))},r)}))},No=function(e,t){var n,r;if(!t)return"";try{r=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(n){return e.warn(Ne.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,"parse `voipCallInfo` of navi failed: ".concat(t.voipCallInfo)),""}if(0===r.strategy)return"";var i=null===(n=r.callEngine)||void 0===n?void 0:n.filter(function(e){return 4===e.engineType});if(!i||0===i.length)return"";var a=i[0];return a.detectorManager?a.detectorManager:""},ko=function(e,t,n){return F(void 0,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_;return E().w(function(r){for(;;)switch(r.n){case 0:return i=No(t,n),a=n.jwtToken||"",o=120,s=0,c=n.ipType||0,u={jwt:a,ipType:c},r.n=1,e.httpReq({url:"".concat(i,"/rtc/detector/servers"),body:JSON.stringify(u),headers:bo(),method:ne.POST});case 1:return l=r.v,_=l.data&&JSON.parse(l.data).detectorAddrs||[],o=l.data&&JSON.parse(l.data).clientDetectMinute,s=l.data&&JSON.parse(l.data).resultCode,r.a(2,{detectoraddrs:_,clientDetectMinute:o,status:s})}},r)}))};!function(e){e.OPEN="2",e.CLOSE="1"}(So||(So={}));function Po(e){var t=e.method||ne.GET,n=e.timeout||6e4,r=e.headers,i=e.query,a=e.body,o=e.onProgress,s=function(e,t){if(e=e.replace(/\?$/,""),!t)return e;var n=Object.keys(t).map(function(e){return"".concat(e,"=").concat(t[e])}).filter(function(e){return!!e});return n.length?[e,n.join("&")].join("?"):e}(e.url,i),c=new XMLHttpRequest;if(c.open(t,s),r&&c.setRequestHeader)for(var u in r)c.setRequestHeader(u,r[u]);return function(e,t,n,r){return new Promise(function(i){e.onreadystatechange=function(){r?2===e.readyState?i({data:e.responseText,status:e.status,xhr:e}):4===e.readyState?r(e.responseText,!0):3===e.readyState&&r(e.responseText,!1):4===e.readyState&&i({data:e.responseText,status:e.status,xhr:e})},e.onerror=function(){i({status:e.status})},0!==t&&setTimeout(function(){e.abort(),i({status:e.status})},t),e.send(n)})}(c,n,a,o)}var Uo,wo=function(){return{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:"web|".concat(Zn.browser,"|").concat(Zn.version),ClientVersion:"26.1.0","Client-Session-Id":Oo(),"Request-Id":Date.now().toString()}},Do=function(){function e(n,r,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;c(this,e),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_msUrl",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_failedMs",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_rtcFinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clusterId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_configUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_msList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_qualityMsList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,r.getConnectionStatus()===t.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}return l(e,[{key:"isNededDetector",value:function(){var t=this._context.getNaviInfo();if(!t)return!1;var n=No(this._logger,t),r=t.jwtToken||"",i=Date.now(),a=!1;return 0===e.detectorTime?a=!1:e.detectValidMinute+e.detectorTime<i&&(a=!0),!(!n||!r||this._msUrl||a)}},{key:"detectorMediaSever",value:function(){this.clearMSList();var e=this._context.getNaviInfo();this._startDetector(e)}},{key:"_startDetector",value:function(t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s;return E().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,ko(this._runtime,this._logger,t);case 1:if(i=n.v,a=i.detectoraddrs,o=i.clientDetectMinute,i.status!==Ae.JWT_TIME_OUT){n.n=3;break}return s=this._context.getPluginContext(),n.n=2,null===(r=s.refetchNaviInfo)||void 0===r?void 0:r.call(s);case 2:return this.detectorMediaSever(),n.a(2);case 3:if(!a.length){n.n=5;break}return n.n=4,Ao(a,this._runtime,t);case 4:e.msInDetector=n.v;case 5:e.detectorTime=Date.now(),e.detectValidMinute=60*o*1e3;case 6:return n.a(2)}},n,this)}))}},{key:"clearMSList",value:function(){this._msList.length=0}},{key:"getMsList",value:function(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),C(this._msList))}},{key:"_sortMediaServiceList",value:function(){var t=e.msInDetector[0],n=e.msInDetector.slice(1),r=function(e,t){var n,r;if(!e)return[];try{r=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(n){return t.warn(Ne.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===r.strategy)return[];var i=null===(n=r.callEngine)||void 0===n?void 0:n.filter(function(e){return 4===e.engineType});if(!i||0===i.length)return[];var a=i[0],o=[];return a.mediaServer&&o.push(a.mediaServer.replace(/^(https?:\/\/)?/,"https://")),a.backupMediaServer&&a.backupMediaServer.forEach(function(e){o.push(e.replace(/^(https?:\/\/)?/,"https://"))}),o}(this._context.getNaviInfo(),this._logger),i=r[0],a=r.slice(1),o=[this._clusterId,t,i].concat(C(n),C(a)).filter(function(e){return!!e}).map(function(e){return e.replace(/^(https?:\/\/)?/,"https://")});this._msList=C(new Set(o)),this._logger.info(Ne.L_MEDIA_SERVICE_MSLIST_CHANGE_O,"MediaServiceList msList -> ".concat(JSON.stringify(this._msList)))}},{key:"_openGzip",value:function(e,t){for(var n=JSON.stringify(t),r=n.length,i=new Uint8Array(r),a=0;a<r;a++)i[a]=n.charCodeAt(a);var o;return{headers:e=Object.assign(Object.assign({},e),{"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),body:t=Io(i,o)}}},{key:"_dealRequestSuccessResult",value:function(e){var t=JSON.parse(e);return t.rtcFinger&&(this._rtcFinger=t.rtcFinger),t.clusterId&&(this._clusterId!==t.clusterId&&this.clearMSList(),this._clusterId=t.clusterId),{code:Ae.SUCCESS,data:t,qualityMsList:this._qualityMsList}}},{key:"_request",value:function(e,t,n,r,i,a){return F(this,void 0,void 0,E().m(function o(){var s,c,u,l,_,d,f,h,g,p,v,m,R,T,I,S,C;return E().w(function(o){for(;;)switch(o.n){case 0:if(this._qualityMsList=[],c=(s={headers:t,body:n}).headers,u=s.body,0!==(l=this.getMsList()).length){o.n=1;break}return this._logger.error(Ne.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ke.FAILED,code:Ae.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),r),o.a(2,{code:Ae.NOT_OPEN_VIDEO_AUDIO_SERVER});case 1:this._rtcFinger&&(u.rtcFinger=this._rtcFinger),_=0;case 2:if(!(_<l.length)){o.n=10;break}if(d=Date.now(),f="".concat(l[_]).concat(e),h=wo(),g=Object.assign(Object.assign({},h),c),p=/x-www-form-urlencoded/.test(g["Content-Type"])?u:JSON.stringify(u),v=h["Request-Id"],this._logger.info(Ne.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:f,"Request-Id":v}),r),m=void 0,R={url:f,body:p,headers:g,method:ne.POST,timeout:this._timeout},!a){o.n=4;break}return o.n=3,Po(Object.assign(Object.assign({},R),{onProgress:a}));case 3:m=o.v,o.n=6;break;case 4:return o.n=5,this._runtime.httpReq(Object.assign({},R));case 5:m=o.v;case 6:if(I=(T=m).status,S=T.data,C=T.xhr,i&&this._qualityMsList.push({rsdur:Date.now()-d,rsid:v,rscod:200===I?Ae.SUCCESS:Ae.REQUEST_FAILED,msa:f}),200!==I){o.n=8;break}if(this._logger.info(Ne.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ke.SUCCESSED,url:f}),r),!a){o.n=7;break}return o.a(2,{code:Ae.SUCCESS,data:C});case 7:return o.a(2,this._dealRequestSuccessResult(S));case 8:this._logger.error(Ne.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ke.FAILED,msg:"request error -> Request-Id: ".concat(v,", status: ").concat(I,", url: ").concat(f),timeout:this._timeout}),r);case 9:_+=1,o.n=2;break;case 10:return o.a(2,{code:Ae.REQUEST_FAILED,qualityMsList:this._qualityMsList})}},o,this)}))}},{key:"exchange",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s;return E().w(function(i){for(;;)switch(i.n){case 0:return i.n=1,this._request("/exchange",e,t,n,r);case 1:return(o=i.v).code===Ae.SUCCESS&&(null===(a=o.data)||void 0===a?void 0:a.resultCode)===Ae.SUCCESS&&(s=o.data.urls)&&(this._configUrl=s.configUrl),i.a(2,o)}},i,this)}))}},{key:"exit",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this._logger.createTraceId(),t.n=1,this._request("/exit",e,{},n);case 1:return r=t.v,i=r.code,t.a(2,i)}},t,this)}))}},{key:"broadcastSubscribe",value:function(e,t){var n=this._logger.createTraceId();return this._request("/broadcast/subscribe",e,t,n,!0)}},{key:"broadcastExit",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this._logger.createTraceId(),t.n=1,this._request("/broadcast/exit",e,{},n,!0);case 1:return r=t.v,i=r.code,t.a(2,{code:i})}},t,this)}))}},{key:"setMcuConfig",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(Ne.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:t}),r),this._configUrl){n.n=1;break}return this._logger.error(Ne.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ke.FAILED,code:Ae.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),r),n.a(2,{code:Ae.MCU_SERVER_NOT_FOUND});case 1:return i="".concat(this._configUrl.replace(/^(https?:\/\/)?/,"https://"),"/server/mcu/config"),a=wo(),o=Object.assign(Object.assign({},a),e),s=JSON.stringify(t),c=a["Request-Id"],n.n=2,this._runtime.httpReq({url:i,headers:o,body:s,method:ne.POST});case 2:if(u=n.v,l=u.status,_=u.data,200!==l){n.n=3;break}return d=JSON.parse(_),(f=d.resultCode)===Ae.SUCCESS?this._logger.info(Ne.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ke.SUCCESSED,"Request-Id":c}),r):this._logger.warn(Ne.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:f,"Request-Id":c}),r),n.a(2,{code:f,res:d});case 3:return this._logger.error(Ne.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ke.FAILED,code:Ae.REQUEST_FAILED,msg:"request error -> Request-Id: ".concat(c,", status: ").concat(l,", url: ").concat(i)}),r),n.a(2,{code:Ae.REQUEST_FAILED})}},n,this)}))}},{key:"getCDNResourceInfo",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l;return E().w(function(r){for(;;)switch(r.n){case 0:return i=wo(),a=Object.assign(Object.assign({},i),e),o=i["Request-Id"],this._logger.info(Ne.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,"Request-Id: ".concat(o,", url: ").concat(t),n),r.n=1,this._runtime.httpReq({url:t,headers:a,method:ne.GET});case 1:if(s=r.v,c=s.status,u=s.data,200!==c){r.n=2;break}return l=JSON.parse(u),this._logger.info(Ne.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:ke.SUCCESSED,cdnPlayerUrl:null==l?void 0:l.data.pull_url}),n),r.a(2,{code:l.resultCode,res:l});case 2:return this._logger.info(Ne.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:ke.FAILED,code:Ae.REQUEST_FAILED}),n),r.a(2,{code:Ae.REQUEST_FAILED})}},r,this)}))}},{key:"updateASRStatus",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i;return E().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,this._request("/rtc/media/v1/asr/update",e,t,n);case 1:return i=r.v,r.a(2,i)}},r,this)}))}},{key:"operateRealtimeTranslation",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i;return E().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,this._request("/rtc/media/v1/asr/translation",e,t,n);case 1:return i=r.v,r.a(2,i)}},r,this)}))}},{key:"operateSummarization",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a;return E().w(function(r){for(;;)switch(r.n){case 0:return i="/rtc/media/v1/ai/room/sum/".concat(t.status===So.OPEN?"start":"stop"),r.n=1,this._request(i,e,t,n);case 1:return a=r.v,r.a(2,a)}},r,this)}))}},{key:"generateSummarization",value:function(e,t,n,r,i,a,o){return F(this,void 0,void 0,E().m(function s(){var c,u,l,_,d,f,h;return E().w(function(s){for(;;)switch(s.n){case 0:return c={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},u={taskId:t,startTime:n,endTime:r,config:{summarization:i.enableSummarization,summarizationDetails:i.enableSummarizationDetails,chapterSummary:i.enableChapterSummary,todoList:i.enableTodoList,hashtag:i.enableHashtag,language:i.destLang,format:i.format,custom:i.customPrompt}},s.n=1,this._request("/rtc/media/v1/ai/room/sum/gen",c,u,o,!1,function(e,t){a(e,t)});case 1:if(l=s.v,_=l.code,d=l.data,f=null==d?void 0:d.getResponseHeader("x-code"),h=null==d?void 0:d.getResponseHeader("x-msg"),_!==Ae.SUCCESS||!f||Number(f)===Ae.SUCCESS){s.n=2;break}return s.a(2,{code:Number(f),msg:h});case 2:return s.a(2,{code:_})}},s,this)}))}},{key:"getASRContent",value:function(e,t,n,r,i,a,o){return F(this,void 0,void 0,E().m(function s(){var c,u,l,_,d,f,h;return E().w(function(s){for(;;)switch(s.n){case 0:return c={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},u={taskId:t,startTime:n,endTime:r,language:o},s.n=1,this._request("/rtc/media/v1/ai/room/sum/asr",c,u,a,!1,function(e,t){i(e,t)});case 1:if(l=s.v,_=l.code,d=l.data,f=null==d?void 0:d.getResponseHeader("x-code"),h=null==d?void 0:d.getResponseHeader("x-msg"),_!==Ae.SUCCESS||!f||Number(f)===Ae.SUCCESS){s.n=2;break}return s.a(2,{code:Number(f),msg:h});case 2:return s.a(2,{code:_})}},s,this)}))}}])}();Object.defineProperty(Do,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(Do,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(Do,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}(Uo||(Uo={}));var Mo,xo=function(e,t){return Math.round(8*t/e)},Vo=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=Math.pow(10,t);return Math.round(e*n)/n},Bo=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;e>1&&(e=1);var n=Math.pow(10,t);return Math.round(e*n)},Go=function(e,t,n,r){if(0===t)return 0;if(!n||!r)return Vo(e/t,3);var i=t-r;if(0===i)return 0;var a=e-n;return a<0||i<0?0:Vo(a/i,3)},jo=function(e){var t=e.jitter,n=e.rtt,r=e.packetsLostRate;return!nr(t)||!nr(n)||0!==r};!function(e){e.TRACK="track",e.STREAM="stream",e.MEDIASOURCE="media-source",e.INBOUNDRTP="inbound-rtp",e.OUTBOUNDRTP="outbound-rtp",e.REMOTEINBOUNDRTP="remote-inbound-rtp",e.PEERCONNECTION="peer-connection",e.TRANSPORT="transport",e.CERTIFICATE="certificate",e.CANDIDATEPAIR="candidate-pair",e.REMOTECANDIDATE="remote-candidate",e.LOCALCANDIDATE="local-candidate"}(Mo||(Mo={}));var Fo=function(){return l(function e(t,n,r,i,a,o){c(this,e),Object.defineProperty(this,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_sdpSemantics",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_latestPacketsSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestPacketsRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}})},[{key:"getTrackIdByMid",value:function(e){return this._sdpStrategy.getTrackIdByMid(e)}},{key:"updateBytesSent",value:function(e,t,n){var r,i;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){var a=this._latestBytesSent[e];r=t-a.bytesSent,i=n-a.timestamp,this._latestBytesSent[e]={bytesSent:t,timestamp:n}}else r=t,i=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:n};return xo(i,r)}},{key:"updateBytesRecv",value:function(e,t,n){var r,i;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){var a=this._latestBytesRecv[e];r=t-a.bytesRecv,i=n-a.timestamp,this._latestBytesRecv[e]={bytesRecv:t,timestamp:n}}else r=t,i=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:n};return xo(i,r)}},{key:"updateSenderPacketsLost",value:function(e,t,n){var r;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){var i=this._latestPacketsSent[e],a=i.packetsLost,o=i.packetsSent;r=Go(t,n,a,o),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=a===t?o:n}else r=Go(t,n),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=n;return r}},{key:"updateReceiverPacketsLost",value:function(e,t,n){var r;if(this._latestPacketsRecv[e]){var i=this._latestPacketsRecv[e],a=i.packetsLost,o=i.packetsRecv;r=Go(t,n+t,a,o+a)}else r=Go(t,n);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:n},r}},{key:"clearLatestpacketsSent",value:function(e){var t=this;e.forEach(function(e){if(parseInt(e.split("_").pop())===nn.VIDEO_ONLY){var n="".concat(e,"_tiny");delete t._latestPacketsSent[n],delete t._latestBytesSent[n]}delete t._latestPacketsSent[e],delete t._latestBytesSent[e]})}},{key:"clearLatestPacketsRecv",value:function(e){var t=this;e.forEach(function(e){delete t._latestPacketsRecv[e],delete t._latestBytesRecv[e]})}},{key:"parseRTCStatsReport",value:function(e){var t,n={},r=_(e.entries());try{for(r.s();!(t=r.n()).done;){var i=I(t.value,2),a=i[0],o=i[1];/codec/gi.test(o)&&a.includes("RTCCodec_")||(n[a]=o)}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"formatRCRTCStateReport",value:function(e){var t={senders:[],receivers:[]};return this._logger.info(Ne.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:ke.SUCCESSED,stats:e,reports:t})),t}},{key:"isValidTranceiver",value:function(e,t){var n,r,i="outbound-rtp"===t?null===(n=this._rtcPeerConn.currentLocalDescription)||void 0===n?void 0:n.sdp:null===(r=this._rtcPeerConn.currentRemoteDescription)||void 0===r?void 0:r.sdp,a=e.ssrc;return!(null==i?void 0:i.split("\r\nm=").some(function(e){return e.includes(a)&&e.includes("a=inactive")}))}},{key:"formatStateData",value:function(e){return Object.values(e).reduce(function(e,t){return t.type===Mo.REMOTEINBOUNDRTP?(e.remoteInbound.push(t),e):t.type===Mo.INBOUNDRTP?(e.inbound.push(t),e):t.type===Mo.OUTBOUNDRTP?(e.outbound.push(t),e):t.type===Mo.TRANSPORT?(e.transport.push(t),e):t.type===Mo.PEERCONNECTION?(e.connection.push(t),e):e},{outbound:[],remoteInbound:[],inbound:[],transport:[],connection:[]})}}])}(),Ho=function(){function e(){return c(this,e),s(this,e,arguments)}return g(e,Fo),l(e,[{key:"formatRCRTCStateReport",value:function(e){var t=this.formatStateData(e),n=t.outbound,r=t.remoteInbound,i=t.inbound,a=t.transport,o=t.connection,s={senders:[],receivers:[]},c=Math.floor(o[0].timestamp);s.timestamp=c;var u=0,l=0,_=this.pickOutbound(n,e,u,c,l);u=_.totalPacketsLost,l=_.bitrateSend,s.senders=_.senders,r.length>0&&s.senders.length>0&&this.pickRemoteInbound(r,s.senders,e);var d=0,f=this.pickInbound(i,e,u,c,d);if(u=f.totalPacketsLost,d=f.bitrateRecv,s.receivers=f.receivers,a.length>0){var h=a[0];this.pickRtcTransport(h,e,s,d,l,u)}return s}},{key:"pickRtcTransport",value:function(e,t,n,r,i,a){var o=e.selectedCandidatePairId;if(o){var s=t[o],c=s.availableOutgoingBitrate,u=s.availableIncomingBitrate,l=s.currentRoundTripTime,_=s.localCandidateId,d=s.remoteCandidateId,f=t[_],h=f.ip,g=f.port,p=f.networkType,E=t[d],v=E.ip,m=E.port,R=E.protocol;n.iceCandidatePair={IP:h,port:g,networkType:p,remoteIP:v,remotePort:m,protocol:R,bitrateRecv:r,bitrateSend:i,rtt:1e3*l,availableOutgoingBitrate:c,availableIncomingBitrate:u,totalPacketsLost:a},n.receivers.forEach(function(e){e.rtt=1e3*l})}}},{key:"pickRemoteInbound",value:function(e,t,n){var r=this;e.forEach(function(e){var i,a=e.localId,o=e.jitter,s=e.roundTripTime,c=e.packetsLost,u=t.filter(function(e){return e.id===a})[0];if(u&&!jo(u)){var l=null===(i=r._store)||void 0===i?void 0:i.getTrackIdBySSRC(n[u.id].ssrc);u.jitter=Math.round(1e3*o),u.rtt=s;var _=r._latestPacketsSent[l].crtPacketsSent;u.packetsLostRate=r.updateSenderPacketsLost(l,c,_)}})}},{key:"_getOutboundVideoAttrs",value:function(e,t,n,r,i){var a,o,s,c=e.framesPerSecond,u=e.frameWidth,l=e.frameHeight;return"video"!==n||u||l||c||(u=(null===(a=t[r])||void 0===a?void 0:a.frameWidth)||t[i].width,l=(null===(o=t[r])||void 0===o?void 0:o.frameHeight)||t[i].height,c=(null===(s=t[i])||void 0===s?void 0:s.framesPerSecond)||null),{frameRate:c,frameWidth:u,frameHeight:l}}},{key:"pickOutbound",value:function(e,t,n,r,i){var a=this,o=[];return e.forEach(function(e){var s;if("unified-plan"!==a._sdpSemantics||a.isValidTranceiver(e,"outbound-rtp")){var c=e.id,u=e.kind,l=e.mediaSourceId,_=e.remoteId,d=e.packetsSent,f=e.bytesSent,h=e.encoderImplementation,g=e.pliCount,p=e.nackCount,E=e.mid,v=e.trackId;if(void 0!==E&&(v=a.getTrackIdByMid(E)),v){var m=a._getOutboundVideoAttrs(e,t,u,v,l),R=m.frameRate,T=m.frameWidth,I=m.frameHeight,S=t[_],C=null,L=null,O=0;S&&(C=S.jitter,L=S.roundTripTime,O=S.packetsLost),n+=O;var y=null===(s=a._store)||void 0===s?void 0:s.getTrackIdBySSRC(e.ssrc);if(y){var b=l?t[l].audioLevel:t[v].audioLevel,A=0;!a._latestPacketsSent[y]&&(a._latestPacketsSent[y]={}),S?A=a.updateSenderPacketsLost(y,O,d):a._latestPacketsSent[y].crtPacketsSent=d;var N=a.updateBytesSent(y,f,r);N<0&&(N=0),i+=N,o.push({id:c,trackId:y,kind:u,packetsLostRate:A,remoteResource:!1,audioLevel:b||0===b?Bo(b):null,frameWidth:T,frameHeight:I,frameRate:R,bitrate:N,jitter:C?Math.round(1e3*C):C,rtt:L?Math.round(1e3*L):L,encoderImplementation:h,pliCount:g,nackCount:p,googFirsSent:Co,samplingRate:Co,googRenderDelayMs:Co,trackState:Co})}}}}),{totalPacketsLost:n,bitrateSend:i,senders:o}}},{key:"_getInboundMediaAttrs",value:function(e,t,n,r,i){var a,o,s,c=e.frameWidth,u=e.frameHeight,l=e.audioLevel;return"video"===i?c||u||(c=(null===(a=t[n])||void 0===a?void 0:a.frameWidth)||t[r].width,u=(null===(o=t[n])||void 0===o?void 0:o.frameHeight)||t[r].height):l||(l=(null===(s=t[n])||void 0===s?void 0:s.audioLevel)||t[r].audioLevel),{frameWidth:c,frameHeight:u,audioLevel:l}}},{key:"pickInbound",value:function(e,t,n,r,i){var a=this,o=[];return e.forEach(function(e){var s;if("unified-plan"!==a._sdpSemantics||a.isValidTranceiver(e,"inbound-rtp")){var c=e.packetsLost,u=e.packetsReceived,l=e.jitter,_=e.bytesReceived,d=e.framesPerSecond,f=e.kind,h=e.codecImplementationName,g=e.nackCount,p=e.pliCount,E=e.mid,v=e.id,m=e.trackId;if(void 0!==E&&(m=a.getTrackIdByMid(E)),m){var R=a._getInboundMediaAttrs(e,t,m,v,f),T=R.frameWidth,I=R.frameHeight,S=R.audioLevel;n+=c;var C=null===(s=a._store)||void 0===s?void 0:s.getTrackIdBySSRC(e.ssrc),L=a.updateReceiverPacketsLost(C,c,u),O=a.updateBytesRecv(C,_,r);O<0&&(O=0),i+=O,o.push({trackId:C,kind:f,packetsLostRate:L,remoteResource:!0,audioLevel:S||0===S?Bo(S):null,frameWidth:T,frameHeight:I,frameRate:d,bitrate:O,jitter:l?Math.round(1e3*l):0,codecImplementationName:h,nackCount:g,pliCount:p,rtt:null,samplingRate:Co,googFirsReceived:Co,googRenderDelayMs:Co,trackState:Co})}}}),{totalPacketsLost:n,bitrateRecv:i,receivers:o}}}])}(),Jo=function(){function e(){var t;return c(this,e),t=s(this,e,arguments),Object.defineProperty(t,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(t,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0}),t}return g(e,Fo),l(e,[{key:"_pickSenderData",value:function(e,t,n){var r;if("unified-plan"!==this._sdpSemantics||this.isValidTranceiver(e,n)){var i=e.kind,a=e.bytesSent,o=e.packetsSent,s=e.bitrateMean,c=e.framerateMean,u=e.nackCount,l=e.pliCount,_=e.remoteId,d=_?t[_]:{jitter:null,roundTripTime:null,packetsLost:0},f=d.jitter,h=d.roundTripTime,g=d.packetsLost,p=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=g;var E=0;!this._latestPacketsSent[p]&&(this._latestPacketsSent[p]={}),_?E=this.updateSenderPacketsLost(p,g,o):this._latestPacketsSent[p].crtPacketsSent=o;var v=0;"video"===i?s&&(v=Math.floor(s/1e3)):v=this.updateBytesSent(p,a,this._reportsData.timestamp),v<0&&(v=0),this._bitrateSend+=v,this._reportsData.senders.push({trackId:p,kind:i,packetsLostRate:E,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(c),bitrate:v,jitter:f?Math.round(1e3*f):null,rtt:h,encoderImplementation:null,pliCount:l,nackCount:u,googFirsSent:Co,samplingRate:Co,googRenderDelayMs:Co,trackState:Co})}}},{key:"_addSenderData",value:function(e,t){var n,r=t.localId,i=null===(n=this._store)||void 0===n?void 0:n.getTrackIdBySSRC(e[r].ssrc),a=this._reportsData.senders.filter(function(e){return e.trackId===i})[0];a&&jo(a)&&(a.jitter=Math.round(1e3*t.jitter),a.rtt=t.rtt,a.packetsLostRate=this.updateSenderPacketsLost(i,t.packetsLost,this._latestPacketsSent[i].crtPacketsSent))}},{key:"_pickReceiverData",value:function(e,t){var n;if("unified-plan"!==this._sdpSemantics||this.isValidTranceiver(e,t)){var r=e.packetsLost,i=e.bytesReceived,a=e.packetsReceived,o=e.jitter,s=e.framerateMean,c=e.kind,u=e.bitrateMean,l=e.nackCount,_=e.pliCount,d=null===(n=this._store)||void 0===n?void 0:n.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=r;var f=this.updateReceiverPacketsLost(d,r,a),h=0;"video"===c?u&&(h=Math.floor(u/1e3)):h=this.updateBytesRecv(d,i,this._reportsData.timestamp),h<0&&(h=0),this._bitrateRecv+=h,this._reportsData.receivers.push({trackId:d,kind:c,packetsLostRate:f,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(s),bitrate:h,jitter:o?Math.round(1e3*o):null,codecImplementationName:null,nackCount:l,pliCount:_,rtt:null,samplingRate:Co,googFirsReceived:Co,googRenderDelayMs:Co,trackState:Co})}}},{key:"_pickIceCandidatePair",value:function(e,t){var n=e[t.localCandidateId],r=n.address,i=n.port,a=e[t.remoteCandidateId],o=a.address,s=a.port,c=a.protocol;this._reportsData.iceCandidatePair={IP:r,port:i,networkType:null,remoteIP:o,remotePort:s,protocol:c,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:this._totalPacketsLost}}},{key:"formatRCRTCStateReport",value:function(e){var t=+new Date;for(var n in this._reportsData={senders:[],receivers:[],timestamp:t},this._totalPacketsLost=0,this._bitrateRecv=0,this._bitrateSend=0,e){var r=e[n],i=r.type;"outbound-rtp"===i&&this._pickSenderData(r,e,i),"remote-inbound-rtp"===i&&this._addSenderData(e,r),"inbound-rtp"===i&&this._pickReceiverData(r,i),"candidate-pair"===i&&"succeeded"===r.state&&this._pickIceCandidatePair(e,r)}return this._reportsData}}])}(),Ko=function(){function e(){var t;return c(this,e),t=s(this,e,arguments),Object.defineProperty(t,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(t,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0}),t}return g(e,Fo),l(e,[{key:"_pickReceiverData",value:function(e,t){var n=this;e.forEach(function(e){var t;if("unified-plan"!==n._sdpSemantics||n.isValidTranceiver(e,"inbound-rtp")){var r=e.packetsLost,i=e.packetsReceived,a=e.jitter,o=e.bytesReceived,s=e.kind,c=e.nackCount,u=e.pliCount,l=e.audioLevel,_=e.frameHeight,d=e.frameWidth,f=null===(t=n._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(f){n._totalPacketsLost+=r;var h=n.updateReceiverPacketsLost(f,r,i),g=n.updateBytesRecv(f,o,n._reportsData.timestamp);g<0&&(g=0),n._bitrateRecv+=g,n._reportsData.receivers.push({trackId:f,kind:s,packetsLostRate:h,remoteResource:!0,audioLevel:l||0===l?Bo(l):null,frameWidth:d,frameHeight:_,frameRate:null,bitrate:g,jitter:a?Math.round(1e3*a):a,codecImplementationName:null,nackCount:c,pliCount:u,rtt:null,samplingRate:Co,googFirsReceived:Co,googRenderDelayMs:Co,trackState:Co})}}})}},{key:"_pickSenderData",value:function(e,t){var n=this;e.forEach(function(e){var r;if("unified-plan"!==n._sdpSemantics||n.isValidTranceiver(e,"outbound-rtp")){var i=null===(r=n._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc),a=e.kind,o=e.bytesSent,s=e.pliCount,c=e.nackCount,u=e.audioLevel,l=e.frameHeight,_=e.frameWidth,d=e.codecId,f=e.remoteId,h=e.packetsSent;if(i){var g=t[f],p=null,E=null,v=0;g&&(p=g.jitter,E=g.roundTripTime,v=g.packetsLost),n._totalPacketsLost+=v;var m=0;!n._latestPacketsSent[i]&&(n._latestPacketsSent[i]={}),g?m=n.updateSenderPacketsLost(i,v,h):n._latestPacketsSent[i].crtPacketsSent=h;var R=n.updateBytesSent(i,o,n._reportsData.timestamp);R<0&&(R=0),n._bitrateSend+=R,n._reportsData.senders.push({trackId:i,kind:a,packetsLostRate:m,remoteResource:!1,audioLevel:u||0===u?Bo(u):null,frameWidth:_,frameHeight:l,frameRate:null,bitrate:R,jitter:p?Math.round(1e3*p):p,rtt:E?Math.round(1e3*E):E,encoderImplementation:t[d].mimeType,pliCount:s,nackCount:c,googFirsSent:Co,samplingRate:Co,googRenderDelayMs:Co,trackState:Co})}}})}},{key:"_pickIceCandidatePair",value:function(e,t){var n=e.selectedCandidatePairId;if(n){var r=t[n],i=r.availableOutgoingBitrate,a=r.availableIncomingBitrate,o=r.currentRoundTripTime,s=r.localCandidateId,c=r.remoteCandidateId,u=t[s],l=u.address,_=u.port,d=t[c],f=d.address,h=d.port,g=d.protocol;this._reportsData.iceCandidatePair={IP:l||null,port:_,networkType:null,remoteIP:f,remotePort:h,protocol:g,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*o,availableOutgoingBitrate:i,availableIncomingBitrate:a,totalPacketsLost:this._totalPacketsLost},this._reportsData.receivers.forEach(function(e){e.rtt=1e3*o})}}},{key:"formatRCRTCStateReport",value:function(e){var t=this.formatStateData(e),n=t.outbound,r=t.inbound,i=t.transport,a=t.connection;this._reportsData={senders:[],receivers:[]};var o=Math.floor(a[0].timestamp);if(this._reportsData.timestamp=o,this._totalPacketsLost=0,this._bitrateSend=0,this._bitrateRecv=0,this._pickSenderData(n,e),this._pickReceiverData(r,e),i.length>0){var s=i[0];this._pickIceCandidatePair(s,e)}return this._reportsData}}])}(),Yo=function(){function e(t,n,r){c(this,e),Object.defineProperty(this,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"SDPHeader",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"videoStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"audioStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]});var i=this.getStreamIndex();this.spliteStreams(i)}return l(e,[{key:"videoSdps",get:function(){return this.videoStreams.slice()}},{key:"audioSdps",get:function(){return this.audioStreams.slice()}},{key:"getStreamIndex",value:function(){for(var e=/m=(?:video|audio)/gim,t=new Set([0]),n=e.exec(this.SDP);null!==n;)t.add(null==n?void 0:n.index),n=e.exec(this.SDP);return t.add(this.SDP.length),C(t)}},{key:"spliteStreams",value:function(e){this.SDPHeader=this.SDP.substring(e[0],e[1]).replace(/\r\ns=-/g,"\r\ns=".concat((new Date).valueOf()));for(var t=1;t<e.length;t++){var n=this.SDP.substring(e[t],e[t+1]);/^\bm=video\b/.test(n)?this.videoStreams.push(n):this.audioStreams.push(n)}}},{key:"setHeaderBitrate",value:function(t){this.SDPHeader=this.SDPHeader.replace(/(\r\ns=[^\r\n]+)/gi,"$1\r\nc=IN IP4 0.0.0.0\r\nb=AS:".concat(t*e.KBitrate,"\r\nb=TIAS:").concat(t*e.KBitrate*850))}},{key:"setAudiosBitrate",value:function(e){var t=this;return this.audioStreams=this.audioStreams.map(function(n){return t.setAudioItemBitrate(n,e)}),this}},{key:"setAudioBitrateWithStreamId",value:function(e,t){var n=this;return this.audioStreams=this.audioStreams.map(function(r){return new RegExp("\\bmsid:".concat(t,"\\b"),"ig").test(r)?n.setAudioItemBitrate(r,e):r}),this}},{key:"setAudioBitrateWithMid",value:function(e,t){var n=this;return this.audioStreams=this.audioStreams.map(function(r){return new RegExp("\\bmid:".concat(t,"\\b"),"ig").test(r)?n.setAudioItemBitrate(r,e):r}),this}},{key:"setAudioItemBitrate",value:function(t,n){if(0===n.max&&/\ba=inactive\b/gi.test(t))return t;if(!/\bmaxaveragebitrate\b/gi.test(t)){var r=["$1","maxaveragebitrate=".concat(n.max*e.KBitrate*1e3)];t=t.replace(/(\buseinbandfec=[^\r\n]+)/gi,r.join(";"))}return this.addAudioBlineAS(t,n)}},{key:"addAudioBlineAS",value:function(t,n){return/\bb=AS:\d+\b/gi.test(t)?t:t.replace(/(\bc=IN[^\r\n]+)/gi,"$1\r\nb=AS:".concat(n.max*e.KBitrate,"\r\nb=TIAS:").concat(n.max*e.KBitrate*850))}},{key:"setVideosBitrate",value:function(e){var t=this;return this.videoStreams=this.videoStreams.map(function(n){return t.setVideoItemBitrate(n,e)}),this}},{key:"setVideoBitrateWithStreamId",value:function(e,t){var n=this;return this.videoStreams=this.videoStreams.map(function(r){return new RegExp("\\bmsid:".concat(t,"\\b"),"ig").test(r)?n.setVideoItemBitrate(r,e):r}),this}},{key:"setVideoBitrateWithMid",value:function(e,t){var n=this;return this.videoStreams=this.videoStreams.map(function(r){return new RegExp("\\bmid:".concat(t,"\\b"),"ig").test(r)?n.setVideoItemBitrate(r,e):r}),this}},{key:"setVideoItemBitrate",value:function(t,n){if(0===n.max&&/\ba=inactive\b/gi.test(t))return t;if(!/\bx-google-max-bitrate\b/.test(t)){var r=["$1","x-google-max-bitrate=".concat(n.max*e.KBitrate),"x-google-min-bitrate=".concat(n.min*e.KBitrate),"x-google-start-bitrate=".concat(n.start||n.max*e.KBitrate*.7)];t=t.replace(/(\bprofile-level-id=42[e0]01f\b)/gi,r.join(";"))}return this.addVideoBlineAS(t,n)}},{key:"addVideoBlineAS",value:function(t,n){return/\bb=AS:\d+\b/gi.test(t)?t:t.replace(/(\bc=IN[^\r\n]+)/gi,"$1\r\nb=AS:".concat(n.max*e.KBitrate,"\r\nb=TIAS:").concat(n.max*e.KBitrate*850))}},{key:"clearnSsrcWithMid",value:function(e,t){var n=this;return this.audioStreams=this.audioStreams.map(function(r){return new RegExp("\\bmid:".concat(e,"\\b"),"ig").test(r)?n.clearSSRC(r,t):r}),this.videoStreams=this.videoStreams.map(function(r){return new RegExp("\\bmid:".concat(e,"\\b"),"ig").test(r)?n.clearSSRC(r,t):r}),this}},{key:"clearSSRC",value:function(e,t){if(t===Zo.SENDONLY&&/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");if(t===Zo.RECVONLY&&/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");if(t===Zo.INACTIVE&&/\ba=inactive\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");return e}}],[{key:"trimBlankLine",value:function(e){return e.replace(/\n\r\s*\r\n/g,"\r\n").replace(/\s+\r\n/g,"\r\n")}},{key:"clearInactiveOrRecvonly",value:function(e){return/\ba=(recvonly|inactive)\b/.test(e)?e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,""):e}}])}();Object.defineProperty(Yo,"KBitrate",{enumerable:!0,configurable:!0,writable:!0,value:1});var qo,Wo=function(){return l(function e(){c(this,e)},null,[{key:"init",value:function(e,t){this._audioEncoder=e.encodeAudio,this._audioDecoder=e.decodeAudio,this._videoEncoder=e.encodeVideo,this._videoDecoder=e.decodeVideo,this._logger=t}},{key:"isInit",value:function(){return!!(this._audioEncoder&&this._audioDecoder&&this._videoEncoder&&this._videoDecoder)}},{key:"decodeAudio",value:function(e){try{return this._audioDecoder(e)}catch(t){return this._logger.error(Ne.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}},{key:"encodeAudio",value:function(e){try{return this._audioEncoder(e)}catch(t){return this._logger.error(Ne.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}},{key:"decodeVideo",value:function(e){try{return this._videoDecoder(e)}catch(t){return this._logger.error(Ne.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}},{key:"encodeVideo",value:function(e){try{return this._videoEncoder(e)}catch(t){return this._logger.error(Ne.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}}])}();!function(e){e[e.NB=0]="NB",e[e.MB=1]="MB",e[e.WB=2]="WB",e[e.SWB=3]="SWB",e[e.FB=4]="FB"}(qo||(qo={})),qo.NB,qo.NB,qo.NB,qo.NB,qo.MB,qo.MB,qo.MB,qo.MB,qo.WB,qo.WB,qo.WB,qo.WB,qo.SWB,qo.SWB,qo.FB,qo.FB,qo.NB,qo.NB,qo.NB,qo.NB,qo.WB,qo.WB,qo.WB,qo.WB,qo.SWB,qo.SWB,qo.SWB,qo.SWB,qo.FB,qo.FB,qo.FB,qo.FB;var zo=function(){function e(){c(this,e)}return l(e,null,[{key:"splitSections",value:function(e){return e.split("\nm=").map(function(e,t){var n=t>0?"m=".concat(e):e;return"".concat(n.trim(),"\r\n")})}},{key:"getMediaSections",value:function(t){var n=e.splitSections(t);return n.shift(),n}},{key:"parseExtmap",value:function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}}},{key:"splitLines",value:function(e){return e.trim().split("\n").map(function(e){return e.trim()})}},{key:"parseMLine",value:function(t){var n=e.splitLines(t)[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}}},{key:"matchPrefix",value:function(t,n){return e.splitLines(t).filter(function(e){return 0===e.indexOf(n)})}},{key:"parseMsid",value:function(t){var n,r=e.matchPrefix(t,"a=msid:");if(1===r.length)return{stream:(n=r[0].substr(7).split(" "))[0],track:n[1]};var i=e.matchPrefix(t,"a=ssrc:").map(function(t){return e.parseSsrcMedia(t)}).filter(function(e){return"msid"===e.attribute});return i.length>0&&i[0].value?{stream:(n=i[0].value.split(" "))[0],track:n[1]}:{stream:"",track:""}}},{key:"parseSsrcMedia",value:function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n}},{key:"getMid",value:function(t){var n=e.matchPrefix(t,"a=mid:")[0];if(n)return n.substr(6)}},{key:"splitNaluData",value:function(e){var t=new Uint8Array(e),n=0;if(this.isIFrame(t)){var r=t.join(","),i=r.indexOf("0,0,0,1,101");-1===i&&(i=r.indexOf("0,0,0,1,37")),n=r.substring(0,i).split(",").length-1+4+8}else n=12;return{header:t.slice(0,n),payloadData:t.slice(n)}}},{key:"deal0x03",value:function(e,t){var n=[];return n="encode"===t?e.join(",").replaceAll(",0,0,1,",",0,0,3,1,").split(",").map(function(e){return Number(e)}):e.join(",").replaceAll(",0,0,3,1,",",0,0,1,").split(",").map(function(e){return Number(e)}),new Uint8Array(n)}},{key:"isIFrame",value:function(e){var t=e.join("").startsWith("0001103");return t||(t=e.join("").startsWith("000139")),t}},{key:"parsePayloadTypes",value:function(t){var n=e.getMediaSections(t).find(function(t){return"audio"===e.parseMLine(t).kind});if(n){var r=n.match(/a=rtpmap:(\d+)\s+(\S+)/g);r&&(e.payloadTypeCodecMap=r.map(function(e){var t=e.match(/a=rtpmap:(\d+)\s+(\w+)/);return t?{payloadType:Number(t[1]),codec:t[2]}:null}).filter(function(e){return!!e}))}}}])}();Object.defineProperty(zo,"payloadTypeCodecMap",{enumerable:!0,configurable:!0,writable:!0,value:[]});var Qo,Zo;function Xo(e,t){for(var n=0,r=t;r<e.length;){var i=e[r];if(n+=i,r++,255!==i)break}return{value:n,nextOffset:r}}function $o(e,t){if(t>=e.length)return null;var n=Xo(e,t),r=n.value,i=n.nextOffset,a=Xo(e,i),o=a.value;if(i=a.nextOffset,o<16)return null;if(i+o>e.length)return null;var s=e.slice(i,i+16),c=i+16,u=o-16,l=e.slice(c,c+u);return l.length>=2&&0===l[l.length-2]&&128===l[l.length-1]?l=l.slice(0,l.length-2):l.length>=1&&128===l[l.length-1]&&(l=l.slice(0,l.length-1)),5===r?{payloadSize:o,uuid:s,content:l}:null}!function(e){e.PLANB="plan-b",e.UNIFIEDPLAN="unified-plan"}(Qo||(Qo={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(Zo||(Zo={}));var es=function(){function e(t,n,r,i){c(this,e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_useEncrypt",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_onReceiveSeiListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_outboundStreams",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return l(e,[{key:"setReceiveSeiListener",value:function(e){this._onReceiveSeiListener=e}},{key:"getOutboundVideoInfo",value:function(){var e=[];for(var t in this._outboundStreams){var n=this._outboundStreams[t].getVideoTracks()[0];if(n){var r=/_tiny$/.test(t),i=Bn(n),a=i.width,o=i.height;e.push({trackId:n.id,simulcast:r?Uo.TINY:Uo.NORMAL,resolution:"".concat(a,"x").concat(o)})}}return e}},{key:"setRemoteAnswer",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)switch(t.p=t.n){case 0:return e=Yo.trimBlankLine(e),t.p=1,t.n=2,this._peer.setRemoteDescription({type:"answer",sdp:e});case 2:t.n=4;break;case 3:return t.p=3,n=t.v,this._logger.info(Ne.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:ke.FAILED,msg:n})),t.a(2,Ae.SET_REMOTE_DESCRIPTION_FAILED);case 4:return this._logger.info(Ne.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:ke.SUCCESSED,sdp:e})),t.a(2,Ae.SUCCESS)}},t,this,[[1,3]])}))}},{key:"getStatParsr",value:function(e,t,n,r){return/chrome/i.test(Zn.browser)?new Ho(this,e,this._logger,t,n,r):/Firefox/i.test(Zn.browser)?new Jo(this,e,this._logger,t,n,r):/Safari/i.test(Zn.browser)?new Ko(this,e,this._logger,t,n,r):null}},{key:"getTrackIdByMid",value:function(e){return null}},{key:"resetSdp",value:function(e){return Yo.trimBlankLine(e)}},{key:"_setupSenderTransform",value:function(e){if(this._useEncrypt){var t=e.createEncodedStreams(),n=t.readable,r=t.writable,i=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});n.pipeThrough(i).pipeTo(r)}}},{key:"_setupReceiverTransform",value:function(e){var t=e.createEncodedStreams(),n=t.readable,r=t.writable,i=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});n.pipeThrough(i).pipeTo(r)}},{key:"_encodeVideoFrame",value:function(e){var t=zo.splitNaluData(e),n=t.header,r=t.payloadData,i=Wo.encodeVideo(r),a=zo.deal0x03(i,"encode");return new Uint8Array([].concat(C(n),C(a))).buffer}},{key:"_decodeVideoFrame",value:function(e){var t,n=new Uint8Array(e),r=n.join(",").indexOf("0,0,0,1,6,5");if(-1!==r&&n.join(",").includes("84,128,131,151,240,35,71,75,183,247,79,50,181,78,6,172")){var i=n.join(",").slice(r);return null===(t=this._onReceiveSeiListener)||void 0===t||t.call(this,i),e}if(!this._useEncrypt)return e;var a=zo.splitNaluData(e),o=a.header,s=a.payloadData,c=zo.deal0x03(s,"decode"),u=Wo.decodeVideo(c);return new Uint8Array([].concat(C(o),C(u))).buffer}},{key:"_handleAudioREDFrame",value:function(e,t){var n=function(e){for(var t=[],n=0;;){var r,i=!(e[n]>>7),a=127&e[n],o=void 0,s=void 0,c=void 0;if(i?(o=0,s=e.byteLength-(t.length>0?t.map(function(e){return 4+e.block.byteLength}).reduce(function(e,t){return e+t}):0)-1,c=e.slice(n,n+1),n+=1):(o=(e[n+1]<<6)+(e[n+2]>>2),s=((3&e[n+2])<<8)+e[n+3],c=e.slice(n,n+4),n+=4),r=new Uint8Array(s),t.push({timestampOffset:o,header:c,block:r,isPrimary:i,blockPType:a}),i)break}return t.forEach(function(t){var r=t.block.byteLength,i=e.slice(n,n+r);t.block.set(i),n+=r}),t}(new Uint8Array(e)),r=[],i=[],a=0;n.forEach(function(e){var n="decode"===t?Wo.decodeAudio(e.block):Wo.encodeAudio(e.block);if(n.byteLength!==e.block.byteLength&&!e.isPrimary){var o=I(e.header,4),s=o[2],c=o[3];s=(s>>2<<2)+n.byteLength>>8,c=255&n.byteLength,e.header=new Uint8Array([e.header[0],e.header[1],s,c])}e.block=n,a+=e.block.byteLength+e.header.byteLength,r.push(e.header),i.push(e.block)});var o=new Uint8Array(a),s=0;return[].concat(r,i).forEach(function(e){o.set(e,s),s+=e.byteLength}),o.buffer}},{key:"_handleOpusFrame",value:function(e,t){var n=new Uint8Array(e);return("encode"===t?Wo.encodeAudio(n):Wo.decodeAudio(n)).buffer}},{key:"_encodeRtpChunk",value:function(e,t,n){var r=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(r);else{var i=t.getMetadata().payloadType,a=zo.payloadTypeCodecMap.filter(function(e){return e.payloadType===i})[0].codec;"red"===a?t.data=this._handleAudioREDFrame(r,"encode"):"opus"===a?t.data=this._handleOpusFrame(r,"encode"):console.error("Unsupport audio payloadType: ".concat(i,", codec: ").concat(a))}n.enqueue(t)}},{key:"_decodeRtpChunk",value:function(e,t,n){var r=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(r);else if(this._useEncrypt){var i=t.getMetadata().payloadType,a=zo.payloadTypeCodecMap.filter(function(e){return e.payloadType===i})[0].codec;"red"===a?t.data=this._handleAudioREDFrame(r,"decode"):"opus"===a?t.data=this._handleOpusFrame(r,"decode"):console.error("Unsupport audio payloadType: ".concat(i,", codec: ").concat(a))}n.enqueue(t)}}],[{key:"setSdpSemantics",value:function(e,t){var n=Zn.browser,r=Zn.version,i=Zn.supportsUnifiedPlan;if(t.info(Ne.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:i,browser:n,version:r})),i)return/chrome/i.test(n)?r?void(this._sdpSemantics=r>92?"unified-plan":r<72?"plan-b":e):void(this._sdpSemantics="unified-plan"):void(/firefox/i.test(n)?this._sdpSemantics="unified-plan":/safari/i.test(n)?this._sdpSemantics=r<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan");this._sdpSemantics="plan-b"}},{key:"getSdpSemantics",value:function(){return e._sdpSemantics}}])}(),ts=function(){function e(t,n){var r;return c(this,e),r=s(this,e,[n,Qo.PLANB,t]),Object.defineProperty(r,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:n}),r}return g(e,Yo),l(e,[{key:"stringify",value:function(){var e=[this.SDPHeader];[].concat(C(this.audioStreams),C(this.videoStreams)).forEach(function(t){var n=t.match(/\ba=mid:(video|audio)\b/),r=Yo.clearInactiveOrRecvonly(t);n&&n[1]===an.AUDIO&&(e[1]=r),n&&n[1]===an.VIDEO&&(e[2]=r)});var t=e.join("");return Yo.trimBlankLine(t)}},{key:"setAudioBitrateWithStreamId",value:function(e,t){return this._logger.warn(Ne.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Audio Bitrate With Stream Id"),this}},{key:"setVideoBitrateWithStreamId",value:function(e,t){return this._logger.warn(Ne.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}])}(),ns=function(){function e(){var t;return c(this,e),t=s(this,e,arguments),Object.defineProperty(t,"senders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(t,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t}return g(e,es),l(e,[{key:"addLocalTrack",value:function(e){this._localTracks.every(function(t){return t.getTrackId()!==e.getTrackId()})&&this._localTracks.push(e);var t=e.getStreamId(),n=e.__innerGetMediaStreamTrack(),r=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);r.getTracks().forEach(function(e){e.kind===n.kind&&r.removeTrack(e)}),r.addTrack(n);var i=e.getTrackId(),a=this.senders[i];a?a.replaceTrack(n):(this.senders[i]=this._peer.addTrack(n,r),Object.defineProperty(n,"trackId",{value:i,writable:!1,enumerable:!1,configurable:!1}))}},{key:"removeLocalTrack",value:function(e){var t=this._localTracks.findIndex(function(t){return t===e});t>=0&&this._localTracks.splice(t,1);var n=e.getTrackId(),r=this.senders[n];r&&(r.replaceTrack(null),this._peer.removeTrack(r),delete this.senders[n])}},{key:"updateSubRemoteTracks",value:function(e){}},{key:"updateRecvTransceiverMap",value:function(e,t){}},{key:"setBitrate",value:function(e,t,n){}},{key:"createOffer",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0});case 1:for(r in n=t.v,this._outboundStreams)i=this._outboundStreams[r].id,n.sdp=n.sdp.replace(new RegExp(i,"g"),r);return n.sdp&&(n.sdp=this.resetSdp(n.sdp)),t.n=2,this._peer.setLocalDescription(n);case 2:return t.a(2,{type:"offer",semantics:"plan-b",sdp:n.sdp})}},t,this)}))}},{key:"setRemoteAnswer",value:function(t){return t=this.resetSdp(t),S(e,"setRemoteAnswer",this,3)([t])}},{key:"_getMaxRangeBitrate",value:function(e){var t=this._localTracks.filter(function(t){return e===nn.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack()}),n={max:0,min:0};return t.forEach(function(e){var t=e.getBitrate(),r=t.min,i=t.max,a=t.start;n.max=n.max<i?i:n.max,n.min=n.min>r?r:n.min,n.max===i?n.start=a:n.start=.7*n.max}),n}},{key:"resetSdp",value:function(e){var t=new ts(this._logger,e),n=this._getMaxRangeBitrate(nn.VIDEO_ONLY),r=this._getMaxRangeBitrate(nn.AUDIO_ONLY);return t.setAudiosBitrate(r),t.setVideosBitrate(n),t.stringify()}}])}(),rs=function(){function e(t,n){return c(this,e),s(this,e,[n,Qo.UNIFIEDPLAN,t])}return g(e,Yo),l(e,[{key:"stringify",value:function(){var e=[this.SDPHeader];[].concat(C(this.audioStreams),C(this.videoStreams)).forEach(function(t){var n=t.match(/\ba=mid:(\d+)\b/);n&&n[1]&&(e[+n[1]+1]=t)}),this.SDPHeader="",this.videoStreams=[],this.audioStreams=[];var t=e.join("");return Yo.trimBlankLine(t)}}])}(),is=function(){function e(){c(this,e),Object.defineProperty(this,"__streams",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}return l(e,[{key:"push",value:function(e,t){return this.__streams.set(e,t),t}},{key:"pickup",value:function(e){return this.__streams.get(e)}},{key:"delete",value:function(e){return this.__streams.delete(e)}},{key:"streams",get:function(){var e,t=new Map,n=_(this.__streams.keys());try{for(n.s();!(e=n.n()).done;){var r=e.value;t.set(r,this.pickup(r))}}catch(e){n.e(e)}finally{n.f()}return t}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}])}(),as=function(){function e(){var t;return c(this,e),t=s(this,e,arguments),Object.defineProperty(t,"_sendTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(t,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(t,"_recvAudio",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(t,"_recvVideo",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(t,"_recvTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(t,"_subedTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(t,"midMsid",{enumerable:!0,configurable:!0,writable:!0,value:{}}),t}return g(e,es),l(e,[{key:"setBitrate",value:function(e,t,n){this._logger.warn(Ne.L_FUNCTION_IS_UNAVAILABLE,"the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}},{key:"getTrackIdByMid",value:function(e){for(var t in this._sendTransceiver){if(this._sendTransceiver[t].mid===e)return t}for(var n in this._recvTransceiver){if(this._recvTransceiver[n].mid===e)return n}return null}},{key:"addLocalTrack",value:function(e){var t,n=e.getTrackId(),r=e.getStreamId(),i=e.__innerGetMediaStreamTrack();this._localTracks[n]=e;var a=this._outboundStreams[r]||(this._outboundStreams[r]=new MediaStream);a.getTracks().forEach(function(e){e.kind===i.kind&&a.removeTrack(e)}),a.addTrack(i);var o=this._sendTransceiver[n];if(o)o.sender.replaceTrack(i),o.direction="sendonly";else{var s=this._sendTransceiver[n]=this._peer.addTransceiver(i,{direction:"sendonly",streams:[a]});this._setupSenderTransform(s.sender)}is.getInstance().push(n,{msid:r,id:this._outboundStreams[r].id,kind:null===(t=e.streamTrack)||void 0===t?void 0:t.kind})}},{key:"removeLocalTrack",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.getTrackId(),r=e.getStreamId();delete this._localTracks[n];var i=this._sendTransceiver[n];if(i){"closed"!==this._peer.connectionState&&(i.direction="inactive",this._peer.removeTrack(i.sender),i.sender.replaceTrack(null));var a=this._outboundStreams[r];(e.isAudioTrack()?a.getAudioTracks():a.getVideoTracks()).forEach(function(e){return a.removeTrack(e)});var o=this._sendTransceiver["".concat(n,"_tiny")];if(o&&"inactive"!==o.direction&&t&&"closed"!==this._peer.connectionState){o.direction="inactive";var s=o.sender,c=s.track;this._peer.removeTrack(s),s.replaceTrack(null),this._outboundStreams["".concat(r,"_tiny")].removeTrack(c),c.stop()}}}},{key:"updateRecvTransceiverMap",value:function(e,t){var n=Fn(e).mediaType;this._recvTransceiver[e]=t;var r=n===nn.AUDIO_ONLY?this._recvAudio:this._recvVideo,i=r.findIndex(function(e){return e===t});i>=0&&r.splice(i,1)}},{key:"updateSubRemoteTracks",value:function(e){var t=this,n=e.slice(),r=this._subedTracks.slice();this._subedTracks=e.slice();for(var i=function(){var e=n[a],t=r.findIndex(function(t){return t===e});t>=0&&(n.splice(a,1),r.splice(t,1))},a=n.length-1;a>=0;a-=1)i();r.length&&r.forEach(function(e){var n=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);var r=t._recvTransceiver[n];r&&(r.direction="inactive")});var o={audio:0,video:0};n.length&&n.forEach(function(e){var n=e.isAudioTrack()?"audio":"video",r=t._recvTransceiver[e.getTrackId()];r?r.direction="recvonly":o[n]+=1});for(var s=this._recvAudio.length;s<o.audio;s+=1){var c=this._peer.addTransceiver("audio",{direction:"recvonly"});this._recvAudio.push(c),this._setupReceiverTransform(c.receiver)}for(var u=this._recvVideo.length;u<o.video;u+=1){var l=this._peer.addTransceiver("video",{direction:"recvonly"});this._recvVideo.push(l),this._setupReceiverTransform(l.receiver)}}},{key:"createOffer",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a;return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._peer.createOffer({iceRestart:e});case 1:for(i in n=t.v,r=n.sdp,this._outboundStreams)a=this._outboundStreams[i].id,r=r.replace(new RegExp(a,"g"),i);return r=(r=this.resetOfferSdp(r)).replace(/(a=ice-options:trickle)/g,"$1\r\na=ice-options:renomination"),n.sdp=r,t.n=2,this._peer.setLocalDescription(n);case 2:return t.a(2,{type:"offer",semantics:"unified-plan",sdp:r})}},t,this)}))}},{key:"setRemoteAnswer",value:function(t){t=this.resetAnswerSdp(t);var n=/[\r\n]+\r\n[\r\n]+/g;return n.test(t)&&(t=t.replace(n,"\r\n")),S(e,"setRemoteAnswer",this,3)([t])}},{key:"_genarateMid",value:function(e,t,n){var r=null;return zo.getMediaSections(e).forEach(function(e){zo.parseExtmap(e);var i=zo.parseMLine(e).kind,a=zo.parseMsid(e).stream,o=zo.getMid(e);"video"===n?/tiny$/.test(a)?a=a.replace(/tiny$/gi,"1_tiny"):a+="_1":a+="_0",a===t&&n===i&&o&&(r=o)}),r}},{key:"_setSenderTransceiverBitrate",value:function(e,t,n,r){var i=this._localTracks[t],a=null==i?void 0:i.getBitrate();r===an.AUDIO&&a&&e.setAudioBitrateWithMid(a,n),r===an.VIDEO&&a&&e.setVideoBitrateWithMid(a,n)}},{key:"_resetSenderTransceiver",value:function(e,t){var n;for(var r in this._sendTransceiver){var i=this._sendTransceiver[r],a=null===(n=i.sender.track)||void 0===n?void 0:n.kind,o=i.direction,s=i.mid;s||(s=this._genarateMid(e,r,a)),s&&(o===Zo.SENDONLY&&this._setSenderTransceiverBitrate(t,r,s,a),o===Zo.INACTIVE&&t.clearnSsrcWithMid(s,Zo.INACTIVE))}}},{key:"_resetRecvTransceiver",value:function(e){for(var t in this._recvTransceiver){var n=this._recvTransceiver[t],r=n.direction,i=n.mid;i&&r===Zo.INACTIVE&&e.clearnSsrcWithMid(i,Zo.RECVONLY)}}},{key:"resetOfferSdp",value:function(e){var t=new rs(this._logger,e);return this._resetSenderTransceiver(e,t),this._resetRecvTransceiver(t),t.stringify()}},{key:"resetAnswerSdp",value:function(e){var t,n=new rs(this._logger,e);for(var r in this._sendTransceiver){var i=this._sendTransceiver[r],a=i.mid;if(a){var o=this._localTracks[r],s=null==o?void 0:o.getBitrate(),c=null===(t=i.sender.track)||void 0===t?void 0:t.kind;c===an.AUDIO&&s&&n.setAudioBitrateWithMid(s,a),c===an.VIDEO&&s&&n.setVideoBitrateWithMid(s,a)}}return n.stringify()}}])}(),os=function(){function e(t,n,r,i,a,o){var u,l=arguments.length>6&&void 0!==arguments[6]&&arguments[6],_=arguments.length>7&&void 0!==arguments[7]&&arguments[7];c(this,e),u=s(this,e),Object.defineProperty(u,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(u,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(u,"_reTryExchange",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(u,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(u,"_store",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(u,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(u,"_isRoomAudience",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(u,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"reportParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"pubLocalTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(u,"_reTryExchangeTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(u,"_reportStatsTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(u,"_reportR3R4ToPolarisTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(u,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_formatStatsData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(u,"_inRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_firstConnectFromPub",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null});var d=es.getSdpSemantics(),f="unified-plan"===d&&_&&"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams&&Wo.isInit(),h=u._rtcPeerConn=new RTCPeerConnection({sdpSemantics:d,encodedInsertableStreams:f});return u._sdpStrategy="plan-b"===d?new ns(t,u._logger,h,!1):new as(t,u._logger,h,f),u._sdpStrategy.setReceiveSeiListener(u._decodeSeiData.bind(u)),u._rtcPeerConn.oniceconnectionstatechange=u._onICEConnectionStateChange.bind(u),u._rtcPeerConn.onconnectionstatechange=u._onConnectionStateChange.bind(u),u._rtcPeerConn.ontrack=u._onTrackReady.bind(u),u.reportParser=u._sdpStrategy.getStatParsr(u._rtcPeerConn,d,u._currentUserId,u._store),u}return g(e,ue),l(e,[{key:"getLocalTracks",value:function(){return Object.values(this.pubLocalTracks)}},{key:"_decodeSeiData",value:function(t){var n=t.split(",").map(function(e){return Number(e)}),r=function(e){if(e.length>=4&&0===e[0]&&0===e[1]&&(1===e[2]||0===e[2]&&1===e[3]))for(var t=0;t+4<e.length;)if(0===e[t]&&0===e[t+1]&&(1===e[t+2]||0===e[t+2]&&1===e[t+3])){var n=t+(1===e[t+2]?3:4);if(n>=e.length)break;if(6==(31&e[n])){var r=$o(e,n+1);if(r)return{payloadSize:r.payloadSize,content:r.content}}t=n+1}else t++;else for(var i=0;i+4<=e.length;){var a=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3];if(a<=0||i+4+a>e.length)break;var o=i+4;if(6==(31&e[o])){var s=o+1,c=$o(e.subarray(s,i+4+a),0);if(c)return{payloadSize:c.payloadSize,content:c.content}}i+=4+a}return null}(new Uint8Array(n));if(null==r?void 0:r.content.length){var i=this._context.decodeAsrText(r.content,n);i.length&&this.emit(e.__INNER_SEI_CONTENT__,i)}}},{key:"_onConnectionStateChange",value:function(){this._logger.info(Ne.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S,"state: ".concat(this._rtcPeerConn.connectionState))}},{key:"startAutoExecute",value:function(e){var t=this;this.stopAutoExecute(),this._reportStatsTimer=setTimeout(function(){t._reportHandle(),t.startAutoExecute(e)},e)}},{key:"stopAutoExecute",value:function(){clearTimeout(this._reportStatsTimer)}},{key:"_onICEConnectionStateChange",value:function(){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o;return E().w(function(t){for(;;)switch(t.n){case 0:return i=this._rtcPeerConn.iceConnectionState,this._logger.info(Ne.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:i})),t.n=1,this._getStatsData();case 1:a=t.v,o=a?this._createRCRTCStateReport(a).iceCandidatePair:null,this.emit(e.__INNER_ICE_STATE_CHANGE__,{status:i,time:Date.now(),iceCandidatePair:o}),"connected"===i?(this.emit(e.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==i&&"disconnected"!==i||this._handleRetry();try{null===(r=null===(n=this._reportListener)||void 0===n?void 0:n.onICEConnectionStateChange)||void 0===r||r.call(n,i)}catch(e){this._logger.error(Ne.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:ke.FAILED,mag:e}))}case 2:return t.a(2)}},t,this)}))}},{key:"_handleRetry",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r=this;return E().w(function(e){for(;;)switch(e.n){case 0:if(!this._inRetry){e.n=1;break}return e.a(2);case 1:return this.clearReTryExchangeTimer(),this._inRetry=!0,e.n=2,this._reTryExchange();case 2:if(t=e.v,n=t.code,this._inRetry=!1,n!==Ae.SUCCESS){e.n=3;break}return e.a(2);case 3:this._reTryExchangeTimer=setTimeout(function(){return r._handleRetry()},15e3);case 4:return e.a(2)}},e,this)}))}},{key:"_onTrackReady",value:function(t){if(t.streams.length){var n=t.streams[0].id,r=t.receiver.track,i=[n,"audio"===r.kind?nn.AUDIO_ONLY:nn.VIDEO_ONLY].join("_");Object.defineProperty(r,"trackId",{value:i,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(i,t.transceiver),Fn(i).tag!==Lo&&this.emit(e.__INNER_EVENT_TRACK_READY__,t)}}},{key:"setBitrate",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){return E().w(function(r){for(;;)switch(r.n){case 0:this._sdpStrategy.setBitrate(e,t,n),this._logger.info(Ne.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:ke.SUCCESSED,max:e,min:t,start:n}));case 1:return r.a(2)}},r,this)}))}},{key:"createOffer",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._sdpStrategy.createOffer(e);case 1:return n=t.v,this._logger.info(Ne.L_RTC_PEER_CONNECTION_CREATE_OFFER_O,JSON.stringify({offerSDP:n.sdp,sdpDemantics:n.semantics})),t.a(2,n)}},t,this)}))}},{key:"setRemoteAnswer",value:function(e){return F(this,arguments,void 0,function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E().m(function r(){var i;return E().w(function(r){for(;;)if(0===r.n)return zo.parsePayloadTypes(null===(i=t._rtcPeerConn.localDescription)||void 0===i?void 0:i.sdp),t._firstConnectFromPub=n,r.a(2,t._sdpStrategy.setRemoteAnswer(e))},r)})()})}},{key:"getLocalTrack",value:function(e){return this.pubLocalTracks[e]||null}},{key:"addLocalTrack",value:function(e){this.pubLocalTracks[e.getTrackId()]=e,this._sdpStrategy.addLocalTrack(e),e.off(Rn.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Rn.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(Rn.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Rn.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(Ne.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O,"trackId: ".concat(e.getTrackId()))}},{key:"removeLocalTrackById",value:function(e){var t=this.getLocalTrack(e);t?(this._logger.info(Ne.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:ke.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(Ne.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:ke.FAILED,msg:"track not found",trackId:e}))}},{key:"removeAllLocalTrack",value:function(){var e=this;Object.keys(this.pubLocalTracks).forEach(function(t){/_tiny$/.test(t)||e.removeLocalTrackById(t)})}},{key:"removeLocalTrack",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.getTrackId();delete this.pubLocalTracks[n],this._sdpStrategy.removeLocalTrack(e,t),e.__innerSetPublished(!1),e.off(Rn.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Rn.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);var r="".concat(n,"_tiny"),i=this.getLocalTrack(r);i&&t&&(this._sdpStrategy.removeLocalTrack(i,t),delete this.pubLocalTracks[r],i.destroy()),this._logger.info(Ne.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:n}))}},{key:"_updateRecvTransceiverMap",value:function(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}},{key:"updateSubRemoteTracks",value:function(e){this._sdpStrategy.updateSubRemoteTracks(e)}},{key:"getOutboundVideoInfo",value:function(){return this._sdpStrategy.getOutboundVideoInfo()}},{key:"_onLocalTrackMuted",value:function(e,t){var n=this.getLocalTrack("".concat(e.getTrackId(),"_tiny"));n&&(n.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(Rn.__INNER_EVENT_MUTED_CHANGE__,e,t)}},{key:"_onLocalTrackDestroied",value:function(e){this.emit(Rn.__INNER_EVENT_DESTROY__,e)}},{key:"registerReportListener",value:function(e){this._reportListener=e}},{key:"_createSenderReport",value:function(e){return e.filter(function(e){return e.trackId}).map(function(e){var t={trackId:e.trackId,kind:e.kind,packetsLostRate:e.packetsLostRate,remoteResource:e.remoteResource,bitrate:e.bitrate,jitter:e.jitter,rtt:e.rtt};return(e.audioLevel||0===e.audioLevel)&&(t.audioLevel=e.audioLevel),e.frameWidth&&(t.frameWidth=e.frameWidth),e.frameHeight&&(t.frameHeight=e.frameHeight),e.frameRate&&(t.frameRate=e.frameRate),Object.assign({},t)})}},{key:"_createReceiverReport",value:function(e){return e.filter(function(e){return e.trackId}).map(function(e){var t={trackId:e.trackId,kind:e.kind,packetsLostRate:e.packetsLostRate,remoteResource:e.remoteResource,bitrate:e.bitrate,jitter:e.jitter,rtt:e.rtt};return(e.audioLevel||0===e.audioLevel)&&(t.audioLevel=e.audioLevel),e.frameWidth&&(t.frameWidth=e.frameWidth),e.frameHeight&&(t.frameHeight=e.frameHeight),e.frameRate&&(t.frameRate=e.frameRate),Object.assign({},t)})}},{key:"_createRCRTCStateReport",value:function(e){var t=e.timestamp,n=e.iceCandidatePair,r=e.senders,i=e.receivers;for(var a in(null==n?void 0:n.totalPacketsLost)&&(null==n||delete n.totalPacketsLost),n)nr(n[a])&&delete n[a];return{timestamp:t,iceCandidatePair:n,senders:this._createSenderReport(r),receivers:this._createReceiverReport(i)}}},{key:"_getStatsData",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i,a;return E().w(function(e){for(;;)switch(e.n){case 0:return this._formatStatsData=null,r=null,e.n=1,this._rtcPeerConn.getStats();case 1:return i=e.v,r=null===(t=this.reportParser)||void 0===t?void 0:t.parseRTCStatsReport(i),a=null===(n=this.reportParser)||void 0===n?void 0:n.formatRCRTCStateReport(r),this._formatStatsData=a,e.a(2,a)}},e,this)}))}},{key:"_reportHandle",value:function(){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u,l;return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._getStatsData();case 1:if(s=t.v){t.n=2;break}return t.a(2);case 2:c=this._createRCRTCStateReport(s);try{null===(r=null===(n=this._reportListener)||void 0===n?void 0:n.onStateReport)||void 0===r||r.call(n,JSON.parse(JSON.stringify(c)))}catch(e){this._logger.error(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}if(u=[].concat(C(s.receivers),C(s.senders)).filter(function(e){return"audio"===e.kind}).map(function(e){return{trackId:e.trackId,audioLevel:e.audioLevel}}),this.emit(e.__INNER_AUDIOLEVEL_CHANGE__,u),this._isRoomAudience&&(null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)){l=this._getLiveAudioState();try{l.length&&(null===(o=null===(a=this._reportListener)||void 0===a?void 0:a.onReportLiveAudioStates)||void 0===o||o.call(a,l))}catch(e){this._logger.error(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}case 3:return t.a(2)}},t,this)}))}},{key:"_getLiveAudioState",value:function(){var e=this,t=[];return this._rtcPeerConn.getReceivers().forEach(function(e){var n=e.getContributingSources();n.length&&t.push.apply(t,C(n))}),t.map(function(t){var n=t.source,r=t.audioLevel,i=e._store.getTrackIdBySSRC(n);if(!i)return{};var a=Fn(i).userId;return{audioLevel:Bo(r),userId:a,trackId:i}}).filter(function(e){return!!e.userId})}},{key:"_sendR3R4Data",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i,a,o,s,c;return E().w(function(e){for(;;)switch(e.n){case 0:if(a=this._formatStatsData){e.n=1;break}return e.a(2);case 1:if(s=(o=a).senders,c=o.receivers,console.log("sendR3R4: senderTrackId: ".concat(null===(t=s[0])||void 0===t?void 0:t.trackId,", receiverTrackId: ").concat(null===(n=c[0])||void 0===n?void 0:n.trackId)),!s.length){e.n=2;break}return e.n=2,null===(r=this._polarisReport)||void 0===r?void 0:r.sendR3Data(a);case 2:if(!c.length){e.n=3;break}return e.n=3,null===(i=this._polarisReport)||void 0===i?void 0:i.sendR4Data(a);case 3:s.length=0,c.length=0,a=null;case 4:return e.a(2)}},e,this)}))}},{key:"__reportR3R4ToPolaris",value:function(){return F(this,void 0,void 0,E().m(function e(){var t=this;return E().w(function(e){for(;;)switch(e.n){case 0:if(!this._isDestroyed){e.n=1;break}return e.a(2);case 1:clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout(function(){return F(t,void 0,void 0,E().m(function e(){var t=this;return E().w(function(e){for(;;)switch(e.n){case 0:if(!this._isDestroyed){e.n=1;break}return e.a(2);case 1:this._sendR3R4Data().then(function(){t.__reportR3R4ToPolaris()});case 2:return e.a(2)}},e,this)}))},2e3);case 2:return e.a(2)}},e,this)}))}},{key:"getRTCPeerConn",value:function(){return this._rtcPeerConn}},{key:"destroy",value:function(){this.clear(),this.clearReTryExchangeTimer(),clearTimeout(this._reportR3R4ToPolarisTimer),this.stopAutoExecute(),this.registerReportListener(null),this._rtcPeerConn.close(),this._isDestroyed=!0,this.reportParser=null,this._logger.info(Ne.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:ke.SUCCESSED}))}},{key:"clearReTryExchangeTimer",value:function(){clearTimeout(this._reTryExchangeTimer),this._reTryExchangeTimer=null}},{key:"isDestroyed",value:function(){return this._isDestroyed}}])}();Object.defineProperty(os,"__INNER_EVENT_TRACK_READY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-track-ready"}),Object.defineProperty(os,"__INNER_AUDIOLEVEL_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-audio-level-change"}),Object.defineProperty(os,"__INNER_ICE_STATE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-state-change"}),Object.defineProperty(os,"__INNER_ICE_CONNECTED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-connected"}),Object.defineProperty(os,"__INNER_SEI_CONTENT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-sei-content"});var ss,cs,us,ls,_s=function(){return l(function e(t,n){c(this,e),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_audioLevelChangeHandler",{enumerable:!0,configurable:!0,writable:!0,value:null})},[{key:"audioLevelReport",value:function(e){var t=this;if(this._audioLevelChangeHandler){var n=[];e.forEach(function(e){var r=Fn(e.trackId).userId,i=t._store.crtUserId===r?t._peer.getLocalTrack(e.trackId):t._store.getRemoteTrack(e.trackId);i&&n.push({track:i,audioLevel:e.audioLevel||0})}),this._audioLevelChangeHandler(n)}}},{key:"onAudioLevelChange",value:function(e){this._audioLevelChangeHandler=e}}])}();!function(e){e[e.ANCHOR=1]="ANCHOR",e[e.AUDIENCE=2]="AUDIENCE"}(ss||(ss={})),function(e){e.UNPUBLISH_PREV="UnpublishPrevCommand",e.PULL_RTCROOM_STATUS="PullRTCRoomStatusCommand",e.JOINROOM="JoinRoomCommand",e.PARSE_REMOTERES="ParseRemoteResCommand",e.PARSE_USERSTATE="ParseUserStateCommand",e.LOCAL_TRACK_MUTE="LocalTrackMuteCommand",e.PUBLISH="PublishCommand",e.RETRY_EXCHANGE="RetryExchangeCommand",e.UNPUBLISH="UnpublishCommand",e.SUBSCRIBE="SubscribeCommand",e.UNSUBSCRIBE="UnsubscribeCommand",e.UPDATE_SUBSCRIBE_LIST="UpdateSubscribeListCommand",e.ON_SIGNAL_RECONNECTED="OnSignalReconnectedCommand",e.LEAVE_OTHER_ROOM="LeaveOtherRoomCommand",e.RTC_IDENTITY_CHANGE="RTCIdentityChangeCommand",e.ENABLE_INNER_CDN="EnableInnerCDNCommand",e.EXCHANGE_WITH_PUSH_OTHER_ROOM="ExchangeWithPushOtherRoomCommand",e.MCUCONFIG_FLUSH="MCUConfigFlushCommand",e.UNKNOWN="Unknown"}(cs||(cs={})),function(e){e[e.LOW=0]="LOW",e[e.NORMAL=1]="NORMAL",e[e.HIGH=2]="HIGH"}(us||(us={})),function(e){e[e.Destroy=40400]="Destroy"}(ls||(ls={}));var ds,fs=function(){return l(function e(){c(this,e)},[{key:"priority",get:function(){return us.LOW}},{key:"kind",get:function(){return cs.UNKNOWN}}])}(),hs=function(){return l(function e(t,n,r,i){c(this,e),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"abortCode",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_busy",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1})},[{key:"_next",value:function(){this._busy=!1,this._execute()}},{key:"_execute",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i,a,o,s;return E().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this._isDestroyed&&!this._busy&&0!==this._queue.length){e.n=1;break}return e.a(2);case 1:return this._busy=!0,t=this._queue.shift(),n=t.command,r=t.resolve,a=this._logger.createTraceId(),e.p=2,this._logger.info(Ne.L_INVOKER_EXECUTE_T,"kind: ".concat(n.kind,", length: ").concat(this._queue.length),a),e.n=3,n.execute(this._context,this._store,this);case 3:i=e.v,e.n=5;break;case 4:return e.p=4,s=e.v,console.error(s),this._logger.error(Ne.L_INVOKER_EXECUTE_R,n.kind,a),this._next(),e.a(2);case 5:(o=i.code)!==Ae.SUCCESS&&o!==we?this._logger.warn(Ne.L_INVOKER_EXECUTE_R,"code: ".concat(o,", kind: ").concat(n.kind),a):this._logger.info(Ne.L_INVOKER_EXECUTE_R,"kind: ".concat(n.kind,", Done"),a),r(i),this._next();case 6:return e.a(2)}},e,this,[[2,4]])}))}},{key:"push",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n=this;return E().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t){if(n._logger.info(Ne.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:n._isDestroyed,kind:e.kind,length:n._queue.length})),n._isDestroyed)t({code:Ae.NOT_IN_ROOM});else{var r=e.priority;if(r===us.LOW)n._queue.push({command:e,resolve:t});else{var i=n._queue.findIndex(function(e){return e.command.priority<r}),a=-1===i?n._queue.length-1:i;n._queue.splice(a,0,{command:e,resolve:t})}setTimeout(function(){n._execute()},0)}}))},t)}))}},{key:"isDestroyed",value:function(){return this._isDestroyed}},{key:"destroy",value:function(){var e=this;this._isDestroyed||(this._logger.info(Ne.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach(function(t){t.resolve({code:e.abortCode})}),this._queue.length=0)}}])}(),gs=function(){function e(t,n){return c(this,e),s(this,e,[t.logger,t,n,Ae.ROOM_HAS_BEEN_DESTROYED])}return g(e,hs),l(e,[{key:"store",get:function(){return this._context.store}},{key:"destroy",value:function(){S(e,"destroy",this,3)([]),this._store.removeRemoteTracks()}}])}();!function(e){e.VOID="0",e.OPEN="2",e.CLOSE="1"}(ds||(ds={}));var ps,Es=function(){return l(function e(t,n,r,i,a,o,s,u){c(this,e),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"appkey",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"roomMode",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"isUpgrade",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"isMainRoom",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(this,"_roomResources",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_collectSubscribeList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_CDNEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_trackIdSSRCMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_roomStatusVersion",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_supportNtf",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_asrStatus",{enumerable:!0,configurable:!0,writable:!0,value:ds.VOID}),Object.defineProperty(this,"_asrEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_srcLanguage",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isStartRealTranslate",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_translationLang",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_summarizationStatusData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_nickName",{enumerable:!0,configurable:!0,writable:!0,value:""})},[{key:"getResourcesByUserId",value:function(e){return this._roomResources[e]||this._asrSeiUris[e]}},{key:"getRemoteTrack",value:function(e){return this._remoteTracks[e]}},{key:"getRemoteTracksByUserId",value:function(e){var t=[];for(var n in this._remoteTracks){var r=this._remoteTracks[n];r.getUserId()===e&&t.push(r)}return t}},{key:"getRemoteTracks",value:function(){return this._remoteTracks}},{key:"getSessionId",value:function(){return this._sessionId}},{key:"getAllUserIds",value:function(){return Object.keys(this._roomResources)}},{key:"getRemoteUserIds",value:function(){var e=this;return this.getAllUserIds().filter(function(t){return t!==e.crtUserId})}},{key:"getSubscribedList",value:function(){return this._subscribedList}},{key:"getCollectSubscribeList",value:function(){return this._collectSubscribeList}},{key:"getPublishedResourceByTrackId",value:function(e){var t=Fn(e),n=t.tag,r=t.userId;return n===Lo?this._asrSeiUris[r][0]:this._roomResources[r].find(function(t){return jn(t)===e})}},{key:"getToken",value:function(){return this._token}},{key:"getCDNEnable",value:function(){return this._CDNEnable}},{key:"getCDNUris",value:function(){return this._CDNUris}},{key:"getRoomStatusVersion",value:function(){return this._roomStatusVersion}},{key:"getTrackIdBySSRC",value:function(e){return this._trackIdSSRCMap.get(e)}},{key:"getRTCRequestHeader",value:function(){return{"App-Key":this.appkey,RoomId:this.roomId,Token:this._token,RoomType:this.roomMode,UserId:this.crtUserId,"Client-Session-Id":this.clientSessionId}}},{key:"getSupportNtf",value:function(){return this._supportNtf}},{key:"getASRIsAvailable",value:function(){return!!this.getASRSeiUris().length}},{key:"getASRStatus",value:function(){return this._asrStatus}},{key:"getASREnable",value:function(){return this._asrEnable}},{key:"getSrcLanguage",value:function(){return this._srcLanguage}},{key:"getASRSeiUris",value:function(){var e=Object.values(this._asrSeiUris);return e.length?e[0]:[]}},{key:"getIsStartRealTranslate",value:function(){return this._isStartRealTranslate}},{key:"getTranslationLang",value:function(){return this._translationLang}},{key:"getSummarizationStatusData",value:function(){return this._summarizationStatusData||null}},{key:"getNickName",value:function(){return this._nickName}}])}(),vs=function(){function e(){return c(this,e),s(this,e,arguments)}return g(e,Es),l(e,[{key:"_updateTrackIdSSRCMap",value:function(){var e=this;Object.values(this._roomResources).forEach(function(t){t.forEach(function(t){var n=JSON.parse(t.uri),r=n.ssrc,i=n.resourceId;e._trackIdSSRCMap.set(r,i)})})}},{key:"setTrackIdSSRCMap",value:function(e,t){this._trackIdSSRCMap.set(e,t)}},{key:"_initRemoteTracks",value:function(){var e=this;for(var t in this._roomResources){var n=this._roomResources[t];t!==this.crtUserId&&0!==n.length&&n.forEach(function(t){var n=jn(t),r=Fn(n),i=r.tag,a=r.userId,o=r.mediaType===nn.AUDIO_ONLY?new Pn(e._logger,i,a):new Un(e._logger,i,a);o.__innerSetRemoteMuted(0===t.state),e._remoteTracks[n]=o})}}},{key:"initWithRoomData",value:function(e,t){this._sessionId=e.sessionId,this._token=e.token,this._roomStatusVersion=cr(e.version),this._roomResources=ar(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(Ne.L_PARSE_ROOMDATA_URIS_R,"room data -> ".concat(JSON.stringify(this._roomResources)),t)}},{key:"assignRoomData",value:function(e){Object.assign(this._roomResources,e),this._updateTrackIdSSRCMap()}},{key:"setResourcesByUserId",value:function(e,t){this._roomResources[e]=t,this._updateTrackIdSSRCMap()}},{key:"removeRemoteTrack",value:function(e){delete this._remoteTracks[e]}},{key:"removeResourcesByUserId",value:function(e){delete this._roomResources[e],this._updateTrackIdSSRCMap()}},{key:"addRemoteTrack",value:function(e){this._remoteTracks[e.getTrackId()]=e}},{key:"removeRemoteTracks",value:function(){var e=Object.values(this._remoteTracks);e.length&&(e.forEach(function(e){e.isAudioTrack()&&e.__releaseMediaElement()}),this._remoteTracks={})}},{key:"setCDNEnabel",value:function(e){this._CDNEnable=e}},{key:"setCDNUris",value:function(e){this._CDNUris=e}},{key:"resetSubscribedList",value:function(e){var t;(t=this._subscribedList).splice.apply(t,[0,this._subscribedList.length].concat(C(e))),this.resetCollectSubscribeList(e)}},{key:"resetCollectSubscribeList",value:function(e){var t;(t=this._collectSubscribeList).splice.apply(t,[0,this._collectSubscribeList.length].concat(C(e)))}},{key:"setRoomStatusVersion",value:function(e){this._roomStatusVersion=cr(e)}},{key:"setASRStatus",value:function(e){this._asrStatus=e}},{key:"setASREnable",value:function(e){this._asrEnable=e}},{key:"setSrcLanguage",value:function(e){this._srcLanguage=e}},{key:"setASRSeiUris",value:function(e){if(e.length){var t=e[0].msid.split("_")[0];this._asrSeiUris[t]=e}else this._asrSeiUris={}}},{key:"addSeiRemoteTrack",value:function(e){var t=e[0].msid.split("_"),n=t.pop(),r=t[0],i=new Un(this._logger,n,r);this.addRemoteTrack(i)}},{key:"removeSeiRemoteTrack",value:function(){if(this.getASRSeiUris().length){var e=this.getASRSeiUris()[0],t=e.msid,n=e.mediaType,r="".concat(t,"_").concat(n);this.removeRemoteTrack(r)}}},{key:"setIsStartRealTranslate",value:function(e){this._isStartRealTranslate=e}},{key:"setTranslationLang",value:function(e){this._translationLang=e}},{key:"setSummarizationStatusData",value:function(e){this._summarizationStatusData=e}},{key:"setNickName",value:function(e){this._nickName=e}}])}(),ms=function(){function e(){return c(this,e),s(this,e,arguments)}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.UNPUBLISH_PREV}},{key:"execute",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c;return E().w(function(n){for(;;)switch(n.n){case 0:return r=e.logger,i=e.context,a=t.getResourcesByUserId(t.crtUserId),o=a.slice(),a.length=0,s=r.createTraceId(),r.info(Ne.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:o}),s),n.n=1,i.setRTCTotalRes(t.roomId,[Dn(er.UNPUBLISH,o)],Mn([]),er.TOTAL_CONTENT_RESOURCE,Mn([]));case 1:return(c=n.v)!==we?r.error(Ne.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:ke.FAILED,code:c}),s):r.info(Ne.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:ke.SUCCESSED}),s),n.a(2,{code:Ae.SUCCESS})}},n)}))}}])}();!function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE",e[e.CROSS_MUTI=7]="CROSS_MUTI",e[e.SIP=4]="SIP",e[e.CALL=5]="CALL"}(ps||(ps={}));var Rs,Ts=function(){function e(t,n,r,i,a,o,u,l,_){var d;return c(this,e),d=s(this,e),Object.defineProperty(d,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(d,"roomType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(d,"joinType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(d,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(d,"innerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(d,"outerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(d,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(d,"srcLanguage",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(d,"nickName",{enumerable:!0,configurable:!0,writable:!0,value:_}),d}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.JOINROOM}},{key:"_getResultTag",value:function(){var e=Ne.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===ps.LIVE&&(e=Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}},{key:"_validateParams",value:function(e,n,r){var i=this;if(e.getConnectionStatus()!==t.CONNECTED)return n.error(r,JSON.stringify({status:ke.FAILED,code:Ae.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:Ae.SIGNAL_DISCONNECTED};if(rr(e.getNaviInfo()))return n.error(r,JSON.stringify({status:ke.FAILED,code:Ae.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:Ae.PACKAGE_ENVIRONMENT_ERROR};if(!ce("roomId",this.roomId,Q,!0))return n.error(r,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:Ae.PARAMS_ERROR};if(!ce("roomType",this.roomType,function(e){return void 0!==ps[e]}))return n.error(r,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:Ae.PARAMS_ERROR};if(!ce("outerUserDatas",this.outerUserDatas,X,!1))return n.error(r,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:Ae.PARAMS_ERROR};if(this.outerUserDatas&&!Object.keys(this.outerUserDatas).every(function(e){return ce("outerUserDatas.".concat(e),i.outerUserDatas[e],Y,!0)}))return n.error(r,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:Ae.PARAMS_ERROR};if(this.nickName&&(!ce("nickName",this.nickName,Y,!0)||this.nickName.length>64))return n.error(r,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> nickName"}),this.traceId),{code:Ae.PARAMS_ERROR};if(this.srcLanguage&&(!ce("srcLanguage",this.srcLanguage,Y,!0)||this.srcLanguage.length>50))return n.error(r,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> srcLanguage"}),this.traceId),{code:Ae.PARAMS_ERROR};return{code:Ae.SUCCESS}}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h,g,p,v,m,R,T,I,S,C,L,O,y;return E().w(function(r){for(;;)switch(r.n){case 0:if(c=Date.now(),u=e.context,l=e.service,_=e.logger,d=e.reportMediaActionLogger,f=this._getResultTag(),h=this._validateParams(u,_,f),(g=h.code)===Ae.SUCCESS){r.n=1;break}return r.a(2,{code:g});case 1:if(l.getMsList().length){r.n=2;break}return _.error(f,JSON.stringify({status:ke.FAILED,code:Ae.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),r.a(2,{code:Ae.NOT_OPEN_VIDEO_AUDIO_SERVER});case 2:return p=t.getSupportNtf(),r.n=3,u.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,p);case 3:if(v=r.v,m=v.code,R=v.data,d.reportQualityJoinRoomData(c,m,this.roomType,null==R?void 0:R.sessionId),m===we&&R){r.n=4;break}return T=40032===m?Ae.SIGNAL_JOIN_RTC_ROOM_REFUSED:m,_.error(f,JSON.stringify({status:ke.FAILED,code:T,msg:"joinRoom failed"}),this.traceId),r.a(2,{code:T});case 4:return t.initWithRoomData(R,this.traceId),this.nickName&&t.setNickName(this.nickName),this.srcLanguage&&t.setSrcLanguage(this.srcLanguage),t.getResourcesByUserId(t.crtUserId).length>0&&n.push(new ms),(I=null===(i=R.roomInfo.filter(function(e){return"cdn_uris"===e.key})[0])||void 0===i?void 0:i.value)&&t.setCDNUris(JSON.parse(I)[0]),(S=null===(a=R.roomInfo.filter(function(e){return"asr_status"===e.key})[0])||void 0===a?void 0:a.value)&&t.setASRStatus(S),(C=null===(o=R.roomInfo.filter(function(e){return"sei_ai_uris"===e.key})[0])||void 0===o?void 0:o.value)&&(L=JSON.parse(C)).length&&(t.setASRSeiUris(L),t.addSeiRemoteTrack(L)),(O=null===(s=R.roomInfo.filter(function(e){return"summarization"===e.key})[0])||void 0===s?void 0:s.value)&&(y=JSON.parse(O),t.setSummarizationStatusData(y)),_.info(f,JSON.stringify({status:ke.SUCCESSED,userId:t.crtUserId,roomId:this.roomId,sessionId:R.sessionId}),this.traceId),r.a(2,{code:Ae.SUCCESS,data:R})}},r,this)}))}}])}();!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(Rs||(Rs={}));var Is,Ss,Cs,Ls="PEER_CONNECTION_CLOSED_BY_EXCEPTION",Os="USER_JOIN",ys="USER_LEAVE",bs="TRACKS_PUBLISH",As="TRACKS_UNPUBLISH",Ns="AUDIO_MUTE_CHANGE",ks="VIDEO_MUTE_CHANGE",Ps="CDN_ENABLE_CHANGE",Us="USER_STATE_CHANGE",ws="ASR_SEI_PUBLISH",Ds="ASR_SEI_UNPUBLISH",Ms="SUMMARIZATION_START",xs="SUMMARIZATION_STOP",Vs=function(){function e(t,n,r,i,a,o,u,l){var _;return c(this,e),_=s(this,e),Object.defineProperty(_,"logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(_,"service",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(_,"context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(_,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(_,"peer",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(_,"store",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(_,"polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(_,"reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(_,"getPushOtherRooms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),_}return g(e,ue),l(e)}();!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(Is||(Is={})),function(e){e.BEGIN="begin",e.END="end"}(Ss||(Ss={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(Cs||(Cs={}));var Bs,Gs=function(){function e(t,n,r){var i;return c(this,e),i=s(this,e),Object.defineProperty(i,"reqBody",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"isNeedUpdateMsas",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return g(e,fs),l(e,[{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f;return E().w(function(n){for(;;)switch(n.n){case 0:return i=e.service,a=e.context,n.n=1,i.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas);case 1:return o=n.v,s=o.code,c=o.data,u=o.qualityMsList,l={code:s,data:{data:c,qualityMsList:u}},_=null===(r=null==c?void 0:c.urls)||void 0===r?void 0:r.pull_url,t.roomMode===ps.LIVE&&_&&(d=JSON.parse(_),t.setCDNUris(d),(null==d?void 0:d.broadcast)===Cs.SPREAD&&(t.setCDNEnabel(!0),f=Object.assign(Object.assign({},d),{enableInnerCDN:!0}),Ys(a,t.roomId,f))),n.a(2,l)}},n,this)}))}}])}();!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(Bs||(Bs={}));var js=function(){function e(t,n,r){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Bs.SUB,o=arguments.length>4?arguments[4]:void 0;return c(this,e),i=s(this,e),Object.defineProperty(i,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(i,"unsubTracks",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(i,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(i,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),i}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.UPDATE_SUBSCRIBE_LIST}},{key:"_dealSubscribeResult",value:function(e,t,n,r){var i=null==r?void 0:r.map(function(e){return"".concat(e.msid,"_").concat(e.mediaType)}),a=n.filter(function(e){return null==i?void 0:i.includes(e.track.getTrackId())}),o=n.filter(function(e){return!(null==i?void 0:i.includes(e.track.getTrackId()))});t.info(Ne.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:ke.SUCCESSED,subSuccessTrackIds:i,failedList:o}),this.traceId);var s=e.getRemoteTracks(),c=function(e){var t=a.some(function(t){return t.track.getTrackId()===e});s[e].__innerSetSubscribed(t);var n=a.some(function(t){return t.track.getTrackId()===e&&t.subTiny});s[e].isVideoTrack()&&s[e].__innerSetIsTinyTrack(n)};for(var u in s)c(u);return e.resetSubscribedList(a),o}},{key:"_getParams",value:function(e,t,n){var r=this,i=n.map(function(e){return e instanceof kn?{track:e}:Object.assign({},e)}),a={};return i=i.filter(function(n){var i=n.track.getTrackId();return e.getRemoteTrack(i)?!a[i]&&(a[i]=!0,!0):(t.warn(Ne.L_UPDATE_SUBSCRIBELIST_COMMAND_P,"track cannot found in room -> trackId: ".concat(i),r.traceId),!1)}).map(function(e){return Object.assign({},e)})}},{key:"_validateParams",value:function(e,t){return ce("tracks",t,function(){return z(t)&&t.every(function(e){return e instanceof kn||e.track instanceof kn})},!0)?{code:Ae.SUCCESS}:(e.warn(Ne.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:Ae.PARAMS_ERROR})}},{key:"_reportPubOrSubQualityData",value:function(e,t,n){(null==n?void 0:n.length)&&e.reportPubOrSubQualityData(this.fromCommand,this._actionStartTime,n,t,this._trackMediaMap)}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h,g,p,v,m,R,T,I,S,C,L,O,y=this;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.peer,o=e.reportMediaActionLogger,s=e.context,this._actionStartTime=Date.now(),c=this.tracks,u=this.forceReq,l=t.roomId,i.info(Ne.L_UPDATE_SUBSCRIBELIST_COMMAND_T,"roomId: ".concat(l,", forceReq: ").concat(u,", trackIds: ").concat(c.map(sr)),this.traceId),_=this._validateParams(i,c),(d=_.code)===Ae.SUCCESS){r.n=1;break}return r.a(2,{code:d});case 1:if(f=this._getParams(t,i,c),h=t.getSubscribedList().map(function(e){return Object.assign({},e)}),u){r.n=3;break}if(ac(f,h)){r.n=2;break}return i.warn(Ne.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ke.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),r.a(2,{code:Ae.SUCCESS});case 2:h.length&&(g=h.map(function(e){return e.track}),i.warn(Ne.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:g.map(function(e){return e.getTrackId()})}),this.traceId),p=t.getSubscribedList().filter(function(e){return g.every(function(t){return t.getTrackId()!==e.track.getTrackId()})}),t.resetSubscribedList(p));case 3:return a.__reportR3R4ToPolaris(),a.clearReTryExchangeTimer(),a.updateSubRemoteTracks(f.map(function(e){return e.track})),r.n=4,Js(f,!1,a,t,s);case 4:return(v=r.v).pushOtherRooms=e.getPushOtherRooms(),r.n=5,new Gs(v,this.traceId,!0).execute(e,t,n);case 5:if(m=r.v,c.forEach(function(e){var t=e instanceof kn?e.getTrackId():e.track.getTrackId();y._trackMediaMap[t]=m.data.qualityMsList||[]}),R=this.fromCommand===Bs.SUB?c:this.unsubTracks,m.code===Ae.SUCCESS){r.n=6;break}return this._reportPubOrSubQualityData(o,m.code,R),i.error(Ne.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ke.FAILED,code:m.code}),this.traceId),r.a(2,{code:m.code});case 6:if(T=m.data.data,I=T.sdp,S=T.resultCode,C=T.subscribedList,S===Ae.SUCCESS){r.n=7;break}return this._reportPubOrSubQualityData(o,S,R),i.error(Ne.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ke.FAILED,code:S}),this.traceId),r.a(2,{code:S});case 7:return o.setPubOrSubSuccessTime(Date.now()),r.n=8,a.setRemoteAnswer(I.sdp);case 8:if(L=r.v,this._reportPubOrSubQualityData(o,L,R),L===Ae.SUCCESS){r.n=9;break}return r.a(2,{code:L});case 9:return O=this._dealSubscribeResult(t,i,f,C),r.a(2,O.length?{code:Ae.SUCCESS,data:O}:{code:Ae.SUCCESS})}},r,this)}))}}])}(),Fs=function(){function e(t,n){var r;return c(this,e),r=s(this,e),Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),r}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.UNSUBSCRIBE}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.polarisReport,o=this.tracks,ce("tracks",o,function(){return z(o)&&o.length>0&&o.every(function(e){return e instanceof kn})},!0)){r.n=1;break}return i.warn(Ne.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),r.a(2,{code:Ae.PARAMS_ERROR});case 1:return i.info(Ne.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:o.map(sr)}),this.traceId),s=t.getSubscribedList().map(function(e){return Object.assign({},e)}).filter(function(e){return o.every(function(t){return t.getTrackId()!==e.track.getTrackId()})}),a.sendR2(Is.SUBSCRIBE,Ss.END,o.map(function(e){return e.getTrackId()})),r.a(2,new js(s,!1,this.traceId,Bs.UNSUB,this.tracks).execute(e,t,n))}},r,this)}))}}])}(),Hs=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),n}return g(e,fs),l(e,[{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o;return E().w(function(r){for(;;)switch(r.n){case 0:return i=e.logger,a=this.tracks,o=i.createTraceId(),i.info(Ne.L_USER_LEFT_UNSUBSCRIBE_O,void 0,o),r.n=1,new Fs(a,o).execute(e,t,n);case 1:return a.forEach(function(e){e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())}),e.emit(As,a),r.a(2,{code:Ae.SUCCESS})}},r,this)}))}}])}();function Js(e,t,n,r,i){return F(this,void 0,void 0,E().m(function a(){var o,s,c,u,l,_,d;return E().w(function(a){for(;;)switch(a.n){case 0:return s=(null===(o=i.getNaviInfo())||void 0===o?void 0:o.ipType)||0,a.n=1,n.createOffer(t);case 1:return c=a.v,u=r.getSrcLanguage(),l=r.getNickName(),_={resolutionInfo:n.getOutboundVideoInfo()},u&&Object.assign(_,{srcLanguage:u}),l&&Object.assign(_,{nickName:l}),d={asr_status:r.getASRStatus(),ipType:s,sdp:c,extend:JSON.stringify(_),subscribeList:e.filter(function(e){var t=e.track.getTrackId(),n=Fn(t).userId,i=r.getResourcesByUserId(n);if(!i)return!1;var a=i.filter(function(e){return t==="".concat(e.msid,"_").concat(e.mediaType)}).length;return a}).map(function(e){return{simulcast:e.subTiny?Uo.TINY:Uo.NORMAL,resolution:"",uri:r.getPublishedResourceByTrackId(e.track.getTrackId()).uri}}),switchstream:!1},a.a(2,d)}},a)}))}function Ks(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a;return E().w(function(r){for(;;)switch(r.n){case 0:return i=e.logger.createTraceId(),e.logger.info(Ne.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:n}),i),r.n=1,e.setRTCCDNUris(t,er.TOTAL_CONTENT_RESOURCE,JSON.stringify([n]));case 1:if((a=r.v)===we){r.n=2;break}return e.logger.error(Ne.L_LIVING_ROOM_SPREAD_CDN_INFO_R,"status: ".concat(ke.FAILED,", code: ").concat(a),i),r.a(2,{code:Ae.SIGNAL_ERROR});case 2:return e.logger.info(Ne.L_LIVING_ROOM_SPREAD_CDN_INFO_R,"status: ".concat(ke.SUCCESSED),i),r.a(2,{code:Ae.SUCCESS})}},r)}))}function Ys(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a;return E().w(function(r){for(;;)switch(r.n){case 0:return i=e.logger.createTraceId(),e.logger.info(Ne.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,"CDNUris: ".concat(n),i),r.n=1,e.setRTCData(t,"cdn_uris",JSON.stringify([n]),!0,Rs.ROOM);case 1:if((a=r.v)===we){r.n=2;break}return e.logger.error(Ne.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,"status: ".concat(ke.FAILED,", code: ").concat(a),i),r.a(2,{code:Ae.SIGNAL_ERROR});case 2:return e.logger.info(Ne.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,"status: ".concat(ke.SUCCESSED),i),r.a(2,{code:Ae.SUCCESS})}},r)}))}function qs(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o;return E().w(function(n){for(;;)switch(n.n){case 0:return r=t.roomId,i=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()}),n.n=1,Promise.all([Ks(e,r,i),Ys(e,r,i)]);case 1:return a=n.v,o=a.every(function(e){return e.code===Ae.SUCCESS}),n.a(2,o?{code:Ae.SUCCESS}:{code:Ae.SIGNAL_ERROR})}},n)}))}var Ws=function(e,t,n,r){return F(void 0,void 0,void 0,E().m(function i(){var a,o,s,c,u,l;return E().w(function(i){for(;;)switch(i.n){case 0:a=e.crtUserId,u=m(r);case 1:if((l=u()).done){i.n=4;break}if((o=l.value)!==a){i.n=2;break}return i.a(3,1);case 2:if(!(s=r[o]).length){i.n=3;break}return c=s.map(function(t){return e.getRemoteTrack(jn(t))}),i.n=3,new Hs(c).execute(t,e,n);case 3:i.n=1;break;case 4:return i.a(2)}},i)}))},zs=function(e,t,n){var r=t.logger;Object.keys(n).forEach(function(i){var a=n[i];if(0!==a.length){var o=a.map(function(t){var n=jn(t),i=Fn(n),a=i.userId,o=i.tag,s=i.mediaType===nn.AUDIO_ONLY?new Pn(r,o,a):new Un(r,o,a);return e.addRemoteTrack(s),s.__innerSetRemoteMuted(0===t.state),s});o.length&&t.emit(bs,o)}})},Qs=function(e,t,n){Object.keys(n).forEach(function(r){n[r].forEach(function(n){var r=jn(n),i=e.getRemoteTrack(r);i.__innerSetRemoteMuted(0===n.state),i.isAudioTrack()?t.emit(Ns,i):t.emit(ks,i)})})};function Zs(e,t,n,r,i,a){return F(this,void 0,void 0,E().m(function o(){var s,c,u,l,_,d,f,h,g,p,v,m,R,T,I,S,C,L,O;return E().w(function(o){for(;;)switch(o.n){case 0:s=n.logger,c=t.roomId,u=t.roomMode,l=[],_={},d={},f={},h=ar(e,c,s,a),g=Object.keys(h),p=t.getAllUserIds(),v=g.length-1;case 1:if(!(v>=0)){o.n=4;break}if(m=g[v],-1!==(R=p.indexOf(m))){o.n=2;break}return l.push(m),_[m]=Jn(h[m]),o.a(3,3);case 2:T=t.getResourcesByUserId(m),I=h[m],S=Kn(T,I,!0),C=S.publishedList,L=S.modifiedList,O=S.unpublishedList,_[m]=Jn(C),d[m]=Jn(O),f[m]=Jn(L),p.splice(R,1);case 3:v-=1,o.n=1;break;case 4:if(p.length&&p.forEach(function(e){t.removeResourcesByUserId(e)}),t.assignRoomData(h),!p.length){o.n=6;break}return o.n=5,$s(p,n,t,r,a);case 5:n.emit(ys,p);case 6:return l.length&&n.emit(Os,l),o.n=7,Ws(t,n,r,d);case 7:zs(t,n,_),Qs(t,n,f),u===_e.LIVE&&Xs(n,t,s,i);case 8:return o.a(2)}},o)}))}function Xs(e,t,n,r){var i;if(r){var a=JSON.parse(r),o=(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN)!==a.enableInnerCDN;t.setCDNUris(a),o&&e.emit(Ps,a.enableInnerCDN)}else n.warn(Ne.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:ke.FAILED,code:"",msg:"cdn_uris not found"}))}function $s(e,t,n,r,i){return F(this,void 0,void 0,E().m(function a(){var o,s;return E().w(function(a){for(;;)switch(a.n){case 0:if(o=[],s=[],e.forEach(function(e){o.push.apply(o,C(n.getRemoteTracksByUserId(e))),s.push(e)}),!o.length){a.n=2;break}return a.n=1,new Fs(o,i).execute(t,n,r);case 1:o.forEach(function(e){return n.removeRemoteTrack(e.getTrackId())});case 2:s.length&&s.forEach(function(e){return n.removeResourcesByUserId(e)});case 3:return a.a(2)}},a)}))}function ec(e){var t,n=e.userId,r=e.userData,i=e.event,a=e.switchRoleType;return{users:[{userId:n,extra:null===(t=r.filter(function(e){return"extra"===e.key})[0])||void 0===t?void 0:t.value,state:i,switchRoleType:a}]}}function tc(e){var t,n,r=e.userId,i=e.userData,a=function(e){return e.some(function(e){return"uris"===e.key||"cdn_uris"===e.key})}(i);if(a){var o=null===(t=i.filter(function(e){return"uris"===e.key})[0])||void 0===t?void 0:t.value,s=null===(n=i.filter(function(e){return"cdn_uris"===e.key})[0])||void 0===n?void 0:n.value;return{userId:r,content:{uris:o?JSON.parse(o):[],cdn_uris:s&&JSON.parse(s)}}}}function nc(e){var t={users:{}},n="";return e.forEach(function(e){var r,i,a=e.userId,o=e.userData;t.users[a]={};var s=null===(r=o.filter(function(e){return"uris"===e.key})[0])||void 0===r?void 0:r.value,c=null===(i=o.filter(function(e){return"cdn_uris"===e.key})[0])||void 0===i?void 0:i.value;n=c||n,t.users[a]={uris:s}}),{urisData:t,CDNUris:n&&JSON.stringify(JSON.parse(n)[0])}}var rc,ic=function(e,t,n){var r=e.split("\r\nm"),i=n===nn.AUDIO_ONLY?"audio":"video",a=r.filter(function(e){return e.includes("=".concat(i))&&e.includes(t)})[0],o=new RegExp("a=ssrc:(.*?) msid:".concat(t)),s=a.match(o);return s?s[1]:""},ac=function(e,t){var n=!1;return e.forEach(function(e){var r=t.findIndex(function(t){return t.track.getTrackId()===e.track.getTrackId()});-1!==r?t.splice(r,1)[0].subTiny!==e.subTiny&&(n=!0):n=!0}),t.length&&(n=!0),n},oc=function(){function e(t,n){var r;return c(this,e),r=s(this,e),Object.defineProperty(r,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),r}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.PARSE_USERSTATE}},{key:"priority",get:function(){return us.NORMAL}},{key:"_isPKRoomUser",value:function(e,t){var n,r=_(t);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.extra&&i.extra.roomId!==e.roomId)return!0;if(1===Number(i.state)&&!e.getRemoteUserIds().includes(i.userId))return!0}}catch(e){r.e(e)}finally{r.f()}return!1}},{key:"_dealAddUser",value:function(e,t,n,r,i){var a=e.getResourcesByUserId(i);a||(r?n.upgrade.push(i):n.joined.push(i),t.info(Ne.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:i,msg:"user ".concat(r?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(i,a||[])}},{key:"_dealReduceUser",value:function(e,t,n,r,i){e.info(Ne.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:i,msg:"user ".concat(r?"downgrade":"left")}),this.traceId),r?t.downgrade.push(i):1!==Number(n)?t.offline.push(i):t.left.push(i)}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c=this;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},0!==(o=this.msgContent.users).length){r.n=1;break}return r.a(2,{code:Ae.SUCCESS,data:a});case 1:if(!this._isPKRoomUser(t,o)){r.n=2;break}return r.a(2,{code:Ae.SUCCESS,data:a});case 2:if(o.forEach(function(e){var n=e.userId;0===Number(e.state)?c._dealAddUser(t,i,a,e.switchRoleType,n):c._dealReduceUser(i,a,e.state,e.switchRoleType,n)}),!(s=[].concat(C(a.left),C(a.downgrade),C(a.offline))).length){r.n=3;break}return r.n=3,$s(s,e,t,n,this.traceId);case 3:return r.a(2,{code:Ae.SUCCESS,data:a})}},r,this)}))}}])}(),sc=function(){function e(t,n,r,i,a){var o;return c(this,e),o=s(this,e),Object.defineProperty(o,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(o,"messageType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"senderId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(o,"sentTime",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(o,"_publishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(o,"_unpublishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(o,"_modifiedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(o,"_nowResources",{enumerable:!0,configurable:!0,writable:!0,value:[]}),o}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.PARSE_REMOTERES}},{key:"priority",get:function(){return us.NORMAL}},{key:"_dealPublishList",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d=this;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.reportMediaActionLogger,o=this._nowResources.map(jn),s=[],c=[],this._publishedList.forEach(function(e){var n=jn(e),r=o.indexOf(n),a=Fn(n),u=a.userId,l=a.tag,_=a.mediaType;r>-1?d._nowResources[r]=e:d._nowResources.push(e);var f=t.getRemoteTrack(n);f?f.isSubscribed()&&s.push(f):(f=_===nn.AUDIO_ONLY?new Pn(i,l,u):new Un(i,l,u),t.addRemoteTrack(f),c.push(f)),f.__innerSetRemoteMuted(0===e.state)}),!s.length){r.n=2;break}return u=s.map(function(e){return e.getTrackId()}),r.n=1,new js(s,!0,this.traceId).execute(e,t,n);case 1:l=r.v,(_=l.code)!==Ae.SUCCESS&&i.error(Ne.L_RESUB_REPUB_RES_R,JSON.stringify({status:ke.FAILED,trackIds:u,code:_}),this.traceId);case 2:c.length&&e.emit(bs,c),a.reportQualityRecvPubMsgData(this.sentTime,this.senderId);case 3:return r.a(2)}},r,this)}))}},{key:"_dealUnpublishList",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s;return E().w(function(r){for(;;)switch(r.n){case 0:for(i=this._unpublishedList.map(jn),a=this._nowResources.length-1;a>=0;a-=1)o=this._nowResources[a],i.includes(jn(o))&&this._nowResources.splice(a,1);return s=this._unpublishedList.map(function(e){var n=jn(e);return t.getRemoteTrack(n)}),r.n=1,new Hs(s).execute(e,t,n);case 1:return r.a(2)}},r,this)}))}},{key:"_dealModifiedList",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u;return E().w(function(n){for(;;)switch(n.n){case 0:r=this._nowResources.map(jn),i=_(this._modifiedList);try{for(i.s();!(a=i.n()).done;)o=a.value,s=jn(o),c=r.indexOf(s),this._nowResources[c].state=o.state,(u=t.getRemoteTrack(s)).__innerSetRemoteMuted(0===o.state),u.isAudioTrack()?e.emit(Ns,u):e.emit(ks,u)}catch(e){i.e(e)}finally{i.f()}case 1:return n.a(2)}},n,this)}))}},{key:"_updateCDNUris",value:function(e,t){var n,r,i=this.msgContent.cdn_uris[0],a=(null===(n=t.getCDNUris())||void 0===n?void 0:n.enableInnerCDN)!==i.enableInnerCDN;t.setCDNUris(i),a&&e.emit(Ps,!!(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN))}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h;return E().w(function(r){for(;;)switch(r.n){case 0:if(l=this.msgContent.uris,this._publishedList=[],this._unpublishedList=[],this._modifiedList=[],d=this.senderId,f=this.messageType,t.getRemoteUserIds().includes(d)){r.n=1;break}return r.a(2,{code:Ae.SUCCESS});case 1:this._nowResources=t.getResourcesByUserId(d)||[],h=f,r.n=h===er.MODIFY?2:h===er.PUBLISH?3:h===er.UNPUBLISH?4:h===er.TOTAL_CONTENT_RESOURCE?5:6;break;case 2:return(i=this._modifiedList).push.apply(i,C(l)),r.a(3,6);case 3:return(a=this._publishedList).push.apply(a,C(l)),r.a(3,6);case 4:return(o=this._unpublishedList).push.apply(o,C(l)),r.a(3,6);case 5:return _=Kn(this._nowResources,l),(s=this._publishedList).push.apply(s,C(_.publishedList)),(c=this._unpublishedList).push.apply(c,C(_.unpublishedList)),(u=this._modifiedList).push.apply(u,C(_.modifiedList)),r.a(3,6);case 6:if(!this._publishedList.length){r.n=7;break}return r.n=7,this._dealPublishList(e,t,n);case 7:if(!this._unpublishedList.length){r.n=8;break}return r.n=8,this._dealUnpublishList(e,t,n);case 8:if(!this._modifiedList.length){r.n=9;break}return r.n=9,this._dealModifiedList(e,t);case 9:if(t.setResourcesByUserId(d,this._nowResources),t.roomMode===ps.LIVE){r.n=10;break}return r.a(2,{code:Ae.SUCCESS});case 10:if(this.msgContent.cdn_uris){r.n=11;break}return r.a(2,{code:Ae.SUCCESS});case 11:return this._updateCDNUris(e,t),r.a(2,{code:Ae.SUCCESS})}},r,this)}))}}])}(),cc=function(){function e(t,n,r){var i;return c(this,e),i=s(this,e),Object.defineProperty(i,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.SUBSCRIBE}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.polarisReport,o=this.tracks,s=this.forceReq,ce("tracks",o,function(){return z(o)&&o.length>0&&o.every(function(e){return e instanceof kn||e.track instanceof kn})},!0)){r.n=1;break}return i.error(Ne.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),r.a(2,{code:Ae.PARAMS_ERROR});case 1:if(i.info(Ne.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:o.map(sr),forceReq:s}),this.traceId),c=t.getSubscribedList().map(function(e){return Object.assign({},e)}),u=o.map(function(e){return e instanceof kn?{track:e}:e}),l=!1,_=[],u.forEach(function(e){var t=e.track.getTrackId();_.push(t);var n=c.find(function(e){return e.track.getTrackId()===t});n&&n.subTiny===e.subTiny||(n?n.subTiny=e.subTiny:c.push(e),l=!0)}),l||s){r.n=2;break}return i.warn(Ne.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:ke.SUCCESSED,msg:"repeat subscribe"}),this.traceId),r.a(2,{code:Ae.SUCCESS});case 2:return a.sendR2(Is.SUBSCRIBE,Ss.BEGIN,_),r.a(2,new js(c,!0,this.traceId).execute(e,t,n))}},r,this)}))}}])}(),uc=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(n,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),n}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.PUBLISH}},{key:"_removePubFailedTracks",value:function(e,t){e.forEach(function(e){var n=e instanceof Rn?e:e.track;t.removeLocalTrackById(n.getTrackId())})}},{key:"_addLocalTracks",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,d,f,h,g,p,v,m,R,T;return E().w(function(n){for(;;)switch(n.p=n.n){case 0:r=[],i=_(e),n.p=1,i.s();case 2:if((a=i.n()).done){n.n=9;break}if(o=a.value,c=(s=o instanceof Rn?{pubTiny:!1,track:o}:o).track,u=s.pubTiny,!c.isVideoTrack()){n.n=7;break}if(!u){n.n=7;break}return l=void 0,n.p=3,l=c.__innerGetMediaStreamTrack().clone(),d=u.frameRate||exports.NCCallVideoFrameRate.FPS_15,f=u.resolution||exports.NCCallVideoResolution.W176_H144,h=qn(f),g=h.width,p=h.height,v=Qn(d),n.n=4,l.applyConstraints({width:g,height:p,frameRate:v});case 4:n.n=6;break;case 5:return n.p=5,R=n.v,null==l||l.stop(),this._logger.warn(Ne.L_ABSTRACT_ROOM_PUBLISH_E,"pubTiny failed -> id: ".concat(c.getTrackId(),", msg: ").concat(R.message),this._traceId),n.a(3,9);case 6:m=new In(this._logger,c.getTag(),c.getUserId(),l,!0),r.push(m),t.addLocalTrack(m),n.n=7;break;case 7:t.addLocalTrack(c);case 8:n.n=2;break;case 9:n.n=11;break;case 10:n.p=10,T=n.v,i.e(T);case 11:return n.p=11,i.f(),n.f(11);case 12:return n.a(2,r)}},n,this,[[3,5],[1,10,11,12]])}))}},{key:"__publish",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l,_,d,f,h,g,p,v,m=this;return E().w(function(i){for(;;)switch(i.n){case 0:if(a=e.peer,o=e.reportMediaActionLogger,s=e.context,t.roomId,c=[],n.forEach(function(e){var t=(e instanceof Rn?{track:e}:e).track;c.push(t)}),n.sort(function(e,t){return(e instanceof Rn?{track:e}:e).track.getBitrate().max-(t instanceof Rn?{track:t}:t).track.getBitrate().max}),!(a.getLocalTracks().length+ir(n,a)>10)){i.n=1;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ke.FAILED,code:Ae.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:n.map(sr),msg:"publish track limit exceeded"}),this._traceId),i.a(2,{code:Ae.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:c});case 1:return i.n=2,this._addLocalTracks(n,a);case 2:return u=i.v,a.clearReTryExchangeTimer(),l=t.getSubscribedList(),i.n=3,Js(l,!1,a,t,s);case 3:return(_=i.v).pushOtherRooms=e.getPushOtherRooms(),i.n=4,new Gs(_,this._traceId,!0).execute(e,t,r);case 4:if(d=i.v,c.forEach(function(e){var t=e.getTrackId();m._trackMediaMap[t]=d.data.qualityMsList||[]}),d.code===Ae.SUCCESS){i.n=5;break}return o.reportPubOrSubQualityData(Bs.PUB,this._actionStartTime,c,d.code,this._trackMediaMap),this._logger.error(Ne.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ke.FAILED,tracks:n.map(sr),code:d.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(n,a),i.a(2,{code:d.code,tracks:c});case 5:if(f=d.data.data,h=f.sdp,g=f.resultCode,p=f.message,g===Ae.SUCCESS){i.n=6;break}return o.reportPubOrSubQualityData(Bs.PUB,this._actionStartTime,c,g,this._trackMediaMap),this._logger.error(Ne.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ke.FAILED,trackIds:n.map(sr),code:g,msg:"exchange inner failed: ".concat(p)}),this._traceId),this._removePubFailedTracks(n,a),i.a(2,{code:g,tracks:c});case 6:return o.setPubOrSubSuccessTime(Date.now()),i.n=7,a.setRemoteAnswer(h.sdp,!0);case 7:if((v=i.v)===Ae.SUCCESS){i.n=8;break}return o.reportPubOrSubQualityData(Bs.PUB,this._actionStartTime,c,v,this._trackMediaMap),this._logger.error(Ne.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ke.FAILED,trackIds:n.map(sr),code:v,msg:"set remote answer error"}),this._traceId),i.a(2,{code:v,tracks:c});case 8:return u.length&&this._updateTinyTrackIdSSRCMap(t,_.sdp.sdp,u),i.a(2,Object.assign(Object.assign({code:g},d.data),{tracks:c}))}},i,this)}))}},{key:"_updateTinyTrackIdSSRCMap",value:function(e,t,n){n.forEach(function(n){var r=ic(t,n.getStreamId(),nn.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(r),n.getTrackId())})}},{key:"_dealPublishRes",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h,g,p,v,m,R,T,I,S,L,O,y,b,A;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=n.polarisReport,a=n.context,o=n.peer,s=n.reportMediaActionLogger,c=t.crtUserId,u=t.roomId,l="",_=t.getResourcesByUserId(c),d=C(_),f=[],h=e.tracks,e.code===Ae.SUCCESS){r.n=1;break}return r.a(2,{code:e.code});case 1:return g=e.data,p=g.publishList,v=g.urls,m=g.mcuPublishList,l=null==v?void 0:v.liveUrl,p.map(function(e){return Object.assign({tag:e.msid.split("_").pop(),state:o.getLocalTrack(jn(e)).isLocalMuted()?0:1},e)}).forEach(function(e){var t=or(e,d),n=t.isInclude,r=t.index;n?d.splice(r,1,e):d.push(e)}),R=(null==m?void 0:m.map(function(e){return Object.assign({tag:e.msid.split("_").pop(),state:1},e)}))||[],f=R,T=Kn(_,d),I=T.publishedList,S=Object.assign(Object.assign({},t.getCDNUris()),{enableInnerCDN:t.getCDNEnable()}),L=S&&S.broadcast===Cs.SPREAD?JSON.stringify([S]):"",O=Date.now(),r.n=2,a.setRTCTotalRes(u,[Dn(er.PUBLISH,I)],Mn(d),er.TOTAL_CONTENT_RESOURCE,Mn(f),L);case 2:if(y=r.v,s.reportPubOrSubQualityData(Bs.PUB,this._actionStartTime,h,y,this._trackMediaMap,[{dur:Date.now()-O,cod:y}]),y===we){r.n=3;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ke.FAILED,code:y,msg:"send publish streams notification failed"}),this._traceId),r.a(2,{code:Ae.SIGNAL_ERROR});case 3:return t.setResourcesByUserId(c,d),b=I.map(function(e){return jn(e)}),i.sendR2(Is.PUBLISH,Ss.BEGIN,b),I.forEach(function(e){o.getLocalTrack("".concat(e.msid,"_").concat(e.mediaType)).__innerSetPublished(!0)}),A={code:Ae.SUCCESS},l&&(A.liveUrl=l),r.a(2,A)}},r,this)}))}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u=this;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.peer,this._traceId=i.createTraceId(),this._logger=i,this._actionStartTime=Date.now(),o=this.tracks,ce("tracks",o,function(){return z(o)&&o.length>0&&o.every(function(e){return e instanceof Rn||e.track instanceof Rn})},!0)){r.n=1;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),r.a(2,{code:Ae.PARAMS_ERROR});case 1:if(this._logger.info(Ne.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:o.map(sr)})),(o=o.filter(function(e){var t=(e instanceof Rn?{track:e}:e).track,n=t.isDestroyed();return n&&u._logger.warn(Ne.L_ABSTRACT_ROOM_PUBLISH_E,"track '".concat(t.getTrackId(),"' has beem destroyed"),u._traceId),!n})).length){r.n=2;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ke.FAILED,code:Ae.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),r.a(2,{code:Ae.PUBLISH_TRACKS_IS_INVALID});case 2:return a.__reportR3R4ToPolaris(),a.clearReTryExchangeTimer(),r.n=3,this.__publish(e,t,o,n);case 3:return s=r.v,r.n=4,this._dealPublishRes(s,t,e);case 4:return c=r.v,r.a(2,c)}},r,this)}))}}])}(),lc=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(n,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),n}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.UNPUBLISH}},{key:"__unpublish",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l,_,d,f,h,g,p,v,m=this;return E().w(function(i){for(;;)switch(i.n){case 0:if(a=e.peer,o=e.polarisReport,s=e.logger,c=e.reportMediaActionLogger,u=e.context,l=r.map(function(e){return e.getTrackId()}),0!==l.map(t.getPublishedResourceByTrackId.bind(t)).filter(function(e){return!!e}).length){i.n=1;break}return i.a(2,{code:Ae.SUCCESS,tracks:r});case 1:return l.forEach(function(e){return a.removeLocalTrackById(e)}),o.sendR2(Is.PUBLISH,Ss.END,l),a.clearReTryExchangeTimer(),_=t.getSubscribedList(),i.n=2,Js(_,!1,a,t,u);case 2:return d=i.v,(f=e.getPushOtherRooms()).length&&(d.pushOtherRooms=f),i.n=3,new Gs(d,this._traceId,!0).execute(e,t,n);case 3:if(h=i.v,r.forEach(function(e){var t=e.getTrackId();m._trackMediaMap[t]=h.data.qualityMsList||[]}),h.code===Ae.SUCCESS){i.n=4;break}return c.reportPubOrSubQualityData(Bs.UNPUB,this._actionStartTime,r,h.code,this._trackMediaMap),s.error(Ne.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:ke.FAILED,code:h.code,trackIds:r.map(sr),msg:"exchange failed"}),this._traceId),i.a(2,{code:h.code,tracks:r});case 4:if(g=h.data.data,p=g.resultCode,v=g.message,p===Ae.SUCCESS){i.n=5;break}return c.reportPubOrSubQualityData(Bs.UNPUB,this._actionStartTime,r,h.data.data.resultCode,this._trackMediaMap),s.error(Ne.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:ke.FAILED,code:p,trackIds:r.map(sr),msg:"exchange inner failed: ".concat(v)}),this._traceId),i.a(2,{code:p,tracks:r});case 5:return i.a(2,Object.assign(Object.assign({code:h.code},h.data),{tracks:r}))}},i,this)}))}},{key:"_dealUnpublishRes",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h,g,p,v,m,R,T,I,S,L;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.context,a=e.logger,o=e.peer,s=e.reportMediaActionLogger,c=i.getCurrentId(),u=t.roomId,l=[],_=[],d=n.tracks,f=n.code,h=n.data,f===Ae.SUCCESS){r.n=1;break}return a.error(Ne.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:f,msg:"unpublish failed"}),this._traceId),r.a(2,{code:f});case 1:if(h){r.n=2;break}return a.info(Ne.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ke.SUCCESSED,msg:"unpublish list is empty "})),r.a(2,{code:Ae.SUCCESS});case 2:return g=h.mcuPublishList,p=d.map(function(e){return e.getTrackId()}),v=p.map(t.getPublishedResourceByTrackId.bind(t)).filter(function(e){return!!e}),l.push.apply(l,C(v)),m=g?g.map(function(e){return Object.assign({tag:e.msid.split("_").pop(),state:1},e)}):[],_=m,R=t.getResourcesByUserId(c),T=R.filter(function(e){return!l.includes(e)}),I=Date.now(),r.n=3,i.setRTCTotalRes(u,[Dn(er.UNPUBLISH,l)],Mn(T),er.TOTAL_CONTENT_RESOURCE,Mn(_));case 3:if(S=r.v,s.reportPubOrSubQualityData(Bs.UNPUB,this._actionStartTime,d,S,this._trackMediaMap,[{dur:Date.now()-I,cod:S}]),S===we){r.n=4;break}return a.error(Ne.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ke.FAILED,code:S,msg:"send unpublish notification failed"}),this._traceId),r.a(2,{code:Ae.SIGNAL_ERROR});case 4:return a.info(Ne.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ke.SUCCESSED,code:Ae.SUCCESS,msg:"unpublish success",unPubResourceIds:p}),this._traceId),L=n.data.sdp,r.n=5,o.setRemoteAnswer(L.sdp);case 5:return t.setResourcesByUserId(c,T),r.a(2,{code:Ae.SUCCESS})}},r,this)}))}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,this._actionStartTime=Date.now(),a=t.crtUserId,o=this.tracks,this._traceId=i.createTraceId(),ce("tracks",o,function(){return o.every(function(e){return e.getUserId()===a&&e instanceof Rn})},!0)){r.n=1;break}return i.error(Ne.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> tracks"})),r.a(2,{code:Ae.PARAMS_ERROR});case 1:return i.info(Ne.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:o.map(sr)})),r.n=2,this.__unpublish(e,t,n,o);case 2:return s=r.v,r.n=3,this._dealUnpublishRes(e,t,s);case 3:return c=r.v,r.a(2,c)}},r,this)}))}}])}(),_c=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"localTrack",{enumerable:!0,configurable:!0,writable:!0,value:t}),n}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.LOCAL_TRACK_MUTE}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,d,f,h,g,p,v,m,T;return E().w(function(n){for(;;)switch(n.p=n.n){case 0:r=e.logger,i=e.context,a=this.localTrack,o=a.getTrackId(),s=t.crtUserId,c=t.roomId,u=!a.isLocalMuted(),l=r.createTraceId(),r.info(Ne.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:u,trackId:this.localTrack.getTrackId()}),l),d=[{resourceId:o,enabled:u}],f=t.getResourcesByUserId(s),h=[],g=_(f),n.p=1,v=E().m(function e(){var t,n,r,i;return E().w(function(e){for(;;)switch(e.n){case 0:if(t=p.value,n=jn(t),r=d.findIndex(function(e){return e.resourceId===n}),!(r>=0)){e.n=1;break}return i=d[r].enabled,t.state=i?1:0,h.push(t),e.a(2,1);case 1:return e.a(2)}},e)}),g.s();case 2:if((p=g.n()).done){n.n=5;break}return n.d(R(v()),3);case 3:if(!n.v){n.n=4;break}return n.a(3,5);case 4:n.n=2;break;case 5:n.n=7;break;case 6:n.p=6,T=n.v,g.e(T);case 7:return n.p=7,g.f(),n.f(7);case 8:return n.n=9,i.setRTCTotalRes(c,[Dn(er.MODIFY,h)],Mn(f),er.TOTAL_CONTENT_RESOURCE);case 9:if((m=n.v)===we){n.n=10;break}return r.error(Ne.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:ke.FAILED,code:m,msg:"signal error"}),l),n.a(2,{code:m});case 10:return r.info(Ne.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:ke.SUCCESSED}),l),n.a(2,{code:Ae.SUCCESS})}},n,this,[[1,6,7,8]])}))}}])}(),dc=function(){function e(){return c(this,e),s(this,e,arguments)}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.RETRY_EXCHANGE}},{key:"priority",get:function(){return us.HIGH}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h,g,p,v,m,R;return E().w(function(r){for(;;)switch(r.n){case 0:return i=e.logger,a=e.peer,o=e.context,s=i.createTraceId(),i.info(Ne.L_RETRY_EXCHANGE_COMMAND_T),c=o.getCurrentId(),u=t.getSubscribedList(),r.n=1,Js(u,!0,a,t,o);case 1:return(l=r.v).pushOtherRooms=e.getPushOtherRooms(),r.n=2,new Gs(l,s).execute(e,t,n);case 2:if((_=r.v).code===Ae.SUCCESS){r.n=3;break}return r.a(2,{code:_.code});case 3:if(d=_.data.data,f=d.sdp,(h=d.resultCode)===Ae.SUCCESS){r.n=4;break}return r.a(2,{code:h});case 4:return a.clearReTryExchangeTimer(),r.n=5,a.setRemoteAnswer(f.sdp);case 5:if((g=r.v)===Ae.SUCCESS){r.n=6;break}return r.a(2,{code:g});case 6:if(p=_.data.data.publishList||[],v=this._diffPublishListChange(p,t,a,c),m=v.plus,R=v.minus,!m.length&&!R.length){r.n=7;break}return r.n=7,this._spreadPublishListUri(e,c,m,R,s);case 7:return r.a(2,{code:Ae.SUCCESS})}},r,this)}))}},{key:"_diffPublishListChange",value:function(e,t,n,r){var i=t.getResourcesByUserId(r),a=JSON.parse(JSON.stringify(i));e.forEach(function(e){var t,r=e.mediaType,i=e.msid,o=a.findIndex(function(e){var t=e.mediaType,n=e.msid;return r===t&&i===n});if(-1===o){var s=Object.assign({tag:i.split("_").pop(),state:(null===(t=n.getLocalTrack(jn(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);a.push(s)}else a[o].uri=e.uri});var o=Kn(i,a,!0),s=o.publishedList,c=o.unpublishedList;return t.setResourcesByUserId(r,a),{plus:s,minus:c}}},{key:"_spreadPublishListUri",value:function(e,t,n,r,i){return F(this,void 0,void 0,E().m(function a(){var o,s,c,u;return E().w(function(a){for(;;)switch(a.n){case 0:return o=e.store,s=e.logger,c=o.getResourcesByUserId(t),s.info(Ne.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:n,minus:r,allPublishList:c}),i),u=[],r.length&&u.push(Dn(er.UNPUBLISH,r)),n.length&&u.push(Dn(er.PUBLISH,n)),a.n=1,e.context.setRTCTotalRes(o.roomId,u,Mn(c),er.TOTAL_CONTENT_RESOURCE);case 1:a.v===we?s.info(Ne.L_RETRY_EXCHANGE_SPREAD_R,"status: ".concat(ke.SUCCESSED),i):s.error(Ne.L_RETRY_EXCHANGE_SPREAD_R,"status: ".concat(ke.FAILED),i);case 2:return a.a(2)}},a)}))}}])}();!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(rc||(rc={}));var fc,hc,gc=function(){function e(t,n,r,i){var a;return c(this,e),a=s(this,e),Object.defineProperty(a,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.PULL_RTCROOM_STATUS}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,d,f,h,g,p,v,m,R,T,I,S,C,L,O,y;return E().w(function(r){for(;;)switch(r.p=r.n){case 0:if(i=e.logger,a=t.getRoomStatusVersion(),i.info(Ne.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:a}),this._traceId),!(this._targetPullVersion&&this._targetPullVersion<=a)){r.n=1;break}return i.info(Ne.L_PULL_ROOM_STATUS_R,JSON.stringify({status:ke.SUCCESSED,msg:"the roomData has been pulled",localVersion:a,targetPullVersion:this._targetPullVersion}),this._traceId),r.a(2,{code:we});case 1:return r.n=2,this._context.pullRTCRoomStatus(this._roomId,a);case 2:if(o=r.v,s=o.code,c=o.data,s===we){r.n=3;break}return i.info(Ne.L_PULL_ROOM_STATUS_R,JSON.stringify({status:ke.FAILED,code:s}),this._traceId),r.a(2,{code:s});case 3:if(u=c.bFullStatus,l=c.version,d=c.usersData,f=c.roomStatus,i.info(Ne.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:u,version:cr(l),usersData:d,roomStatus:f}),this._traceId),t.setRoomStatusVersion(l),!u){r.n=5;break}return h=nc(d),g=h.urisData,p=h.CDNUris,r.n=4,Zs(g,t,e,n,p,this._traceId);case 4:return r.a(2,{code:s});case 5:v=_(f),r.p=6,v.s();case 7:if((m=v.n()).done){r.n=14;break}if((R=m.value).event!==rc.RESOURCECHANGE){r.n=11;break}if(T=tc(R)){r.n=8;break}return r.a(3,13);case 8:if(I=T.content,(S=T.userId)!==t.crtUserId){r.n=9;break}return r.a(3,13);case 9:return r.n=10,new sc(I,er.TOTAL_CONTENT_RESOURCE,S,this._traceId).execute(e,t,n);case 10:r.n=13;break;case 11:return C=ec(R),r.n=12,new oc(C,this._traceId).execute(e,t,n);case 12:L=r.v,O=L.data,e.emit(Us,O);case 13:r.n=7;break;case 14:r.n=16;break;case 15:r.p=15,y=r.v,v.e(y);case 16:return r.p=16,v.f(),r.f(16);case 17:return r.a(2,{code:s})}},r,this,[[6,15,16,17]])}))}}])}(),pc=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:t}),n}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.ON_SIGNAL_RECONNECTED}},{key:"priority",get:function(){return us.HIGH}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.peer,o=e.context,s=t.roomId,c=t.roomMode,u=i.createTraceId(),i.info(Ne.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,u),"closed"!==a.getRTCPeerConn().connectionState){r.n=1;break}return i.error(Ne.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",u),e.emit(Ls),r.a(2,{code:Ae.SUCCESS});case 1:return r.n=2,o.rtcPing(s,c);case 2:if(l=r.v,40001!==l.code){r.n=5;break}return r.n=3,this._joinRoom(e,t,n,u);case 3:if(r.v!==we){r.n=4;break}return r.n=4,this._restoreMediaServer(e,t,n);case 4:r.n=6;break;case 5:return r.n=6,new gc(s,u,o).execute(e,t,n);case 6:return r.a(2,{code:Ae.SUCCESS})}},r,this)}))}},{key:"_joinRoom",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l,_,d,f,h,g,p,v,m,R,T,I,S,C,L,O;return E().w(function(i){for(;;)switch(i.n){case 0:return u=e.context,l=e.logger,i.n=1,u.joinRTCRoom(t.roomId,t.roomMode,this.livingType);case 1:if(_=i.v,d=_.code,f=_.data,d===we){i.n=2;break}return l.error(Ne.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ke.FAILED,code:d,msg:"im reconnect joinRTCRoom failed"}),r),i.a(2);case 2:if(f){i.n=3;break}return l.info(Ne.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ke.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),r),i.a(2);case 3:return h=null===(a=f.roomInfo.filter(function(e){return"cdn_uris"===e.key})[0])||void 0===a?void 0:a.value,i.n=4,Zs(f,t,e,n,h,r);case 4:return(g=null===(o=f.roomInfo.filter(function(e){return"asr_status"===e.key})[0])||void 0===o?void 0:o.value)&&t.setASRStatus(g),p=null===(s=f.roomInfo.filter(function(e){return"sei_ai_uris"===e.key})[0])||void 0===s?void 0:s.value,v=t.getASRIsAvailable(),p&&((m=JSON.parse(p)).length?(v||e.emit(ws),t.setASRSeiUris(m),R=m[0],T=R.msid,I=R.mediaType,S="".concat(T,"_").concat(I),!t.getRemoteTrack(S)&&t.addSeiRemoteTrack(m)):(v&&e.emit(Ds),t.removeSeiRemoteTrack(),t.setASRSeiUris(m))),(C=null===(c=f.roomInfo.filter(function(e){return"summarization"===e.key})[0])||void 0===c?void 0:c.value)&&(L=JSON.parse(C),(O=t.getSummarizationStatusData())&&O.status!==L.status&&e.emit(L.status===So.OPEN?Ms:xs,L.taskId),t.setSummarizationStatusData(L)),l.info(Ne.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ke.SUCCESSED,roomData:f}),r),i.a(2,d)}},i,this)}))}},{key:"_restoreMediaServer",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.peer.getLocalTracks(),a=Object.values(t.getRemoteTracks()).filter(function(e){return!!e.isSubscribed()}),!i.length){r.n=1;break}return r.n=1,new uc(i).execute(e,t,n);case 1:if(i.length||!a.length){r.n=2;break}return r.n=2,new cc(a,!0).execute(e,t,n);case 2:return r.a(2)}},r)}))}}])}(),Ec=1,vc=5;!function(e){e[e.new=0]="new",e[e.checking=1]="checking",e[e.connected=2]="connected",e[e.completed=3]="completed",e[e.failed=4]="failed",e[e.disconnected=5]="disconnected",e[e.closed=6]="closed"}(fc||(fc={})),function(e){e[e.SERVER_KICK=1]="SERVER_KICK",e[e.OTHER_KICK=2]="OTHER_KICK",e[e.IM_DISCONNECTED=3]="IM_DISCONNECTED",e[e.IM_LOGOUT=4]="IM_LOGOUT",e[e.OTHER_CLIENT_IM_CONNECTED=5]="OTHER_CLIENT_IM_CONNECTED"}(hc||(hc={}));var mc,Rc,Tc,Ic,Sc=function(){return l(function e(t,n,r,i){var a=this;c(this,e),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_baseReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_networkReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pubOrSubSuccessTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_peerCStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reportQualityJoinRoomData",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t,n,r){a._baseReportData=Object.assign(a._baseReportData,{snid:r});var i=Object.assign(Object.assign(Object.assign({},a._baseReportData),a._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:n});a._logger.__statistics(Ne.L_QS_JOIN_ROOM_S,JSON.stringify(i))}}),this._baseReportData={rid:this._roomId,csnid:this._clientSessionId,snid:"",time:Date.now(),uid:this._userId},this._networkReportData={cr:"unknown",net:"unknown"}},[{key:"reportQualityKickedData",value:function(e){var t=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{time:Date.now(),cod:e===hc.OTHER_KICK?vc:Ec});this._logger.__statistics(Ne.L_QS_KICKED_S,JSON.stringify(t))}},{key:"reportPubOrSubQualityData",value:function(e,t,n,r,i,a){var o=this;n.forEach(function(n){var s,c,u=n instanceof Rn||n instanceof kn?n:n.track,l=u.getTrackId(),_=Fn(l).mediaType,d=!1;d=u instanceof Rn?!!u.isVideoTrack()&&(null===(c=(s=u).__isTiny)||void 0===c?void 0:c.call(s)):n.subTiny||!1;var f=Object.assign(Object.assign(Object.assign({},o._baseReportData),o._networkReportData),{resid:l,mtp:_,smct:d?Uo.TINY:Uo.NORMAL,stp:"Rongcloud"!==u.getTag()?1:0,cod:r,msas:i?i[l]:[],sigs:a,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":o._logger.__statistics(Ne.L_QS_PUBLISH_S,JSON.stringify(f));break;case"unpub":o._logger.__statistics(Ne.L_QS_UNPUBLISH_S,JSON.stringify(f));break;case"sub":o._logger.__statistics(Ne.L_QS_SUBSCRIBE_S,JSON.stringify(f));break;case"unsub":o._logger.__statistics(Ne.L_QS_UNSUBSCRIBE_S,JSON.stringify(f))}})}},{key:"reportQualityRecvPubMsgData",value:function(e,t){var n=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(Ne.L_QS_RECV_PUB_MSG_S,JSON.stringify(n))}},{key:"setPubOrSubSuccessTime",value:function(e){this._pubOrSubSuccessTime=e}},{key:"reportIceFirstConnectData",value:function(e){var t=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{time:this._pubOrSubSuccessTime,dur:Date.now()-this._pubOrSubSuccessTime}),n="pub"===e?Ne.L_QS_PUB_ICE_STATUS_S:Ne.L_QS_SUB_ICE_STATUS_S;this._logger.__statistics(n,JSON.stringify(t))}},{key:"recordQualityIceStatusData",value:function(e,t,n){var r=this._peerCStatus||{},i=r.status,a=r.time;if(a){var o=e.IP,s=e.port,c=e.networkType,u=e.remoteIP,l=e.remotePort,_=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{dur:n-a,time:n,pices:fc[i],ices:fc[t],rcdts:[{ip:"".concat(u,":").concat(l)}],lcdts:[{ip:"".concat(o,":").concat(s),nttp:c}],cncdts:[]});this._logger.__statistics(Ne.L_QS_ICE_STATUS_S,JSON.stringify(_)),this._peerCStatus={status:t,time:n}}else this._peerCStatus={status:t,time:n}}}])}();!function(e){e[e.DISABLE=0]="DISABLE",e[e.ENABLE=1]="ENABLE"}(mc||(mc={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(Rc||(Rc={})),function(e){e[e.NOT_REPORT=-1]="NOT_REPORT",e[e.REPORT_SUCCESS=1e4]="REPORT_SUCCESS",e[e.REPORT_FAIL=0]="REPORT_FAIL",e[e.PB_ERROR=40001]="PB_ERROR"}(Tc||(Tc={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(Ic||(Ic={}));var Cc,Lc=function(){return l(function e(t,n,r,i){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Rc.MeetingOrAnchor;c(this,e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_crtRTCRoom",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_userRole",{enumerable:!0,configurable:!0,writable:!0,value:a})},[{key:"_send",value:function(e){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)switch(n.n){case 0:if(this._context.getConnectionStatus()===t.CONNECTED){n.n=1;break}return n.a(2,Tc.NOT_REPORT);case 1:return n.n=2,this._context.setRTCState(this._roomId,e);case 2:if(n.v!==we){n.n=3;break}return n.a(2,Tc.REPORT_SUCCESS);case 3:return n.a(2,Tc.REPORT_FAIL)}},n,this)}))}},{key:"_getClientID",value:function(){var e="uuid",t=this._runtime.localStorage.getItem(e);return t||(t=Yn(),this._runtime.localStorage.setItem(e,t)),t}},{key:"_getRealResourceId",value:function(e){var t=e,n=e.indexOf("_tiny");return n>-1&&(t=e.slice(0,n)),t}},{key:"_getPolarisTrackId",value:function(e){var t="",n=e.split("_");if(e.includes("_tiny")){var r=n.pop(),i=parseInt(n.pop())===nn.AUDIO_ONLY?"audio":"video",a=n.pop();t=[n.join("_"),a,r,i].join("_")}else{var o=parseInt(n.pop())===nn.AUDIO_ONLY?"audio":"video",s=n.pop();t=[n.join("_"),s,o].join("_")}return t}},{key:"_getBaseData",value:function(e){return{bitrateSend:(null==e?void 0:e.bitrateSend)||Co,bitrateRecv:(null==e?void 0:e.bitrateRecv)||Co,networkType:(null==e?void 0:e.networkType)||"unknown",rtt:(null==e?void 0:e.rtt)||Co,localAddress:"".concat((null==e?void 0:e.IP)||Co,":").concat(null==e?void 0:e.port),remoteAddress:"".concat(null==e?void 0:e.remoteIP,":").concat(null==e?void 0:e.remotePort),receiveBand:(null==e?void 0:e.availableIncomingBitrate)||Co,sendBand:(null==e?void 0:e.availableOutgoingBitrate)||Co,packetsLost:(null==e?void 0:e.totalPacketsLost)||Co,deviceId:this._context.getCurrentId()}}},{key:"_getAudioLevel",value:function(e){return e||0===e?e:Co}},{key:"_getBitrate",value:function(e){return e||0===e?e:Co}},{key:"_getPacketsLostRate",value:function(e){return e||0===e?e:Co}},{key:"_getFrameRate",value:function(e){return e||Co}},{key:"_getResolution",value:function(e,t){return e&&t?"".concat(e," * ").concat(t):"".concat(Co)}},{key:"_getJitter",value:function(e){return e||Co}},{key:"_getNackCount",value:function(e){return e||0===e?e:Co}},{key:"_getPliCount",value:function(e){return e||0===e?e:Co}},{key:"_getRTT",value:function(e){return e||Co}},{key:"_getTrackState",value:function(e,t){var n=e?this._crtRTCRoom.getLocalTrack(t):this._crtRTCRoom.getRemoteTrack(t);return(null==n?void 0:n.isLocalMuted())?mc.DISABLE:mc.ENABLE}},{key:"sendR3Data",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s=this;return E().w(function(t){for(;;)switch(t.n){case 0:return n=e.iceCandidatePair,r=e.senders,i=this._getBaseData(n),a="R3\t".concat(i.bitrateSend,"\t-1\t-1\t-1\t").concat(i.networkType,"\t").concat(i.rtt,"\t").concat(i.localAddress,"\t").concat(i.receiveBand,"\t").concat(i.sendBand,"\t").concat(i.packetsLost,"\t").concat(i.deviceId,"\r"),o=r.map(function(e){var t=e.trackId,n=e.audioLevel,r=e.samplingRate,i=e.bitrate,a=e.packetsLostRate,o=e.frameRate,c=e.frameWidth,u=e.frameHeight,l=e.googRenderDelayMs,_=e.jitter,d=e.nackCount,f=e.pliCount,h=e.rtt,g=e.googFirsSent,p=e.encoderImplementation,E=s._getPolarisTrackId(t),v=s._getRealResourceId(t);return{trackId:E,googCodecName:p||String(Co),audioLevel:s._getAudioLevel(n),bitrate:s._getBitrate(i),packetsLostRate:s._getPacketsLostRate(a),frameRate:s._getFrameRate(o),resolution:s._getResolution(c,u),jitter:s._getJitter(_),nackCount:s._getNackCount(d),pliCount:s._getPliCount(f),rtt:s._getRTT(h),googFirsSent:g,samplingRate:r,googRenderDelayMs:l,encoderImplementation:p||String(Co),trackState:s._getTrackState(!0,v)}}),a+=o.map(function(e){return"".concat(e.trackId,"\t").concat(e.googCodecName,"\t").concat(e.audioLevel,"\t").concat(e.samplingRate,"\t").concat(e.bitrate,"\t").concat(e.packetsLostRate,"\t").concat(e.frameRate,"\t").concat(e.resolution,"\t").concat(e.googRenderDelayMs,"\t").concat(e.jitter,"\t").concat(e.nackCount,"\t").concat(e.pliCount,"\t").concat(e.rtt,"\t").concat(e.googFirsSent,"\t").concat(e.encoderImplementation,"\t").concat(e.trackState)}).join("\n"),t.n=1,this._send("".concat(a,"\r").concat(this._userRole));case 1:if(t.v===Tc.REPORT_SUCCESS){t.n=2;break}return t.a(2,Tc.REPORT_FAIL);case 2:return t.a(2,Tc.REPORT_SUCCESS)}},t,this)}))}},{key:"sendR4Data",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s=this;return E().w(function(t){for(;;)switch(t.n){case 0:return n=e.iceCandidatePair,r=e.receivers,i=this._getBaseData(n),a="R4\t".concat(i.bitrateRecv,"\t-1\t-1\t-1\t").concat(i.networkType,"\t").concat(i.rtt,"\t").concat(i.localAddress,"\t").concat(i.receiveBand,"\t").concat(i.sendBand,"\t").concat(i.packetsLost,"\t").concat(i.deviceId,"\r"),o=r.filter(function(e){return!!e.trackId}).map(function(e){var t=e.trackId,n=e.audioLevel,r=e.samplingRate,i=e.bitrate,a=e.packetsLostRate,o=e.frameRate,c=e.frameWidth,u=e.frameHeight,l=e.googRenderDelayMs,_=e.jitter,d=e.nackCount,f=e.pliCount,h=e.rtt,g=e.googFirsReceived,p=e.codecImplementationName,E=s._getPolarisTrackId(t),v=s._getRealResourceId(t);return{trackId:E,googCodecName:p||String(Co),audioLevel:s._getAudioLevel(n),bitrate:s._getBitrate(i),packetsLostRate:s._getPacketsLostRate(a),frameRate:s._getFrameRate(o),resolution:s._getResolution(c,u),jitter:s._getJitter(_),nackCount:s._getNackCount(d),pliCount:s._getPliCount(f),rtt:s._getRTT(h),googFirsReceived:g,samplingRate:r,googRenderDelayMs:l,codecImplementationName:p||String(Co),trackState:s._getTrackState(!1,v)}}),a+=o.map(function(e){return"".concat(e.trackId,"\t").concat(e.googCodecName,"\t").concat(e.audioLevel,"\t").concat(e.samplingRate,"\t").concat(e.bitrate,"\t").concat(e.packetsLostRate,"\t").concat(e.frameRate,"\t").concat(e.resolution,"\t").concat(e.googRenderDelayMs,"\t").concat(e.jitter,"\t").concat(e.nackCount,"\t").concat(e.pliCount,"\t").concat(e.rtt,"\t").concat(e.googFirsReceived,"\t").concat(e.codecImplementationName,"\t").concat(e.trackState)}).join("\n"),t.n=1,this._send("".concat(a,"\r").concat(this._userRole));case 1:if(t.v===Tc.REPORT_SUCCESS){t.n=2;break}return t.a(2,Tc.REPORT_FAIL);case 2:return t.a(2,Tc.REPORT_SUCCESS)}},t,this)}))}},{key:"sendR1",value:function(){var e,t=this._context.getCoreVersion(),n=(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platformn)||navigator.platform,r=Zn.browser,i=Zn.version,a=this._getClientID(),o="R1\t".concat("26.1.0","\t").concat(t,"\t").concat("web","\t").concat(n,"\t").concat(-1,"\t").concat(r,"\t").concat(i,"\t").concat(a,"\t").concat(this._userRole);this._send(o)}},{key:"sendR2",value:function(e,t,n){var r=this._getClientID(),i="R2\t".concat(e,"\t").concat(t,"\t").concat(r,"\r").concat(n.join("\t"),"\r").concat(this._userRole);this._send(i)}}])}(),Oc=function(){function e(t,n){var r;return c(this,e),r=s(this,e),Object.defineProperty(r,"oldTrack",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"newTrack",{enumerable:!0,configurable:!0,writable:!0,value:n}),r}return g(e,fs),l(e,[{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h,g=this;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.peer,a=e.logger,this.oldTrack&&this.newTrack){r.n=1;break}return a.error(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack or newTrack is empty"),r.a(2,{code:Ae.PARAMS_ERROR});case 1:if(![bn,yn].every(function(e){return!(g.oldTrack instanceof e)})){r.n=2;break}return a.error(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),r.a(2,{code:Ae.PARAMS_ERROR});case 2:if(![bn,yn].every(function(e){return!(g.newTrack instanceof e)})){r.n=3;break}return a.error(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"newTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),r.a(2,{code:Ae.PARAMS_ERROR});case 3:if(o=this.oldTrack.getSettings(),s=this.newTrack.getSettings(),c=this.oldTrack.getTrackId(),u=this.newTrack.getTrackId(),l=this.oldTrack.isAudioTrack()?"audio":"video",_=this.newTrack.isAudioTrack()?"audio":"video",a.info(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T,JSON.stringify({oldTrackId:c,newTrackId:u,oldSettings:o,newSettings:s})),this.oldTrack.isPublished()){r.n=4;break}return a.error(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not published"),r.a(2,{code:Ae.PARAMS_ERROR});case 4:if(c===u){r.n=5;break}return a.error(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack trackId are different, oldTrackId: ".concat(c,", newTrackId: ").concat(u)),r.a(2,{code:Ae.PARAMS_ERROR});case 5:if(l===_){r.n=6;break}return a.error(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack are not the same kind, oldTrackKind: ".concat(l,", newTrackKind: ").concat(_)),r.a(2,{code:Ae.PARAMS_ERROR});case 6:if((null==o?void 0:o.deviceId)!==(null==s?void 0:s.deviceId)){r.n=7;break}return a.error(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack deviceId are the same, oldDeviceId: ".concat(null==o?void 0:o.deviceId,", newDeviceId: ").concat(null==s?void 0:s.deviceId)),r.a(2,{code:Ae.PARAMS_ERROR});case 7:if(i.addLocalTrack(this.newTrack),d=(null==o?void 0:o.width)!==(null==s?void 0:s.width)||(null==o?void 0:o.height)!==(null==s?void 0:s.height)||(null==o?void 0:o.frameRate)!==(null==s?void 0:s.frameRate),f=i.getLocalTrack("".concat(this.oldTrack.getTrackId(),"_tiny")),d){r.n=8;break}return f&&f.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),a.info(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),r.a(2,{code:Ae.SUCCESS});case 8:return r.n=9,(new dc).execute(e,t,n);case 9:if((h=r.v).code===Ae.SUCCESS){r.n=10;break}return i.removeLocalTrack(this.newTrack,!1),i.addLocalTrack(this.oldTrack),this.newTrack.destroy(),a.error(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"negotiation failed, code: ".concat(h.code)),r.a(2,{code:h.code});case 10:return f&&f.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),a.info(Ne.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),r.a(2,{code:h.code})}},r,this)}))}}])}();!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(Cc||(Cc={}));var yc,bc=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"_type",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return g(e,fs),l(e,[{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=e.logger,i=e.context,a=e.service,this._traceId=r.createTraceId(),this._logger=r,this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T,"type: ".concat(this._type),this._traceId),(null==(o=i.getNaviInfo())?void 0:o.rtcAISwitch)!==Cc.CLOSE){n.n=1;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:Ae.ASR_NOT_AVAILABLE}),this._traceId),n.a(2,{code:Ae.ASR_NOT_AVAILABLE});case 1:if(this._type!==t.getASRStatus()){n.n=2;break}return this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:Ae.SUCCESS}),this._traceId),n.a(2,{code:Ae.SUCCESS});case 2:return s=t.roomId,n.n=3,i.setRTCData(s,"asr_status",this._type.toString(),!0,Rs.ROOM,{name:er.ASR_STATUS,content:JSON.stringify({asr_status:this._type.toString()})});case 3:if((c=n.v)===we){n.n=4;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:c}),this._traceId),n.a(2,{code:Ae.SIGNAL_ERROR});case 4:return t.setASRStatus(this._type),n.n=5,a.updateASRStatus(t.getRTCRequestHeader(),{asr_status:this._type},this._traceId);case 5:if(u=n.v,l=u.code,_=u.data,l===Ae.SUCCESS&&((null==_?void 0:_.resultCode)===Ae.SUCCESS||42200===(null==_?void 0:_.resultCode))){n.n=6;break}return d=l!==Ae.SUCCESS?l:null==_?void 0:_.resultCode,this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:d}),this._traceId),n.a(2,{code:d});case 6:return this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:Ae.SUCCESS}),this._traceId),n.a(2,{code:Ae.SUCCESS})}},n,this)}))}}])}(),Ac=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"_enable",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return g(e,fs),l(e,[{key:"_updateSubSei",value:function(e,t,n,r){var i="".concat(e[0].msid,"_").concat(e[0].mediaType),a=n.getRemoteTrack(i);return this._enable?new cc([a]).execute(t,n,r):new Fs([a],this._traceId).execute(t,n,r)}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.context,this._traceId=i.createTraceId(),this._logger=i,this._logger.info(Ne.L_ABSTRACT_ROOM_SET_ENABLE_ASR_T,"enable: ".concat(this._enable),this._traceId),t.setASREnable(this._enable),(null==(o=a.getNaviInfo())?void 0:o.rtcAISwitch)!==Cc.CLOSE){r.n=1;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:Ae.ASR_NOT_AVAILABLE}),this._traceId),r.a(2,{code:Ae.ASR_NOT_AVAILABLE});case 1:if((s=t.getASRSeiUris()).length){r.n=2;break}return this._logger.info(Ne.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:Ae.SUCCESS,asrSeiUrisLength:0}),this._traceId),r.a(2,{code:Ae.SUCCESS});case 2:return r.n=3,this._updateSubSei(s,e,t,n);case 3:if(c=r.v,(u=c.code)===Ae.SUCCESS){r.n=4;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:u}),this._traceId),r.a(2,{code:u});case 4:return this._logger.info(Ne.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:Ae.SUCCESS}),this._traceId),r.a(2,{code:Ae.SUCCESS})}},r,this)}))}}])}();!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(yc||(yc={}));var Nc,kc,Pc,Uc,wc=function(){function e(t,n){var r;return c(this,e),r=s(this,e),Object.defineProperty(r,"_status",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"_destLanguage",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return g(e,fs),l(e,[{key:"_operateWithRetry",value:function(e,t){return F(this,arguments,void 0,function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:3e3;return E().m(function a(){var o,s,c,u;return E().w(function(a){for(;;)switch(a.p=a.n){case 0:o=1;case 1:if(!(o<=r)){a.n=8;break}return a.p=2,a.n=3,t.operateRealtimeTranslation(e.getRTCRequestHeader(),{status:n._status},n._traceId);case 3:if(s=a.v,c=s.code,s.data,c!==Ae.SUCCESS){a.n=4;break}return a.a(2);case 4:console.warn("第 ".concat(o," 次调用失败,code=").concat(c)),a.n=6;break;case 5:a.p=5,u=a.v,console.error("第 ".concat(o," 次调用异常:"),u);case 6:if(!(o<r)){a.n=7;break}return a.n=7,new Promise(function(e){setTimeout(e,i)});case 7:o++,a.n=1;break;case 8:return a.a(2)}},a,null,[[2,5]])})()})}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=e.logger,i=e.service,a=e.context,this._traceId=r.createTraceId(),this._logger=r,this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_T,JSON.stringify({status:this._status,destLanguage:this._destLanguage}),this._traceId),(null==(o=a.getNaviInfo())?void 0:o.rtcAISwitch)!==Cc.CLOSE){n.n=1;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:Ae.ASR_NOT_AVAILABLE}),this._traceId),n.a(2,{code:Ae.ASR_NOT_AVAILABLE});case 1:if(this._status!==yc.OPEN){n.n=3;break}if(this._destLanguage){n.n=2;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:Ae.PARAMS_ERROR}),this._traceId),n.a(2,{code:Ae.PARAMS_ERROR});case 2:if(t.getASRSeiUris().length){n.n=3;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:Ae.ASR_NOT_START}),this._traceId),n.a(2,{code:Ae.ASR_NOT_START});case 3:return s={status:this._status},this._destLanguage&&(s.destLanguage=this._destLanguage),n.n=4,i.operateRealtimeTranslation(t.getRTCRequestHeader(),s,this._traceId);case 4:if(c=n.v,u=c.code,l=c.data,this._status!==yc.CLOSE){n.n=5;break}return t.setIsStartRealTranslate(!1),this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:Ae.SUCCESS}),this._traceId),u!==Ae.SUCCESS&&this._operateWithRetry(t,i),n.a(2,{code:Ae.SUCCESS});case 5:if(u===Ae.SUCCESS&&(null==l?void 0:l.resultCode)===Ae.SUCCESS){n.n=6;break}return _=u!==Ae.SUCCESS?u:null==l?void 0:l.resultCode,this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:_}),this._traceId),n.a(2,{code:_});case 6:return t.setIsStartRealTranslate(!0),this._destLanguage&&t.setTranslationLang(this._destLanguage),this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:Ae.SUCCESS}),this._traceId),n.a(2,{code:Ae.SUCCESS})}},n,this)}))}}])}(),Dc=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"_type",{enumerable:!0,configurable:!0,writable:!0,value:t}),n}return g(e,fs),l(e,[{key:"execute",value:function(e,t){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return t.setASRStatus(this._type),e.a(2,{code:Ae.SUCCESS})},e,this)}))}}])}(),Mc=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:t}),n}return g(e,fs),l(e,[{key:"_setEnableAsr",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i;return E().w(function(r){for(;;)switch(r.n){case 0:if(!(i=t.getASREnable())){r.n=2;break}return r.n=1,new Ac(this._asrSeiUris.length>0).execute(e,t,n);case 1:t.setASREnable(i);case 2:return r.a(2)}},r,this)}))}},{key:"_onPublish",value:function(e,t,n){e.emit(ws),t.setASRSeiUris(this._asrSeiUris),t.addSeiRemoteTrack(this._asrSeiUris),this._setEnableAsr(e,t,n)}},{key:"_onUnPublish",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){return E().w(function(r){for(;;)switch(r.n){case 0:return e.emit(Ds),r.n=1,this._setEnableAsr(e,t,n);case 1:t.removeSeiRemoteTrack(),t.setASRSeiUris(this._asrSeiUris);case 2:return r.a(2)}},r,this)}))}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){return E().w(function(r){for(;;)if(0===r.n)return this._asrSeiUris.length?this._onPublish(e,t,n):this._onUnPublish(e,t,n),r.a(2,{code:Ae.SUCCESS})},r,this)}))}}])}(),xc=function(){function e(t){var n;return c(this,e),n=s(this,e),Object.defineProperty(n,"_isStart",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return g(e,fs),l(e,[{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d;return E().w(function(n){for(;;)switch(n.n){case 0:if(a=e.logger,o=e.context,s=e.service,this._traceId=a.createTraceId(),this._logger=a,this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_T,"isStart: ".concat(this._isStart),this._traceId),(null==(c=o.getNaviInfo())?void 0:c.rtcAISwitch)!==Cc.CLOSE){n.n=1;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({code:Ae.ASR_NOT_AVAILABLE}),this._traceId),n.a(2,{code:Ae.ASR_NOT_AVAILABLE});case 1:if(t.getASRSeiUris().length){n.n=2;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:Ae.ASR_NOT_START}),this._traceId),n.a(2,{code:Ae.ASR_NOT_START});case 2:if(!((null===(r=t.getSummarizationStatusData())||void 0===r?void 0:r.status)===So.OPEN&&this._isStart||(null===(i=t.getSummarizationStatusData())||void 0===i?void 0:i.status)===So.CLOSE&&!this._isStart)){n.n=3;break}return this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:Ae.SUCCESS,taskId:t.getSummarizationStatusData().taskId}),this._traceId),n.a(2,{code:Ae.SUCCESS,taskId:t.getSummarizationStatusData().taskId});case 3:return u={status:this._isStart?So.OPEN:So.CLOSE},n.n=4,s.operateSummarization(t.getRTCRequestHeader(),u,this._traceId);case 4:if(l=n.v,_=l.code,d=l.data,_===Ae.SUCCESS){n.n=5;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:_}),this._traceId),n.a(2,{code:_});case 5:return t.setSummarizationStatusData({taskId:d.taskId,status:this._isStart?So.OPEN:So.CLOSE}),this._logger.info(Ne.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:Ae.SUCCESS,taskId:null==d?void 0:d.taskId}),this._traceId),n.a(2,{code:Ae.SUCCESS,taskId:null==d?void 0:d.taskId})}},n,this)}))}}])}(),Vc=function(){function e(t,n){var r;return c(this,e),r=s(this,e),Object.defineProperty(r,"_status",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"_taskId",{enumerable:!0,configurable:!0,writable:!0,value:n}),r}return g(e,fs),l(e,[{key:"execute",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return t.setSummarizationStatusData({status:this._status,taskId:this._taskId}),e.emit(this._status===So.OPEN?Ms:xs,this._taskId),n.a(2,{code:Ae.SUCCESS})},n,this)}))}}])}(),Bc="evt-leave",Gc=function(){function t(e,n,r,i,a,o,u,l){var _,d=arguments.length>8&&void 0!==arguments[8]?arguments[8]:Oo(),f=arguments.length>9&&void 0!==arguments[9]&&arguments[9];c(this,t),_=s(this,t),Object.defineProperty(_,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(_,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(_,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(_,"_service",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(_,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(_,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:d}),Object.defineProperty(_,"_pinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_peerConnection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(_,"_onRecvPKMsg",{enumerable:!0,configurable:!0,writable:!0,value:null});var h=_._logger=_._context.logger;_._reportMediaActionLogger=new Sc(h,_._roomId,_._clientSessionId,_._context.getCurrentId()),_._polarisReport=new Lc(_._context,_._runtime,_._roomId,_);var g=_._context.getCurrentId(),p=new vs(h,d,_._context.getAppkey(),r,g,i,u,l),v=_._peerConnection=new os(e,h,_._reTryExchange.bind(_),g,p,_._polarisReport,!1,f);_._setPeerConnectionListener();var m=_._executeCtx=new Vs(h,_._service,e,n,v,p,_._polarisReport,_._reportMediaActionLogger);return m.getPushOtherRooms=function(){return _._getPushOtherRoomsParams()},_.setCommandEventListener(),_._invoker=new gs(m,p),_._store=_._invoker.store,_._audioLevelReport=new _s(_._store,v),v.on(os.__INNER_AUDIOLEVEL_CHANGE__,_._audioLevelReport.audioLevelReport,_._audioLevelReport),_._pinger=new lr(_._context,_._roomId,i,_._initOptions.pingGap),_._pinger.onFailed=_.__kickoff.bind(_),_._pinger.onPingResult=_._handlePingResult.bind(_),_._context.registerRTCSignalListener(function(e){return F(_,void 0,void 0,E().m(function t(){var n,r,i,a,o;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._context.decodeRtcNotify(e),r=n.time,i=n.type,a=n.roomId,!this._invoker.isDestroyed()){t.n=1;break}return this._logger.info(Ne.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:i,time:r,roomId:a})),t.a(2);case 1:2===i&&a===this._roomId&&(o=this._logger.createTraceId(),this._logger.info(Ne.L_RTCNTF_PULL_ROOM_STATUS_O,null,o),this._startPullRTCRoomStatus(a,o,r));case 2:return t.a(2)}},t,this)}))}),_}return g(t,ue),l(t,[{key:"_setPeerConnectionListener",value:function(){var e=this,t=this._peerConnection;t.on(os.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),t.on(Rn.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),t.on(Rn.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),t.once(os.__INNER_ICE_CONNECTED__,function(t){e._reportMediaActionLogger.reportIceFirstConnectData(t?"pub":"sub")},this),t.on(os.__INNER_ICE_STATE_CHANGE__,function(t){var n=t.status,r=t.time,i=t.iceCandidatePair;i&&e._reportMediaActionLogger.recordQualityIceStatusData(i,n,r)}),t.on(os.__INNER_SEI_CONTENT__,this._onReceiveAsrSeiContent,this)}},{key:"setCommandEventListener",value:function(){var e=this._executeCtx;e.on(Ls,this._rtcpeerClosed,this),e.on(Os,this._callAppListener.bind(this,"onUserJoin"),this),e.on(ys,this._callAppListener.bind(this,"onUserLeave"),this),e.on(bs,this._onTrackPublish,this),e.on(As,this._onTrackUnpublish,this),e.on(Ns,this._onAudioMuteChange,this),e.on(ks,this._onVideoMuteChange,this),e.on(Ps,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(Us,this._dealUserAppListener,this),e.on(ws,this._callAppListener.bind(this,"onReceiveStartASR"),this),e.on(Ds,this._callAppListener.bind(this,"onReceiveStopASR"),this),e.on(Ms,this._callAppListener.bind(this,"onReceiveStartSummarization"),this),e.on(xs,this._callAppListener.bind(this,"onReceiveStopSummarization"),this)}},{key:"_startPullRTCRoomStatus",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){return E().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,this._invoker.push(new gc(e,t,this._context,n));case 1:return r.a(2)}},r,this)}))}},{key:"__innerInit",value:function(e,t,n,r,i,a,o,s){return F(this,void 0,void 0,E().m(function c(){var u,l,_;return E().w(function(c){for(;;)switch(c.n){case 0:return c.n=1,this._invoker.push(new Ts(this._roomId,e,t,n,r,i,a,o,s));case 1:if(u=c.v,l=u.code,_=u.data,l===Ae.SUCCESS){c.n=2;break}return c.a(2,{code:l});case 2:return this._initWithRoomData(_.offlineKickTime),c.a(2,{code:l,data:_})}},c,this)}))}},{key:"_initWithRoomData",value:function(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}},{key:"_handlePingResult",value:function(e,t){if(e===tr.SUCCESS&&(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf())){var n=this._logger.createTraceId();this._logger.info(Ne.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),n),this._startPullRTCRoomStatus(this._roomId,n,t)}this._callAppListener("onPing",e)}},{key:"setBitrate",value:function(e,t,n){this._logger.warn(Ne.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),se("max",e,function(e){return W(e)&&e>Math.max(t||1,200)},!0),se("min",t,function(t){return W(t)&&t>=1&&(!W(e)||t<e)},!0),se("start",n,function(n){return W(n)&&n>t&&n<=e}),this._peerConnection.setBitrate(e,t,n)}},{key:"_onTrackReady",value:function(e){var t=e.streams[0].id,n=e.receiver.track,r=[t,"audio"===n.kind?nn.AUDIO_ONLY:nn.VIDEO_ONLY].join("_"),i=this._store.getRemoteTrack(r);i?(i.__innerSetMediaStreamTrack(n),this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onTrackReady",trackId:i.getTrackId()})),this._callAppListener("onTrackReady",i)):this._logger.warn(Ne.L_ABSTRACT_ROOM_ONTRACKREADY_O,"cannot found remote track ".concat(n.id))}},{key:"_callAppListener",value:function(e){var t,n=null===(t=this._appListener)||void 0===t?void 0:t[e];if(n)try{for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];n.apply(void 0,i)}catch(e){this._logger.error(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}},{key:"_onTrackUnpublish",value:function(e){this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map(function(e){return e.getTrackId()})})),this._callAppListener("onTrackUnpublish",e)}},{key:"__parseInnerMessage",value:function(e,t){var n=e.targetId;if(n===this._roomId){this._logger.info(Ne.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,"recv inner msg -> message: ".concat(JSON.stringify(e)," | roomid: ").concat(this._roomId),t);var r=e.content;switch(e.messageType){case er.KICK:this.__kickoff(!0,r);break;case er.STATE:this._stateHandle(r,t);break;case er.MODIFY:case er.PUBLISH:case er.UNPUBLISH:case er.TOTAL_CONTENT_RESOURCE:this._resourceHandle(r,e.messageType,e.senderUserId,e.sentTime,t);break;case er.ASR_STATUS:this._invoker.push(new Dc(r.asr_status));break;case er.ASR_SEI:this._invoker.push(new Mc(JSON.parse(r.sei_ai_uris||[])));break;case er.SUMMARIZATION_STATUS:this._invoker.push(new Vc(r.status,r.taskId));break;case er.ROOM_NOTIFY:this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onRoomAttributeChange",messageType:e.messageType,messageContent:e.content})),this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case er.USER_NOTIFY:this._logger.warn(Ne.L_OLD_DAILY_RECORD_O,"TODO: ".concat(er.USER_NOTIFY));break;case er.PK_INVITE:case er.PK_CANCEL_INVITE:case er.PK_INVITE_TIMEOUT:case er.PK_INVITE_ANSWER:case er.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case er.OTHER_ROOM_OFFLINE:break;default:this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onMessageReceive",messageType:e.messageType,messageContent:e.content,senderUserId:e.senderUserId,messageUId:e.messageUId})),this._callAppListener("onMessageReceive",e.messageType,r,e.senderUserId,e.messageUId)}}else this._logger.warn(Ne.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:ke.FAILED,message:"roomId is different, msg roomId-> ".concat(n,", this._roomId-> ").concat(this._roomId," ")}),t)}},{key:"__kickoff",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a=this;return E().w(function(n){for(;;)switch(n.n){case 0:if(!this._invoker.isDestroyed()){n.n=1;break}return n.a(2);case 1:this._logger.warn(Ne.L_ABSTRACT_ROOM_ONKICKOFF_O,"onKickOff -> byServer: ".concat(e,", kickContent: ").concat(JSON.stringify(t))),this.emit(Bc),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach(function(e){e.userId===a._context.getCurrentId()&&(i=e.type,r=e.kickExtra,a._reportMediaActionLogger.reportQualityKickedData(i))}),this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onKickOff",byServer:e,kickType:i,kickExtra:r})),this._callAppListener("onKickOff",e,i,r);case 2:return n.a(2)}},n,this)}))}},{key:"_rtcpeerClosed",value:function(){this.emit(Bc),this._leaveHandle(!0),this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,"onRTCPeerConnectionCloseByException"),this._callAppListener("onRTCPeerConnectionCloseByException")}},{key:"_onReceiveAsrSeiContent",value:function(e){var t=this;e.forEach(function(e){"destLangCode"in e?t._store.getIsStartRealTranslate()&&t._store.getTranslationLang()===e.destLangCode&&t._callAppListener("onReceiveRealtimeTranslationContent",e):t._callAppListener("onReceiveASRContent",e)})}},{key:"_resourceHandle",value:function(e,t,n,r,i){return F(this,void 0,void 0,E().m(function a(){var o;return E().w(function(a){for(;;)switch(a.n){case 0:if(o=e.uris,!e.ignore&&o){a.n=1;break}return a.a(2);case 1:this._invoker.push(new sc(e,t,n,i,r));case 2:return a.a(2)}},a,this)}))}},{key:"_onTrackPublish",value:function(e,t,n){this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map(function(e){return e.getTrackId()})})),this._callAppListener("onTrackPublish",e)}},{key:"_stateHandle",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,this._invoker.push(new oc(e,t));case 1:r=n.v,i=r.data,this._dealUserAppListener(i);case 2:return n.a(2)}},n,this)}))}},{key:"_dealUserAppListener",value:function(e){var t,n,r=this,i=e.left,a=e.joined,o=e.upgrade,s=e.downgrade,c=e.offline,u=C(a),l=C(i);(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==o||o.forEach(function(e){r._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onSwitchRole",userId:e,role:ss.ANCHOR})),r._callAppListener("onSwitchRole",e,ss.ANCHOR)}),null==s||s.forEach(function(e){r._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onSwitchRole",userId:e,role:ss.AUDIENCE})),r._callAppListener("onSwitchRole",e,ss.AUDIENCE)})):(u.push.apply(u,C(o)),l.push.apply(l,C(s))),c.length&&((null===(n=this._appListener)||void 0===n?void 0:n.onUserOffline)?(this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onUserOffline",offline:c})),this._callAppListener("onUserOffline",c)):l.push.apply(l,C(c))),u.length>0&&(this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onUserJoin",allJoined:u})),this._callAppListener("onUserJoin",u)),l.length>0&&(this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onUserLeave",allLeft:l})),this._callAppListener("onUserLeave",l))}},{key:"getRoomId",value:function(){return this._roomId}},{key:"getCrtUserId",value:function(){return this._context.getCurrentId()}},{key:"getRemoteUserIds",value:function(){return this._store.getRemoteUserIds()}},{key:"getRemoteTracks",value:function(){var e=this,t=[];return this.getRemoteUserIds().forEach(function(n){t.push.apply(t,C(e.getRemoteTracksByUserId(n)))}),t}},{key:"getRemoteTracksByUserId",value:function(e){return this._store.getRemoteTracksByUserId(e)}},{key:"getSessionId",value:function(){return this._store.getSessionId()}},{key:"sendMessage",value:function(t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o;return E().w(function(r){for(;;)switch(r.n){case 0:return i=this._logger.createTraceId(),this._logger.info(Ne.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:t,content:n}),i),r.n=1,this._context.sendMessage(e.RTC_ROOM,this._roomId,{messageType:t,content:n,isStatusMessage:!0});case 1:if(a=r.v,(o=a.code)===we){r.n=2;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:ke.FAILED,code:o}),i),r.a(2,{code:Ae.SIGNAL_ERROR});case 2:return this._logger.info(Ne.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:ke.SUCCESSED,name:t,content:n}),i),r.a(2,{code:Ae.SUCCESS})}},r,this)}))}},{key:"setRoomAttribute",value:function(e,t,n){return F(this,arguments,void 0,function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E().m(function a(){var o,s;return E().w(function(a){for(;;)switch(a.n){case 0:return o=r._logger.createTraceId(),r._logger.info(Ne.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:r._roomId,key:e,value:t,message:n,isInner:i}),o),a.n=1,r._context.setRTCData(r._roomId,e,t,i,Rs.ROOM,n);case 1:if((s=a.v)===we){a.n=2;break}return r._logger.error(Ne.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:ke.FAILED,code:s}),o),a.a(2,{code:Ae.SIGNAL_ERROR});case 2:return r._logger.info(Ne.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:ke.SUCCESSED,roomId:r._roomId,key:e,value:t,message:n,isInner:i}),o),a.a(2,{code:Ae.SUCCESS})}},a)})()})}},{key:"deleteRoomAttributes",value:function(e,t){return F(this,arguments,void 0,function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return E().m(function i(){var a,o;return E().w(function(i){for(;;)switch(i.n){case 0:return a=n._logger.createTraceId(),n._logger.info(Ne.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:n._roomId,keys:e,message:t,isInner:r}),a),i.n=1,n._context.removeRTCData(n._roomId,e,r,Rs.ROOM,t);case 1:if((o=i.v)===we){i.n=2;break}return n._logger.error(Ne.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ke.FAILED,code:o}),a),i.a(2,{code:Ae.SIGNAL_ERROR});case 2:return n._logger.info(Ne.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ke.SUCCESSED,roomId:n._roomId,keys:e,message:t,isInner:r}),a),i.a(2,{code:Ae.SUCCESS})}},i)})()})}},{key:"getRoomAttributes",value:function(){return F(this,arguments,void 0,function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E().m(function r(){var i,a,o,s;return E().w(function(r){for(;;)switch(r.n){case 0:return i=e._logger.createTraceId(),e._logger.info(Ne.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:e._roomId,keys:t,isInner:n}),i),r.n=1,e._context.getRTCData(e._roomId,t,n,Rs.ROOM);case 1:if(a=r.v,o=a.code,s=a.data,o===we){r.n=2;break}return e._logger.error(Ne.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,"GetRoomAttributes Failed: ".concat(o),i),r.a(2,{code:Ae.SIGNAL_ERROR});case 2:return e._logger.info(Ne.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ke.SUCCESSED,data:s}),i),r.a(2,{code:Ae.SUCCESS,data:s})}},r)})()})}},{key:"_setUserAttributeValue",value:function(e,t,n){return this._context.setRTCData(this._roomId,e,t,!1,Rs.PERSON,n)}},{key:"_deleteUserAttributes",value:function(e,t){return this._context.removeRTCData(this._roomId,e,!1,Rs.PERSON,t)}},{key:"_getUserAttributes",value:function(e){return this._context.getRTCData(this._roomId,e,!1,Rs.PERSON)}},{key:"isDestroyed",value:function(){return this._invoker.isDestroyed()}},{key:"__destroy",value:function(e){return this._leaveHandle(e)}},{key:"_muteRemoteTracksBeforeQuit",value:function(){var e=Object.values(this._store.getRemoteTracks());e.length&&e.forEach(function(e){return e.mute()})}},{key:"_leaveHandle",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)switch(t.n){case 0:if(!this._invoker.isDestroyed()){t.n=1;break}return t.a(2);case 1:if(this._invoker.destroy(),this._muteRemoteTracksBeforeQuit(),!e){t.n=2;break}return t.n=2,this._context.quitRTCRoom(this._roomId);case 2:if(!this._store.isMainRoom){t.n=3;break}return t.n=3,this._quitAllPKRoom();case 3:return this._pinger.stop(),t.n=4,this._service.exit(this._store.getRTCRequestHeader());case 4:this._releasePCManager();case 5:return t.a(2)}},t,this)}))}},{key:"_releasePCManager",value:function(){var e=this._peerConnection;e.removeAllLocalTrack(),e.destroy()}},{key:"_onLocalTrackDestroied",value:function(e){e instanceof In&&e.__isTiny()||this.unpublish([e])}},{key:"_onLocalTrackMuted",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,this._invoker.push(new _c(e));case 1:r=n.v,i=r.code,t(i);case 2:return n.a(2)}},n,this)}))}},{key:"publish",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)if(0===t.n)return t.a(2,this._invoker.push(new uc(e)))},t,this)}))}},{key:"_getPushOtherRoomsParams",value:function(){return[]}},{key:"_reTryExchange",value:function(){return this._invoker.push(new dc)}},{key:"unpublish",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)if(0===t.n)return t.a(2,this._invoker.push(new lc(e)))},t,this)}))}},{key:"_isValidResourceId",value:function(e){var t,n=Fn(e).userId;return!!(null===(t=this._store.getResourcesByUserId(n))||void 0===t?void 0:t.find(function(t){return jn(t)===e}))}},{key:"subscribe",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)if(0===t.n)return t.a(2,this._invoker.push(new cc(e,void 0,void 0)))},t,this)}))}},{key:"unsubscribe",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)if(0===t.n)return n=this._logger.createTraceId(),this._logger.info(Ne.L_APP_CALL_UNSUBSCRIBE_O,void 0,n),t.a(2,this._invoker.push(new Fs(e,n)))},t,this)}))}},{key:"updateSubList",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)if(0===t.n)return t.a(2,this._invoker.push(new js(e,!0,this._logger.createTraceId())))},t,this)}))}},{key:"getLocalTrack",value:function(e){return this._peerConnection.getLocalTrack(e)}},{key:"getLocalTracks",value:function(){return this._peerConnection.getLocalTracks()}},{key:"getRemoteTrack",value:function(e){return this._store.getRemoteTrack(e)||null}},{key:"subscribedTracks",get:function(){return this._store.getSubscribedList().slice()}},{key:"registerRoomEventListener",value:function(e){this._logger.info(Ne.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e,this.asrIsAvailable()&&this._executeCtx.emit(ws);var t=this.getSummarizationStatusData();t&&(null==t?void 0:t.status)===So.OPEN&&this._executeCtx.emit(Ms,t.taskId)}},{key:"registerReportListener",value:function(e){this._logger.info(Ne.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}},{key:"onAudioLevelChange",value:function(e,t){this._logger.info(Ne.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}},{key:"__onReconnected",value:function(e){this._invoker.push(new pc(e))}},{key:"_onAudioMuteChange",value:function(e){this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}},{key:"_onVideoMuteChange",value:function(e){this._logger.info(Ne.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ke.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}},{key:"_registerPKMsgListener",value:function(e){this._onRecvPKMsg=e}},{key:"_quitAllPKRoom",value:function(){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return e.a(2)},e)}))}},{key:"getClientSessionId",value:function(){return this._store.clientSessionId}},{key:"changeMediaDevice",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return n.a(2,this._invoker.push(new Oc(e,t)))},n,this)}))}},{key:"startASR",value:function(){return this._invoker.push(new bc(ds.OPEN))}},{key:"stopASR",value:function(){return this._invoker.push(new bc(ds.CLOSE))}},{key:"asrIsAvailable",value:function(){return this._store.getASRIsAvailable()}},{key:"setEnableASR",value:function(e){return this._invoker.push(new Ac(e))}},{key:"startRealtimeTranslation",value:function(e){return this._invoker.push(new wc(yc.OPEN,e))}},{key:"stopRealtimeTranslation",value:function(){return this._invoker.push(new wc(yc.CLOSE))}},{key:"startSummarization",value:function(){return this._invoker.push(new xc(!0))}},{key:"stopSummarization",value:function(){return this._invoker.push(new xc(!1))}},{key:"getSummarizationStatusData",value:function(){return this._store.getSummarizationStatusData()}}])}(),jc=function(){function e(t,n){var r;return c(this,e),r=s(this,e),Object.defineProperty(r,"data",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:n}),r}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.MCUCONFIG_FLUSH}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f;return E().w(function(n){for(;;)switch(n.n){case 0:return s=e.context,c=e.service,u={"App-Key":s.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:s.getCurrentId(),SessionId:t.getSessionId()},n.n=1,c.setMcuConfig(u,this.data);case 1:if(l=n.v,_=l.code,d=l.res,_===Ae.SUCCESS){n.n=2;break}return n.a(2,{code:_});case 2:return d.pull_url&&t.setCDNUris(JSON.parse(d.pull_url)),f=this.cdnValues,_===Ae.SUCCESS&&((null===(i=null===(r=f.output)||void 0===r?void 0:r.video.normal)||void 0===i?void 0:i.width)||(null===(o=null===(a=f.output)||void 0===a?void 0:a.video.normal)||void 0===o?void 0:o.fps))&&qs(s,t),n.a(2,{code:_,data:d})}},n,this)}))}}])}();!function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(Nc||(Nc={})),function(e){e[e.CUSTOMIZE=1]="CUSTOMIZE",e[e.SUSPENSION=2]="SUSPENSION",e[e.ADAPTATION=3]="ADAPTATION"}(kc||(kc={})),function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(Pc||(Pc={})),function(e){e[e.AUDIO_VIDEO_ALL=0]="AUDIO_VIDEO_ALL",e[e.AUDIO_VIDEO_NO=1]="AUDIO_VIDEO_NO",e[e.AUDIO_ALL_VIDEO_NO=2]="AUDIO_ALL_VIDEO_NO",e[e.AUDIO_NO_VIDEO_ALL=3]="AUDIO_NO_VIDEO_ALL",e[e.AUDIO_VIDEO_INPUT=4]="AUDIO_VIDEO_INPUT",e[e.AUDIO_ALL_VIDEO_INPUT=5]="AUDIO_ALL_VIDEO_INPUT",e[e.AUDIO_NO_VIDEO_INPUT=6]="AUDIO_NO_VIDEO_INPUT",e[e.AUDIO_INPUT_VIDEO_ALL=7]="AUDIO_INPUT_VIDEO_ALL",e[e.AUDIO_INPUT_VIDEO_NO=8]="AUDIO_INPUT_VIDEO_NO",e[e.ROOM_AUDIO_VIDEO_APPEND=9]="ROOM_AUDIO_VIDEO_APPEND",e[e.ROOM_AUDIO_VIDEO_NOT_APPEND=10]="ROOM_AUDIO_VIDEO_NOT_APPEND",e[e.ROOM_AUDIO_APPEND=11]="ROOM_AUDIO_APPEND",e[e.ROOM_AUDIO_NOT_APPEND=12]="ROOM_AUDIO_NOT_APPEND",e[e.ROOM_VIDEO_APPEND=13]="ROOM_VIDEO_APPEND",e[e.ROOM_VIDEO_NOT_APPEND=14]="ROOM_VIDEO_NOT_APPEND"}(Uc||(Uc={}));var Fc,Hc=function(){return{version:2,mode:kc.SUSPENSION}},Jc=function(){return l(function e(t,n,r){c(this,e),Object.defineProperty(this,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_isValidTrackId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_values",{enumerable:!0,configurable:!0,writable:!0,value:Hc()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._executeCtx.logger},[{key:"setHostVideoTrack",value:function(e){if(!this._isValidTrackId(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,msg:"videoTrackId: ".concat(e," is invalid")})),this;var t=Fn(e),n=t.mediaType,r=t.tag,i=t.userId;return n!==nn.VIDEO_ONLY?(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,msg:"kind of ".concat(e," is not video")})),this):(this._values.host_stream_id=Hn(i,r),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ke.SUCCESSED,videoTrackId:e})),this)}},{key:"setMixLayoutMode",value:function(e){return[kc.CUSTOMIZE,kc.SUSPENSION,kc.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:ke.SUCCESSED,mode:e})),this):(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:ke.SUCCESSED,msg:"mode: ".concat(e," is invalid")})),this)}},{key:"_addOutputValue",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"normal",r=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"!==e)if("audio"!==e){var i=r.video;if("normal"!==n&&"tiny"!==n)if("backgroundColor"!==n)if("exparams"!==n){if("backgroundPicture"===n){var a=i.backgroundPicture||(i.backgroundPicture={fillMode:Nc.CROP,picture:[]});Object.assign(a,t)}}else i.exparams={renderMode:t};else i.backgroundColor=t;else{var o=i[n]||(i[n]={});Object.assign(o,t)}}else r.audio={bitrate:t};else r.cdn=t}},{key:"setOutputVideoResolution",value:function(e){if(!Wn(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:ke.FAILED,msg:"params error -> resolution: ".concat(e)})),this;var t=qn(e),n=t.width,r=t.height;return this._addOutputValue("video",{width:n,height:r},"normal"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:ke.SUCCESSED,resolution:e})),this}},{key:"setOutputVideoFPS",value:function(e){if(!zn(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:ke.FAILED,msg:"params error -> fps: ".concat(e)})),this;var t=Qn(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:ke.SUCCESSED,fps:e})),this}},{key:"setOutputVideoBitrate",value:function(e){return!W(e)||e<=0?(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> bitrate: ".concat(e)})),this):(this._addOutputValue("video",{bitrate:e},"normal"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:ke.SUCCESSED,bitrate:e})),this)}},{key:"setOutputTinyVideoResolution",value:function(e){if(!Wn(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:ke.FAILED,msg:"params error -> resolution: ".concat(e)})),this;var t=qn(e),n=t.width,r=t.height;return this._addOutputValue("video",{width:n,height:r},"tiny"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:ke.SUCCESSED,resolution:e})),this}},{key:"setOutputTinyVideoFPS",value:function(e){if(!zn(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:ke.FAILED,msg:"params error -> fps: ".concat(e)})),this;var t=Qn(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:ke.SUCCESSED,fps:e})),this}},{key:"setOutputTinyVideoBitrate",value:function(e){return!W(e)||e<=0?(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> bitrate: ".concat(e)})),this):(this._addOutputValue("video",{bitrate:e},"tiny"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:ke.SUCCESSED,bitrate:e})),this)}},{key:"setOutputVideoRenderMode",value:function(e){return[Pc.CROP,Pc.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:ke.SUCCESSED,renderMode:e})),this):(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> renderMode: ".concat(e)})),this)}},{key:"setOutputAudioBitrate",value:function(e){return W(e)&&e>0?(this._addOutputValue("audio",e),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:ke.SUCCESSED,bitrate:e})),this):(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> bitrate: ".concat(e)})),this)}},{key:"setOutputBackgroundColor",value:function(e){return/^0x[a-fA-F0-9]{6}$/.test(e)?(this._addOutputValue("video",e,"backgroundColor"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:ke.SUCCESSED,color:e})),this):(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:ke.FAILED,msg:"params error -> color: ".concat(e)})),this)}},{key:"addOutputBackgroundPicture",value:function(e,t,n,r,i){var a,o,s;if(!te(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> uri: ".concat(e)})),this;if([t,n,r,i].some(function(e){return!W(e)||e<0||e>1}))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ke.FAILED,msg:"params of (x, y, w, h) error -> x: ".concat(t,", y: ").concat(n,", w: ").concat(r,", h: ").concat(i)})),this;var c=(null===(s=null===(o=null===(a=this._values.output)||void 0===a?void 0:a.video)||void 0===o?void 0:o.backgroundPicture)||void 0===s?void 0:s.picture)||[];return c.push({uri:e,w:r,h:i,x:t,y:n}),this._addOutputValue("video",{picture:c},"backgroundPicture"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ke.SUCCESSED,uri:e,x:t,y:n,w:r,h:i})),this}},{key:"removeOutputBackgroundPicture",value:function(e){var t,n,r;if(!te(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> uri: ".concat(e)})),this;var i=null===(r=null===(n=null===(t=this._values.output)||void 0===t?void 0:t.video)||void 0===n?void 0:n.backgroundPicture)||void 0===r?void 0:r.picture;return i&&(i=i.filter(function(t){return t.uri!==e}),this._addOutputValue("video",{pictures:i},"backgroundPicture")),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ke.SUCCESSED,uri:e})),this}},{key:"clearOutputBackgroundPicture",value:function(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}},{key:"setOutputBackgroundPictureFillMode",value:function(e){return[Nc.CROP,Nc.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ke.SUCCESSED,fillMode:e})),this):(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> fillMode: ".concat(e)})),this)}},{key:"addPublishStreamUrls",value:function(e){var t,n,r=/^rtmp:\/\/.+/;if(!z(e)||0===e.length||e.some(function(e){return!r.test(e)}))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> urls: ".concat(e.join(","))})),this;var i=(null===(n=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===n?void 0:n.concat())||[],a=!1;return e.forEach(function(e){i.some(function(t){return t.pushurl===e})||(a=!0,i.push({pushurl:e}))}),i.length>5?(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ke.FAILED,msg:"params error -> publish stream urls no more than 5, length: ".concat(e.length)})),this):(a&&this._addOutputValue("cdn",i),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ke.SUCCESSED,urls:e})),this)}},{key:"removePublishStreamUrls",value:function(e){var t,n,r=/^rtmp:\/\/.+/;if(!z(e)||0===e.length||e.some(function(e){return!r.test(e)}))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ke.FAILED,msg:"params error -> urls: ".concat(e.join(","))})),this;for(var i=(null===(n=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===n?void 0:n.concat())||[],a=i.length-1;a>=0;a-=1){var o=i[a].pushurl,s=e.indexOf(o);s>=0&&(e.splice(s,1),i.splice(a,1))}return this._addOutputValue("cdn",i),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ke.SUCCESSED,urls:e})),this}},{key:"clearPublishStreamUrls",value:function(){return this._addOutputValue("cdn",[]),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O),this}},{key:"addCustomizeLayoutVideo",value:function(e,t,n,r,i){if(!Q(e)||!this._isValidTrackId(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.FAILED,msg:"params error -> trackId: ".concat(e)})),this;if(!W(t)||!W(n))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.FAILED,msg:"params x or y is error -> x: ".concat(t,", y: ").concat(n)})),this;if([r,i].some(function(e){return!W(e)||e<0}))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.FAILED,msg:"params width or height error -> width: ".concat(r,", height: ").concat(i)})),this;var a=Fn(e),o=a.userId,s=a.tag;if(a.mediaType!==nn.VIDEO_ONLY)return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.FAILED,msg:"type of trackId: ".concat(e," is not video")})),this;var c=Hn(o,s),u=this._values.input||(this._values.input={}),l=u.video||(u.video=[]);return l.some(function(e){return e.height===i&&e.width===r&&e.stream_id===c&&e.user_id===o&&e.x===t&&e.y===n})?(this._logger.warn(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.FAILED,msg:"Duplicate configuration item place ignored"})),this):(l.push({user_id:o,stream_id:c,x:t,y:n,width:r,height:i}),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.SUCCESSED,trackId:e,x:t,y:n,width:r,height:i})),this)}},{key:"removeCustomizeLayoutVideo",value:function(e){if(!this._isValidTrackId(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=Fn(e),n=t.userId,r=t.tag;if(t.mediaType!==nn.VIDEO_ONLY)return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.FAILED,msg:"type of trackId: ".concat(e," is not video")})),this;var i=Hn(n,r),a=this._values.input;return(null==a?void 0:a.video)&&a.video.length>0&&(a.video=a.video.filter(function(e){return e.stream_id===i})),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ke.SUCCESSED,trackId:e})),this}},{key:"clearCustomizeLayoutVideo",value:function(){var e=this._values.input;return null==e||delete e.video,this._logger.info(Ne.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O),this}},{key:"setCustomizeInputAudio",value:function(e){var t=this;return e.some(function(e){return t._isValidTrackId(e)})?(this._logger.error(Ne.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ke.FAILED,msg:"trackIds contain invalid item -> trackIds: ".concat(e.join(","))})),this):((this._values.input||(this._values.input={})).audio=e.map(function(e){var t=Fn(e),n=t.userId,r=t.tag;return{stream_id:Hn(n,r),user_id:n}}),this._values.inputFilterMode=Uc.AUDIO_INPUT_VIDEO_ALL,this._logger.info(Ne.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ke.SUCCESSED,trackIds:e})),this)}},{key:"addCustomizeInputAudio",value:function(e){if(!this._isValidTrackId(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ke.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=this._values.input||(this._values.input={}),n=t.audio||(t.audio=[]),r=Fn(e),i=r.userId,a=r.tag,o=Hn(i,a);return n.some(function(e){return e.stream_id===o&&e.user_id===i})?(this._logger.warn(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ke.FAILED,msg:"trackId: ".concat(e," is exist")})),this):(n.push({user_id:i,stream_id:o}),this._values.inputFilterMode=Uc.AUDIO_INPUT_VIDEO_ALL,this._logger.info(Ne.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ke.SUCCESSED,trackId:e})),this)}},{key:"removeCustomizeInputAudio",value:function(e){if(!this._isValidTrackId(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ke.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=this._values.input;if(!(null==t?void 0:t.audio)||0===t.audio.length)return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ke.FAILED,msg:"type of trackId: ".concat(e," is not audio")})),this;var n=Fn(e),r=n.userId,i=n.tag,a=Hn(r,i);return t.audio=t.audio.filter(function(e){return r!==e.user_id||a!==e.stream_id}),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ke.SUCCESSED,trackId:e})),this}},{key:"clearCustomizeInputAudio",value:function(){var e=this._values.input;return(null==e?void 0:e.audio)&&delete e.audio,this._values.inputFilterMode=Uc.AUDIO_VIDEO_ALL,this._logger.info(Ne.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O),this}},{key:"addPictureWaterMark",value:function(e,t,n,r,i,a){if(!this._isValidTrackId(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ke.FAILED,msg:"params error -> trackId: ".concat(e)})),this;if(!te(t))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ke.FAILED,msg:"params error -> uri: ".concat(t)})),this;if([n,r,i,a].some(function(e){return!W(e)||e<0||e>1})||n+i>1||r+a>1)return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ke.FAILED,msg:"some attrs of (x, y, w, h) is invalid -> x: ".concat(n,", y: ").concat(r,", w: ").concat(i,", h: ").concat(a)})),this;var o=Fn(e),s=o.userId,c=o.tag,u=Hn(s,c),l=(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen,_=l.filter(function(e){return e.streamId===u})[0];return _?_.picture.push({uri:t,w:i,h:a,x:n,y:r}):l.push({streamId:u,picture:[{uri:t,w:i,h:a,x:n,y:r}]}),this._values.waterMark.singleScreen=l,this._logger.info(Ne.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ke.SUCCESSED,trackId:e,uri:t,x:n,y:r,w:i,h:a,singleScreen:l})),this}},{key:"clearPictureWaterMark",value:function(){return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen=[],this._logger.info(Ne.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}},{key:"removePictureWaterMark",value:function(e,t){if(!Q(e)||!this._isValidTrackId(e))return this._logger.error(Ne.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:ke.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var n=Fn(e),r=n.userId,i=n.tag,a=Hn(r,i);return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen.forEach(function(e){e.streamId===a&&(e.picture=e.picture.filter(function(e){return e.uri!==t}))}),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:ke.SUCCESSED,trackId:e,uri:t})),this}},{key:"reset",value:function(){return this._values=Hc(),this._logger.info(Ne.L_MCU_CONFIG_BUILDER_RESET_O),this}},{key:"flush",value:function(){return F(this,arguments,void 0,function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:return r=JSON.parse(JSON.stringify(e._values)),n.n=1,e._invoker.push(new jc(r,e._values));case 1:return i=n.v,a=i.code,t&&(e._values=Hc()),n.a(2,{code:a})}},n)})()})}},{key:"__innerGetValues",value:function(){return JSON.parse(JSON.stringify(this._values))}}])}();!function(e){e[e.VIDEO=0]="VIDEO",e[e.AUDIO=1]="AUDIO"}(Fc||(Fc={}));var Kc,Yc=function(){function e(t,n,r){var i;return c(this,e),i=s(this,e),Object.defineProperty(i,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return g(e,fs),l(e,[{key:"_exchangeWithPushOtherRoom",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.peer,o=e.context,a.getLocalTracks().length){r.n=1;break}return i.info(Ne.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ke.SUCCESSED,msg:"have not published resource"}),this.traceId),r.a(2);case 1:return s=a,c=t.getSubscribedList(),r.n=2,Js(c,!1,s,t,o);case 2:return u=r.v,l=e.getPushOtherRooms(),u.pushOtherRooms=l,r.n=3,new Gs(u,this.traceId,!0).execute(e,t,n);case 3:if((_=r.v).code===Ae.SUCCESS){r.n=4;break}return i.error(Ne.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ke.FAILED,code:_.code,pushOtherRooms:l}),this.traceId),r.a(2);case 4:if(d=_.data.data,f=d.sdp,(h=d.resultCode)===Ae.SUCCESS){r.n=5;break}return i.error(Ne.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ke.FAILED,code:h,pushOtherRooms:l}),this.traceId),r.a(2);case 5:i.info(Ne.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ke.SUCCESSED,pushOtherRooms:l}),this.traceId),s.setRemoteAnswer(f.sdp);case 6:return r.a(2)}},r,this)}))}},{key:"kind",get:function(){return cs.EXCHANGE_WITH_PUSH_OTHER_ROOM}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=this.roomId,i.info(Ne.L_EXCHANGE_WITH_PUSHOTHERROOM_T,a),this.roomPKHandler){r.n=1;break}return i.error(Ne.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ke.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),r.a(2,{code:Ae.SUCCESS});case 1:if(this.roomPKHandler.getPKInfo(a)){r.n=2;break}return i.warn(Ne.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ke.FAILED,msg:"PKInfo not exist"}),this.traceId),r.a(2,{code:Ae.SUCCESS});case 2:return r.n=3,this._exchangeWithPushOtherRoom(e,t,n);case 3:return r.a(2,{code:Ae.SUCCESS})}},r,this)}))}}])}(),qc=function(){function e(t,n,r,i,a,o){var u;return c(this,e),u=s(this,e),Object.defineProperty(u,"pkHandler",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(u,"room",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(u,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(u,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(u,"isQuitPK",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(u,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:o}),u}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.LEAVE_OTHER_ROOM}},{key:"quitRoomPK",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l,_,d,f,h;return E().w(function(i){for(;;)switch(i.n){case 0:if(a=e.logger,o=e.context,a.info(Ne.L_QUIT_PK_T,"roomId: ".concat(t),r),this._PKInfo[t]){i.n=1;break}return a.warn(Ne.L_QUIT_PK_R,"status: ".concat(ke.FAILED,", msg: pkinfo is empty"),r),i.a(2);case 1:return s=this._PKInfo[t],c=s.inviterRoomId,u=s.inviteeRoomId,l=s.inviterUserId,_=s.inviteSessionId,d={inviteeRoomId:u,inviterRoomId:c,userId:n.crtUserId},f={roomId:n.roomId,endRoomId:t,sessionId:_,content:JSON.stringify(d),keys:["".concat(c,"|").concat(l)]},i.n=2,o.endRoomPK(f);case 2:if((h=i.v)===we){i.n=3;break}return a.error(Ne.L_QUIT_PK_R,"status: ".concat(ke.FAILED,", code: ").concat(h),r),i.a(2,{code:Ae.SIGNAL_ERROR});case 3:a.info(Ne.L_QUIT_PK_R,"status: ".concat(ke.SUCCESSED),r),delete this._PKInfo[t];case 4:return i.a(2)}},i,this)}))}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s;return E().w(function(r){for(;;)switch(r.n){case 0:return i=e.logger,a=this.room,o=this.isQuitPK,s=a.getRoomId(),i.info(Ne.L_LIVING_ROOM_LEAVE_PK_ROOM_T,JSON.stringify({roomId:s,isQuitPK:o}),this.traceId),r.n=1,a.__destroy(!0);case 1:return delete this._joinedPKRooms[s],r.n=2,new Yc(s,this.pkHandler,this.traceId).execute(e,t,n);case 2:return o&&this.quitRoomPK(e,s,t,this.traceId),i.info(Ne.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:ke.SUCCESSED}),this.traceId),r.a(2,{code:Ae.SUCCESS})}},r,this)}))}}])}(),Wc=function(){return l(function e(t,n,r,i,a,o,s,u,l,_){c(this,e),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_mainLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_registerPKMsgListener",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(this,"_onJoinedPKRoom",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_inviteTimeout",{enumerable:!0,configurable:!0,writable:!0,value:30}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mainRoomId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,this._registerPKMsgListener(this._onRecvPKMsg.bind(this)),this._mainRoomId=this._mainLivingRoom.getRoomId()},[{key:"_callAppListener",value:function(e){var t,n=null===(t=this._appListener)||void 0===t?void 0:t[e];if(n)try{for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];n.apply(void 0,i)}catch(e){this._logger.error(Ne.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}},{key:"_onInvite",value:function(e){var t=e.inviteInfo||{},n=t.inviterRoomId,r={inviterRoomId:n,inviterUserId:t.inviterUserId,extra:t.extra};this._PKInfo[n]=t,this._logger.info(Ne.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:r})),this._callAppListener("onRequestJoinOtherRoom",r)}},{key:"_onCancelInvite",value:function(e){var t=e.inviteInfo||{},n=t.inviterRoomId,r={inviterRoomId:n,inviterUserId:t.inviterUserId,extra:t.extra};delete this._PKInfo[n],this._logger.info(Ne.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCancelRequestOtherRoom",cancelInfo:r})),this._callAppListener("onCancelRequestOtherRoom",r)}},{key:"_onInviteTimeout",value:function(e){}},{key:"_onInviteAnswer",value:function(e){var t=e.answerCode,n=e.inviteContent,r=n.inviteSessionId,i=n.inviterUserId,a=n.inviterRoomId,o=n.inviteeUserId,s=n.inviterUserAutoMix,c=n.inviteeUserAutoMix,u=n.inviteeRoomId,l={agree:1===t,inviterRoomId:a,inviterUserId:i,inviteeRoomId:u,inviteeUserId:o,extra:n.extra};this._PKInfo[u]=this._PKInfo[u]||{inviteSessionId:r,inviterRoomId:a,inviterUserId:i,inviterUserAutoMix:s,inviteeRoomId:u},this._PKInfo[u].inviteeUserAutoMix=c,this._logger.info(Ne.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:l})),this._callAppListener("onResponseJoinOtherRoom",l)}},{key:"createLeaveOtherRoomCommand",value:function(e,t,n){return new qc(this,e,this._PKInfo,this._joinedPKRooms,t,n)}},{key:"_onPKEnd",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=e.inviteInfo,r=n.inviteeRoomId,i=n.inviterRoomId,a=n.userId,o=i===this._mainRoomId?r:i,s={endRoomId:o,endUserId:a},c=this._joinedPKRooms[o],u=this._logger.createTraceId(),this._logger.info(Ne.L_QUIT_PK_LEAVE_PK_ROOM_O,void 0,u),!c){t.n=1;break}return t.n=1,this._invoker.push(this.createLeaveOtherRoomCommand(c,!0,u));case 1:delete this._PKInfo[o],this._logger.info(Ne.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:s})),this._callAppListener("onFinishOtherRoom",s);case 2:return t.a(2)}},t,this)}))}},{key:"_onRecvPKMsg",value:function(e){var t=e.content;switch(e.messageType){case er.PK_INVITE:this._onInvite(t);break;case er.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case er.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case er.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case er.PK_END:this._onPKEnd(t)}}},{key:"registerRoomPKEventListener",value:function(e){this._logger.info(Ne.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O,JSON.stringify({listener:e&&Object.keys(e)})),this._appListener=e}},{key:"requestJoinOtherRoom",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=this._logger.createTraceId(),this._logger.info(Ne.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,options:n}),i),ce("inviteeRoomId",e,Q,!0)&&ce("inviteeUserId",t,Q,!0)){r.n=1;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),i),r.a(2,{code:Ae.PARAMS_ERROR});case 1:return a=Oo(),o=!q(null==n?void 0:n.autoMix)||(null==n?void 0:n.autoMix),s={inviteSessionId:a,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:o,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(null==n?void 0:n.extra)||""},c={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(s),inviteSessionId:a},r.n=2,this._context.requestRoomPK(c);case 2:if((u=r.v)===we){r.n=3;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:u}),i),r.a(2,{code:u});case 3:return this._PKInfo[e]={inviteSessionId:a,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:o,inviteeRoomId:e},this._logger.info(Ne.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.SUCCESSED}),i),r.a(2,{code:Ae.SUCCESS})}},r,this)}))}},{key:"cancelRequestJoinOtherRoom",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=this._logger.createTraceId(),this._logger.info(Ne.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,extra:n}),i),ce("inviteeRoomId",e,Q,!0)&&ce("inviteeUserId",t,Q,!0)){r.n=1;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),i),r.a(2,{code:Ae.PARAMS_ERROR});case 1:if(this._PKInfo[e]){r.n=2;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"The request to connect with ".concat(t," user in room ").concat(e," is not initiated")}),i),r.a(2,{code:Ae.PARAMS_ERROR});case 2:return a={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:n||""},o={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(a)},r.n=3,this._context.cancelRoomPK(o);case 3:if((s=r.v)===we){r.n=4;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:s}),i),r.a(2,{code:s});case 4:return this._logger.info(Ne.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.SUCCESSED}),i),delete this._PKInfo[e],r.a(2,{code:Ae.SUCCESS})}},r,this)}))}},{key:"responseJoinOtherRoom",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l,_,d,f,h;return E().w(function(i){for(;;)switch(i.n){case 0:if(a=this._logger.createTraceId(),this._logger.info(Ne.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:e,inviterUserId:t,agree:n,options:r}),a),ce("inviterRoomId",e,Q,!0)&&ce("inviterUserId",t,Q,!0)){i.n=1;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),a),i.a(2,{code:Ae.PARAMS_ERROR});case 1:if(this._PKInfo[e]){i.n=2;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"User ".concat(t," in room ").concat(e," did not send a request for connection")}),a),i.a(2,{code:Ae.PARAMS_ERROR});case 2:return o=this._PKInfo[e],s=o.inviteSessionId,c=o.inviterUserAutoMix,u=!q(null==r?void 0:r.autoMix)||(null==r?void 0:r.autoMix),l={inviteSessionId:s,inviterRoomId:e,inviterUserId:t,inviterUserAutoMix:c,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:u},_=Object.assign(l,{inviterUserAutoMix:c}),d=n?Object.assign(l,{MultiRoomKey:"".concat(e,"|").concat(this._mainRoomId),MultiRoomValue:JSON.stringify(_)}):l,!ee(null==r?void 0:r.extra)&&Object.assign(d,{extra:r.extra}),f={agree:n,roomId:this._mainRoomId,inviteSessionId:s,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(d),key:"".concat(e,"|").concat(this._mainRoomId),value:JSON.stringify(l)},i.n=3,this._context.responseRoomPK(f);case 3:if((h=i.v)===we){i.n=4;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:h}),a),i.a(2,{code:h});case 4:return this._logger.info(Ne.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.SUCCESSED}),a),this._PKInfo[e].inviteeUserAutoMix=u,i.a(2,{code:Ae.SUCCESS})}},i,this)}))}},{key:"joinOtherRoom",value:function(e){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(Ne.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:e}),r),ce("roomId",e,Q,!0)){n.n=1;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> roomId"}),r),n.a(2,{code:Ae.PARAMS_ERROR});case 1:if(this._context.getConnectionStatus()===t.CONNECTED){n.n=2;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),r),n.a(2,{code:Ae.SIGNAL_DISCONNECTED});case 2:if(!this._joinedPKRooms[e]){n.n=3;break}return this._logger.warn(Ne.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),n.a(2,{code:Ae.REPERT_JOIN_ROOM});case 3:return i=Fc.VIDEO,a={extra:'{"roomId": "'.concat(this._mainRoomId,'"}')},o=new eu(this._context,this._runtime,e,this._service,this._initOptions,i,!1,!1,this._clientSessionId),n.n=4,o.__innerInit(ps.LIVE,void 0,i,a);case 4:if(s=n.v,(c=s.code)===Ae.SUCCESS){n.n=5;break}return this._logger.error(Ne.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.FAILED,code:c}),r),n.a(2,{code:c});case 5:return this._joinedPKRooms[e]=o,n.n=6,this._onJoinedPKRoom(e,r);case 6:return this._logger.info(Ne.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ke.SUCCESSED}),r),n.a(2,{room:o,code:Ae.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()})}},n,this)}))}},{key:"leaveOtherRoom",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r;return E().w(function(n){for(;;)if(0===n.n)return r=this._logger.createTraceId(),this._logger.info(Ne.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,r),n.a(2,this._invoker.push(this.createLeaveOtherRoomCommand(e,t,r)))},n,this)}))}},{key:"getPKInfo",value:function(e){return this._PKInfo[e]}},{key:"getAllPKInfo",value:function(){return this._PKInfo}},{key:"getJoinedPKRooms",value:function(){return this._joinedPKRooms}}])}();!function(e){e[e.OPEN=1]="OPEN",e[e.STOP=2]="STOP"}(Kc||(Kc={}));var zc,Qc=function(){function e(t,n){var r;return c(this,e),r=s(this,e),Object.defineProperty(r,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"enable",{enumerable:!0,configurable:!0,writable:!0,value:n}),r}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.ENABLE_INNER_CDN}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.logger,a=e.context,o=this.enable,i.info(Ne.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:t.roomId,enable:o})),t.isMainRoom){r.n=1;break}return i.error(Ne.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ke.FAILED,code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),r.a(2,{code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM});case 1:if(q(o)){r.n=2;break}return i.error(Ne.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> enable"})),r.a(2,{code:Ae.PARAMS_ERROR});case 2:return t.setCDNEnabel(o),s={version:2,output:{inCDNModel:o?Kc.OPEN:Kc.STOP}},r.n=3,new jc(s,this.cdnValues).execute(e,t,n);case 3:if(c=r.v,(u=c.code)===Ae.SUCCESS){r.n=4;break}return i.error(Ne.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ke.FAILED,code:u,msg:"signal error"})),r.a(2,{code:Ae.SIGNAL_ERROR});case 4:if(!(l=t.getCDNUris())||l.broadcast===Cs.SPREAD){r.n=5;break}return i.info(Ne.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ke.SUCCESSED,enable:o})),r.a(2,{code:Ae.SUCCESS});case 5:return r.n=6,qs(a,t);case 6:if(_=r.v,(d=_.code)!==Ae.SUCCESS){r.n=7;break}return i.info(Ne.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ke.SUCCESSED,enable:o})),r.a(2,{code:Ae.SUCCESS});case 7:return i.error(Ne.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ke.FAILED,code:d})),r.a(2,{code:d})}},r,this)}))}}])}();!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(zc||(zc={}));var Zc,Xc,$c=function(){function e(t,n){var r;return c(this,e),r=s(this,e),Object.defineProperty(r,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),r}return g(e,fs),l(e,[{key:"kind",get:function(){return cs.RTC_IDENTITY_CHANGE}},{key:"execute",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u;return E().w(function(r){for(;;)switch(r.n){case 0:return a=e.context,r.n=1,a.rtcIdentityChange(t.roomId,zc.ViewerToAnchor,this.livingType);case 1:if(o=r.v,s=o.code,c=o.data,s===we&&c){r.n=2;break}return r.a(2,{code:s});case 2:return t.initWithRoomData(c,this.traceId),t.getResourcesByUserId(t.crtUserId).length>0&&n.push(new ms),(u=null===(i=c.roomInfo.filter(function(e){return"cdn_uris"===e.key})[0])||void 0===i?void 0:i.value)&&t.setCDNUris(JSON.parse(u)[0]),r.a(2,{code:s,data:c})}},r,this)}))}}])}(),eu=function(){function e(t,n,r,i,a,o,u,l,_){var d;return c(this,e),d=s(this,e,[t,n,r,ps.LIVE,i,a,u,l,_]),Object.defineProperty(d,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(d,"_mcuConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(d,"_roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),d._mcuConfigBuilder=new Jc(d._executeCtx,d._invoker,d._isValidResourceId.bind(d)),d}return g(e,Gc),l(e,[{key:"_initRoomPKHandler",value:function(t){if(this._store.isMainRoom){var n=(r=this._roomId,i=t.roomInfo,a={},i.forEach(function(e){var t=JSON.parse(e.value),n=t.inviterRoomId,i=t.inviteeRoomId;a[r===n?i:n]=JSON.parse(e.value)}),a);this._roomPKHandler=new Wc(this._invoker,n,this._context,this._runtime,this._service,this._initOptions,this,S(e,"_registerPKMsgListener",this,1).bind(this),this._onJoinedPKRoom.bind(this),this._clientSessionId)}var r,i,a}},{key:"__innerInit",value:function(t,n,r,i,a,o){var s=this,c=Object.create(null,{__innerInit:{get:function(){return S(e,"__innerInit",s,1)}}});return F(this,void 0,void 0,E().m(function e(){var s,u,l;return E().w(function(e){for(;;)switch(e.n){case 0:if(ce("livingType",r,function(e){return e===Fc.AUDIO||e===Fc.VIDEO})){e.n=1;break}return this._logger.error(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> livingType"}),o),e.a(2,{code:Ae.PARAMS_ERROR});case 1:return e.n=2,c.__innerInit.call(this,t,n,r,i,a,o);case 2:return s=e.v,u=s.code,l=s.data,u===Ae.SUCCESS&&l&&this._initRoomPKHandler(l),e.a(2,{code:u,data:l})}},e,this)}))}},{key:"__innerInitByIdentityChange",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._invoker.push(new $c(this._livingType,e));case 1:return n=t.v,r=n.code,i=n.data,r===we&&i?(this._initRoomPKHandler(i),this._initWithRoomData(i.offlineKickTime),this._logger.info(Ne.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ke.SUCCESSED,roomData:i}),e)):this._logger.error(Ne.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ke.FAILED,code:r}),e),t.a(2,r)}},t,this)}))}},{key:"publish",value:function(t){var n=this,r=Object.create(null,{publish:{get:function(){return S(e,"publish",n,1)}}});return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)switch(e.n){case 0:if(this._store.isMainRoom){e.n=1;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ke.FAILED,code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),e.a(2,{code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM});case 1:return e.a(2,r.publish.call(this,t))}},e,this)}))}},{key:"unpublish",value:function(t){var n=this,r=Object.create(null,{unpublish:{get:function(){return S(e,"unpublish",n,1)}}});return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)switch(e.n){case 0:if(this._store.isMainRoom){e.n=1;break}return this._logger.error(Ne.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ke.FAILED,code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),e.a(2,{code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM});case 1:return e.a(2,r.unpublish.call(this,t))}},e,this)}))}},{key:"_isValidResourceId",value:function(e){var t,n,r=Fn(e).userId,i=!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find(function(t){return jn(t)===e})),a=this.getRoomPKHandler(),o=a.code,s=a.roomPKHandler;if(o!==Ae.SUCCESS||!s)return i;var c=s.getJoinedPKRooms(),u=[];return Object.values(c).forEach(function(e){u.push.apply(u,C(e.getRemoteTracks()))}),n=u.some(function(t){return e===t.getTrackId()}),i||n}},{key:"getLivingType",value:function(){return this._livingType}},{key:"getMCUConfigBuilder",value:function(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(Ne.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}},{key:"enableInnerCDN",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)if(0===t.n)return t.a(2,this._invoker.push(new Qc(this._mcuConfigBuilder.__innerGetValues(),e)))},t,this)}))}},{key:"_resourceHandle",value:function(t,n,r,i,a){var o=this,s=Object.create(null,{_resourceHandle:{get:function(){return S(e,"_resourceHandle",o,1)}}});return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)switch(e.n){case 0:s._resourceHandle.call(this,t,n,r,i,a);case 1:return e.a(2)}},e,this)}))}},{key:"__getCDNEnable",value:function(){var e;return!!(null===(e=this._store.getCDNUris())||void 0===e?void 0:e.enableInnerCDN)}},{key:"__getCDNPushMode",value:function(){var e;return null===(e=this._store.getCDNUris())||void 0===e?void 0:e.push_mode}},{key:"_onJoinedPKRoom",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)switch(n.n){case 0:this._invoker.push(new Yc(e,this._roomPKHandler,t));case 1:return n.a(2)}},n,this)}))}},{key:"_getPushOtherRoomsParams",value:function(){var e=[];if(!this.isMainRoom()||!this._roomPKHandler)return e;var t=this._roomPKHandler.getJoinedPKRooms();for(var n in t){var r=t[n].getSessionId(),i=this._roomPKHandler.getPKInfo(n);if(i){var a=i.inviterUserAutoMix,o=i.inviteeUserAutoMix,s=i.inviterUserId,c=this._context.getCurrentId()===s;e.push({roomId:n,sessionId:r,autoMix:c?!!a:!!o})}}return e}},{key:"getRoomPKHandler",value:function(){return this._store.isMainRoom?(this._logger.info(Ne.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:ke.SUCCESSED})),{code:Ae.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(Ne.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:ke.SUCCESSED,code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}},{key:"_quitAllPKRoom",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n;return E().w(function(e){for(;;)switch(e.n){case 0:for(n in t=this._roomPKHandler.getJoinedPKRooms())this._roomPKHandler.leaveOtherRoom(t[n]);this._logger.info(Ne.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:ke.SUCCESSED,roomIds:Object.keys(t)}));case 1:return e.a(2)}},e,this)}))}},{key:"isMainRoom",value:function(){return this._store.isMainRoom}}])}(),tu=function(){function e(t,n,r,i,a){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:ps.RTC,u=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return c(this,e),s(this,e,[t,n,r,o,i,a,!1,!1,Oo(),u])}return g(e,Gc),l(e)}(),nu=new(function(){return l(function e(){c(this,e),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"locked",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"taskCount",{enumerable:!0,configurable:!0,writable:!0,value:0})},[{key:"checkToStart",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i,a,o;return E().w(function(e){for(;;)switch(e.p=e.n){case 0:if(0!==this.queue.length&&!this.locked){e.n=1;break}return e.a(2);case 1:return this.locked=!0,t=this.queue.shift(),n=t.resolve,r=t.task,i=t.reject,e.p=2,e.n=3,r();case 3:a=e.v,n(a),e.n=5;break;case 4:e.p=4,o=e.v,i(o);case 5:this.locked=!1,this.checkToStart();case 6:return e.a(2)}},e,this,[[2,4]])}))}},{key:"push",value:function(e){var t=this,n=new Promise(function(n,r){t.queue.push({resolve:n,task:e,reject:r})});return this.checkToStart(),n}}])}()),ru=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return nu.push(e,t)},iu=function(){return l(function e(t,n,r){c(this,e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcToken",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_liveUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_subTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:Oo()}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_subTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_fromRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._crtUserId=this._context.getCurrentId(),this._service=new Do(n,t,r.mediaServer),this._logger=this._context.logger,this._store=new vs(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,ps.LIVE)},[{key:"_getReqHeaders",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._crtUserId,this._rtcToken){t.n=3;break}return t.n=1,this._context.getRTCToken(n,ps.LIVE,e);case 1:if(r=t.v,i=r.code,a=r.data,i===we){t.n=2;break}return t.a(2,{code:Ae.SIGNAL_ERROR});case 2:this._rtcToken=a.rtcToken;case 3:return t.a(2,{code:Ae.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:n,RoomType:ps.LIVE,Token:this._rtcToken,"Client-Session-Id":this._clientSessionId}})}},t,this)}))}},{key:"_clearSubscribeInfo",value:function(){var e;this._liveUrl="",this._livingType=null,this._mediaType=null,this._subTiny=!1,this._subTracks.length=0,null===(e=this._pc)||void 0===e||e.destroy(),this._pc=null}},{key:"_reTryExchange",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r;return E().w(function(e){for(;;)switch(e.n){case 0:return this._fromRetry=!0,e.n=1,this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);case 1:return n=e.v,(r=n.code)===Ae.SUCCESS&&(null===(t=this._pc)||void 0===t||t.clearReTryExchangeTimer()),e.a(2,{code:r})}},e,this)}))}},{key:"subscribe",value:function(e,t,n){return F(this,arguments,void 0,function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E().m(function a(){return E().w(function(a){for(;;)if(0===a.n)return a.a(2,ru(function(){return r.__subscribe(e,t,n,i)},"audience-client-sub"))},a)})()})}},{key:"__subscribe",value:function(e,t,n){return F(this,arguments,void 0,function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return E().m(function a(){var o,s,c,u,l,_,d,f,h,g,p,v,m,R;return E().w(function(a){for(;;)switch(a.n){case 0:if(r._logger.info(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:e,livingType:t,mediaType:n,subTiny:i})),s=[],!rr(r._context.getNaviInfo())){a.n=1;break}return r._logger.error(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),a.a(2,{code:Ae.PACKAGE_ENVIRONMENT_ERROR,tracks:s});case 1:if(!r._fromRetry&&(null===(o=r._pc)||void 0===o||o.clearReTryExchangeTimer()),r._fromRetry=!1,Y(e)){a.n=2;break}return r._logger.error(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> liveUrl: ".concat(e)})),a.a(2,{code:Ae.PARAMS_ERROR,tracks:s});case 2:if([Fc.AUDIO,Fc.VIDEO].includes(t)){a.n=3;break}return r._logger.error("livingType is invalid: ".concat(t)),r._logger.error(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> livingType: ".concat(t)})),a.a(2,{code:Ae.PARAMS_ERROR,tracks:s});case 3:if([nn.AUDIO_ONLY,nn.VIDEO_ONLY,nn.AUDIO_VIDEO].includes(n)){a.n=4;break}return r._logger.error(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> -> mediaType: ".concat(n)})),a.a(2,{code:Ae.PARAMS_ERROR,tracks:s});case 4:if(!r._liveUrl||r._liveUrl===e){a.n=5;break}return r._logger.error(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),a.a(2,{code:Ae.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:s});case 5:return r._pc||(r._pc=new os(r._context,r._logger,r._reTryExchange.bind(r),r._crtUserId,r._store,void 0,!1),r._pc.on(os.__INNER_EVENT_TRACK_READY__,r._onTrackReady,r),r._pc.registerReportListener(r._reportListener),r._pc.__reportR3R4ToPolaris()),r._liveUrl=e,a.n=6,r._getReqHeaders(t);case 6:if(c=a.v,u=c.code,l=c.headers,u===Ae.SUCCESS){a.n=7;break}return r._logger.error(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:u,msg:"getRTCToken failed"})),a.a(2,{code:u,tracks:s});case 7:return _="rc_mcu_".concat(Date.now()),d="RongCloudRTC",0===r._subTracks.length&&(r._subTracks.push(new Pn(r._logger,d,_),new Un(r._logger,d,_)),r._pc.updateSubRemoteTracks(r._subTracks.slice())),a.n=8,r._pc.createOffer(!0);case 8:return f=a.v,h={sdp:f,liveUrl:e,mediaType:n,simulcast:i?Uo.TINY:Uo.NORMAL,switchstream:!1},a.n=9,r._service.broadcastSubscribe(l,h);case 9:if((g=a.v).code===Ae.SUCCESS){a.n=10;break}return r._logger.error(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:g.code})),a.a(2,{code:g.code,tracks:s});case 10:if((p=g.data).resultCode===Ae.SUCCESS){a.n=11;break}return r._logger.error(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:p.resultCode,msg:p.message})),a.a(2,{code:p.resultCode,tracks:s});case 11:return r._livingType=t,r._mediaType=n,r._subTiny=i,v=p.sdp,m=p.subscribedList,r._subscribedList=m,R=[],m.forEach(function(e){var t=e.mediaType,n=r._subTracks[t];R.push(n),n.__innerSetRemoteMuted(!0)}),r._pc.setRemoteAnswer(v.sdp),R&&r._updateTrackIdSSRCMap(v.sdp,R),r._logger.info(Ne.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ke.SUCCESSED,liveUrl:e})),a.a(2,{code:Ae.SUCCESS,tracks:R})}},a)})()})}},{key:"_updateTrackIdSSRCMap",value:function(e,t){var n=this;t.forEach(function(t){var r=t.getTrackId(),i=Fn(r).mediaType,a=n._subscribedList.filter(function(e){return e.mediaType===i})[0].msid,o=ic(e,a,i);n._store.setTrackIdSSRCMap(Number(o),r)})}},{key:"unsubscribe",value:function(){return F(this,void 0,void 0,E().m(function e(){var t=this;return E().w(function(e){for(;;)if(0===e.n)return e.a(2,ru(function(){return t.__unsubscribe()},"audience-client-unsub"))},e)}))}},{key:"__unsubscribe",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i,a;return E().w(function(e){for(;;)switch(e.n){case 0:if(this._logger.info(Ne.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T,JSON.stringify({liveUrl:this._liveUrl})),null===(t=this._pc)||void 0===t||t.clearReTryExchangeTimer(),this._rtcToken&&this._liveUrl){e.n=1;break}return this._logger.warn(Ne.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),e.a(2,{code:Ae.SUCCESS});case 1:return e.n=2,this._getReqHeaders();case 2:return n=e.v,r=n.headers,e.n=3,this._service.broadcastExit(r);case 3:return i=e.v,(a=i.code)!==Ae.SUCCESS?this._logger.error(Ne.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:a})):(this._logger.info(Ne.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ke.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),e.a(2,{code:a})}},e,this)}))}},{key:"registerReportListener",value:function(e){this._reportListener=e}},{key:"registerTrackEventListener",value:function(e){this._appListener=e}},{key:"_onTrackReady",value:function(e){var t,n,r=e.receiver.track,i="audio"===r.kind?nn.AUDIO_ONLY:nn.VIDEO_ONLY,a=this._subTracks[i];a.__innerSetMediaStreamTrack(r);try{this._logger.info(Ne.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,"trackId: ".concat(a.getTrackId())),null===(n=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===n||n.call(t,a)}catch(e){this._logger.error(Ne.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}])}();!function(e){e.RTMP="rtmp",e.FLV="flv",e.HLS="hls"}(Zc||(Zc={})),function(e){e[e.NOT_HTTPS=0]="NOT_HTTPS",e[e.HTTPS=1]="HTTPS"}(Xc||(Xc={}));var au,ou=Object.assign(Object.assign({},qn(exports.NCCallVideoResolution.W176_H144)),{frameRate:Qn(exports.NCCallVideoFrameRate.FPS_15)}),su=function(){return l(function e(t,n,r,i,a,o){var s=this,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Oo();c(this,e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_joinResData",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_roomAnchorList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_roomRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_roomAnchorRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isPulling",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_pullTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger,this._crtUserId=this._context.getCurrentId(),this._polarisReport=new Lc(this._context,this._runtime,this._roomId,this,Rc.Audience),this._reportMediaActionLogger=new Sc(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new Do(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);var l=this._store=new vs(this._logger,u,t.getAppkey(),i,this._crtUserId,ps.LIVE),_=this._pc=new os(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,l,this._polarisReport,!0);this._audioLevelReport=new _s(this._store,_),_.on(os.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener(function(e){return F(s,void 0,void 0,E().m(function t(){var n,r,i,a;return E().w(function(t){for(;;)switch(t.n){case 0:n=this._context.decodeRtcNotify(e),r=n.time,i=n.type,a=n.roomId,1===i&&this._startPull(a,r);case 1:return t.a(2)}},t,this)}))}),this._setInitData()},[{key:"_startPull",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s;return E().w(function(n){for(;;)switch(n.n){case 0:if(!this._isPulling){n.n=1;break}return n.a(2);case 1:if(this._isPulling=!0,!(this._pullTime>t)){n.n=2;break}return this._isPulling=!1,n.a(2);case 2:return r=this._logger.createTraceId(),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,"pullTime: ".concat(this._pullTime),r),n.n=3,this._context.pullRTCRoomEntry(e);case 3:i=n.v,a=i.code,o=i.data,a===we&&(this._isPulling=!1,this._pullTime=(null==o?void 0:o.syncTime)||0,s=(null==o?void 0:o.kvEntries)||[],this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,"status: ".concat(ke.SUCCESSED,", kvEntries: ").concat(JSON.stringify(s)),r),this.singalDataChange(s,e,r)),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,"status: ".concat(ke.FAILED,", code: ").concat(a),r);case 4:return n.a(2)}},n,this)}))}},{key:"_setInitData",value:function(){var e=this,t=function(e,t,n){var r=t.filter(function(e){return"RC_RTC_SESSIONID"===e.key})[0],i=r?r.value:"",a=t.filter(function(e){return"RC_ANCHOR_LIST"===e.key}).map(function(e){return JSON.parse(e.value||"[]")})[0],o=t.filter(function(e){return e.key.includes("RC_RES_")}).map(function(e){return JSON.parse(e.value||"{}")}),s=o.length?JSON.parse(o[0].mcu_uris||"[]"):[],c=[];s.forEach(function(t){var r=t.mediaType,i=t.tag,a=r===nn.AUDIO_ONLY?new Pn(n,i,"",e):new Un(n,i,"",e);c.push(a)});var u=[],l=[];o.forEach(function(e){var t=JSON.parse(e.uris||"[]");u.push.apply(u,C(t)),t.forEach(function(e){var t=e.mediaType,r=e.tag,i=e.msid.split("_");i.pop();var a=i.join("_"),o=t===nn.AUDIO_ONLY?new Pn(n,r,a):new Un(n,r,a);l.push(o)})});var _=t.filter(function(e){return"RC_CDN"===e.key}).map(function(e){var t=JSON.parse(e.value||"[]");return JSON.parse(t.cdn_uris)[0]})[0];return{sessionId:i,remoteUserIds:a||[],remoteRTCUris:u,remoteMUCUris:s,remoteRTCTracks:l,remoteMCUTracks:c,remoteTracks:[].concat(l,c),CDNUris:_||{}}}(this._roomId,this._joinResData.kvEntries,this._logger),n=t.sessionId,r=t.remoteUserIds,i=t.remoteRTCUris,a=t.remoteMUCUris,o=t.remoteTracks,s=t.CDNUris;this._sessionId=n,this._roomAnchorList=r,o.forEach(function(t){e._remoteTracks[t.getTrackId()]=t}),this._CDNUris=s,i.forEach(function(t){var n=t.msid.split("_")[0];e._roomAnchorRes[n]?e._roomAnchorRes[n].push(t):e._roomAnchorRes[n]=[t];var r=JSON.parse(t.uri),i=r.ssrc,a=r.resourceId;e._store.setTrackIdSSRCMap(i,a)}),a.forEach(function(t){var n=t.mediaType,r=t.tag,i=[e._roomId,r,n].join("_");e._roomRes[i]=t;var a=JSON.parse(t.uri).ssrc;e._store.setTrackIdSSRCMap(a,i)}),i.forEach(function(t){var n=jn(t);e._roomRes[n]=t})}},{key:"_assertRoomDestroyed",value:function(){if(this._destroyed)return Ae.ROOM_HAS_BEEN_DESTROYED}},{key:"singalDataChange",value:function(e,t,n){var r,i=this;if(t===this._roomId){var a=[],o=null===(r=e.filter(function(e){return"RC_CDN"===e.key})[0])||void 0===r?void 0:r.value;o&&this._diffCDNUris(JSON.parse(JSON.parse(o).cdn_uris)[0],n),e.forEach(function(e){var t=e.key,r=e.value,o=e.uid;if(-1!==t.indexOf("RC_RES_")){var s=JSON.parse(r||"{}"),c=JSON.parse(s.mcu_uris||"[]"),u=JSON.parse(s.uris||"[]");return a.push.apply(a,C(c)),void i._diffAnchorResource(u,o,n)}if("RC_ANCHOR_LIST"===t){var l=JSON.parse(r||"[]");i._diffAnchorList(l,n)}}),this._diffRoomResource(a,n)}else this._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:ke.FAILED,msg:"roomId inconsistency -> params roomId:".concat(t,", current roomId:").concat(this._roomId)}),n)}},{key:"_diffAnchorList",value:function(e,t){var n=this,r=e.filter(function(e){return n._roomAnchorList.indexOf(e)<0}),i=this._roomAnchorList.filter(function(t){return e.indexOf(t)<0});r.length>0&&this._handleNewJoinedAnchor(r,t),i.length>0&&this._handleLeftedAnchor(i,t)}},{key:"_handleNewJoinedAnchor",value:function(e,t){var n;(n=this._roomAnchorList).push.apply(n,C(e)),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}},{key:"_handleLeftedAnchor",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i=this;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._roomAnchorList=this._roomAnchorList.filter(function(t){return!e.includes(t)}),r=[],e.forEach(function(e){r.push.apply(r,C(i.getRemoteTracksByUserId(e))),delete i._roomAnchorRes[e]}),!r.length){n.n=2;break}return n.n=1,this.unsubscribe(r);case 1:r.forEach(function(e){return delete i._remoteTracks[e.getTrackId()]});case 2:this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e);case 3:return n.a(2)}},n,this)}))}},{key:"_diffRoomResource",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o=this;return E().w(function(n){for(;;)switch(n.n){case 0:r=[],i=[],a=[],e.forEach(function(e){var t=jn(e),n=Fn(t),i=n.tag,s=n.mediaType,c=[o._roomId,i,s].join("_"),u=JSON.parse(e.uri).ssrc;if(o._store.setTrackIdSSRCMap(u,c),!o._remoteTracks[c]){var l=s===nn.AUDIO_ONLY?new Pn(o._logger,i,"",o._roomId):new Un(o._logger,i,"",o._roomId);r.push(l),o._remoteTracks[c]=l,o._roomRes[l.getTrackId()]=e}a.push(c)}),Object.keys(this._remoteTracks).forEach(function(e){a.indexOf(e)<0&&o._remoteTracks[e].isMCUTrack()&&i.push(o._remoteTracks[e])}),r.length>0&&(this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackPublish",trackIds:r.map(function(e){return e.getTrackId()})}),t),this._callAppListener("onTrackPublish",r)),i.length>0&&this._onUserUnpublish(i,"onTrackUnpublish",t);case 1:return n.a(2)}},n,this)}))}},{key:"_dealPublished",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l=this;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=e.map(jn),a=[],o=[],t.forEach(function(t){var n=jn(t),r=i.indexOf(n),s=Fn(n),c=s.userId,u=s.tag,_=s.mediaType,d=JSON.parse(t.uri).ssrc;l._store.setTrackIdSSRCMap(d,n),r>-1?e[r]=t:e.push(t);var f=l._remoteTracks[n];l._roomRes[n]=t,f?f.isSubscribed()&&a.push(f):(f=_===nn.AUDIO_ONLY?new Pn(l._logger,u,c):new Un(l._logger,u,c),l._remoteTracks[n]=f,o.push(f)),f.__innerSetRemoteMuted(0===t.state)}),!a.length){r.n=2;break}return s=a.map(function(e){return e.getTrackId()}),r.n=1,ru(function(){return l._subscribeHandle(a,!0)});case 1:c=r.v,(u=c.code)!==Ae.SUCCESS&&this._logger.error(Ne.L_RESUB_REPUB_RES_R,JSON.stringify({status:ke.FAILED,trackIds:s,code:u}));case 2:this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:o.map(function(e){return e.getTrackId()})}),n),this._callAppListener("onAnchorTrackPublish",o);case 3:return r.a(2)}},r,this)}))}},{key:"_dealUnpublished",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c=this;return E().w(function(r){for(;;)switch(r.n){case 0:for(i=t.map(jn),a=e.length-1;a>=0;a-=1)o=e[a],i.includes(jn(o))&&e.splice(a,1);return s=t.map(function(e){var t=jn(e);return c._remoteTracks[t]}),r.n=1,this._onUserUnpublish(s,"onAnchorTrackUnpublish",n);case 1:return r.a(2)}},r,this)}))}},{key:"_dealModified",value:function(e,t,n){var r,i=e.map(jn),a=_(t);try{for(a.s();!(r=a.n()).done;){var o=r.value,s=jn(o);e[i.indexOf(s)].state=o.state;var c=this._remoteTracks[s];c.__innerSetRemoteMuted(0===o.state);var u=c.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:u,trackId:c.getTrackId()}),n),this._callAppListener(u,c)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_diffAnchorResource",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),a=Kn(i,e),o=a.publishedList,s=a.unpublishedList,c=a.modifiedList,!o.length){r.n=1;break}return r.n=1,this._dealPublished(i,o,n);case 1:if(!s.length){r.n=2;break}return r.n=2,this._dealUnpublished(i,s,n);case 2:c.length&&this._dealModified(i,c,n);case 3:return r.a(2)}},r,this)}))}},{key:"_onUserUnpublish",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i=this;return E().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,this.unsubscribe(e);case 1:e.forEach(function(e){i._subscribedList=i._subscribedList.filter(function(t){return t.track.getTrackId()!==e.getTrackId()}),delete i._roomRes[e.getTrackId()],e.__innerDestroy(),delete i._remoteTracks[e.getTrackId()]}),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:t,trackIds:e.map(function(e){return e.getTrackId()})}),n),this._callAppListener(t,e);case 2:return r.a(2)}},r,this)}))}},{key:"_callAppListener",value:function(e){var t,n=null===(t=this._appListener)||void 0===t?void 0:t[e];if(n)try{for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];n.apply(void 0,i)}catch(e){this._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}},{key:"_reTryExchange",value:function(){return F(this,void 0,void 0,E().m(function e(){var t=this;return E().w(function(e){for(;;)if(0===e.n)return e.a(2,ru(function(){return F(t,void 0,void 0,E().m(function e(){var t,n,r,i,a,o,s,c,u,l,_,d;return E().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this._createSubscribeParams(this._subscribedList,{},!0);case 1:return n=e.v,r=n.reqBody,e.n=2,this._exchangeHandle(r);case 2:if((i=e.v).code===Ae.SUCCESS){e.n=3;break}return e.a(2,{code:i.code});case 3:if(a=i.data,o=a.sdp,(s=a.resultCode)===Ae.SUCCESS){e.n=4;break}return e.a(2,{code:s});case 4:return this._pc.clearReTryExchangeTimer(),(c=this._subscribedList.filter(function(e){return e.track.isMCUTrack()})).length>0&&(u=c[0].track.getTrackId(),l=null===(t=this._roomRes[u])||void 0===t?void 0:t.msid,_=[this._roomId,"RongCloudRTC"].join("_"),o.sdp=o.sdp.replace(new RegExp(l,"g"),_)),e.n=5,this._pc.setRemoteAnswer(o.sdp);case 5:return d=e.v,e.a(2,{code:d})}},e,this)}))},"audience-retry-exchange"))},e)}))}},{key:"_createSubscribeParams",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c=this;return E().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,this._pc.createOffer(n);case 1:return i=r.v,a={resolutionInfo:[]},o={min:0,max:0},Object.keys(t).forEach(function(e){var n=t[e];[n.mediaStream,n.tinyStream].forEach(function(t,n){var r,s=1===n?[e,"tiny"].join("_"):e;i.sdp=null===(r=i.sdp)||void 0===r?void 0:r.replace(new RegExp(t.id,"g"),s);var c=t.getVideoTracks()[0];if(c){var u=0===n,l=u?Bn(c):ou,_=l.width,d=l.height,f=l.frameRate;a.resolutionInfo.push({trackId:c.id,simulcast:u?Uo.NORMAL:Uo.TINY,resolution:"".concat(_,"x").concat(d)});var h=cn(_,d),g=ln(f);o.min+=h.minBitrate*g,o.max+=h.maxBitrate*g}})}),s={sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map(function(e){return{simulcast:e.subTiny?Uo.TINY:Uo.NORMAL,resolution:"",uri:c._roomRes[e.track.getTrackId()].uri}})},r.a(2,{reqBody:s,dynamicBitrate:o,offer:i})}},r,this)}))}},{key:"_subscribeHandle",value:function(e){return F(this,arguments,void 0,function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return E().m(function i(){var a,o,s,c,u,l;return E().w(function(i){for(;;)switch(i.n){case 0:if(a=Date.now(),o=r?Bs.SUB:void 0,s=t._logger.createTraceId(),t._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:e.map(sr),forceReq:n}),s),!t._assertRoomDestroyed()){i.n=1;break}return t._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),s),t._reportPubOrSubQualityData(a,e,Ae.ROOM_HAS_BEEN_DESTROYED,o),i.a(2,{code:Ae.ROOM_HAS_BEEN_DESTROYED});case 1:if(ce("tracks",e,function(){return z(e)&&e.length>0&&e.every(function(e){return e instanceof kn||e.track instanceof kn})},!0)){i.n=2;break}return t._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> tracks"}),s),t._reportPubOrSubQualityData(a,e,Ae.PARAMS_ERROR,o),i.a(2,{code:Ae.PARAMS_ERROR});case 2:return t._pc.__reportR3R4ToPolaris(),t._pc.registerReportListener(t._reportListener),t._addPeerCEvent(),c=t._subscribedList.map(function(e){return Object.assign({},e)}),u=e.map(function(e){return e instanceof kn?{track:e}:e}),l=[],u.forEach(function(e){var t=e.track.getTrackId();l.push(t);var n=c.find(function(e){return e.track.getTrackId()===t});n&&n.subTiny===e.subTiny||(n?n.subTiny=e.subTiny:c.push(e))}),t._polarisReport.sendR2(Is.SUBSCRIBE,Ss.BEGIN,l),i.a(2,t._updateSubListHandle(c,s,a,o,!0))}},i)})()})}},{key:"_addPeerCEvent",value:function(){var e=this;this._pc.on(os.__INNER_EVENT_TRACK_READY__,function(t){var n=t.streams[0].id,r=t.receiver.track,i=[n,"audio"===r.kind?nn.AUDIO_ONLY:nn.VIDEO_ONLY].join("_"),a=e._remoteTracks[i];a?(a.__innerSetMediaStreamTrack(r),e._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:a.getTrackId()})),e._callAppListener("onTrackReady",a)):e._logger.warn(Ne.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,"cannot found RCRemoteTrack: ".concat(r.id))}),this._pc.once(os.__INNER_ICE_CONNECTED__,function(){e._reportMediaActionLogger.reportIceFirstConnectData("sub")},this),this._pc.on(os.__INNER_ICE_STATE_CHANGE__,function(t){var n=t.status,r=t.time,i=t.iceCandidatePair;i&&e._reportMediaActionLogger.recordQualityIceStatusData(i,n,r)})}},{key:"_getReqHeaders",value:function(){var e=this._crtUserId;return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:ps.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}},{key:"_exchangeHandle",value:function(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}},{key:"_dealSubscribeResult",value:function(e,t,n){var r,i=this,a=null==t?void 0:t.map(function(e){return"".concat(e.msid,"_").concat(e.mediaType)}),o=e.filter(function(e){if(e.track.isMCUTrack()){var t=i._roomRes[e.track.getTrackId()],n="".concat(t.msid,"_").concat(t.mediaType);return a.includes(n)}return null==a?void 0:a.includes(e.track.getTrackId())}),s=null==o?void 0:o.map(function(e){return"".concat(e.track.getTrackId())}),c=e.filter(function(e){return!(null==s?void 0:s.includes(e.track.getTrackId()))}),u=function(e){var t=o.some(function(t){return t.track.getTrackId()===e});i._remoteTracks[e].__innerSetSubscribed(t)};for(var l in this._remoteTracks)u(l);return(r=this._subscribedList).splice.apply(r,[0,this._subscribedList.length].concat(C(o))),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ke.SUCCESSED,subSuccessTrackIds:a,failedList:c}),n),c}},{key:"_getParams",value:function(e){var t=e.map(function(e){return e instanceof kn?{track:e}:Object.assign({},e)}),n={};return t=t.filter(function(e){var t=e.track.getTrackId();return!n[t]&&(n[t]=!0,!0)}).map(function(e){return Object.assign({},e)})}},{key:"_reportPubOrSubQualityData",value:function(e,t,n,r){r&&this._reportMediaActionLogger.reportPubOrSubQualityData(r,e,t,n,this._trackMediaMap)}},{key:"_updateSubListHandle",value:function(e,t,n,r){return F(this,arguments,void 0,function(e,t,n,r){var i=this,a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return E().m(function o(){var s,c,u,l,_,d,f,h,g,p,v,m,R,T;return E().w(function(o){for(;;)switch(o.n){case 0:if(i._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(sr),forceReq:a}),t),c=i._getParams(e),u=i._subscribedList.map(function(e){return Object.assign({},e)}),a||ac(c,u)){o.n=1;break}return i._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ke.SUCCESSED,msg:"repeat subscribe"}),t),o.a(2,{code:Ae.SUCCESS});case 1:return i._pc.clearReTryExchangeTimer(),i._pc.updateSubRemoteTracks(c.map(function(e){return e.track})),o.n=2,i._createSubscribeParams(c,{},!1);case 2:return l=o.v,_=l.reqBody,o.n=3,i._exchangeHandle(_);case 3:if(d=o.v,u.length&&(f=[],u.forEach(function(e){f.push(e.track.getTrackId())}),null===(s=i._pc.reportParser)||void 0===s||s.clearLatestPacketsRecv(f)),e.forEach(function(e){var t=e instanceof kn?e.getTrackId():e.track.getTrackId();i._trackMediaMap[t]=d.qualityMsList||[]}),d.code===Ae.SUCCESS){o.n=4;break}return i._reportPubOrSubQualityData(n,e,d.code,r),i._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ke.FAILED,code:d.code}),t),o.a(2,{code:d.code});case 4:if(h=d.data,g=h.sdp,p=h.resultCode,v=h.message,m=h.subscribedList,p===Ae.SUCCESS){o.n=5;break}return i._reportPubOrSubQualityData(n,e,p,r),i._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ke.FAILED,code:p,msg:v}),t),o.a(2,{code:p});case 5:return c.forEach(function(e){var t=e.track;if(t.isMCUTrack()){var n=i._roomRes[t.getTrackId()].msid,r=Fn(t.getTrackId()),a=r.tag,o=[r.userId,a].join("_");g.sdp=g.sdp.replace(new RegExp(n,"g"),o)}}),o.n=6,i._pc.setRemoteAnswer(g.sdp);case 6:if(R=o.v,i._reportPubOrSubQualityData(n,e,R,r),R===Ae.SUCCESS){o.n=7;break}return i._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ke.FAILED,code:R,msg:"set remote answer error"}),t),o.a(2,{code:R});case 7:return T=i._dealSubscribeResult(c,m,t),o.a(2,T.length?{code:Ae.SUCCESS,failedList:T}:{code:Ae.SUCCESS})}},o)})()})}},{key:"_diffCDNUris",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:if(!this._CDNUris.url||e.url){n.n=1;break}return this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoDisable"}),t),this._callAppListener("onCDNInfoDisable"),this._CDNUris=e,n.a(2);case 1:(!this._CDNUris||!this._CDNUris.url&&e.url)&&(this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoEnable",resolution:"W".concat(e.w,"_H").concat(e.h),fps:"FPS_".concat(e.fps)}),t),this._callAppListener("onCDNInfoEnable",{resolution:"W".concat(e.w,"_H").concat(e.h),fps:"FPS_".concat(e.fps)})),r=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,i=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,a=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps,(r||i||a)&&(this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoChange",resolution:"W".concat(e.w,"_H").concat(e.h),fps:"FPS_".concat(e.fps)}),t),this._callAppListener("onCDNInfoChange",{resolution:"W".concat(e.w,"_H").concat(e.h),fps:"FPS_".concat(e.fps)})),this._CDNUris=e;case 2:return n.a(2)}},n,this)}))}},{key:"_getCDNPlayUrl",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f,h,g,p,v,m;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=e.w,i=e.h,a=e.fps,o=this._initOptions.pullInnerCDNProtocol||Zc.FLV,s=this._initOptions.pullInnerCDNUseHttps===Xc.NOT_HTTPS?Xc.NOT_HTTPS:Xc.HTTPS,this._CDNUris.url){n.n=1;break}return this._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ke.FAILED,code:Ae.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),n.a(2,{code:Ae.CDN_RESOURCE_IS_EMPTY});case 1:return c={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},u=[],l=this._CDNUris,_=l.w,d=void 0===_?0:_,f=l.h,d/(void 0===f?1:f)>1?(r&&u.push("w=".concat(r)),i&&u.push("h=".concat(i))):(r&&u.push("h=".concat(r)),i&&u.push("w=".concat(i))),a&&u.push("fps=".concat(a)),u.push("kind=".concat(o)),u.push("is_https=".concat(s)),h=u.join("&"),g="".concat(this._CDNUris.url,"?"),h&&(g+=h),n.n=2,this._service.getCDNResourceInfo(c,g,t);case 2:if(p=n.v,v=p.code,m=p.res,v===Ae.SUCCESS){n.n=3;break}return n.a(2,{code:v});case 3:return n.a(2,{code:v,CDNPlayUrl:null==m?void 0:m.data.pull_url})}},n,this)}))}},{key:"getCDNPlayUrl",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),r),!e||Wn(e)){n.n=1;break}return this._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> resolution"}),r),n.a(2,{code:Ae.PARAMS_ERROR});case 1:if(!t||zn(t)){n.n=2;break}return this._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> fps"}),r),n.a(2,{code:Ae.PARAMS_ERROR});case 2:return i=e?qn(e):{width:null,height:null},a=i.width,o=i.height,s=t?Qn(t):null,c={},a&&(c.w=a),o&&(c.h=o),s&&(c.fps=s),n.a(2,this._getCDNPlayUrl(c,r))}},n,this)}))}},{key:"subscribe",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n=this;return E().w(function(t){for(;;)if(0===t.n)return t.a(2,ru(function(){return n._subscribeHandle(e,!1,!0)},"audience-sub"))},t)}))}},{key:"__unsubscribe",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=Date.now(),r=Bs.UNSUB,i=this._logger.createTraceId(),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(function(e){return e.getTrackId()})}),i),!this._assertRoomDestroyed()){t.n=1;break}return this._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),i),t.a(2,{code:Ae.ROOM_HAS_BEEN_DESTROYED});case 1:if(ce("tracks",e,function(){return z(e)&&e.length>0&&e.every(function(e){return e instanceof kn})},!0)){t.n=2;break}return this._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> tracks"}),i),t.a(2,{code:Ae.PARAMS_ERROR});case 2:return a=this._subscribedList.map(function(e){return Object.assign({},e)}).filter(function(t){return e.every(function(e){return e.getTrackId()!==t.track.getTrackId()})}),this._polarisReport.sendR2(Is.SUBSCRIBE,Ss.END,e.map(function(e){return e.getTrackId()})),t.a(2,this._updateSubListHandle(a,i,n,r,!1))}},t,this)}))}},{key:"unsubscribe",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n=this;return E().w(function(t){for(;;)if(0===t.n)return t.a(2,ru(function(){return n.__unsubscribe(e)},"audience-unsub"))},t)}))}},{key:"__destroy",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)switch(t.n){case 0:if(!this._destroyed){t.n=1;break}return t.a(2);case 1:if(this._destroyed=!0,!e){t.n=2;break}return t.n=2,this._context.quitLivingRoomAsAudience(this._roomId);case 2:return t.n=3,this._service.broadcastExit(this._getReqHeaders());case 3:null===(n=this._pc)||void 0===n||n.destroy(),this._context.registerRTCSignalListener();case 4:return t.a(2)}},t,this)}))}},{key:"getRemoteTrack",value:function(e){return this._remoteTracks[e]}},{key:"getLocalTrack",value:function(e){return{}}},{key:"__onReconnected",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n;return E().w(function(e){for(;;)switch(e.n){case 0:return t=this._logger.createTraceId(),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,t),e.n=1,this._context.joinLivingRoomAsAudience(this._roomId,ps.LIVE);case 1:n=e.v,n.code!==we&&this._logger.error(Ne.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,"status: ".concat(ke.FAILED),t),this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,"status: ".concat(ke.SUCCESSED),t);case 2:return e.a(2)}},e,this)}))}},{key:"registerRoomEventListener",value:function(e){this._appListener=e}},{key:"onAudioLevelChange",value:function(e,t){this._logger.info(Ne.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O),this._audioLevelReport.onAudioLevelChange(e)}},{key:"registerReportListener",value:function(e){this._reportListener=e}},{key:"getRoomId",value:function(){return this._roomId}},{key:"getCrtUserId",value:function(){return this._crtUserId}},{key:"getSessionId",value:function(){return this._sessionId}},{key:"getRemoteUserIds",value:function(){return this._roomAnchorList}},{key:"getRemoteTracksByUserId",value:function(e){var t=[];for(var n in this._remoteTracks){var r=this._remoteTracks[n];r.getUserId()===e&&t.push(r)}return t}},{key:"getRemoteTracks",value:function(){var e=this,t=[],n=[];for(var r in this._remoteTracks){if(2===n.length)break;var i=this._remoteTracks[r];i.isMCUTrack()&&n.push(i)}return this._roomAnchorList.forEach(function(n){t.push.apply(t,C(e.getRemoteTracksByUserId(n)))}),[].concat(n,t)}},{key:"getRemoteRTCTracks",value:function(){var e=[];for(var t in this._remoteTracks){var n=this._remoteTracks[t];n.isMCUTrack()||e.push(n)}return e}},{key:"getRemoteMCUTracks",value:function(){var e=[];for(var t in this._remoteTracks){var n=this._remoteTracks[t];n.isMCUTrack()&&e.push(n)}return e}},{key:"getCDNInfo",value:function(){return this._CDNUris.w?{resolution:"W".concat(this._CDNUris.w,"_H").concat(this._CDNUris.h),fps:"FPS_".concat(this._CDNUris.fps),CDNEnable:this._CDNUris.enableInnerCDN}:{CDNEnable:!1}}},{key:"getClientSessionId",value:function(){return this._clientSessionId}}])}();!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}(au||(au={}));var cu,uu,lu=function(){function e(t){c(this,e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isElectron",{enumerable:!0,configurable:!0,writable:!0,value:/Electron/.test(navigator.userAgent)}),this._logger=t.logger}return l(e,[{key:"_getMediaStream",value:function(e){return F(this,arguments,void 0,function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"getUserMedia";return E().m(function r(){var i,a,o;return E().w(function(r){for(;;)switch(r.p=r.n){case 0:return r.p=0,i=t.setConstraintsConfig(e),r.n=1,navigator.mediaDevices[n](i);case 1:return a=r.v,r.a(2,{code:Ae.SUCCESS,stream:a});case 2:if(r.p=2,o=r.v,t._logger.error(Ne.L_GET_MEDIA_STREAM_E,JSON.stringify({name:o.name,message:o.message})),"Permission denied"!==o.message){r.n=3;break}return r.a(2,{code:Ae.BROWSER_PERMISSION_DENIED});case 3:if("Permission denied by system"!==o.message){r.n=4;break}return r.a(2,{code:Ae.SYSTEM_PERMISSION_DENIED});case 4:return r.a(2,{code:"getUserMedia"===n?Ae.GET_USER_MEDIA_FAILED:Ae.GET_DISPLAY_MEDIA_FAILED})}},r,null,[[0,2]])})()})}},{key:"_getMediaStreamErrorReason",value:function(e){var t="";return e===Ae.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===Ae.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}},{key:"setConstraintsConfig",value:function(e){var t,n;if((null==e?void 0:e.audio)&&!this._isElectron){"boolean"==typeof e.audio&&(e.audio={});var r=null===(n=(t=navigator.mediaDevices).getSupportedConstraints)||void 0===n?void 0:n.call(t);(null==r?void 0:r.noiseSuppression)&&(e.audio.noiseSuppression=!!r.noiseSuppression),(null==r?void 0:r.autoGainControl)&&(e.audio.autoGainControl=!!r.autoGainControl),(null==r?void 0:r.echoCancellation)&&(e.audio.echoCancellation=!!r.echoCancellation),this._logger.info(Ne.L_SET_AUDIO_CONSTRAINTS_O,"browser supported -> ".concat(JSON.stringify(r)))}return e}},{key:"createMicrophoneAudioTrack",value:function(){return F(this,arguments,void 0,function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"RongCloudRTC",n=arguments.length>1?arguments[1]:void 0;return E().m(function r(){var i,a,o,s,c,u;return E().w(function(r){for(;;)switch(r.n){case 0:if(xn(t)){r.n=1;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_TAGS,msg:"invalid tag"})),r.a(2,{code:Ae.INVALID_TAGS});case 1:if(i=e._context.getCurrentId()){r.n=2;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),r.a(2,{code:Ae.INVALID_USER_ID});case 2:return r.n=3,e._getMediaStream({audio:{deviceId:(null==n?void 0:n.micphoneId)?{exact:null==n?void 0:n.micphoneId}:void 0,sampleRate:null==n?void 0:n.sampleRate,noiseSuppression:null==n?void 0:n.noiseSuppression,echoCancellation:null==n?void 0:n.echoCancellation,autoGainControl:null==n?void 0:n.autoGainControl}});case 3:if(a=r.v,o=a.stream,(s=a.code)===Ae.SUCCESS){r.n=4;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ke.FAILED,code:s,msg:e._getMediaStreamErrorReason(s)})),r.a(2,{code:s});case 4:return c=o.getAudioTracks()[0],u=new yn(e._logger,t,i,c),e._logger.info(Ne.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ke.SUCCESSED,trackId:u.getTrackId()})),r.a(2,{code:s,track:u})}},r)})()})}},{key:"createCameraVideoTrack",value:function(){return F(this,arguments,void 0,function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"RongCloudRTC",n=arguments.length>1?arguments[1]:void 0;return E().m(function r(){var i,a,o,s,c,u,l,_,d,f;return E().w(function(r){for(;;)switch(r.n){case 0:if(xn(t)){r.n=1;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_TAGS,msg:"invalid tag"})),r.a(2,{code:Ae.INVALID_TAGS});case 1:if(i=e._context.getCurrentId()){r.n=2;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),r.a(2,{code:Ae.INVALID_USER_ID});case 2:return a=Wn(null==n?void 0:n.resolution)?n.resolution:exports.NCCallVideoResolution.W640_H480,o=qn(a),s=o.width,c=o.height,r.n=3,e._getMediaStream({video:{deviceId:(null==n?void 0:n.cameraId)?{exact:null==n?void 0:n.cameraId}:void 0,frameRate:Qn((null==n?void 0:n.frameRate)||exports.NCCallVideoFrameRate.FPS_15),width:{ideal:s,max:s},height:{ideal:c,max:c},facingMode:null==n?void 0:n.faceMode}});case 3:if(u=r.v,l=u.stream,(_=u.code)===Ae.SUCCESS){r.n=4;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,code:_,msg:e._getMediaStreamErrorReason(_)})),r.a(2,{code:_});case 4:return d=l.getVideoTracks()[0],r.n=5,e._applyVideoAspectRatio(d,s,c);case 5:return f=new bn(e._logger,t,i,d),e._logger.info(Ne.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ke.SUCCESSED,trackId:f.getTrackId()})),r.a(2,{code:_,track:f})}},r)})()})}},{key:"createMicrophoneAndCameraTracks",value:function(){return F(this,arguments,void 0,function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"RongCloudRTC",n=arguments.length>1?arguments[1]:void 0;return E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h,g,p,v,m;return E().w(function(r){for(;;)switch(r.n){case 0:if(a=[],xn(t)){r.n=1;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_TAGS,msg:"invalid tag"})),r.a(2,{code:Ae.INVALID_TAGS,tracks:a});case 1:if(o=e._context.getCurrentId()){r.n=2;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),r.a(2,{code:Ae.INVALID_USER_ID,tracks:a});case 2:return s=Wn(null===(i=null==n?void 0:n.video)||void 0===i?void 0:i.resolution)?n.video.resolution:exports.NCCallVideoResolution.W640_H480,c=qn(s),u=c.width,l=c.height,_=null==n?void 0:n.audio,d=null==n?void 0:n.video,r.n=3,e._getMediaStream({video:{deviceId:(null==d?void 0:d.cameraId)?{exact:null==d?void 0:d.cameraId}:void 0,frameRate:Qn((null==d?void 0:d.frameRate)||exports.NCCallVideoFrameRate.FPS_15),width:{ideal:u,max:u},height:{ideal:l,max:l},facingMode:null==d?void 0:d.faceMode},audio:{deviceId:(null==_?void 0:_.micphoneId)?{exact:null==_?void 0:_.micphoneId}:void 0,sampleRate:null==_?void 0:_.sampleRate,noiseSuppression:null==_?void 0:_.noiseSuppression,echoCancellation:null==_?void 0:_.echoCancellation,autoGainControl:null==_?void 0:_.autoGainControl}});case 3:if(f=r.v,h=f.stream,(g=f.code)===Ae.SUCCESS){r.n=4;break}return e._logger.error(Ne.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ke.FAILED,code:g,msg:e._getMediaStreamErrorReason(g)})),r.a(2,{code:g,tracks:a});case 4:p=h.getTracks(),v=0;case 5:if(!(v<p.length)){r.n=9;break}if("video"!==(m=p[v]).kind){r.n=7;break}return r.n=6,e._applyVideoAspectRatio(m,u,l);case 6:a.push(new bn(e._logger,t,o,m)),r.n=8;break;case 7:a.unshift(new yn(e._logger,t,o,m));case 8:v++,r.n=5;break;case 9:return e._logger.info(Ne.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ke.SUCCESSED,trackIds:a.map(function(e){return e.getTrackId()})})),r.a(2,{code:g,tracks:a})}},r)})()})}},{key:"createScreenVideoTrack",value:function(){return F(this,arguments,void 0,function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"screenshare",n=arguments.length>1?arguments[1]:void 0;return E().m(function r(){var i;return E().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,e._createScreenTracks(t,!1,Ne.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,n);case 1:if((i=r.v).code!==Ae.SUCCESS){r.n=2;break}return r.a(2,{code:i.code,track:i.tracks[0]});case 2:return r.a(2,i)}},r)})()})}},{key:"createScreenWithAudioTracks",value:function(){return F(this,arguments,void 0,function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"screenshare",n=arguments.length>1?arguments[1]:void 0;return E().m(function r(){return E().w(function(r){for(;;)if(0===r.n)return r.a(2,e._createScreenTracks(t,!0,Ne.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,n))},r)})()})}},{key:"_createScreenTracks",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l,_,d,f,h,g,p;return E().w(function(i){for(;;)switch(i.n){case 0:if(xn(e)){i.n=1;break}return this._logger.error(n,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_TAGS,msg:"invalid tag"})),i.a(2,{code:Ae.INVALID_TAGS});case 1:if(a=this._context.getCurrentId()){i.n=2;break}return this._logger.error(n,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),i.a(2,{code:Ae.INVALID_USER_ID});case 2:if($n()){i.n=3;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.BROWSER_NOT_SUPPORT,msg:"browser not support"})),i.a(2,{code:Ae.BROWSER_NOT_SUPPORT});case 3:if(o=/macintosh|mac os x/i.test(navigator.userAgent),s=(!this._isElectron||!o)&&t,c=Wn(null==r?void 0:r.resolution)?r.resolution:exports.NCCallVideoResolution.W1280_H720,!this._isElectron){i.n=5;break}return i.n=4,this._createElectronScreenStream(t,n,c,null==r?void 0:r.chromeMediaSourceId);case 4:p=i.v,i.n=7;break;case 5:return i.n=6,this._createWebScreenStream(t,c,null==r?void 0:r.frameRate);case 6:p=i.v;case 7:if(l=(u=p).stream,(_=u.code)===Ae.SUCCESS){i.n=8;break}return this._logger.error(n,JSON.stringify({status:ke.FAILED,code:_,msg:this._getMediaStreamErrorReason(_)})),i.a(2,{code:_});case 8:return d=l.getVideoTracks()[0],f=new An(this._logger,e,a,d),h=[f],s&&(g=l.getAudioTracks()[0])&&h.push(new Nn(this._logger,e,a,g)),this._logger.info(n,JSON.stringify({status:ke.SUCCESSED,trackIds:h.map(function(e){return e.getTrackId()})})),i.a(2,{code:_,tracks:h})}},i,this)}))}},{key:"_createElectronScreenStream",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l,_,d,f;return E().w(function(i){for(;;)switch(i.n){case 0:if(s=/macintosh|mac os x/i.test(navigator.userAgent),this._isElectron&&s&&e&&this._logger.warn(t,JSON.stringify({status:ke.INFO,code:Ae.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"})),c=(!this._isElectron||!s)&&e,!this._isElectron||ee(r)||Y(r)){i.n=1;break}return this._logger.error(t,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),i.a(2,{code:Ae.PARAMS_ERROR});case 1:return u=qn(n),l=u.width,_=u.height,d={mandatory:{chromeMediaSourceId:r,chromeMediaSource:"desktop",minWidth:l,maxWidth:l,minHeight:_,maxHeight:_}},!r&&this._isElectron&&(null===(a=d.mandatory)||void 0===a||delete a.chromeMediaSourceId),f=null,c&&this._isElectron&&(null===(o=d.mandatory)||void 0===o||delete o.chromeMediaSourceId,f={mandatory:{chromeMediaSource:"desktop"}}),i.a(2,this._getMediaStream({video:d,audio:f||c},"getUserMedia"))}},i,this)}))}},{key:"_createWebScreenStream",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s;return E().w(function(r){for(;;)if(0===r.n)return i=qn(t),a=i.width,o=i.height,s={frameRate:Qn(n||exports.NCCallVideoFrameRate.FPS_15),width:a,height:o},r.a(2,this._getMediaStream({video:s,audio:e},"getDisplayMedia"))},r,this)}))}},{key:"createLocalAudioTrack",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:if(xn(e)){n.n=1;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_TAGS,msg:"invalid tag"})),n.a(2,{code:Ae.INVALID_TAGS});case 1:if(t&&"[object MediaStreamTrack]"===t.toString()&&"audio"===t.kind){n.n=2;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),n.a(2,{code:Ae.CREATE_CUSTOM_TRACK_FAILED});case 2:if(r=this._context.getCurrentId()){n.n=3;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),n.a(2,{code:Ae.INVALID_USER_ID});case 3:return i=new Tn(this._logger,e,r,t),this._logger.info(Ne.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ke.SUCCESSED,trackId:i.getTrackId()})),n.a(2,{code:Ae.SUCCESS,track:i})}},n,this)}))}},{key:"createLocalVideoTrack",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:if(xn(e)){n.n=1;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_TAGS,msg:"invalid tag"})),n.a(2,{code:Ae.INVALID_TAGS});case 1:if(t&&t instanceof MediaStreamTrack&&"video"===t.kind){n.n=2;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),n.a(2,{code:Ae.CREATE_CUSTOM_TRACK_FAILED});case 2:if(r=this._context.getCurrentId()){n.n=3;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),n.a(2,{code:Ae.INVALID_USER_ID});case 3:return i=new In(this._logger,e,r,t),this._logger.info(Ne.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ke.SUCCESSED,trackId:i.getTrackId()})),n.a(2,{code:Ae.SUCCESS,track:i})}},n,this)}))}},{key:"_validateCreateLocalFileTracks",value:function(e,t){if(!xn(e))return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_TAGS,msg:"invalid tag"})),{code:Ae.INVALID_TAGS,tracks:[]};if(!Xn())return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:Ae.BROWSER_NOT_SUPPORT,tracks:[]};var n=t instanceof File?URL.createObjectURL(t):t;return te(n)||/^blob:/.test(n)?this._context.getCurrentId()?{code:Ae.SUCCESS,tracks:[],url:n}:(this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:Ae.INVALID_USER_ID,tracks:[]}):(this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> file"})),{code:Ae.PARAMS_ERROR,tracks:[]})}},{key:"createLocalFileTracks",value:function(t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s=this;return E().w(function(i){for(;;)switch(i.n){case 0:if((a=this._validateCreateLocalFileTracks(t,n)).code===Ae.SUCCESS){i.n=1;break}return i.a(2,a);case 1:return o=this._context.getCurrentId(),i.a(2,new Promise(function(n){var i=document.createElement("video");(null==r?void 0:r.withoutAudio)&&(i.muted=!0),i.onloadedmetadata=function(){var a,c=[];try{var u=i.mozCaptureStream?"mozCaptureStream":"captureStream";a=i[u]()}catch(e){s._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.CREATE_FILE_TRACK_FAILED,msg:"captureSteam error -> ".concat(JSON.stringify(e))})),n({code:Ae.CREATE_FILE_TRACK_FAILED,tracks:c})}var l=I(e.getTracksWithOptions(a,r),2),_=l[0],d=l[1];_&&c.push(new On(s._logger,t,o,_,i)),d&&c.push(new Ln(s._logger,t,o,d,i)),0===c.length&&(i.pause(),i.src=""),i.onerror=null,s._logger.info(Ne.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ke.SUCCESSED,trackIds:c.map(function(e){return e.getTrackId()})})),n({code:Ae.SUCCESS,tracks:c})},i.onerror=function(){s._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),n({code:Ae.CREATE_FILE_TRACK_FAILED,tracks:[]})},i.src=a.url,i.loop=!0,i.play()}))}},i,this)}))}},{key:"createLocalTracks",value:function(t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l;return E().w(function(i){for(;;)switch(i.n){case 0:if(a=[],xn(t)){i.n=1;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_TAGS,msg:"invalid tag"})),i.a(2,{code:Ae.INVALID_TAGS,tracks:a});case 1:if(n instanceof MediaStream){i.n=2;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> stream"})),i.a(2,{code:Ae.PARAMS_ERROR,tracks:a});case 2:if(o=this._context.getCurrentId()){i.n=3;break}return this._logger.error(Ne.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ke.FAILED,code:Ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),i.a(2,{code:Ae.INVALID_USER_ID,tracks:a});case 3:return s=e.getTracksWithOptions(n,r),c=I(s,2),u=c[0],l=c[1],u&&a.push(new Tn(this._logger,t,o,u)),l&&a.push(new In(this._logger,t,o,l)),this._logger.info(Ne.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ke.SUCCESSED,trackIds:a.map(function(e){return e.getTrackId()})})),i.a(2,{code:Ae.SUCCESS,tracks:a})}},i,this)}))}},{key:"_applyVideoAspectRatio",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c;return E().w(function(r){for(;;)switch(r.p=r.n){case 0:if(i=e.getSettings(),a=i.width,o=i.height,a!==t||o!==n){r.n=1;break}return r.a(2);case 1:return s=t/n>=1?{width:{ideal:a,max:a}}:{height:{ideal:o,max:o}},r.p=2,r.n=3,e.applyConstraints(Object.assign(Object.assign({},s),{aspectRatio:{ideal:t/n}}));case 3:this._logger.info(Ne.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:ke.SUCCESSED,msg:"apply aspectRatio success -> ".concat(t," / ").concat(n)})),r.n=5;break;case 4:r.p=4,c=r.v,this._logger.warn(Ne.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:ke.FAILED,msg:"apply aspectRatio error -> ".concat(JSON.stringify(c))}));case 5:return r.a(2)}},r,this,[[2,4]])}))}}],[{key:"getTracksWithOptions",value:function(e,t){var n=[];return n[0]=(null==t?void 0:t.withoutAudio)?void 0:e.getAudioTracks()[0],n[1]=(null==t?void 0:t.withoutVideo)?void 0:e.getVideoTracks()[0],n}}])}(),_u=function(){var e,t={},n=function(e){var t=function(e,n,i){if(void 0===e&&(e=t.DEFAULT_CAPACITY),void 0===n&&(n=t.DEFAULT_ENDIAN),void 0===i&&(i=t.DEFAULT_NOASSERT),!i){if((e|=0)<0)throw RangeError("Illegal capacity");n=!!n,i=!!i}this.buffer=0===e?r:new ArrayBuffer(e),this.view=0===e?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=n,this.noAssert=i};t.VERSION="5.0.1",t.LITTLE_ENDIAN=!0,t.BIG_ENDIAN=!1,t.DEFAULT_CAPACITY=16,t.DEFAULT_ENDIAN=t.BIG_ENDIAN,t.DEFAULT_NOASSERT=!1,t.Long=e||null;var n=t.prototype;n.__isByteBuffer__,Object.defineProperty(n,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var r=new ArrayBuffer(0),i=String.fromCharCode;function a(e){var t=0;return function(){return t<e.length?e.charCodeAt(t++):null}}function o(){var e=[],t=[];return function(){if(0===arguments.length)return t.join("")+i.apply(String,e);e.length+arguments.length>1024&&(t.push(i.apply(String,e)),e.length=0),Array.prototype.push.apply(e,arguments)}}function s(e,t,n,r,i){var a,o,s=8*i-r-1,c=(1<<s)-1,u=c>>1,l=-7,_=n?i-1:0,d=n?-1:1,f=e[t+_];for(_+=d,a=f&(1<<-l)-1,f>>=-l,l+=s;l>0;a=256*a+e[t+_],_+=d,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=r;l>0;o=256*o+e[t+_],_+=d,l-=8);if(0===a)a=1-u;else{if(a===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),a-=u}return(f?-1:1)*o*Math.pow(2,a-r)}function c(e,t,n,r,i,a){var o,s,c,u=8*a-i-1,l=(1<<u)-1,_=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:a-1,h=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+_>=1?d/c:d*Math.pow(2,1-_))*c>=2&&(o++,c/=2),o+_>=l?(s=0,o=l):o+_>=1?(s=(t*c-1)*Math.pow(2,i),o+=_):(s=t*Math.pow(2,_-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&s,f+=h,s/=256,i-=8);for(o=o<<i|s,u+=i;u>0;e[n+f]=255&o,f+=h,o/=256,u-=8);e[n+f-h]|=128*g}t.accessor=function(){return Uint8Array},t.allocate=function(e,n,r){return new t(e,n,r)},t.concat=function(e,n,r,i){"boolean"!=typeof n&&"string"==typeof n||(i=r,r=n,n=void 0);for(var a,o=0,s=0,c=e.length;s<c;++s)t.isByteBuffer(e[s])||(e[s]=t.wrap(e[s],n)),(a=e[s].limit-e[s].offset)>0&&(o+=a);if(0===o)return new t(0,r,i);var u,l=new t(o,r,i);for(s=0;s<c;)(a=(u=e[s++]).limit-u.offset)<=0||(l.view.set(u.view.subarray(u.offset,u.limit),l.offset),l.offset+=a);return l.limit=l.offset,l.offset=0,l},t.isByteBuffer=function(e){return!0===(e&&e.__isByteBuffer__)},t.type=function(){return ArrayBuffer},t.wrap=function(e,r,i,a){if("string"!=typeof r&&(a=i,i=r,r=void 0),"string"==typeof e)switch(void 0===r&&(r="utf8"),r){case"base64":return t.fromBase64(e,i);case"hex":return t.fromHex(e,i);case"binary":return t.fromBinary(e,i);case"utf8":return t.fromUTF8(e,i);case"debug":return t.fromDebug(e,i);default:throw Error("Unsupported encoding: "+r)}if(null===e||"object"!==O(e))throw TypeError("Illegal buffer");var o;if(t.isByteBuffer(e))return(o=n.clone.call(e)).markedOffset=-1,o;if(e instanceof Uint8Array)o=new t(0,i,a),e.length>0&&(o.buffer=e.buffer,o.offset=e.byteOffset,o.limit=e.byteOffset+e.byteLength,o.view=new Uint8Array(e.buffer));else if(e instanceof ArrayBuffer)o=new t(0,i,a),e.byteLength>0&&(o.buffer=e,o.offset=0,o.limit=e.byteLength,o.view=e.byteLength>0?new Uint8Array(e):null);else{if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Illegal buffer");(o=new t(e.length,i,a)).limit=e.length;for(var s=0;s<e.length;++s)o.view[s]=e[s]}return o},n.writeBitSet=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if(!(e instanceof Array))throw TypeError("Illegal BitSet: Not an array");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var r,i=t,a=e.length,o=a>>3,s=0;for(t+=this.writeVarint32(a,t);o--;)r=1&!!e[s++]|(1&!!e[s++])<<1|(1&!!e[s++])<<2|(1&!!e[s++])<<3|(1&!!e[s++])<<4|(1&!!e[s++])<<5|(1&!!e[s++])<<6|(1&!!e[s++])<<7,this.writeByte(r,t++);if(s<a){var c=0;for(r=0;s<a;)r|=(1&!!e[s++])<<c++;this.writeByte(r,t++)}return n?(this.offset=t,this):t-i},n.readBitSet=function(e){var t=void 0===e;t&&(e=this.offset);var n,r=this.readVarint32(e),i=r.value,a=i>>3,o=0,s=[];for(e+=r.length;a--;)n=this.readByte(e++),s[o++]=!!(1&n),s[o++]=!!(2&n),s[o++]=!!(4&n),s[o++]=!!(8&n),s[o++]=!!(16&n),s[o++]=!!(32&n),s[o++]=!!(64&n),s[o++]=!!(128&n);if(o<i){var c=0;for(n=this.readByte(e++);o<i;)s[o++]=!!(n>>c++&1)}return t&&(this.offset=e),s},n.readBytes=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}var r=this.slice(t,t+e);return n&&(this.offset+=e),r},n.writeBytes=n.append,n.writeInt8=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,n&&(this.offset+=1),this},n.writeByte=n.writeInt8,n.readInt8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var n=this.view[e];return 128&~n||(n=-(255-n+1)),t&&(this.offset+=1),n},n.readByte=n.readInt8,n.writeUint8=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,n&&(this.offset+=1),this},n.writeUInt8=n.writeUint8,n.readUint8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var n=this.view[e];return t&&(this.offset+=1),n},n.readUInt8=n.readUint8,n.writeInt16=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),n&&(this.offset+=2),this},n.writeShort=n.writeInt16,n.readInt16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var n=0;return this.littleEndian?(n=this.view[e],n|=this.view[e+1]<<8):(n=this.view[e]<<8,n|=this.view[e+1]),32768&~n||(n=-(65535-n+1)),t&&(this.offset+=2),n},n.readShort=n.readInt16,n.writeUint16=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),n&&(this.offset+=2),this},n.writeUInt16=n.writeUint16,n.readUint16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var n=0;return this.littleEndian?(n=this.view[e],n|=this.view[e+1]<<8):(n=this.view[e]<<8,n|=this.view[e+1]),t&&(this.offset+=2),n},n.readUInt16=n.readUint16,n.writeInt32=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),n&&(this.offset+=4),this},n.writeInt=n.writeInt32,n.readInt32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var n=0;return this.littleEndian?(n=this.view[e+2]<<16,n|=this.view[e+1]<<8,n|=this.view[e],n+=this.view[e+3]<<24>>>0):(n=this.view[e+1]<<16,n|=this.view[e+2]<<8,n|=this.view[e+3],n+=this.view[e]<<24>>>0),n|=0,t&&(this.offset+=4),n},n.readInt=n.readInt32,n.writeUint32=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),n&&(this.offset+=4),this},n.writeUInt32=n.writeUint32,n.readUint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var n=0;return this.littleEndian?(n=this.view[e+2]<<16,n|=this.view[e+1]<<8,n|=this.view[e],n+=this.view[e+3]<<24>>>0):(n=this.view[e+1]<<16,n|=this.view[e+2]<<8,n|=this.view[e+3],n+=this.view[e]<<24>>>0),t&&(this.offset+=4),n},n.readUInt32=n.readUint32,e&&(n.writeInt64=function(t,n){var r=void 0===n;if(r&&(n=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),n+=8;var i=this.buffer.byteLength;n>i&&this.resize((i*=2)>n?i:n),n-=8;var a=t.low,o=t.high;return this.littleEndian?(this.view[n+3]=a>>>24&255,this.view[n+2]=a>>>16&255,this.view[n+1]=a>>>8&255,this.view[n]=255&a,n+=4,this.view[n+3]=o>>>24&255,this.view[n+2]=o>>>16&255,this.view[n+1]=o>>>8&255,this.view[n]=255&o):(this.view[n]=o>>>24&255,this.view[n+1]=o>>>16&255,this.view[n+2]=o>>>8&255,this.view[n+3]=255&o,n+=4,this.view[n]=a>>>24&255,this.view[n+1]=a>>>16&255,this.view[n+2]=a>>>8&255,this.view[n+3]=255&a),r&&(this.offset+=8),this},n.writeLong=n.writeInt64,n.readInt64=function(t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var r=0,i=0;this.littleEndian?(r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0,t+=4,i=this.view[t+2]<<16,i|=this.view[t+1]<<8,i|=this.view[t],i+=this.view[t+3]<<24>>>0):(i=this.view[t+1]<<16,i|=this.view[t+2]<<8,i|=this.view[t+3],i+=this.view[t]<<24>>>0,t+=4,r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0);var a=new e(r,i,!1);return n&&(this.offset+=8),a},n.readLong=n.readInt64,n.writeUint64=function(t,n){var r=void 0===n;if(r&&(n=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),n+=8;var i=this.buffer.byteLength;n>i&&this.resize((i*=2)>n?i:n),n-=8;var a=t.low,o=t.high;return this.littleEndian?(this.view[n+3]=a>>>24&255,this.view[n+2]=a>>>16&255,this.view[n+1]=a>>>8&255,this.view[n]=255&a,n+=4,this.view[n+3]=o>>>24&255,this.view[n+2]=o>>>16&255,this.view[n+1]=o>>>8&255,this.view[n]=255&o):(this.view[n]=o>>>24&255,this.view[n+1]=o>>>16&255,this.view[n+2]=o>>>8&255,this.view[n+3]=255&o,n+=4,this.view[n]=a>>>24&255,this.view[n+1]=a>>>16&255,this.view[n+2]=a>>>8&255,this.view[n+3]=255&a),r&&(this.offset+=8),this},n.writeUInt64=n.writeUint64,n.readUint64=function(t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var r=0,i=0;this.littleEndian?(r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0,t+=4,i=this.view[t+2]<<16,i|=this.view[t+1]<<8,i|=this.view[t],i+=this.view[t+3]<<24>>>0):(i=this.view[t+1]<<16,i|=this.view[t+2]<<8,i|=this.view[t+3],i+=this.view[t]<<24>>>0,t+=4,r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0);var a=new e(r,i,!0);return n&&(this.offset+=8),a},n.readUInt64=n.readUint64),n.writeFloat32=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,c(this.view,e,t,this.littleEndian,23,4),n&&(this.offset+=4),this},n.writeFloat=n.writeFloat32,n.readFloat32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var n=s(this.view,e,this.littleEndian,23,4);return t&&(this.offset+=4),n},n.readFloat=n.readFloat32,n.writeFloat64=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=8;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=8,c(this.view,e,t,this.littleEndian,52,8),n&&(this.offset+=8),this},n.writeDouble=n.writeFloat64,n.readFloat64=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+8) <= "+this.buffer.byteLength)}var n=s(this.view,e,this.littleEndian,52,8);return t&&(this.offset+=8),n},n.readDouble=n.readFloat64,t.MAX_VARINT32_BYTES=5,t.calculateVarint32=function(e){return(e>>>=0)<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5},t.zigZagEncode32=function(e){return((e|=0)<<1^e>>31)>>>0},t.zigZagDecode32=function(e){return e>>>1^-(1&e)},n.writeVarint32=function(e,n){var r=void 0===n;if(r&&(n=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}var i,a=t.calculateVarint32(e);n+=a;var o=this.buffer.byteLength;for(n>o&&this.resize((o*=2)>n?o:n),n-=a,e>>>=0;e>=128;)i=127&e|128,this.view[n++]=i,e>>>=7;return this.view[n++]=e,r?(this.offset=n,this):a},n.writeVarint32ZigZag=function(e,n){return this.writeVarint32(t.zigZagEncode32(e),n)},n.readVarint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var n,r=0,i=0;do{if(!this.noAssert&&e>this.limit){var a=Error("Truncated");throw a.truncated=!0,a}n=this.view[e++],r<5&&(i|=(127&n)<<7*r),++r}while(128&n);return i|=0,t?(this.offset=e,i):{value:i,length:r}},n.readVarint32ZigZag=function(e){var n=this.readVarint32(e);return"object"===O(n)?n.value=t.zigZagDecode32(n.value):n=t.zigZagDecode32(n),n},e&&(t.MAX_VARINT64_BYTES=10,t.calculateVarint64=function(t){"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t));var n=t.toInt()>>>0,r=t.shiftRightUnsigned(28).toInt()>>>0,i=t.shiftRightUnsigned(56).toInt()>>>0;return 0==i?0==r?n<16384?n<128?1:2:n<1<<21?3:4:r<16384?r<128?5:6:r<1<<21?7:8:i<128?9:10},t.zigZagEncode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned()},t.zigZagDecode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftRightUnsigned(1).xor(t.and(e.ONE).toSigned().negate()).toSigned()},n.writeVarint64=function(n,r){var i=void 0===r;if(i&&(r=this.offset),!this.noAssert){if("number"==typeof n)n=e.fromNumber(n);else if("string"==typeof n)n=e.fromString(n);else if(!(n&&n instanceof e))throw TypeError("Illegal value: "+n+" (not an integer or Long)");if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}"number"==typeof n?n=e.fromNumber(n,!1):"string"==typeof n?n=e.fromString(n,!1):!1!==n.unsigned&&(n=n.toSigned());var a=t.calculateVarint64(n),o=n.toInt()>>>0,s=n.shiftRightUnsigned(28).toInt()>>>0,c=n.shiftRightUnsigned(56).toInt()>>>0;r+=a;var u=this.buffer.byteLength;switch(r>u&&this.resize((u*=2)>r?u:r),r-=a,a){case 10:this.view[r+9]=c>>>7&1;case 9:this.view[r+8]=9!==a?128|c:127&c;case 8:this.view[r+7]=8!==a?s>>>21|128:s>>>21&127;case 7:this.view[r+6]=7!==a?s>>>14|128:s>>>14&127;case 6:this.view[r+5]=6!==a?s>>>7|128:s>>>7&127;case 5:this.view[r+4]=5!==a?128|s:127&s;case 4:this.view[r+3]=4!==a?o>>>21|128:o>>>21&127;case 3:this.view[r+2]=3!==a?o>>>14|128:o>>>14&127;case 2:this.view[r+1]=2!==a?o>>>7|128:o>>>7&127;case 1:this.view[r]=1!==a?128|o:127&o}return i?(this.offset+=a,this):a},n.writeVarint64ZigZag=function(e,n){return this.writeVarint64(t.zigZagEncode64(e),n)},n.readVarint64=function(t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+1) <= "+this.buffer.byteLength)}var r=t,i=0,a=0,o=0,s=0;if(i=127&(s=this.view[t++]),128&s&&(i|=(127&(s=this.view[t++]))<<7,(128&s||this.noAssert&&void 0===s)&&(i|=(127&(s=this.view[t++]))<<14,(128&s||this.noAssert&&void 0===s)&&(i|=(127&(s=this.view[t++]))<<21,(128&s||this.noAssert&&void 0===s)&&(a=127&(s=this.view[t++]),(128&s||this.noAssert&&void 0===s)&&(a|=(127&(s=this.view[t++]))<<7,(128&s||this.noAssert&&void 0===s)&&(a|=(127&(s=this.view[t++]))<<14,(128&s||this.noAssert&&void 0===s)&&(a|=(127&(s=this.view[t++]))<<21,(128&s||this.noAssert&&void 0===s)&&(o=127&(s=this.view[t++]),(128&s||this.noAssert&&void 0===s)&&(o|=(127&(s=this.view[t++]))<<7,128&s||this.noAssert&&void 0===s))))))))))throw Error("Buffer overrun");var c=e.fromBits(i|a<<28,a>>>4|o<<24,!1);return n?(this.offset=t,c):{value:c,length:t-r}},n.readVarint64ZigZag=function(n){var r=this.readVarint64(n);return r&&r.value instanceof e?r.value=t.zigZagDecode64(r.value):r=t.zigZagDecode64(r),r}),n.writeCString=function(e,t){var n=void 0===t;n&&(t=this.offset);var r,i=e.length;if(!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(r=0;r<i;++r)if(0===e.charCodeAt(r))throw RangeError("Illegal str: Contains NULL-characters");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}i=l.calculateUTF16asUTF8(a(e))[1],t+=i+1;var o=this.buffer.byteLength;return t>o&&this.resize((o*=2)>t?o:t),t-=i+1,l.encodeUTF16toUTF8(a(e),function(e){this.view[t++]=e}.bind(this)),this.view[t++]=0,n?(this.offset=t,this):i},n.readCString=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var n,r=e,i=-1;return l.decodeUTF8toUTF16(function(){if(0===i)return null;if(e>=this.limit)throw RangeError("Illegal range: Truncated data, "+e+" < "+this.limit);return 0===(i=this.view[e++])?null:i}.bind(this),n=o(),!0),t?(this.offset=e,n()):{string:n(),length:e-r}},n.writeIString=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var r,i=t;r=l.calculateUTF16asUTF8(a(e),this.noAssert)[1],t+=4+r;var o=this.buffer.byteLength;if(t>o&&this.resize((o*=2)>t?o:t),t-=4+r,this.littleEndian?(this.view[t+3]=r>>>24&255,this.view[t+2]=r>>>16&255,this.view[t+1]=r>>>8&255,this.view[t]=255&r):(this.view[t]=r>>>24&255,this.view[t+1]=r>>>16&255,this.view[t+2]=r>>>8&255,this.view[t+3]=255&r),t+=4,l.encodeUTF16toUTF8(a(e),function(e){this.view[t++]=e}.bind(this)),t!==i+4+r)throw RangeError("Illegal range: Truncated data, "+t+" == "+(t+4+r));return n?(this.offset=t,this):t-i},n.readIString=function(e){var n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=e,i=this.readUint32(e),a=this.readUTF8String(i,t.METRICS_BYTES,e+=4);return e+=a.length,n?(this.offset=e,a.string):{string:a.string,length:e-r}},t.METRICS_CHARS="c",t.METRICS_BYTES="b",n.writeUTF8String=function(e,t){var n,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var i=t;n=l.calculateUTF16asUTF8(a(e))[1],t+=n;var o=this.buffer.byteLength;return t>o&&this.resize((o*=2)>t?o:t),t-=n,l.encodeUTF16toUTF8(a(e),function(e){this.view[t++]=e}.bind(this)),r?(this.offset=t,this):t-i},n.writeString=n.writeUTF8String,t.calculateUTF8Chars=function(e){return l.calculateUTF16asUTF8(a(e))[0]},t.calculateUTF8Bytes=function(e){return l.calculateUTF16asUTF8(a(e))[1]},t.calculateString=t.calculateUTF8Bytes,n.readUTF8String=function(e,n,r){"number"==typeof n&&(r=n,n=void 0);var i=void 0===r;if(i&&(r=this.offset),void 0===n&&(n=t.METRICS_CHARS),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");if(e|=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}var a,s=0,c=r;if(n===t.METRICS_CHARS){if(a=o(),l.decodeUTF8(function(){return s<e&&r<this.limit?this.view[r++]:null}.bind(this),function(e){++s,l.UTF8toUTF16(e,a)}),s!==e)throw RangeError("Illegal range: Truncated data, "+s+" == "+e);return i?(this.offset=r,a()):{string:a(),length:r-c}}if(n===t.METRICS_BYTES){if(!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+"+e+") <= "+this.buffer.byteLength)}var u=r+e;if(l.decodeUTF8toUTF16(function(){return r<u?this.view[r++]:null}.bind(this),a=o(),this.noAssert),r!==u)throw RangeError("Illegal range: Truncated data, "+r+" == "+u);return i?(this.offset=r,a()):{string:a(),length:r-c}}throw TypeError("Unsupported metrics: "+n)},n.readString=n.readUTF8String,n.writeVString=function(e,n){var r=void 0===n;if(r&&(n=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}var i,o,s=n;i=l.calculateUTF16asUTF8(a(e),this.noAssert)[1],o=t.calculateVarint32(i),n+=o+i;var c=this.buffer.byteLength;if(n>c&&this.resize((c*=2)>n?c:n),n-=o+i,n+=this.writeVarint32(i,n),l.encodeUTF16toUTF8(a(e),function(e){this.view[n++]=e}.bind(this)),n!==s+i+o)throw RangeError("Illegal range: Truncated data, "+n+" == "+(n+i+o));return r?(this.offset=n,this):n-s},n.readVString=function(e){var n=void 0===e;if(n&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r=e,i=this.readVarint32(e),a=this.readUTF8String(i.value,t.METRICS_BYTES,e+=i.length);return e+=a.length,n?(this.offset=e,a.string):{string:a.string,length:e-r}},n.append=function(e,n,r){"number"!=typeof n&&"string"==typeof n||(r=n,n=void 0);var i=void 0===r;if(i&&(r=this.offset),!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,n));var a=e.limit-e.offset;if(a<=0)return this;r+=a;var o=this.buffer.byteLength;return r>o&&this.resize((o*=2)>r?o:r),r-=a,this.view.set(e.view.subarray(e.offset,e.limit),r),e.offset+=a,i&&(this.offset+=a),this},n.appendTo=function(e,t){return e.append(this,t),this},n.assert=function(e){return this.noAssert=!e,this},n.capacity=function(){return this.buffer.byteLength},n.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},n.clone=function(e){var n=new t(0,this.littleEndian,this.noAssert);return e?(n.buffer=new ArrayBuffer(this.buffer.byteLength),n.view=new Uint8Array(n.buffer)):(n.buffer=this.buffer,n.view=this.view),n.offset=this.offset,n.markedOffset=this.markedOffset,n.limit=this.limit,n},n.compact=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(0===e&&t===this.buffer.byteLength)return this;var n=t-e;if(0===n)return this.buffer=r,this.view=null,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=0,this;var i=new ArrayBuffer(n),a=new Uint8Array(i);return a.set(this.view.subarray(e,t)),this.buffer=i,this.view=a,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=n,this},n.copy=function(e,n){if(void 0===e&&(e=this.offset),void 0===n&&(n=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal end: Not an integer");if(n>>>=0,e<0||e>n||n>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+n+" <= "+this.buffer.byteLength)}if(e===n)return new t(0,this.littleEndian,this.noAssert);var r=n-e,i=new t(r,this.littleEndian,this.noAssert);return i.offset=0,i.limit=r,i.markedOffset>=0&&(i.markedOffset-=e),this.copyTo(i,0,e,n),i},n.copyTo=function(e,n,r,i){var a,o;if(!this.noAssert&&!t.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(n=(o=void 0===n)?e.offset:0|n,r=(a=void 0===r)?this.offset:0|r,i=void 0===i?this.limit:0|i,n<0||n>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+n+" <= "+e.buffer.byteLength);if(r<0||i>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+r+" <= "+this.buffer.byteLength);var s=i-r;return 0===s?e:(e.ensureCapacity(n+s),e.view.set(this.view.subarray(r,i),n),a&&(this.offset+=s),o&&(e.offset+=s),this)},n.ensureCapacity=function(e){var t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this},n.fill=function(e,t,n){var r=void 0===t;if(r&&(t=this.offset),"string"==typeof e&&e.length>0&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===n&&(n=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal begin: Not an integer");if(t>>>=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal end: Not an integer");if(n>>>=0,t<0||t>n||n>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+n+" <= "+this.buffer.byteLength)}if(t>=n)return this;for(;t<n;)this.view[t++]=e;return r&&(this.offset=t),this},n.flip=function(){return this.limit=this.offset,this.offset=0,this},n.mark=function(e){if(e=void 0===e?this.offset:e,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=e,this},n.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},n.LE=function(e){return this.littleEndian=void 0===e||!!e,this},n.BE=function(e){return this.littleEndian=void 0!==e&&!e,this},n.prepend=function(e,n,r){"number"!=typeof n&&"string"==typeof n||(r=n,n=void 0);var i=void 0===r;if(i&&(r=this.offset),!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,n));var a=e.limit-e.offset;if(a<=0)return this;var o=a-r;if(o>0){var s=new ArrayBuffer(this.buffer.byteLength+o),c=new Uint8Array(s);c.set(this.view.subarray(r,this.buffer.byteLength),a),this.buffer=s,this.view=c,this.offset+=o,this.markedOffset>=0&&(this.markedOffset+=o),this.limit+=o,r+=o}else new Uint8Array(this.buffer);return this.view.set(e.view.subarray(e.offset,e.limit),r-a),e.offset=e.limit,i&&(this.offset-=a),this},n.prependTo=function(e,t){return e.prepend(this,t),this},n.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},n.remaining=function(){return this.limit-this.offset},n.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},n.resize=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal capacity: "+e+" (not an integer)");if((e|=0)<0)throw RangeError("Illegal capacity: 0 <= "+e)}if(this.buffer.byteLength<e){var t=new ArrayBuffer(e),n=new Uint8Array(t);n.set(this.view),this.buffer=t,this.view=n}return this},n.reverse=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}return e===t||Array.prototype.reverse.call(this.view.subarray(e,t)),this},n.skip=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");e|=0}var t=this.offset+e;if(!this.noAssert&&(t<0||t>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+e+" <= "+this.buffer.byteLength);return this.offset=t,this},n.slice=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var n=this.clone();return n.offset=e,n.limit=t,n},n.toBuffer=function(e){var t=this.offset,n=this.limit;if(!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: Not an integer");if(t>>>=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal limit: Not an integer");if(n>>>=0,t<0||t>n||n>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+n+" <= "+this.buffer.byteLength)}if(!e&&0===t&&n===this.buffer.byteLength)return this.buffer;if(t===n)return r;var i=new ArrayBuffer(n-t);return new Uint8Array(i).set(new Uint8Array(this.buffer).subarray(t,n),0),i},n.toArrayBuffer=n.toBuffer,n.toString=function(e,t,n){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(n=t=e="utf8"),e){case"utf8":return this.toUTF8(t,n);case"base64":return this.toBase64(t,n);case"hex":return this.toHex(t,n);case"binary":return this.toBinary(t,n);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}};var u=function(){for(var e={},t=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],n=[],r=0,i=t.length;r<i;++r)n[t[r]]=r;return e.encode=function(e,n){for(var r,i;null!==(r=e());)n(t[r>>2&63]),i=(3&r)<<4,null!==(r=e())?(n(t[63&((i|=r>>4&15)|r>>4&15)]),i=(15&r)<<2,null!==(r=e())?(n(t[63&(i|r>>6&3)]),n(t[63&r])):(n(t[63&i]),n(61))):(n(t[63&i]),n(61),n(61))},e.decode=function(e,t){var r,i,a;function o(e){throw Error("Illegal character code: "+e)}for(;null!==(r=e());)if(void 0===(i=n[r])&&o(r),null!==(r=e())&&(void 0===(a=n[r])&&o(r),t(i<<2>>>0|(48&a)>>4),null!==(r=e()))){if(void 0===(i=n[r])){if(61===r)break;o(r)}if(t((15&a)<<4>>>0|(60&i)>>2),null!==(r=e())){if(void 0===(a=n[r])){if(61===r)break;o(r)}t((3&i)<<6>>>0|a)}}},e.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)},e}();n.toBase64=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity||e>t)throw RangeError("begin, end");var n;return u.encode(function(){return e<t?this.view[e++]:null}.bind(this),n=o()),n()},t.fromBase64=function(e,n){if("string"!=typeof e)throw TypeError("str");var r=new t(e.length/4*3,n),i=0;return u.decode(a(e),function(e){r.view[i++]=e}),r.limit=i,r},t.btoa=function(e){return t.fromBinary(e).toBase64()},t.atob=function(e){return t.fromBase64(e).toBinary()},n.toBinary=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity()||e>t)throw RangeError("begin, end");if(e===t)return"";for(var n=[],r=[];e<t;)n.push(this.view[e++]),n.length>=1024&&(r.push(String.fromCharCode.apply(String,n)),n=[]);return r.join("")+String.fromCharCode.apply(String,n)},t.fromBinary=function(e,n){if("string"!=typeof e)throw TypeError("str");for(var r,i=0,a=e.length,o=new t(a,n);i<a;){if((r=e.charCodeAt(i))>255)throw RangeError("illegal char code: "+r);o.view[i++]=r}return o.limit=a,o},n.toDebug=function(e){for(var t,n=-1,r=this.buffer.byteLength,i="",a="",o="";n<r;){if(-1!==n&&(i+=(t=this.view[n])<16?"0"+t.toString(16).toUpperCase():t.toString(16).toUpperCase(),e&&(a+=t>32&&t<127?String.fromCharCode(t):".")),++n,e&&n>0&&n%16==0&&n!==r){for(;i.length<51;)i+=" ";o+=i+a+"\n",i=a=""}n===this.offset&&n===this.limit?i+=n===this.markedOffset?"!":"|":n===this.offset?i+=n===this.markedOffset?"[":"<":n===this.limit?i+=n===this.markedOffset?"]":">":i+=n===this.markedOffset?"'":e||0!==n&&n!==r?" ":""}if(e&&" "!==i){for(;i.length<51;)i+=" ";o+=i+a+"\n"}return e?o:i},t.fromDebug=function(e,n,r){for(var i,a,o=e.length,s=new t((o+1)/3|0,n,r),c=0,u=0,l=!1,_=!1,d=!1,f=!1,h=!1;c<o;){switch(i=e.charAt(c++)){case"!":if(!r){if(_||d||f){h=!0;break}_=d=f=!0}s.offset=s.markedOffset=s.limit=u,l=!1;break;case"|":if(!r){if(_||f){h=!0;break}_=f=!0}s.offset=s.limit=u,l=!1;break;case"[":if(!r){if(_||d){h=!0;break}_=d=!0}s.offset=s.markedOffset=u,l=!1;break;case"<":if(!r){if(_){h=!0;break}_=!0}s.offset=u,l=!1;break;case"]":if(!r){if(f||d){h=!0;break}f=d=!0}s.limit=s.markedOffset=u,l=!1;break;case">":if(!r){if(f){h=!0;break}f=!0}s.limit=u,l=!1;break;case"'":if(!r){if(d){h=!0;break}d=!0}s.markedOffset=u,l=!1;break;case" ":l=!1;break;default:if(!r&&l){h=!0;break}if(a=parseInt(i+e.charAt(c++),16),!r&&(isNaN(a)||a<0||a>255))throw TypeError("Illegal str: Not a debug encoded string");s.view[u++]=a,l=!0}if(h)throw TypeError("Illegal str: Invalid symbol at "+c)}if(!r){if(!_||!f)throw TypeError("Illegal str: Missing offset or limit");if(u<s.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+u+" < "+o)}return s},n.toHex=function(e,t){if(e=void 0===e?this.offset:e,t=void 0===t?this.limit:t,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}for(var n,r=new Array(t-e);e<t;)(n=this.view[e++])<16?r.push("0",n.toString(16)):r.push(n.toString(16));return r.join("")},t.fromHex=function(e,n,r){if(!r){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if(e.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(var i,a=e.length,o=new t(a/2|0,n),s=0,c=0;s<a;s+=2){if(i=parseInt(e.substring(s,s+2),16),!r&&(!isFinite(i)||i<0||i>255))throw TypeError("Illegal str: Contains non-hex characters");o.view[c++]=i}return o.limit=c,o};var l=function(){var e={MAX_CODEPOINT:1114111,encodeUTF8:function(e,t){var n=null;for("number"==typeof e&&(n=e,e=function(){return null});null!==n||null!==(n=e());)n<128?t(127&n):n<2048?(t(n>>6&31|192),t(63&n|128)):n<65536?(t(n>>12&15|224),t(n>>6&63|128),t(63&n|128)):(t(n>>18&7|240),t(n>>12&63|128),t(n>>6&63|128),t(63&n|128)),n=null},decodeUTF8:function(e,t){for(var n,r,i,a,o=function(e){e=e.slice(0,e.indexOf(null));var t=Error(e.toString());throw t.name="TruncatedError",t.bytes=e,t};null!==(n=e());)if(128&n)if(192==(224&n))null===(r=e())&&o([n,r]),t((31&n)<<6|63&r);else if(224==(240&n))(null===(r=e())||null===(i=e()))&&o([n,r,i]),t((15&n)<<12|(63&r)<<6|63&i);else{if(240!=(248&n))throw RangeError("Illegal starting byte: "+n);(null===(r=e())||null===(i=e())||null===(a=e()))&&o([n,r,i,a]),t((7&n)<<18|(63&r)<<12|(63&i)<<6|63&a)}else t(n)},UTF16toUTF8:function(e,t){for(var n,r=null;null!==(n=null!==r?r:e());)n>=55296&&n<=57343&&null!==(r=e())&&r>=56320&&r<=57343?(t(1024*(n-55296)+r-56320+65536),r=null):t(n);null!==r&&t(r)},UTF8toUTF16:function(e,t){var n=null;for("number"==typeof e&&(n=e,e=function(){return null});null!==n||null!==(n=e());)n<=65535?t(n):(t(55296+((n-=65536)>>10)),t(n%1024+56320)),n=null},encodeUTF16toUTF8:function(t,n){e.UTF16toUTF8(t,function(t){e.encodeUTF8(t,n)})},decodeUTF8toUTF16:function(t,n){e.decodeUTF8(t,function(t){e.UTF8toUTF16(t,n)})},calculateCodePoint:function(e){return e<128?1:e<2048?2:e<65536?3:4},calculateUTF8:function(e){for(var t,n=0;null!==(t=e());)n+=t<128?1:t<2048?2:t<65536?3:4;return n},calculateUTF16asUTF8:function(t){var n=0,r=0;return e.UTF16toUTF8(t,function(e){++n,r+=e<128?1:e<2048?2:e<65536?3:4}),[n,r]}};return e}();return n.toUTF8=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var n;try{l.decodeUTF8toUTF16(function(){return e<t?this.view[e++]:null}.bind(this),n=o())}catch(n){if(e!==t)throw RangeError("Illegal range: Truncated data, "+e+" != "+t)}return n()},t.fromUTF8=function(e,n,r){if(!r&&"string"!=typeof e)throw TypeError("Illegal str: Not a string");var i=new t(l.calculateUTF16asUTF8(a(e),!0)[1],n,r),o=0;return l.encodeUTF16toUTF8(a(e),function(e){i.view[o++]=e}),i.limit=o,i},t}(function(){function e(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function t(e){return!0===(e&&e.__isLong__)}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=t;var n={},r={};function i(e,t){var i,a,s;return t?(s=0<=(e>>>=0)&&e<256)&&(a=r[e])?a:(i=o(e,(0|e)<0?-1:0,!0),s&&(r[e]=i),i):(s=-128<=(e|=0)&&e<128)&&(a=n[e])?a:(i=o(e,e<0?-1:0,!1),s&&(n[e]=i),i)}function a(e,t){if(isNaN(e)||!isFinite(e))return t?g:h;if(t){if(e<0)return g;if(e>=_)return R}else{if(e<=-d)return T;if(e+1>=d)return m}return e<0?a(-e,t).neg():o(e%l|0,e/l|0,t)}function o(t,n,r){return new e(t,n,r)}e.fromInt=i,e.fromNumber=a,e.fromBits=o;var s=Math.pow;function c(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return h;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return c(e.substring(1),t,n).neg();for(var i=a(s(n,8)),o=h,u=0;u<e.length;u+=8){var l=Math.min(8,e.length-u),_=parseInt(e.substring(u,u+l),n);if(l<8){var d=a(s(n,l));o=o.mul(d).add(a(_))}else o=(o=o.mul(i)).add(a(_))}return o.unsigned=t,o}function u(t){return t instanceof e?t:"number"==typeof t?a(t):"string"==typeof t?c(t):o(t.low,t.high,t.unsigned)}e.fromString=c,e.fromValue=u;var l=4294967296,_=l*l,d=_/2,f=i(1<<24),h=i(0);e.ZERO=h;var g=i(0,!0);e.UZERO=g;var p=i(1);e.ONE=p;var E=i(1,!0);e.UONE=E;var v=i(-1);e.NEG_ONE=v;var m=o(-1,2147483647,!1);e.MAX_VALUE=m;var R=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=R;var T=o(0,-2147483648,!1);e.MIN_VALUE=T;var I=e.prototype;return I.toInt=function(){return this.unsigned?this.low>>>0:this.low},I.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)},I.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(T)){var t=a(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=a(s(e,6),this.unsigned),o=this,c="";;){var u=o.div(i),l=(o.sub(u.mul(i)).toInt()>>>0).toString(e);if((o=u).isZero())return l+c;for(;l.length<6;)l="0"+l;c=""+l+c}},I.getHighBits=function(){return this.high},I.getHighBitsUnsigned=function(){return this.high>>>0},I.getLowBits=function(){return this.low},I.getLowBitsUnsigned=function(){return this.low>>>0},I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(T)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},I.isZero=function(){return 0===this.high&&0===this.low},I.isNegative=function(){return!this.unsigned&&this.high<0},I.isPositive=function(){return this.unsigned||this.high>=0},I.isOdd=function(){return!(1&~this.low)},I.isEven=function(){return!(1&this.low)},I.equals=function(e){return t(e)||(e=u(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},I.eq=I.equals,I.notEquals=function(e){return!this.eq(e)},I.neq=I.notEquals,I.lessThan=function(e){return this.comp(e)<0},I.lt=I.lessThan,I.lessThanOrEqual=function(e){return this.comp(e)<=0},I.lte=I.lessThanOrEqual,I.greaterThan=function(e){return this.comp(e)>0},I.gt=I.greaterThan,I.greaterThanOrEqual=function(e){return this.comp(e)>=0},I.gte=I.greaterThanOrEqual,I.compare=function(e){if(t(e)||(e=u(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},I.comp=I.compare,I.negate=function(){return!this.unsigned&&this.eq(T)?T:this.not().add(p)},I.neg=I.negate,I.add=function(e){t(e)||(e=u(e));var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,a=65535&this.low,s=e.high>>>16,c=65535&e.high,l=e.low>>>16,_=0,d=0,f=0,h=0;return f+=(h+=a+(65535&e.low))>>>16,d+=(f+=i+l)>>>16,_+=(d+=r+c)>>>16,_+=n+s,o((f&=65535)<<16|(h&=65535),(_&=65535)<<16|(d&=65535),this.unsigned)},I.subtract=function(e){return t(e)||(e=u(e)),this.add(e.neg())},I.sub=I.subtract,I.multiply=function(e){if(this.isZero())return h;if(t(e)||(e=u(e)),e.isZero())return h;if(this.eq(T))return e.isOdd()?T:h;if(e.eq(T))return this.isOdd()?T:h;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(f)&&e.lt(f))return a(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,s=65535&this.low,c=e.high>>>16,l=65535&e.high,_=e.low>>>16,d=65535&e.low,g=0,p=0,E=0,v=0;return E+=(v+=s*d)>>>16,p+=(E+=i*d)>>>16,E&=65535,p+=(E+=s*_)>>>16,g+=(p+=r*d)>>>16,p&=65535,g+=(p+=i*_)>>>16,p&=65535,g+=(p+=s*l)>>>16,g+=n*d+r*_+i*l+s*c,o((E&=65535)<<16|(v&=65535),(g&=65535)<<16|(p&=65535),this.unsigned)},I.mul=I.multiply,I.divide=function(e){if(t(e)||(e=u(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?g:h;var n,r,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return g;if(e.gt(this.shru(1)))return E;i=g}else{if(this.eq(T))return e.eq(p)||e.eq(v)?T:e.eq(T)?p:(n=this.shr(1).div(e).shl(1)).eq(h)?e.isNegative()?p:v:(r=this.sub(e.mul(n)),i=n.add(r.div(e)));if(e.eq(T))return this.unsigned?g:h;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=h}for(r=this;r.gte(e);){n=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(n)/Math.LN2),c=o<=48?1:s(2,o-48),l=a(n),_=l.mul(e);_.isNegative()||_.gt(r);)_=(l=a(n-=c,this.unsigned)).mul(e);l.isZero()&&(l=p),i=i.add(l),r=r.sub(_)}return i},I.div=I.divide,I.modulo=function(e){return t(e)||(e=u(e)),this.sub(this.div(e).mul(e))},I.mod=I.modulo,I.not=function(){return o(~this.low,~this.high,this.unsigned)},I.and=function(e){return t(e)||(e=u(e)),o(this.low&e.low,this.high&e.high,this.unsigned)},I.or=function(e){return t(e)||(e=u(e)),o(this.low|e.low,this.high|e.high,this.unsigned)},I.xor=function(e){return t(e)||(e=u(e)),o(this.low^e.low,this.high^e.high,this.unsigned)},I.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o(0,this.low<<e-32,this.unsigned)},I.shl=I.shiftLeft,I.shiftRight=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},I.shr=I.shiftRight,I.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0===(e&=63))return this;var n=this.high;return e<32?o(this.low>>>e|n<<32-e,n>>>e,this.unsigned):o(32===e?n:n>>>e-32,0,this.unsigned)},I.shru=I.shiftRightUnsigned,I.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},I.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},I.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},I.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255]},I.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t]},e}());return t.ByteBuffer=n,t.Long=n.Long||null,t.VERSION="5.0.3",t.WIRE_TYPES={},t.WIRE_TYPES.VARINT=0,t.WIRE_TYPES.BITS64=1,t.WIRE_TYPES.LDELIM=2,t.WIRE_TYPES.STARTGROUP=3,t.WIRE_TYPES.ENDGROUP=4,t.WIRE_TYPES.BITS32=5,t.PACKABLE_WIRE_TYPES=[t.WIRE_TYPES.VARINT,t.WIRE_TYPES.BITS64,t.WIRE_TYPES.BITS32],t.TYPES={int32:{name:"int32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.ZERO:void 0},uint64:{name:"uint64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.UZERO:void 0},sint64:{name:"sint64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.ZERO:void 0},bool:{name:"bool",wireType:t.WIRE_TYPES.VARINT,defaultValue:!1},double:{name:"double",wireType:t.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:t.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:t.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:t.WIRE_TYPES.BITS64,defaultValue:t.Long?t.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:t.WIRE_TYPES.BITS64,defaultValue:t.Long?t.Long.ZERO:void 0},float:{name:"float",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},enum:{name:"enum",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:t.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:t.WIRE_TYPES.STARTGROUP,defaultValue:null}},t.MAP_KEY_TYPES=[t.TYPES.int32,t.TYPES.sint32,t.TYPES.sfixed32,t.TYPES.uint32,t.TYPES.fixed32,t.TYPES.int64,t.TYPES.sint64,t.TYPES.sfixed64,t.TYPES.uint64,t.TYPES.fixed64,t.TYPES.bool,t.TYPES.string,t.TYPES.bytes],t.ID_MIN=1,t.ID_MAX=536870911,t.convertFieldsToCamelCase=!1,t.populateAccessors=!0,t.populateDefaults=!0,t.Util=((e={}).IS_NODE=!("object"!==("undefined"==typeof process?"undefined":O(process))||process+""!="[object process]"||process.browser),e.toCamelCase=function(e){return e.replace(/_([a-zA-Z])/g,function(e,t){return t.toUpperCase()})},e),t.Lang={DELIM:/[\s\{\}=;:\[\],'"\(\)<>]/g,RULE:/^(?:required|optional|repeated|map)$/,TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,FQTYPEREF:/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g},t.DotProto=function(e,t){var n={},r=function(e){this.source=e+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},i=r.prototype;i._readString=function(){var e='"'===this._stringOpen?t.STRING_DQ:t.STRING_SQ;e.lastIndex=this.index-1;var n=e.exec(this.source);if(!n)throw Error("unterminated string");return this.index=e.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,n[1]},i.next=function(){if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(null!==this._stringOpen)return this._readString();var e,n,r;do{for(e=!1;t.WHITESPACE.test(r=this.source.charAt(this.index));)if("\n"===r&&++this.line,++this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if(++this.index,"/"===this.source.charAt(this.index)){for(;"\n"!==this.source.charAt(++this.index);)if(this.index==this.source.length)return null;++this.index,++this.line,e=!0}else{if("*"!==(r=this.source.charAt(this.index)))return"/";do{if("\n"===r&&++this.line,++this.index===this.source.length)return null;n=r,r=this.source.charAt(this.index)}while("*"!==n||"/"!==r);++this.index,e=!0}}while(e);if(this.index===this.source.length)return null;var i=this.index;if(t.DELIM.lastIndex=0,!t.DELIM.test(this.source.charAt(i++)))for(;i<this.source.length&&!t.DELIM.test(this.source.charAt(i));)++i;var a=this.source.substring(this.index,this.index=i);return'"'!==a&&"'"!==a||(this._stringOpen=a),a},i.peek=function(){if(0===this.stack.length){var e=this.next();if(null===e)return null;this.stack.push(e)}return this.stack[0]},i.skip=function(e){var t=this.next();if(t!==e)throw Error("illegal '"+t+"', '"+e+"' expected")},i.omit=function(e){return this.peek()===e&&(this.next(),!0)},i.toString=function(){return"Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"},n.Tokenizer=r;var a=function(e){this.tn=new r(e),this.proto3=!1},o=a.prototype;function s(e,n){var r=-1,i=1;if("-"==e.charAt(0)&&(i=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))r=parseInt(e);else if(t.NUMBER_HEX.test(e))r=parseInt(e.substring(2),16);else{if(!t.NUMBER_OCT.test(e))throw Error("illegal id value: "+(i<0?"-":"")+e);r=parseInt(e.substring(1),8)}if(r=i*r|0,!n&&r<0)throw Error("illegal id value: "+(i<0?"-":"")+e);return r}function c(e){var n=1;if("-"==e.charAt(0)&&(n=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))return n*parseInt(e,10);if(t.NUMBER_HEX.test(e))return n*parseInt(e.substring(2),16);if(t.NUMBER_OCT.test(e))return n*parseInt(e.substring(1),8);if("inf"===e)return n*(1/0);if("nan"===e)return NaN;if(t.NUMBER_FLT.test(e))return n*parseFloat(e);throw Error("illegal number value: "+(n<0?"-":"")+e)}function u(e,t,n){void 0===e[t]?e[t]=n:(Array.isArray(e[t])||(e[t]=[e[t]]),e[t].push(n))}return o.parse=function(){var e,n,r={name:"[ROOT]",package:null,messages:[],enums:[],imports:[],options:{},services:[]},i=!0;try{for(;e=this.tn.next();)switch(e){case"package":if(!i||null!==r.package)throw Error("unexpected 'package'");if(e=this.tn.next(),!t.TYPEREF.test(e))throw Error("illegal package name: "+e);this.tn.skip(";"),r.package=e;break;case"import":if(!i)throw Error("unexpected 'import'");("public"===(e=this.tn.peek())||(n="weak"===e))&&this.tn.next(),e=this._readString(),this.tn.skip(";"),n||r.imports.push(e);break;case"syntax":if(!i)throw Error("unexpected 'syntax'");this.tn.skip("="),"proto3"===(r.syntax=this._readString())&&(this.proto3=!0),this.tn.skip(";");break;case"message":this._parseMessage(r,null),i=!1;break;case"enum":this._parseEnum(r),i=!1;break;case"option":this._parseOption(r);break;case"service":this._parseService(r);break;case"extend":this._parseExtend(r);break;default:throw Error("unexpected '"+e+"'")}}catch(e){throw e.message="Parse error at line "+this.tn.line+": "+e.message,e}return delete r.name,r},a.parse=function(e){return new a(e).parse()},o._readString=function(){var e,t,n="";do{if("'"!==(t=this.tn.next())&&'"'!==t)throw Error("illegal string delimiter: "+t);n+=this.tn.next(),this.tn.skip(t),e=this.tn.peek()}while('"'===e||'"'===e);return n},o._readValue=function(e){var n=this.tn.peek();if('"'===n||"'"===n)return this._readString();if(this.tn.next(),t.NUMBER.test(n))return c(n);if(t.BOOL.test(n))return"true"===n.toLowerCase();if(e&&t.TYPEREF.test(n))return n;throw Error("illegal value: "+n)},o._parseOption=function(e,n){var r=this.tn.next(),i=!1;if("("===r&&(i=!0,r=this.tn.next()),!t.TYPEREF.test(r))throw Error("illegal option name: "+r);var a=r;i&&(this.tn.skip(")"),a="("+a+")",r=this.tn.peek(),t.FQTYPEREF.test(r)&&(a+=r,this.tn.next())),this.tn.skip("="),this._parseOptionValue(e,a),n||this.tn.skip(";")},o._parseOptionValue=function(e,n){var r=this.tn.peek();if("{"!==r)u(e.options,n,this._readValue(!0));else for(this.tn.skip("{");"}"!==(r=this.tn.next());){if(!t.NAME.test(r))throw Error("illegal option name: "+n+"."+r);this.tn.omit(":")?u(e.options,n+"."+r,this._readValue(!0)):this._parseOptionValue(e,n+"."+r)}},o._parseService=function(e){var n=this.tn.next();if(!t.NAME.test(n))throw Error("illegal service name at line "+this.tn.line+": "+n);var r={name:n,rpc:{},options:{}};for(this.tn.skip("{");"}"!==(n=this.tn.next());)if("option"===n)this._parseOption(r);else{if("rpc"!==n)throw Error("illegal service token: "+n);this._parseServiceRPC(r)}this.tn.omit(";"),e.services.push(r)},o._parseServiceRPC=function(e){var n="rpc",r=this.tn.next();if(!t.NAME.test(r))throw Error("illegal rpc service method name: "+r);var i=r,a={request:null,response:null,request_stream:!1,response_stream:!1,options:{}};if(this.tn.skip("("),"stream"===(r=this.tn.next()).toLowerCase()&&(a.request_stream=!0,r=this.tn.next()),!t.TYPEREF.test(r))throw Error("illegal rpc service request type: "+r);if(a.request=r,this.tn.skip(")"),"returns"!==(r=this.tn.next()).toLowerCase())throw Error("illegal rpc service request type delimiter: "+r);if(this.tn.skip("("),"stream"===(r=this.tn.next()).toLowerCase()&&(a.response_stream=!0,r=this.tn.next()),a.response=r,this.tn.skip(")"),"{"===(r=this.tn.peek())){for(this.tn.next();"}"!==(r=this.tn.next());){if("option"!==r)throw Error("illegal rpc service token: "+r);this._parseOption(a)}this.tn.omit(";")}else this.tn.skip(";");void 0===e[n]&&(e[n]={}),e[n][i]=a},o._parseMessage=function(e,n){var r=!!n,i=this.tn.next(),a={name:"",fields:[],enums:[],messages:[],options:{},services:[],oneofs:{}};if(!t.NAME.test(i))throw Error("illegal "+(r?"group":"message")+" name: "+i);for(a.name=i,r&&(this.tn.skip("="),n.id=s(this.tn.next()),a.isGroup=!0),"["===(i=this.tn.peek())&&n&&this._parseFieldOptions(n),this.tn.skip("{");"}"!==(i=this.tn.next());)if(t.RULE.test(i))this._parseMessageField(a,i);else if("oneof"===i)this._parseMessageOneOf(a);else if("enum"===i)this._parseEnum(a);else if("message"===i)this._parseMessage(a);else if("option"===i)this._parseOption(a);else if("service"===i)this._parseService(a);else if("extensions"===i)a.hasOwnProperty("extensions")?a.extensions=a.extensions.concat(this._parseExtensionRanges()):a.extensions=this._parseExtensionRanges();else if("reserved"===i)this._parseIgnored();else if("extend"===i)this._parseExtend(a);else{if(!t.TYPEREF.test(i))throw Error("illegal message token: "+i);if(!this.proto3)throw Error("illegal field rule: "+i);this._parseMessageField(a,"optional",i)}return this.tn.omit(";"),e.messages.push(a),a},o._parseIgnored=function(){for(;";"!==this.tn.peek();)this.tn.next();this.tn.skip(";")},o._parseMessageField=function(e,n,r){if(!t.RULE.test(n))throw Error("illegal message field rule: "+n);var i,a={rule:n,type:"",name:"",options:{},id:0};if("map"===n){if(r)throw Error("illegal type: "+r);if(this.tn.skip("<"),i=this.tn.next(),!t.TYPE.test(i)&&!t.TYPEREF.test(i))throw Error("illegal message field type: "+i);if(a.keytype=i,this.tn.skip(","),i=this.tn.next(),!t.TYPE.test(i)&&!t.TYPEREF.test(i))throw Error("illegal message field: "+i);if(a.type=i,this.tn.skip(">"),i=this.tn.next(),!t.NAME.test(i))throw Error("illegal message field name: "+i);a.name=i,this.tn.skip("="),a.id=s(this.tn.next()),"["===(i=this.tn.peek())&&this._parseFieldOptions(a),this.tn.skip(";")}else if("group"===(r=void 0!==r?r:this.tn.next())){var o=this._parseMessage(e,a);if(!/^[A-Z]/.test(o.name))throw Error("illegal group name: "+o.name);a.type=o.name,a.name=o.name.toLowerCase(),this.tn.omit(";")}else{if(!t.TYPE.test(r)&&!t.TYPEREF.test(r))throw Error("illegal message field type: "+r);if(a.type=r,i=this.tn.next(),!t.NAME.test(i))throw Error("illegal message field name: "+i);a.name=i,this.tn.skip("="),a.id=s(this.tn.next()),"["===(i=this.tn.peek())&&this._parseFieldOptions(a),this.tn.skip(";")}return e.fields.push(a),a},o._parseMessageOneOf=function(e){var n=this.tn.next();if(!t.NAME.test(n))throw Error("illegal oneof name: "+n);var r,i=n,a=[];for(this.tn.skip("{");"}"!==(n=this.tn.next());)(r=this._parseMessageField(e,"optional",n)).oneof=i,a.push(r.id);this.tn.omit(";"),e.oneofs[i]=a},o._parseFieldOptions=function(e){this.tn.skip("[");for(var t=!0;"]"!==this.tn.peek();)t||this.tn.skip(","),this._parseOption(e,!0),t=!1;this.tn.next()},o._parseEnum=function(e){var n={name:"",values:[],options:{}},r=this.tn.next();if(!t.NAME.test(r))throw Error("illegal name: "+r);for(n.name=r,this.tn.skip("{");"}"!==(r=this.tn.next());)if("option"===r)this._parseOption(n);else{if(!t.NAME.test(r))throw Error("illegal name: "+r);this.tn.skip("=");var i={name:r,id:s(this.tn.next(),!0)};"["===(r=this.tn.peek())&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),n.values.push(i)}this.tn.omit(";"),e.enums.push(n)},o._parseExtensionRanges=function(){var t,n,r,i=[];do{for(n=[];;){switch(t=this.tn.next()){case"min":r=e.ID_MIN;break;case"max":r=e.ID_MAX;break;default:r=c(t)}if(n.push(r),2===n.length)break;if("to"!==this.tn.peek()){n.push(r);break}this.tn.next()}i.push(n)}while(this.tn.omit(","));return this.tn.skip(";"),i},o._parseExtend=function(e){var n=this.tn.next();if(!t.TYPEREF.test(n))throw Error("illegal extend reference: "+n);var r={ref:n,fields:[]};for(this.tn.skip("{");"}"!==(n=this.tn.next());)if(t.RULE.test(n))this._parseMessageField(r,n);else{if(!t.TYPEREF.test(n))throw Error("illegal extend token: "+n);if(!this.proto3)throw Error("illegal field rule: "+n);this._parseMessageField(r,"optional",n)}return this.tn.omit(";"),e.messages.push(r),r},o.toString=function(){return"Parser at line "+this.tn.line},n.Parser=a,n}(t,t.Lang),t.Reflect=function(e){var t={},r=function(e,t,n){this.builder=e,this.parent=t,this.name=n,this.className},i=r.prototype;i.fqn=function(){for(var e=this.name,t=this;;){if(null==(t=t.parent))break;e=t.name+"."+e}return e},i.toString=function(e){return(e?this.className+" ":"")+this.fqn()},i.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},t.T=r;var a=function(e,t,n,i,a){r.call(this,e,t,n),this.className="Namespace",this.children=[],this.options=i||{},this.syntax=a||"proto2"},o=a.prototype=Object.create(r.prototype);o.getChildren=function(e){if(null==(e=e||null))return this.children.slice();for(var t=[],n=0,r=this.children.length;n<r;++n)this.children[n]instanceof e&&t.push(this.children[n]);return t},o.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof l.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof l.Field&&e.name!==e.originalName&&null===this.getChild(e.originalName)))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+e.name);e.name=e.originalName}this.children.push(e)},o.getChild=function(e){for(var t="number"==typeof e?"id":"name",n=0,r=this.children.length;n<r;++n)if(this.children[n][t]===e)return this.children[n];return null},o.resolve=function(e,n){var r,i="string"==typeof e?e.split("."):e,a=this,o=0;if(""===i[o]){for(;null!==a.parent;)a=a.parent;o++}do{do{if(!(a instanceof t.Namespace)){a=null;break}if(!(r=a.getChild(i[o]))||!(r instanceof t.T)||n&&!(r instanceof t.Namespace)){a=null;break}a=r,o++}while(o<i.length);if(null!=a)break;if(null!==this.parent)return this.parent.resolve(e,n)}while(null!=a);return a},o.qn=function(e){var n=[],r=e;do{n.unshift(r.name),r=r.parent}while(null!==r);for(var i=1;i<=n.length;i++){var a=n.slice(n.length-i);if(e===this.resolve(a,e instanceof t.Namespace))return a.join(".")}return e.fqn()},o.build=function(){for(var e,t={},n=this.children,r=0,i=n.length;r<i;++r)(e=n[r])instanceof a&&(t[e.name]=e.build());return Object.defineProperty&&Object.defineProperty(t,"$options",{value:this.buildOpt()}),t},o.buildOpt=function(){for(var e={},t=Object.keys(this.options),n=0,r=t.length;n<r;++n){var i=t[n],a=this.options[t[n]];e[i]=a}return e},o.getOption=function(e){return void 0===e?this.options:void 0!==this.options[e]?this.options[e]:null},t.Namespace=a;var s=function(t,n,r,i,a){if(this.type=t,this.resolvedType=n,this.isMapKey=r,this.syntax=i,this.name=a,r&&e.MAP_KEY_TYPES.indexOf(t)<0)throw Error("Invalid map key type: "+t.name)},c=s.prototype;function u(t,n){if(t&&"number"==typeof t.low&&"number"==typeof t.high&&"boolean"==typeof t.unsigned&&t.low==t.low&&t.high==t.high)return new e.Long(t.low,t.high,void 0===n?t.unsigned:n);if("string"==typeof t)return e.Long.fromString(t,n||!1,10);if("number"==typeof t)return e.Long.fromNumber(t,n||!1);throw Error("not convertible to Long")}s.defaultFieldValue=function(t){if("string"==typeof t&&(t=e.TYPES[t]),void 0===t.defaultValue)throw Error("default value for type "+t.name+" is not supported");return t==e.TYPES.bytes?new n(0):t.defaultValue},c.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"},c.verifyValue=function(t){var r=this;function i(e,t){throw Error("Illegal value for "+r.toString(!0)+" of type "+r.type.name+": "+e+" ("+t+")")}switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:return("number"!=typeof t||t==t&&t%1!=0)&&i(O(t),"not an integer"),t>4294967295?0|t:t;case e.TYPES.uint32:case e.TYPES.fixed32:return("number"!=typeof t||t==t&&t%1!=0)&&i(O(t),"not an integer"),t<0?t>>>0:t;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return u(t,!1)}catch(e){i(O(t),e.message)}else i(O(t),"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return u(t,!0)}catch(e){i(O(t),e.message)}else i(O(t),"requires Long.js");case e.TYPES.bool:return"boolean"!=typeof t&&i(O(t),"not a boolean"),t;case e.TYPES.float:case e.TYPES.double:return"number"!=typeof t&&i(O(t),"not a number"),t;case e.TYPES.string:return"string"==typeof t||t&&t instanceof String||i(O(t),"not a string"),""+t;case e.TYPES.bytes:return n.isByteBuffer(t)?t:n.wrap(t,"base64");case e.TYPES.enum:var a=this.resolvedType.getChildren(e.Reflect.Enum.Value);for(s=0;s<a.length;s++){if(a[s].name==t)return a[s].id;if(a[s].id==t)return a[s].id}if("proto3"===this.syntax)return("number"!=typeof t||t==t&&t%1!=0)&&i(O(t),"not an integer"),(t>4294967295||t<0)&&i(O(t),"not in range for uint32"),t;i(t,"not a valid enum value");case e.TYPES.group:case e.TYPES.message:if(t&&"object"===O(t)||i(O(t),"object expected"),t instanceof this.resolvedType.clazz)return t;if(t instanceof e.Builder.Message){var o={};for(var s in t)t.hasOwnProperty(s)&&(o[s]=t[s]);t=o}return new this.resolvedType.clazz(t)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+t+" (undefined type "+this.type+")")},c.calculateLength=function(t,r){if(null===r)return 0;var i;switch(this.type){case e.TYPES.int32:return r<0?n.calculateVarint64(r):n.calculateVarint32(r);case e.TYPES.uint32:return n.calculateVarint32(r);case e.TYPES.sint32:return n.calculateVarint32(n.zigZagEncode32(r));case e.TYPES.fixed32:case e.TYPES.sfixed32:case e.TYPES.float:return 4;case e.TYPES.int64:case e.TYPES.uint64:return n.calculateVarint64(r);case e.TYPES.sint64:return n.calculateVarint64(n.zigZagEncode64(r));case e.TYPES.fixed64:case e.TYPES.sfixed64:return 8;case e.TYPES.bool:return 1;case e.TYPES.enum:return n.calculateVarint32(r);case e.TYPES.double:return 8;case e.TYPES.string:return i=n.calculateUTF8Bytes(r),n.calculateVarint32(i)+i;case e.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");return n.calculateVarint32(r.remaining())+r.remaining();case e.TYPES.message:return i=this.resolvedType.calculate(r),n.calculateVarint32(i)+i;case e.TYPES.group:return(i=this.resolvedType.calculate(r))+n.calculateVarint32(t<<3|e.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")},c.encodeValue=function(t,r,i){if(null===r)return i;switch(this.type){case e.TYPES.int32:r<0?i.writeVarint64(r):i.writeVarint32(r);break;case e.TYPES.uint32:i.writeVarint32(r);break;case e.TYPES.sint32:i.writeVarint32ZigZag(r);break;case e.TYPES.fixed32:i.writeUint32(r);break;case e.TYPES.sfixed32:i.writeInt32(r);break;case e.TYPES.int64:case e.TYPES.uint64:i.writeVarint64(r);break;case e.TYPES.sint64:i.writeVarint64ZigZag(r);break;case e.TYPES.fixed64:i.writeUint64(r);break;case e.TYPES.sfixed64:i.writeInt64(r);break;case e.TYPES.bool:"string"==typeof r?i.writeVarint32("false"===r.toLowerCase()?0:!!r):i.writeVarint32(r?1:0);break;case e.TYPES.enum:i.writeVarint32(r);break;case e.TYPES.float:i.writeFloat32(r);break;case e.TYPES.double:i.writeFloat64(r);break;case e.TYPES.string:i.writeVString(r);break;case e.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");var a=r.offset;i.writeVarint32(r.remaining()),i.append(r),r.offset=a;break;case e.TYPES.message:var o=(new n).LE();this.resolvedType.encode(r,o),i.writeVarint32(o.offset),i.append(o.flip());break;case e.TYPES.group:this.resolvedType.encode(r,i),i.writeVarint32(t<<3|e.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")}return i},c.decode=function(t,n,r){if(n!=this.type.wireType)throw Error("Unexpected wire type for element");var i,a;switch(this.type){case e.TYPES.int32:return 0|t.readVarint32();case e.TYPES.uint32:return t.readVarint32()>>>0;case e.TYPES.sint32:return 0|t.readVarint32ZigZag();case e.TYPES.fixed32:return t.readUint32()>>>0;case e.TYPES.sfixed32:return 0|t.readInt32();case e.TYPES.int64:return t.readVarint64();case e.TYPES.uint64:return t.readVarint64().toUnsigned();case e.TYPES.sint64:return t.readVarint64ZigZag();case e.TYPES.fixed64:return t.readUint64();case e.TYPES.sfixed64:return t.readInt64();case e.TYPES.bool:return!!t.readVarint32();case e.TYPES.enum:return t.readVarint32();case e.TYPES.float:return t.readFloat();case e.TYPES.double:return t.readDouble();case e.TYPES.string:return t.readVString();case e.TYPES.bytes:if(a=t.readVarint32(),t.remaining()<a)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+a+" required but got only "+t.remaining());return(i=t.clone()).limit=i.offset+a,t.offset+=a,i;case e.TYPES.message:return a=t.readVarint32(),this.resolvedType.decode(t,a);case e.TYPES.group:return this.resolvedType.decode(t,-1,r)}throw Error("[INTERNAL] Illegal decode type")},c.valueFromString=function(t){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:case e.TYPES.uint32:case e.TYPES.fixed32:return this.verifyValue(parseInt(t));case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:case e.TYPES.uint64:case e.TYPES.fixed64:return this.verifyValue(t);case e.TYPES.bool:return"true"===t;case e.TYPES.string:return this.verifyValue(t);case e.TYPES.bytes:return n.fromBinary(t)}},c.valueToString=function(t){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===e.TYPES.bytes?t.toString("binary"):t.toString()},t.Element=s;var l=function(e,t,n,r,i,o){a.call(this,e,t,n,r,o),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!i,this._fields=null,this._fieldsById=null,this._fieldsByName=null},_=l.prototype=Object.create(a.prototype);function d(t,n){var r=n.readVarint32(),i=7&r,a=r>>>3;switch(i){case e.WIRE_TYPES.VARINT:do{r=n.readUint8()}while(!(128&~r));break;case e.WIRE_TYPES.BITS64:n.offset+=8;break;case e.WIRE_TYPES.LDELIM:r=n.readVarint32(),n.offset+=r;break;case e.WIRE_TYPES.STARTGROUP:d(a,n);break;case e.WIRE_TYPES.ENDGROUP:if(a===t)return!1;throw Error("Illegal GROUPEND after unknown group: "+a+" ("+t+" expected)");case e.WIRE_TYPES.BITS32:n.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+t+": "+i)}return!0}_.build=function(t){if(this.clazz&&!t)return this.clazz;var r=function(e,t){var r=t.getChildren(e.Reflect.Message.Field),i=t.getChildren(e.Reflect.Message.OneOf),a=function(o,s){e.Builder.Message.call(this);for(var c=0,u=i.length;c<u;++c)this[i[c].name]=null;for(c=0,u=r.length;c<u;++c){var l=r[c];this[l.name]=l.repeated?[]:l.map?new e.Map(l):null,!l.required&&"proto3"!==t.syntax||null===l.defaultValue||(this[l.name]=l.defaultValue)}var _;if(arguments.length>0)if(1!==arguments.length||null===o||"object"!==O(o)||!("function"!=typeof o.encode||o instanceof a)||Array.isArray(o)||o instanceof e.Map||n.isByteBuffer(o)||o instanceof ArrayBuffer||e.Long&&o instanceof e.Long)for(c=0,u=arguments.length;c<u;++c)void 0!==(_=arguments[c])&&this.$set(r[c].name,_);else this.$set(o)},o=a.prototype=Object.create(e.Builder.Message.prototype);o.add=function(n,r,i){var a=t._fieldsByName[n];if(!i){if(!a)throw Error(this+"#"+n+" is undefined");if(!(a instanceof e.Reflect.Message.Field))throw Error(this+"#"+n+" is not a field: "+a.toString(!0));if(!a.repeated)throw Error(this+"#"+n+" is not a repeated field");r=a.verifyValue(r,!0)}return null===this[n]&&(this[n]=[]),this[n].push(r),this},o.$add=o.add,o.set=function(n,r,i){if(n&&"object"===O(n)){for(var a in i=r,n)n.hasOwnProperty(a)&&void 0!==(r=n[a])&&void 0===t._oneofsByName[a]&&this.$set(a,r,i);return this}var o=t._fieldsByName[n];if(i)this[n]=r;else{if(!o)throw Error(this+"#"+n+" is not a field: undefined");if(!(o instanceof e.Reflect.Message.Field))throw Error(this+"#"+n+" is not a field: "+o.toString(!0));this[o.name]=r=o.verifyValue(r)}if(o&&o.oneof){var s=this[o.oneof.name];null!==r?(null!==s&&s!==o.name&&(this[s]=null),this[o.oneof.name]=o.name):s===n&&(this[o.oneof.name]=null)}return this},o.$set=o.set,o.get=function(n,r){if(r)return this[n];var i=t._fieldsByName[n];if(!(i&&i instanceof e.Reflect.Message.Field))throw Error(this+"#"+n+" is not a field: undefined");if(!(i instanceof e.Reflect.Message.Field))throw Error(this+"#"+n+" is not a field: "+i.toString(!0));return this[i.name]},o.$get=o.get;for(var s=0;s<r.length;s++){var c=r[s];c instanceof e.Reflect.Message.ExtensionField||t.builder.options.populateAccessors&&function(e){var n=e.originalName.replace(/(_[a-zA-Z])/g,function(e){return e.toUpperCase().replace("_","")});n=n.substring(0,1).toUpperCase()+n.substring(1);var r=e.originalName.replace(/([A-Z])/g,function(e){return"_"+e}),i=function(t,n){return this[e.name]=n?t:e.verifyValue(t),this},a=function(){return this[e.name]};null===t.getChild("set"+n)&&(o["set"+n]=i),null===t.getChild("set_"+r)&&(o["set_"+r]=i),null===t.getChild("get"+n)&&(o["get"+n]=a),null===t.getChild("get_"+r)&&(o["get_"+r]=a)}(c)}function u(t,r,i,a){if(null===t||"object"!==O(t)){if(a&&a instanceof e.Reflect.Enum){var o=e.Reflect.Enum.getName(a.object,t);if(null!==o)return o}return t}if(n.isByteBuffer(t))return r?t.toBase64():t.toBuffer();if(e.Long.isLong(t))return i?t.toString():e.Long.fromValue(t);var s;if(Array.isArray(t))return s=[],t.forEach(function(e,t){s[t]=u(e,r,i,a)}),s;if(s={},t instanceof e.Map){for(var c=t.entries(),l=c.next();!l.done;l=c.next())s[t.keyElem.valueToString(l.value[0])]=u(l.value[1],r,i,t.valueElem.resolvedType);return s}var _=t.$type,d=void 0;for(var f in t)t.hasOwnProperty(f)&&(_&&(d=_.getChild(f))?s[f]=u(t[f],r,i,d.resolvedType):s[f]=u(t[f],r,i));return s}return o.encode=function(e,r){"boolean"==typeof e&&(r=e,e=void 0);var i=!1;e||(e=new n,i=!0);var a=e.littleEndian;try{return t.encode(this,e.LE(),r),(i?e.flip():e).LE(a)}catch(t){throw e.LE(a),t}},a.encode=function(e,t,n){return new a(e).encode(t,n)},o.calculate=function(){return t.calculate(this)},o.encodeDelimited=function(e,r){var i=!1;e||(e=new n,i=!0);var a=(new n).LE();return t.encode(this,a,r).flip(),e.writeVarint32(a.remaining()),e.append(a),i?e.flip():e},o.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toArrayBuffer()),e}},o.toArrayBuffer=o.encodeAB,o.encodeNB=function(){try{return this.encode().toBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBuffer()),e}},o.toBuffer=o.encodeNB,o.encode64=function(){try{return this.encode().toBase64()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBase64()),e}},o.toBase64=o.encode64,o.encodeHex=function(){try{return this.encode().toHex()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toHex()),e}},o.toHex=o.encodeHex,o.toRaw=function(e,t){return u(this,!!e,!!t,this.$type)},o.encodeJSON=function(){return JSON.stringify(u(this,!0,!0,this.$type))},a.decode=function(e,r,i){"string"==typeof r&&(i=r,r=-1),"string"==typeof e?e=n.wrap(e,i||"base64"):n.isByteBuffer(e)||(e=n.wrap(e));var a=e.littleEndian;try{var o=t.decode(e.LE(),r);return e.LE(a),o}catch(t){throw e.LE(a),t}},a.decodeDelimited=function(e,r){if("string"==typeof e?e=n.wrap(e,r||"base64"):n.isByteBuffer(e)||(e=n.wrap(e)),e.remaining()<1)return null;var i=e.offset,a=e.readVarint32();if(e.remaining()<a)return e.offset=i,null;try{var o=t.decode(e.slice(e.offset,e.offset+a).LE());return e.offset+=a,o}catch(t){throw e.offset+=a,t}},a.decode64=function(e){return a.decode(e,"base64")},a.decodeHex=function(e){return a.decode(e,"hex")},a.decodeJSON=function(e){return new a(JSON.parse(e))},o.toString=function(){return t.toString()},Object.defineProperty&&(Object.defineProperty(a,"$options",{value:t.buildOpt()}),Object.defineProperty(o,"$options",{value:a.$options}),Object.defineProperty(a,"$type",{value:t}),Object.defineProperty(o,"$type",{value:t})),a}(e,this);this._fields=[],this._fieldsById={},this._fieldsByName={},this._oneofsByName={};for(var i,a=0,o=this.children.length;a<o;a++)if((i=this.children[a])instanceof p||i instanceof l||i instanceof m){if(r.hasOwnProperty(i.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+i.toString(!0)+" cannot override static property '"+i.name+"'");r[i.name]=i.build()}else if(i instanceof l.Field)i.build(),this._fields.push(i),this._fieldsById[i.id]=i,this._fieldsByName[i.name]=i;else if(i instanceof l.OneOf)this._oneofsByName[i.name]=i;else if(!(i instanceof l.OneOf||i instanceof v))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[a].toString(!0));return this.clazz=r},_.encode=function(e,t,n){for(var r,i,a=null,o=0,s=this._fields.length;o<s;++o)i=e[(r=this._fields[o]).name],r.required&&null===i?null===a&&(a=r):r.encode(n?i:r.verifyValue(i),t,e);if(null!==a){var c=Error("Missing at least one required field for "+this.toString(!0)+": "+a);throw c.encoded=t,c}return t},_.calculate=function(e){for(var t,n,r=0,i=0,a=this._fields.length;i<a;++i){if(n=e[(t=this._fields[i]).name],t.required&&null===n)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);r+=t.calculate(n,e)}return r},_.decode=function(t,n,r){"number"!=typeof n&&(n=-1);for(var i,a,o,s,c=t.offset,u=new this.clazz;t.offset<c+n||-1===n&&t.remaining()>0;){if(o=(i=t.readVarint32())>>>3,(a=7&i)===e.WIRE_TYPES.ENDGROUP){if(o!==r)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+o+" ("+(r?r+" expected":"not a group")+")");break}if(s=this._fieldsById[o]){if(s.repeated&&!s.options.packed)u[s.name].push(s.decode(a,t));else if(s.map){var l=s.decode(a,t);u[s.name].set(l[0],l[1])}else if(u[s.name]=s.decode(a,t),s.oneof){var _=u[s.oneof.name];null!==_&&_!==s.name&&(u[_]=null),u[s.oneof.name]=s.name}}else switch(a){case e.WIRE_TYPES.VARINT:t.readVarint32();break;case e.WIRE_TYPES.BITS32:t.offset+=4;break;case e.WIRE_TYPES.BITS64:t.offset+=8;break;case e.WIRE_TYPES.LDELIM:var f=t.readVarint32();t.offset+=f;break;case e.WIRE_TYPES.STARTGROUP:for(;d(o,t););break;default:throw Error("Illegal wire type for unknown field "+o+" in "+this.toString(!0)+"#decode: "+a)}}for(var h=0,g=this._fields.length;h<g;++h)if(null===u[(s=this._fields[h]).name])if("proto3"===this.syntax)u[s.name]=s.defaultValue;else{if(s.required){var p=Error("Missing at least one required field for "+this.toString(!0)+": "+s.name);throw p.decoded=u,p}e.populateDefaults&&null!==s.defaultValue&&(u[s.name]=s.defaultValue)}return u},t.Message=l;var f=function(t,n,i,a,o,s,c,u,_,d){r.call(this,t,n,s),this.className="Message.Field",this.required="required"===i,this.repeated="repeated"===i,this.map="map"===i,this.keyType=a||null,this.type=o,this.resolvedType=null,this.id=c,this.options=u||{},this.defaultValue=null,this.oneof=_||null,this.syntax=d||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof l.ExtensionField||(this.name=e.Util.toCamelCase(this.name))},h=f.prototype=Object.create(r.prototype);h.build=function(){this.element=new s(this.type,this.resolvedType,!1,this.syntax,this.name),this.map&&(this.keyElement=new s(this.keyType,void 0,!0,this.syntax,this.name)),"proto3"!==this.syntax||this.repeated||this.map?void 0!==this.options.default&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=s.defaultFieldValue(this.type)},h.verifyValue=function(t,n){n=n||!1;var r,i=this;function a(e,t){throw Error("Illegal value for "+i.toString(!0)+" of type "+i.type.name+": "+e+" ("+t+")")}if(null===t)return this.required&&a(O(t),"required"),"proto3"===this.syntax&&this.type!==e.TYPES.message&&a(O(t),"proto3 field without field presence cannot be null"),null;if(this.repeated&&!n){Array.isArray(t)||(t=[t]);var o=[];for(r=0;r<t.length;r++)o.push(this.element.verifyValue(t[r]));return o}return this.map&&!n?t instanceof e.Map?t:(t instanceof Object||a(O(t),"expected ProtoBuf.Map or raw object for map field"),new e.Map(this,t)):(!this.repeated&&Array.isArray(t)&&a(O(t),"no array expected"),this.element.verifyValue(t))},h.hasWirePresence=function(t,n){if("proto3"!==this.syntax)return null!==t;if(this.oneof&&n[this.oneof.name]===this.name)return!0;switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:case e.TYPES.uint32:case e.TYPES.fixed32:return 0!==t;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:case e.TYPES.uint64:case e.TYPES.fixed64:return 0!==t.low||0!==t.high;case e.TYPES.bool:return t;case e.TYPES.float:case e.TYPES.double:return 0!==t;case e.TYPES.string:return t.length>0;case e.TYPES.bytes:return t.remaining()>0;case e.TYPES.enum:return 0!==t;case e.TYPES.message:return null!==t;default:return!0}},h.encode=function(t,r,i){if(null===this.type||"object"!==O(this.type))throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===t||this.repeated&&0==t.length)return r;try{var a;if(this.repeated)if(this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.ensureCapacity(r.offset+=1);var o=r.offset;for(a=0;a<t.length;a++)this.element.encodeValue(this.id,t[a],r);var s=r.offset-o,c=n.calculateVarint32(s);if(c>1){var u=r.slice(o,r.offset);o+=c-1,r.offset=o,r.append(u)}r.writeVarint32(s,o-c)}else for(a=0;a<t.length;a++)r.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t[a],r);else this.map?t.forEach(function(t,i,a){var o=n.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,i)+n.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,t);r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.writeVarint32(o),r.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,i,r),r.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,t,r)},this):this.hasWirePresence(t,i)&&(r.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t,r))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return r},h.calculate=function(t,r){if(t=this.verifyValue(t),null===this.type||"object"!==O(this.type))throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===t||this.repeated&&0==t.length)return 0;var i=0;try{var a,o;if(this.repeated)if(this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(i+=n.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),o=0,a=0;a<t.length;a++)o+=this.element.calculateLength(this.id,t[a]);i+=n.calculateVarint32(o),i+=o}else for(a=0;a<t.length;a++)i+=n.calculateVarint32(this.id<<3|this.type.wireType),i+=this.element.calculateLength(this.id,t[a]);else this.map?t.forEach(function(t,r,a){var o=n.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,r)+n.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,t);i+=n.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),i+=n.calculateVarint32(o),i+=o},this):this.hasWirePresence(t,r)&&(i+=n.calculateVarint32(this.id<<3|this.type.wireType),i+=this.element.calculateLength(this.id,t))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return i},h.decode=function(t,n,r){var i,a;if(!(!this.map&&t==this.type.wireType||!r&&this.repeated&&this.options.packed&&t==e.WIRE_TYPES.LDELIM||this.map&&t==e.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+t+" ("+this.type.wireType+" expected)");if(t==e.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!r){a=n.readVarint32(),a=n.offset+a;for(var o=[];n.offset<a;)o.push(this.decode(this.type.wireType,n,!0));return o}if(this.map){var c=s.defaultFieldValue(this.keyType);if(i=s.defaultFieldValue(this.type),a=n.readVarint32(),n.remaining()<a)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+a+" required but got only "+n.remaining());var u=n.clone();for(u.limit=u.offset+a,n.offset+=a;u.remaining()>0;){var l=u.readVarint32();t=7&l;var _=l>>>3;if(1===_)c=this.keyElement.decode(u,t,_);else{if(2!==_)throw Error("Unexpected tag in map field key/value submessage");i=this.element.decode(u,t,_)}}return[c,i]}return this.element.decode(n,t,this.id)},t.Message.Field=f;var g=function(e,t,n,r,i,a,o){f.call(this,e,t,n,null,r,i,a,o),this.extension};g.prototype=Object.create(f.prototype),t.Message.ExtensionField=g;t.Message.OneOf=function(e,t,n){r.call(this,e,t,n),this.fields=[]};var p=function(e,t,n,r,i){a.call(this,e,t,n,r,i),this.className="Enum",this.object=null};p.getName=function(e,t){for(var n,r=Object.keys(e),i=0;i<r.length;++i)if(e[n=r[i]]===t)return n;return null},(p.prototype=Object.create(a.prototype)).build=function(t){if(this.object&&!t)return this.object;for(var n=new e.Builder.Enum,r=this.getChildren(p.Value),i=0,a=r.length;i<a;++i)n[r[i].name]=r[i].id;return Object.defineProperty&&Object.defineProperty(n,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=n},t.Enum=p;var E=function(e,t,n,i){r.call(this,e,t,n),this.className="Enum.Value",this.id=i};E.prototype=Object.create(r.prototype),t.Enum.Value=E;var v=function(e,t,n,i){r.call(this,e,t,n),this.field=i};v.prototype=Object.create(r.prototype),t.Extension=v;var m=function(e,t,n,r){a.call(this,e,t,n,r),this.className="Service",this.clazz=null};(m.prototype=Object.create(a.prototype)).build=function(t){return this.clazz&&!t?this.clazz:this.clazz=function(e,t){for(var r=function(t){e.Builder.Service.call(this),this.rpcImpl=t||function(e,t,n){setTimeout(n.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},i=r.prototype=Object.create(e.Builder.Service.prototype),a=t.getChildren(e.Reflect.Service.RPCMethod),o=0;o<a.length;o++)(function(e){i[e.name]=function(r,i){try{try{r=e.resolvedRequestType.clazz.decode(n.wrap(r))}catch(e){if(!(e instanceof TypeError))throw e}if(null===r||"object"!==O(r))throw Error("Illegal arguments");r instanceof e.resolvedRequestType.clazz||(r=new e.resolvedRequestType.clazz(r)),this.rpcImpl(e.fqn(),r,function(n,r){if(n)i(n);else{null===r&&(r="");try{r=e.resolvedResponseType.clazz.decode(r)}catch(e){}r&&r instanceof e.resolvedResponseType.clazz?i(null,r):i(Error("Illegal response type received in service method "+t.name+"#"+e.name))}})}catch(e){setTimeout(i.bind(this,e),0)}},r[e.name]=function(t,n,i){new r(t)[e.name](n,i)},Object.defineProperty&&(Object.defineProperty(r[e.name],"$options",{value:e.buildOpt()}),Object.defineProperty(i[e.name],"$options",{value:r[e.name].$options}))})(a[o]);return Object.defineProperty&&(Object.defineProperty(r,"$options",{value:t.buildOpt()}),Object.defineProperty(i,"$options",{value:r.$options}),Object.defineProperty(r,"$type",{value:t}),Object.defineProperty(i,"$type",{value:t})),r}(e,this)},t.Service=m;var R=function(e,t,n,i){r.call(this,e,t,n),this.className="Service.Method",this.options=i||{}};(R.prototype=Object.create(r.prototype)).buildOpt=o.buildOpt,t.Service.Method=R;var T=function(e,t,n,r,i,a,o,s){R.call(this,e,t,n,s),this.className="Service.RPCMethod",this.requestName=r,this.responseName=i,this.requestStream=a,this.responseStream=o,this.resolvedRequestType=null,this.resolvedResponseType=null};return T.prototype=Object.create(R.prototype),t.Service.RPCMethod=T,t}(t),t.Builder=function(e,t,n){var r=function(e){this.ns=new n.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=e||{}},i=r.prototype;function a(e){e.messages&&e.messages.forEach(function(t){t.syntax=e.syntax,a(t)}),e.enums&&e.enums.forEach(function(t){t.syntax=e.syntax})}return r.isMessage=function(e){return"string"==typeof e.name&&(void 0===e.values&&void 0===e.rpc)},r.isMessageField=function(e){return"string"==typeof e.rule&&"string"==typeof e.name&&"string"==typeof e.type&&void 0!==e.id},r.isEnum=function(e){return"string"==typeof e.name&&!(void 0===e.values||!Array.isArray(e.values)||0===e.values.length)},r.isService=function(e){return!("string"!=typeof e.name||"object"!==O(e.rpc)||!e.rpc)},r.isExtend=function(e){return"string"==typeof e.ref},i.reset=function(){return this.ptr=this.ns,this},i.define=function(e){if("string"!=typeof e||!t.TYPEREF.test(e))throw Error("illegal namespace: "+e);return e.split(".").forEach(function(e){var t=this.ptr.getChild(e);null===t&&this.ptr.addChild(t=new n.Namespace(this,this.ptr,e)),this.ptr=t},this),this},i.create=function(t){if(!t)return this;if(Array.isArray(t)){if(0===t.length)return this;t=t.slice()}else t=[t];for(var i=[t];i.length>0;){if(t=i.pop(),!Array.isArray(t))throw Error("not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var a=t.shift();if(r.isMessage(a)){var o=new n.Message(this,this.ptr,a.name,a.options,a.isGroup,a.syntax),s={};a.oneofs&&Object.keys(a.oneofs).forEach(function(e){o.addChild(s[e]=new n.Message.OneOf(this,o,e))},this),a.fields&&a.fields.forEach(function(e){if(null!==o.getChild(0|e.id))throw Error("duplicate or invalid field id in "+o.name+": "+e.id);if(e.options&&"object"!==O(e.options))throw Error("illegal field options in "+o.name+"#"+e.name);var t=null;if("string"==typeof e.oneof&&!(t=s[e.oneof]))throw Error("illegal oneof in "+o.name+"#"+e.name+": "+e.oneof);e=new n.Message.Field(this,o,e.rule,e.keytype,e.type,e.name,e.id,e.options,t,a.syntax),t&&t.fields.push(e),o.addChild(e)},this);var c=[];if(a.enums&&a.enums.forEach(function(e){c.push(e)}),a.messages&&a.messages.forEach(function(e){c.push(e)}),a.services&&a.services.forEach(function(e){c.push(e)}),a.extensions&&("number"==typeof a.extensions[0]?o.extensions=[a.extensions]:o.extensions=a.extensions),this.ptr.addChild(o),c.length>0){i.push(t),t=c,c=null,this.ptr=o,o=null;continue}c=null}else if(r.isEnum(a))o=new n.Enum(this,this.ptr,a.name,a.options,a.syntax),a.values.forEach(function(e){o.addChild(new n.Enum.Value(this,o,e.name,e.id))},this),this.ptr.addChild(o);else if(r.isService(a))o=new n.Service(this,this.ptr,a.name,a.options),Object.keys(a.rpc).forEach(function(e){var t=a.rpc[e];o.addChild(new n.Service.RPCMethod(this,o,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))},this),this.ptr.addChild(o);else{if(!r.isExtend(a))throw Error("not a valid definition: "+JSON.stringify(a));if(o=this.ptr.resolve(a.ref,!0))a.fields.forEach(function(t){if(null!==o.getChild(0|t.id))throw Error("duplicate extended field id in "+o.name+": "+t.id);if(o.extensions){var r=!1;if(o.extensions.forEach(function(e){t.id>=e[0]&&t.id<=e[1]&&(r=!0)}),!r)throw Error("illegal extended field id in "+o.name+": "+t.id+" (not within valid ranges)")}var i=t.name;this.options.convertFieldsToCamelCase&&(i=e.Util.toCamelCase(i));var a=new n.Message.ExtensionField(this,o,t.rule,t.type,this.ptr.fqn()+"."+i,t.id,t.options),s=new n.Extension(this,this.ptr,t.name,a);a.extension=s,this.ptr.addChild(s),o.addChild(a)},this);else if(!/\.?google\.protobuf\./.test(a.ref))throw Error("extended message "+a.ref+" is not defined")}a=null,o=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},i.import=function(t,n){var r="/";if("string"==typeof n){if(e.Util.IS_NODE&&(n=require("path").resolve(n)),!0===this.files[n])return this.reset();this.files[n]=!0}else if("object"===O(n)){var i,o=n.root;if(e.Util.IS_NODE&&(o=require("path").resolve(o)),(o.indexOf("\\")>=0||n.file.indexOf("\\")>=0)&&(r="\\"),i=e.Util.IS_NODE?require("path").join(o,n.file):o+r+n.file,!0===this.files[i])return this.reset();this.files[i]=!0}if(t.imports&&t.imports.length>0){var s,c=!1;"object"===O(n)?(this.importRoot=n.root,c=!0,s=this.importRoot,n=n.file,(s.indexOf("\\")>=0||n.indexOf("\\")>=0)&&(r="\\")):"string"==typeof n?this.importRoot?s=this.importRoot:n.indexOf("/")>=0?""===(s=n.replace(/\/[^\/]*$/,""))&&(s="/"):n.indexOf("\\")>=0?(s=n.replace(/\\[^\\]*$/,""),r="\\"):s=".":s=null;for(var u=0;u<t.imports.length;u++)if("string"==typeof t.imports[u]){if(!s)throw Error("cannot determine import root");var l=t.imports[u];if("google/protobuf/descriptor.proto"===l)continue;if(l=e.Util.IS_NODE?require("path").join(s,l):s+r+l,!0===this.files[l])continue;/\.proto$/i.test(l)&&!e.DotProto&&(l=l.replace(/\.proto$/,".json"));var _=e.Util.fetch(l);if(null===_)throw Error("failed to import '"+l+"' in '"+n+"': file not found");/\.json$/i.test(l)?this.import(JSON.parse(_+""),l):this.import(e.DotProto.Parser.parse(_),l)}else n?/\.(\w+)$/.test(n)?this.import(t.imports[u],n.replace(/^(.+)\.(\w+)$/,function(e,t,n){return t+"_import"+u+"."+n})):this.import(t.imports[u],n+"_import"+u):this.import(t.imports[u]);c&&(this.importRoot=null)}t.package&&this.define(t.package),t.syntax&&a(t);var d=this.ptr;return t.options&&Object.keys(t.options).forEach(function(e){d.options[e]=t.options[e]}),t.messages&&(this.create(t.messages),this.ptr=d),t.enums&&(this.create(t.enums),this.ptr=d),t.services&&(this.create(t.services),this.ptr=d),t.extends&&this.create(t.extends),this.reset()},i.resolveAll=function(){var r;if(null==this.ptr||"object"===O(this.ptr.type))return this;if(this.ptr instanceof n.Namespace)this.ptr.children.forEach(function(e){this.ptr=e,this.resolveAll()},this);else if(this.ptr instanceof n.Message.Field){if(t.TYPE.test(this.ptr.type))this.ptr.type=e.TYPES[this.ptr.type];else{if(!t.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(!(r=(this.ptr instanceof n.Message.ExtensionField?this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0)))throw Error("unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(this.ptr.resolvedType=r,r instanceof n.Enum){if(this.ptr.type=e.TYPES.enum,"proto3"===this.ptr.syntax&&"proto3"!==r.syntax)throw Error("proto3 message cannot reference proto2 enum")}else{if(!(r instanceof n.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=r.isGroup?e.TYPES.group:e.TYPES.message}}if(this.ptr.map){if(!t.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=e.TYPES[this.ptr.keyType]}"proto3"===this.ptr.syntax&&this.ptr.repeated&&void 0===this.ptr.options.packed&&-1!==e.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType)&&(this.ptr.options.packed=!0)}else if(this.ptr instanceof e.Reflect.Service.Method){if(!(this.ptr instanceof e.Reflect.Service.RPCMethod))throw Error("illegal service type in "+this.ptr.toString(!0));if(!((r=this.ptr.parent.resolve(this.ptr.requestName,!0))&&r instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=r,!((r=this.ptr.parent.resolve(this.ptr.responseName,!0))&&r instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=r}else if(!(this.ptr instanceof e.Reflect.Message.OneOf||this.ptr instanceof e.Reflect.Extension||this.ptr instanceof e.Reflect.Enum.Value))throw Error("illegal object in namespace: "+O(this.ptr)+": "+this.ptr);return this.reset()},i.build=function(e){if(this.reset(),this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null),null===this.result&&(this.result=this.ns.build()),!e)return this.result;for(var t="string"==typeof e?e.split("."):e,n=this.result,r=0;r<t.length;r++){if(!n[t[r]]){n=null;break}n=n[t[r]]}return n},i.lookup=function(e,t){return e?this.ns.resolve(e,t):this.ns},i.toString=function(){return"Builder"},r.Message=function(){},r.Enum=function(){},r.Service=function(){},r}(t,t.Lang,t.Reflect),t.Map=function(e,t){var n=function(e,n){if(!e.map)throw Error("field is not a map");if(this.field=e,this.keyElem=new t.Element(e.keyType,null,!0,e.syntax),this.valueElem=new t.Element(e.type,e.resolvedType,!1,e.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),n)for(var r=Object.keys(n),i=0;i<r.length;i++){var a=this.keyElem.valueFromString(r[i]),o=this.valueElem.verifyValue(n[r[i]]);this.map[this.keyElem.valueToString(a)]={key:a,value:o}}},r=n.prototype;function i(e){var t=0;return{next:function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}}return r.clear=function(){this.map={}},r.delete=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e)),n=t in this.map;return delete this.map[t],n},r.entries=function(){for(var e,t=[],n=Object.keys(this.map),r=0;r<n.length;r++)t.push([(e=this.map[n[r]]).key,e.value]);return i(t)},r.keys=function(){for(var e=[],t=Object.keys(this.map),n=0;n<t.length;n++)e.push(this.map[t[n]].key);return i(e)},r.values=function(){for(var e=[],t=Object.keys(this.map),n=0;n<t.length;n++)e.push(this.map[t[n]].value);return i(e)},r.forEach=function(e,t){for(var n,r=Object.keys(this.map),i=0;i<r.length;i++)e.call(t,(n=this.map[r[i]]).value,n.key,this)},r.set=function(e,t){var n=this.keyElem.verifyValue(e),r=this.valueElem.verifyValue(t);return this.map[this.keyElem.valueToString(n)]={key:n,value:r},this},r.get=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e));if(t in this.map)return this.map[t].value},r.has=function(e){return this.keyElem.valueToString(this.keyElem.verifyValue(e))in this.map},n}(0,t.Reflect),t.loadProto=function(e,n,r){return("string"==typeof n||n&&"string"==typeof n.file&&"string"==typeof n.root)&&(r=n,n=void 0),t.loadJson(t.DotProto.Parser.parse(e),n,r)},t.newBuilder=function(e){return void 0===(e=e||{}).convertFieldsToCamelCase&&(e.convertFieldsToCamelCase=t.convertFieldsToCamelCase),void 0===e.populateAccessors&&(e.populateAccessors=t.populateAccessors),new t.Builder(e)},t.loadJson=function(e,n,r){return("string"==typeof n||n&&"string"==typeof n.file&&"string"==typeof n.root)&&(r=n,n=null),n&&"object"===O(n)||(n=t.newBuilder()),"string"==typeof e&&(e=JSON.parse(e)),n.import(e,r),n.resolveAll(),n},t}(),du=function(){return l(function e(t){c(this,e),cu.add(this),Object.defineProperty(this,"pbModules",{enumerable:!0,configurable:!0,writable:!0,value:void 0});var n=_u.loadProto(t);this.pbModules=n.build("Modules").probuf},[{key:"encode",value:function(e,t){return this.pbModules[e].encode(t).toArrayBuffer()}},{key:"decode",value:function(e,t){try{var n=this.pbModules[e].decode(t);return H(this,cu,"m",uu).call(this,n)}catch(t){var r="name: ".concat(e,", stack: ").concat(t.stack);throw null===console||void 0===console||console.error("pb decode error!",r),t}}}])}();cu=new WeakSet,uu=function e(t){var n,r=this;if(t instanceof Array)return t.map(function(t){return H(r,cu,"m",e).call(r,t)});if(n=t,"[object Object]"!==Object.prototype.toString.call(n))return t;if(t instanceof _u.ByteBuffer)return t.toArrayBuffer();if(t instanceof _u.Long)return t.toNumber();var i={};return Object.keys(t).forEach(function(n){i[n]=H(r,cu,"m",e).call(r,t[n])}),i};var fu,hu,gu,pu,Eu,vu,mu;!function(e){e[e.PERSON=1]="PERSON",e[e.PERSONS=2]="PERSONS",e[e.GROUP=3]="GROUP",e[e.TEMPGROUP=4]="TEMPGROUP",e[e.CUSTOMERSERVICE=5]="CUSTOMERSERVICE",e[e.NOTIFY=6]="NOTIFY",e[e.MC=7]="MC",e[e.MP=8]="MP",e[e.ULTRAGROUP=10]="ULTRAGROUP"}(fu||(fu={})),function(e){e[e.IMAGE=1]="IMAGE",e[e.AUDIO=2]="AUDIO",e[e.VIDEO=3]="VIDEO",e[e.FILE=4]="FILE",e[e.SIGHT=5]="SIGHT",e[e.COMBINE_HTML=6]="COMBINE_HTML"}(hu||(hu={})),function(e){e[e.GROUP_SUCCESS=0]="GROUP_SUCCESS",e[e.GROUP_FAILURE=1]="GROUP_FAILURE"}(gu||(gu={})),function(e){e[e.IsSilent=1]="IsSilent",e[e.IsTop=2]="IsTop",e[e.Tags=3]="Tags",e[e.AutoTrans=4]="AutoTrans"}(pu||(pu={})),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE",e[e.COEXIST=2]="COEXIST"}(Eu||(Eu={})),function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(vu||(vu={})),function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(mu||(mu={})),new du("package Modules;\nmessage probuf {\n message SetUserStatusOutput {\n optional int32 nothing=1;\n }\n message GetUserStatusInput {\n optional int32 nothing=1;\n }\n message GetUserStatusOutput {\n optional string status=1;\n optional string subUserId=2;\n }\n message SubUserStatusInput {\n repeated string userid =1;\n }\n message SubUserStatusOutput {\n optional int32 nothing=1;\n }\n message VoipDynamicInput {\n required int32 engineType = 1;\n required string channelName = 2;\n optional string channelExtra = 3;\n }\n message VoipDynamicOutput {\n required string dynamicKey=1;\n }\n message NotifyMsg {\n required int32 type = 1;\n optional int64 time = 2;\n optional string chrmId=3;\n }\n message SyncRequestMsg {\n required int64 syncTime = 1;\n required bool ispolling = 2;\n optional bool isweb=3;\n optional bool isPullSend=4;\n optional bool isKeeping=5;\n optional int64 sendBoxSyncTime=6;\n optional int64 broadcastSyncTime=7;\n optional int64 endTime = 8;\n optional bool compressioEnabled = 9;\n }\n message UpStreamMessage {\n required int32 sessionId = 1;\n required string classname = 2;\n required string content = 3;\n optional string pushText = 4;\n optional string appData = 5;\n repeated string toUserIds = 6;\n optional int64 delMsgTime = 7;\n optional string delMsgId = 8;\n optional int32 configFlag = 9;\n optional int64 clientUniqueId = 10;\n optional string extraContent = 11;\n optional PushExtra pushExt = 12;\n optional string busChannel = 13;\n optional string systemId = 16;\n optional string senderPortrait = 21;\n optional int64 optionBits = 22;\n }\n message PushExtra {\n optional string title = 1;\n optional int32 templateIdNoUse= 2;\n optional string pushId = 3;\n optional string pushConfigs = 4;\n optional string templateId = 5;\n }\n message DownStreamMessages {\n repeated DownStreamMessage list = 1;\n required int64 syncTime = 2;\n optional bool finished = 3;\n optional int64 broadcastSyncTime = 4;\n optional int64 systemTime = 5;\n optional int64 credibleStartTime = 6;\n optional int64 credibleEndTime = 7;\n optional bool compressioEnabled = 8;\n optional bytes compressedData = 9;\n }\n message ChrmDownStreamMessages {\n repeated bytes list = 1;\n required int64 syncTime = 2;\n optional bool compressioEnabled = 3;\n optional bytes compressedData = 4;\n }\n message DownStreamMessage {\n required string fromUserId = 1;\n required ChannelType type = 2;\n optional string groupId = 3;\n required string classname = 4;\n required string content = 5;\n required int64 dataTime = 6;\n required int64 status = 7;\n optional int64 extra = 8;\n optional string msgId = 9;\n optional int32 direction = 10;\n optional int32 plantform =11;\n optional int32 isRemoved = 12;\n optional string source = 13;\n optional int64 clientUniqueId = 14;\n optional string extraContent = 15;\n optional string pushContent = 16;\n optional int32 configFlag = 17;\n optional PushExtra pushExt = 18;\n optional string busChannel = 19;\n optional int64 extStatus = 20;\n repeated string toUserIds = 21;\n optional int32 groupUnpush = 22;\n optional int64 optionBits = 23;\n optional string convertExt = 24;\n optional ExtMsgData extMsgData = 25;\n }\n message ExtMsgData {\n optional int64 seqId = 1;\n optional int64 sendTime = 2;\n }\n enum ChannelType {\n PERSON = 1;\n PERSONS = 2;\n GROUP = 3;\n TEMPGROUP = 4;\n CUSTOMERSERVICE = 5;\n NOTIFY = 6;\n MC=7;\n MP=8;\n ULTRAGROUP = 10;\n }\n message CreateDiscussionInput {\n optional string name = 1;\n }\n message CreateDiscussionOutput {\n required string id = 1;\n }\n message ChannelInvitationInput {\n repeated string users = 1;\n }\n message LeaveChannelInput {\n required int32 nothing = 1;\n }\n message ChannelEvictionInput {\n required string user = 1;\n }\n message RenameChannelInput {\n required string name = 1;\n }\n message ChannelInfoInput {\n required int32 nothing = 1;\n }\n message ChannelInfoOutput {\n required ChannelType type = 1;\n required string channelId = 2;\n required string channelName = 3;\n required string adminUserId = 4;\n repeated string firstTenUserIds = 5;\n required int32 openStatus = 6;\n }\n message ChannelInfosInput {\n required int32 page = 1;\n optional int32 number = 2;\n }\n message ChannelInfosOutput {\n repeated ChannelInfoOutput channels = 1;\n required int32 total = 2;\n }\n message MemberInfo {\n required string userId = 1;\n required string userName = 2;\n required string userPortrait = 3;\n required string extension = 4;\n }\n message GroupMembersInput {\n required int32 page = 1;\n optional int32 number = 2;\n }\n message GroupMembersOutput {\n repeated MemberInfo members = 1;\n required int32 total = 2;\n }\n message GetUserInfoInput {\n required int32 nothing = 1;\n }\n message GetUserInfoOutput {\n required string userId = 1;\n required string userName = 2;\n required string userPortrait = 3;\n }\n message GetSessionIdInput {\n required int32 nothing = 1;\n }\n message GetSessionIdOutput {\n required int32 sessionId = 1;\n }\n enum FileType {\n IMAGE = 1;\n AUDIO = 2;\n VIDEO = 3;\n FILE = 4;\n SIGHT = 5;\n COMBINE_HTML = 6;\n }\n message GetQNupTokenInput {\n required FileType type = 1;\n optional string key = 2;\n optional string httpMethod = 3;\n optional string queryString = 4;\n optional string url = 5;\n optional string ext = 6;\n optional int64 size = 7;\n optional int32 ipType = 8;\n }\n message GetQNdownloadUrlInput {\n required FileType type = 1;\n required string key = 2;\n optional string fileName = 3;\n }\n message GetDownloadUrlInput {\n required FileType type = 1;\n required string key = 2;\n optional string fileName = 3;\n optional string ext = 4;\n optional int64 size = 5;\n optional int32 ipType = 6;\n }\n message GetQNupTokenOutput {\n required int64 deadline = 1;\n required string token = 2;\n optional string bosToken = 3;\n optional string bosDate = 4;\n optional string path = 5;\n\n optional string osskeyId = 6;\n optional string ossPolicy = 7;\n optional string ossSign = 8;\n optional string ossBucketName = 9;\n\n optional string s3Credential = 10;\n optional string s3Algorithm = 11;\n optional string s3Date = 12;\n optional string s3Policy = 13;\n optional string s3Signature = 14;\n optional string s3BucketName = 15;\n\n optional string stcAuthorization = 16;\n optional string stcContentSha256 = 17;\n optional string stcDate = 18;\n optional string stcBucketName = 19;\n\n optional string minioAuthorization = 20;\n optional string minioContentSha256 = 21;\n optional string minioDate = 22;\n optional string minioBucketName = 23;\n\n optional string downloadAuthInfo = 24;\n optional string ossConfig = 25;\n }\n message GetQNdownloadUrlOutput {\n required string downloadUrl = 1;\n }\n message GetDownloadUrlOutput {\n required string downloadUrl = 1;\n }\n message Add2BlackListInput {\n required string userId = 1;\n }\n message RemoveFromBlackListInput {\n required string userId = 1;\n }\n message QueryBlackListInput {\n required int32 nothing = 1;\n }\n message QueryBlackListOutput {\n repeated string userIds = 1;\n }\n message BlackListStatusInput {\n required string userId = 1;\n }\n message BlockPushInput {\n required string blockeeId = 1;\n }\n message ModifyPermissionInput {\n required int32 openStatus = 1;\n }\n message GroupInput {\n repeated GroupInfo groupInfo = 1;\n }\n message GroupOutput {\n required int32 nothing = 1;\n }\n message GroupInfo {\n required string id = 1;\n required string name = 2;\n }\n message GroupHashInput {\n required string userId = 1;\n required string groupHashCode = 2;\n }\n message GroupHashOutput {\n required GroupHashType result = 1;\n }\n enum GroupHashType {\n GROUP_SUCCESS = 0x00;\n GROUP_FAILURE = 0x01;\n }\n message ChrmInput {\n required int32 nothing = 1;\n optional string extra = 2;\n }\n message ChrmOutput {\n required int32 nothing = 1;\n optional string sessionId = 2;\n optional int64 joinTime = 3;\n optional int64 createTime = 4;\n optional int32 memberCount = 5;\n optional int32 chatroomBanState = 6;\n optional int32 whiteListState = 7;\n }\n message ChrmPullMsg {\n required int64 syncTime = 1;\n required int32 count = 2;\n optional int32 pullMsgType = 3;\n optional bool compressioEnabled = 4;\n }\n message ChrmPullMsgNew {\n required int32 count = 1;\n required int64 syncTime = 2;\n optional string chrmId=3;\n }\n message RelationQryInput {\n optional ChannelType type = 1;\n optional int32 count = 2;\n optional int64 startTime = 3;\n optional int32 order = 4;\n optional bool isEraseMsgContent = 5;\n optional int64 endTime = 6;\n optional bool compressioEnabled = 7;\n optional int32 qryType = 8;\n }\n message RelationsOutput {\n repeated RelationInfo info = 1;\n optional bool isFinished = 2;\n optional int64 pullTime = 3;\n optional bool compressioEnabled = 4; \n optional bytes compressedData = 5;\n }\n message RelationInfo {\n required ChannelType type = 1;\n required string userId = 2;\n optional DownStreamMessage msg =3;\n optional int64 readMsgTime= 4;\n optional int64 unreadCount= 5;\n optional string busChannel = 6;\n optional int64 versionTime = 7;\n optional int64 remindCount = 8;\n optional int32 busChannelType = 9;\n optional UnreadMsgInfo msgInfo = 10;\n optional int32 remindMeCount = 11;\n }\n message UnreadMsgInfo {\n required string msgId = 1;\n required int64 msgTime= 2;\n optional int32 remindType= 3;\n optional string className = 4;\n }\n message QryRemindListReq {\n required string groupId = 1;\n optional string busChannel = 2;\n optional int64 msgTime = 3;\n optional int32 size = 4;\n }\n message QryRemindListResp {\n repeated UnreadMsgInfo msgInfo = 1;\n }\n message RelationInfoReadTime {\n required ChannelType type = 1;\n required int64 readMsgTime= 2;\n required string targetId = 3;\n }\n message CleanHisMsgInput {\n required string targetId = 1;\n required int64 dataTime = 2;\n optional int32 conversationType= 3;\n optional string busChannel = 4;\n }\n message CleanMsgBatchReq {\n repeated CleanHisMsgInput input = 1;\n }\n message HistoryMessageInput {\n required string targetId = 1;\n required int64 dataTime =2;\n required int32 size = 3;\n }\n\n message HistoryMessagesOuput {\n repeated DownStreamMessage list = 1;\n required int64 syncTime = 2;\n required int32 hasMsg = 3;\n optional int64 credibleStartTime = 4;\n optional int64 credibleEndTime = 5;\n optional bool compressioEnabled = 6; \n optional bytes compressedData = 7;\n }\n message QueryChatRoomInfoInput {\n required int32 count= 1;\n optional int32 order= 2;\n }\n\n message QueryChatRoomInfoOutput {\n optional int32 userTotalNums = 1;\n repeated ChrmMember userInfos = 2;\n }\n message ChrmMember {\n required int64 time = 1;\n required string id = 2;\n }\n message MPFollowInput {\n required string id = 1;\n }\n\n message MPFollowOutput {\n required int32 nothing = 1;\n optional MpInfo info =2;\n }\n\n message MCFollowOutput {\n required int32 nothing = 1;\n optional MpInfo info =2;\n }\n\n message MpInfo {\n required string mpid=1;\n required string name = 2;\n required string type = 3;\n required int64 time=4;\n optional string portraitUrl=5;\n optional string extra =6;\n }\n\n message SearchMpInput {\n required int32 type=1;\n required string id=2;\n }\n\n message SearchMpOutput {\n required int32 nothing=1;\n repeated MpInfo info = 2;\n }\n\n message PullMpInput {\n required int64 time=1;\n required string mpid=2;\n }\n\n message PullMpOutput {\n required int32 status=1;\n repeated MpInfo info = 2;\n }\n message HistoryMsgInput {\n optional string targetId = 1;\n optional int64 time = 2;\n optional int32 count = 3;\n optional int32 order = 4;\n optional string busChannel = 5;\n optional bool compressioEnabled = 6;\n optional bool ignoreCmd = 10;\n }\n\n message HistoryMsgOuput {\n repeated DownStreamMessage list=1;\n required int64 syncTime=2;\n required int32 hasMsg=3;\n optional int64 credibleStartTime = 4;\n optional int64 credibleEndTime = 5;\n optional bool compressioEnabled = 6;\n optional bytes compressedData = 7;\n }\n message SessionsAttQryInput {\n required int32 nothing = 1;\n }\n message SessionsAttOutput {\n required int64 inboxTime = 1;\n required int64 sendboxTime = 2;\n required int64 totalUnreadCount = 3;\n }\n message SessionMsgReadInput {\n required ChannelType type = 1;\n required int64 msgTime = 2;\n required string channelId = 3;\n optional string busChannel = 4;\n }\n message SessionMsgReadOutput {\n optional int32 nothing=1;\n }\n message DeleteSessionsInput {\n repeated SessionInfo sessions = 1;\n }\n message SessionInfo {\n required ChannelType type = 1;\n required string channelId = 2;\n optional int64 unreadCount = 3;\n optional string busChannel = 4;\n }\n message QuerySessionsInput {\n repeated SessionInfo sessions = 1;\n }\n message QuerySessionsOutPut {\n repeated SessionInfo sessions = 1;\n }\n message DeleteSessionsOutput {\n optional int32 nothing=1;\n }\n message RelationDelBatchReq {\n repeated RelationOpInput relation = 1;\n optional bool cleanMsg = 2;\n }\n message RelationOpInput {\n required string conversationId = 1;\n required ChannelType conversationType = 2;\n optional string busChannel = 3;\n }\n message DeleteMsgInput {\n optional ChannelType type = 1;\n optional string conversationId = 2;\n repeated DeleteMsg msgs = 3;\n optional string busChannel = 4;\n }\n message DeleteMsg {\n optional string msgId = 1;\n optional int64 msgDataTime = 2;\n optional int32 direct = 3;\n }\n message ChrmKVEntity {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n optional int64 version = 6;\n }\n message SetChrmKV {\n required ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message SetChrmKVS {\n repeated ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message DeleteChrmKVS {\n repeated ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message ChrmKVOutput {\n repeated ChrmKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3;\n optional bool compressioEnabled = 4; \n optional bytes compressedData = 5;\n }\n message ChrmKVSVersionEntity {\n optional int64 version = 1;\n optional string key = 2;\n }\n\n message ChrmKVSOutput {\n repeated ChrmKVSOutputEntity errorKeys = 1;\n repeated ChrmKVSVersionEntity keysVersion = 2;\n }\n message ChrmKVSOutputEntity {\n optional string key = 1;\n optional int32 errorCode = 2;\n }\n message QueryChrmKV {\n required int64 timestamp = 1;\n optional bool compressioEnabled = 2;\n }\n message SetUserSettingInput {\n required int64 version=1;\n required string value=2;\n optional bool ignoreVersion = 3;\n }\n message SetUserSettingOutput {\n required int64 version=1;\n required bool reserve=2;\n optional bool updateVersion = 3;\n }\n message PullUserSettingInput {\n required int64 version=1;\n optional bool reserve=2;\n optional int32 ipType = 3;\n }\n message PullUserSettingOutput {\n repeated UserSettingItem items = 1;\n required int64 version=2;\n }\n message UserSettingItem {\n required string targetId= 1;\n required ChannelType type = 2;\n required string key = 4;\n required bytes value = 5;\n required int64 version=6;\n required int32 status=7;\n repeated SessionTagItem tags= 8;\n }\n message SessionReq {\n required int64 time = 1;\n }\n message SessionStates {\n required int64 version=1;\n repeated SessionState state= 2;\n }\n message SessionState {\n required ChannelType type = 1;\n required string channelId = 2;\n optional int64 time = 3;\n repeated SessionStateItem stateItem = 4;\n optional string busChannel = 5;\n }\n message SessionStateItem {\n required SessionStateType sessionStateType = 1;\n required string value = 2;\n repeated SessionTagItem tags = 3;\n optional int64 time = 4;\n }\n enum SessionStateType {\n IsSilent = 1;\n IsTop = 2;\n Tags = 3;\n AutoTrans = 4;\n }\n message SessionStateModifyReq {\n required int64 version=1;\n repeated SessionState state= 2;\n optional bool ignoreVersion = 3;\n }\n message GroupUnpushQuery {\n optional string busChannel = 1;\n }\n message GroupUnpushSet{\n optional string busChannel = 1;\n required int32 unpushLevel = 2;\n }\n message GroupUnpushResult {\n required string groupId = 1;\n optional string busChannel = 2;\n required int32 unpushLevel = 3;\n }\n message SessionStateModifyResp {\n required int64 version=1;\n optional bool updateVersion = 2;\n }\n message TypeUnpushInput {\n required ChannelType type = 1;\n required int64 version = 2;\n required int32 unpushLevel = 3;\n optional bool ignoreVersion = 4;\n }\n message TypeUnpushOutput {\n required int64 version = 1;\n optional bool updateVersion = 2;\n }\n message GrpReadReceiptMsg {\n repeated string msgId=1;\n optional string channelId = 2;\n }\n message GrpReadReceiptQryReq {\n repeated string msgId=1;\n optional string channelId = 2;\n }\n message ReadReceipt {\n optional string targetId = 1;\n optional int32 type = 2;\n optional string channelId = 3;\n optional int32 readType =4 ;\n repeated string msgIds= 5 ;\n optional string fromId = 6;\n }\n message QueryReceiptReq {\n optional string targetId = 1;\n optional string busChannel =2;\n optional int32 type = 3;\n repeated string msgIds = 4;\n optional int32 qryType = 5;\n optional int32 order =6;\n optional bool compress = 7;\n optional int32 readType = 8;\n optional int32 pageType = 9; \n optional int32 pageSize = 10;\n optional string pageToken = 11;\n repeated string users = 12;\n }\n message QueryReceiptBatchReq {\n repeated QueryReceipt items = 1;\n optional bool compress = 2;\n }\n message QueryReceipt {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 type = 3;\n repeated string msgIds = 4;\n }\n message ReceiptResp {\n repeated QueryReceiptRespItem resp = 1;\n optional bool compress = 2;\n optional bytes compressData = 3;\n optional string pageToken = 4;\n }\n message QueryReceiptBatchResp {\n repeated QueryReceiptBatchRespItem item = 1;\n optional bool compress = 2;\n optional bytes compressData = 3;\n }\n\n message QueryReceiptBatchRespItem {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 type = 3;\n repeated QueryReceiptRespItem msg = 4;\n }\n message QueryReceiptRespItem {\n optional string msgId = 1;\n optional int64 msgTime = 2;\n optional int32 totalCnt = 3;\n optional int64 readCnt = 4;\n repeated ReceiptUser readUser = 5;\n repeated string unreadList = 6;\n optional int64 unreadCnt = 7;\n repeated ReceiptUser unreadUser = 8;\n }\n message GrpReadReceiptQryResp {\n required int32 totalMemberNum = 1;\n repeated GrpMsgReadUser list = 2;\n }\n message GrpMsgReadUser {\n required int64 readTime = 1;\n required string userId = 2;\n }\n message SessionTagAddInput {\n required int64 version=1;\n repeated SessionTagItem tags=2;\n optional bool ignoreVersion = 3;\n }\n message SessionTagItem {\n required string tagId=1;\n optional string name=2;\n optional int64 createdTime=3;\n optional bool isTop=4;\n }\n message SessionTagDelInput {\n required int64 version=1;\n repeated SessionTagItem tags=2;\n optional bool ignoreVersion = 3;\n }\n message SessionDisTagReq {\n repeated string tagId=1;\n }\n message UserSettingNotification {\n required int64 version=1;\n required bool reserve=2;\n }\n message ReportSDKInput {\n required string sdkInfo=1;\n }\n message ReportSDKOutput {\n optional int32 nothing=1;\n }\n message UltraGrpPullSes {\n required int64 syncTime = 1;\n optional bool isEraseMsgContent = 2;\n }\n message UltraGrpPullMsg {\n required int64 syncTime = 1;\n optional bool compressioEnabled = 2;\n }\n message MsgChangeReq {\n required string fromUserId = 1;\n required string targetId = 2;\n required ChannelType type = 3;\n required string msgUID = 4;\n required int64 msgTime = 5;\n optional string busChannel = 6;\n optional string content = 7;\n }\n message ModifyMsgResp {\n optional int64 modifyTime = 1;\n optional DownStreamMessage msg = 2;\n }\n message QueryMsgChange {\n required int64 syncTime = 1;\n optional int32 needCompress = 2;\n optional int64 onlineTime = 3;\n optional string targetId = 4;\n }\n message EventChangeList {\n repeated EventChange list = 1;\n required int64 syncTime = 2;\n optional bool hasNext = 3 ;\n optional string targetId = 4;\n optional bool isCompress = 5 ;\n }\n message EventChange {\n optional string businessId = 1;\n optional ChannelType channelType = 2;\n optional int64 time = 3;\n optional int32 changeType = 4;\n optional string originalId = 5;\n optional int64 originalTime = 6;\n optional string secondaryId = 7;\n optional bool isAdmin = 8;\n optional bool additionalMark = 9; \n optional string operatorId = 10;\n optional int32 subChangeType = 11;\n optional int32 secondaryType = 12;\n optional bool isRemindMe = 13;\n repeated string extIds = 14;\n optional int32 remindType = 15;\n optional bytes eventData = 16;\n }\n message MsgChangeList {\n repeated MsgChange list = 1;\n required int64 syncTime = 2;\n optional bool hasNext = 3 ;\n }\n message MsgChange {\n required string targetId = 1;\n required ChannelType type = 2;\n required int64 time = 3;\n required int32 changeType = 4;\n required string msgUID = 5;\n required int64 msgTime = 6;\n optional string busChannel = 7;\n optional bool isAdmin = 8;\n optional bool isDel = 9;\n optional string operatorId = 10;\n optional int32 subChangeType = 11;\n optional int32 busChannelType = 12;\n optional bool isRemindMe = 13;\n repeated string userGroupIds = 14;\n optional int32 remindType = 15;\n }\n message MsgQuery {\n required string targetId = 1;\n required ChannelType type = 2;\n repeated MessageQueryInfo query = 3; //\n }\n message MessageQueryInfo {\n required int64 msgTime = 1;\n required string msgUID = 2;\n optional string busChannel = 3;\n }\n message MsgQueryAck {\n repeated DownStreamMessage list = 1;\n repeated string notExistMsgId = 2;\n }\n message OperateStatus {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional int32 opType = 3;\n optional string busChannel = 4;\n }\n message OperateStatusNotify {\n optional ChannelType type = 1;\n optional int64 notifyType = 2;\n repeated OperateInfo info = 3 ;\n repeated OperateSummary summary = 4 ;\n }\n message OperateInfo {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional string userId = 3;\n optional int32 opType = 4;\n optional int64 optime = 5;\n }\n \n message OperateSummary {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 count = 3;\n optional int32 opType = 4;\n }\n\n message SetRtcRoomIdInput {\n required string rtcRoomId= 1;\n }\n message SetRtcRoomIdOutput {\n required int32 nothing = 1;\n }\n message CallInfoUpStream {\n required string key= 1;\n required string dataContent=2;\n }\n message CallInfoDownStream {\n required string key= 1;\n required string dataContent=2;\n required int64 maxTime=3;\n }\n message KvInput {\n required int64 syncTime = 1;\n }\n message KvOutput {\n required int64 maxTime = 1;\n repeated KvInfo info = 2;\n }\n message KvInfo {\n required string key =1;\n required string value =2;\n }\n message ReadReceiptMsg {\n required string targetId = 1;\n required ChannelType type = 2;\n optional string busChannel = 3;\n optional string startMsgId = 4;\n optional string endMsgId = 5;\n }\n message ReceiptQryReq {\n required string msgId = 1;\n optional string busChannel = 2;\n required string targetId = 3;\n }\n message QueryReceiptResp {\n optional int32 num = 1;\n repeated ReceiptUser list = 2;\n optional int32 readCnt = 3;\n }\n message ReceiptUser {\n optional int64 receiptTime = 1;\n optional string userId = 2;\n optional string name = 3;\n optional string portrait = 4;\n optional bool mentioned= 5;\n }\n message ReceiptCntQryReq {\n optional ChannelType type = 1;\n optional string channelId = 2;\n optional string busChannel = 3;\n repeated string msgId = 4;\n }\n message ReceiptCntQryResp {\n repeated MsgReadCnt result= 1;\n }\n\n message MsgReadCnt {\n optional string msgId = 1;\n optional int32 cnt = 2;\n optional int32 tmn = 3;\n }\n message UpdateUserSubReq {\n optional int32 subType = 1;\n repeated UserSubDetail subUsers = 2;\n optional int32 opType = 3;\n optional int32 expiry = 4;\n }\n message UserSubDetail {\n optional string subUserId = 1;\n }\n message UpdateUserSubResp {\n repeated UserSubDetail subUsers = 1;\n optional int64 subTime = 2;\n }\n message PullUserSubReq {\n optional int64 version = 1;\n optional string pageToken = 2;\n }\n message PUllUserSubResp {\n repeated UserSubList list = 1;\n optional int64 version = 2;\n optional bool hasNext = 3;\n optional string pageToken = 4;\n optional bool isFull = 5;\n }\n message UserSubList {\n repeated UserSubDetail subUsers = 1;\n optional int32 subType = 2;\n optional int64 subTime = 3;\n optional int32 expiry = 4;\n optional int32 opType = 5;\n }\n message PullSubDataReq {\n optional int64 versionTime = 1;\n optional bool needAllData = 2;\n optional string pageToken = 3;\n }\n message PullSubDataResp {\n repeated SubDataDetail list = 1;\n optional int64 versionTime = 2;\n optional bool hasNext = 3;\n optional string pageToken = 4;\n optional bool isFull = 5;\n }\n message SubDataDetail {\n optional string statusStr = 1;\n optional string subUserId = 2;\n repeated SubData data = 3;\n optional int32 subType = 4;\n }\n\n message SubData {\n optional int32 platformInfo = 1;\n optional int32 value = 2;\n optional int64 versionTime = 3;\n }\n message QrySubDataReq {\n optional int32 subType = 1;\n repeated UserSubDetail subUsers = 2;\n }\n message UserProfile {\n optional int64 version = 1;\n optional string userId = 2;\n repeated ProfileInfo userProfile = 3;\n repeated ProfileInfo userExtProfile = 4;\n }\n message ProfileInfo {\n optional string key = 1;\n optional string value = 2;\n }\n message SetUserProfileResp {\n optional int64 version = 1;\n optional string key = 2;\n repeated string censorFailedFields = 3;\n }\n message PullUserProfileReq {\n repeated string userId = 1;\n }\n message UserProfiles {\n repeated UserProfile UserProfile = 1;\n }\n message UserProfileInput {\n required int32 nothing = 1;\n }\n message UserProfilePermission {\n optional int32 permission = 1;\n }\n message UserProfileOutput {\n required int32 nothing = 1;\n }\n message SearchUserProfile {\n optional string uniqueId = 1;\n }\n message ChannelsInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated ProfileInfo settingProfile = 3;\n repeated ProfileInfo extProfile = 4;\n optional ChannelBaseInfo baseInfo = 5;\n repeated string users = 6;\n }\n\n message ChannelBaseInfo {\n optional string creatorId = 1;\n optional string ownerId = 2;\n optional int64 createTime = 3;\n optional int32 memberCount = 4;\n }\n\n message ChannelsOutput {\n optional int64 operateTime = 1;\n optional int32 flag = 2;\n optional string msg = 3;\n optional int32 processCode = 4;\n optional ChannelsJoinedInfo channelInfo = 5;\n repeated ChannelsUserInfo userInfos = 6;\n optional FriendInviteInfo friendInviteInfo = 7;\n optional FriendUserInfo friendUserInfo = 8;\n repeated string censorFailedFields = 9;\n }\n\n message MultiChannels {\n optional ChannelType type = 1;\n repeated ChannelsInput list = 2;\n }\n\n message ModifyChannelsInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional QuitChannelsSetting settingInfo = 3;\n repeated string users = 4;\n optional int32 operateType = 5;\n }\n\n message QuitChannelsSetting {\n optional bool isQuit = 1;\n optional bool isDelBan = 2;\n optional bool isDelWhite = 3;\n optional bool isDelAttention = 4;\n }\n\n message ChannelsQueryInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional ChannelsPageParam page = 3;\n repeated string ids = 4;\n optional int32 roleType = 5;\n }\n\n message ChannelsPageParam {\n optional int32 size = 1;\n optional string pageToken = 2;\n optional bool hasNext = 3 ;\n optional int32 total = 4 ;\n optional int32 order = 5 ;\n }\n\n message ChannelsListResult {\n optional int32 listType = 1;\n optional bytes result = 2;\n optional ChannelsPageParam page = 3;\n }\n \n message ChannelsInviteStatusInfos {\n repeated ChannelsInviteStatusInfo list = 1;\n }\n \n message ChannelsUserInfos {\n repeated ChannelsUserInfo list = 1;\n }\n \n message ChannelsJoinedInfos {\n repeated ChannelsJoinedInfo list = 1;\n }\n\n message ChannelsUserInfo {\n optional string userId = 1;\n optional ChannelsUserExtInfo ext = 2;\n optional int64 opTime = 3;\n optional string name = 4;\n optional string portraitUrl = 5;\n }\n\n message ChannelsUserExtInfo {\n optional int32 role = 1;\n optional int64 joinTime = 2;\n optional string channelNickName = 3;\n optional string additional = 4;\n optional string remarkName = 5;\n optional bool isBan = 6;\n optional int64 banEndTime = 7;\n }\n\n message ChannelsMemberUpdateInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional string userId = 3;\n optional string channelNickName = 4;\n optional string additional = 5;\n optional int32 operateType = 6;\n }\n message ChannelsJoinedInfo {\n optional string targetId = 1;\n repeated ProfileInfo settingProfile = 2;\n repeated ProfileInfo extProfile = 3;\n optional ChannelBaseInfo baseInfo = 4;\n optional ChannelsUserExtInfo userInfo = 5;\n }\n message ChannelsInviteStatusInfo {\n optional string targetId = 1;\n optional ChannelsUserInfo joinUserInfo = 2;\n optional ChannelsUserInfo inviterInfo = 3;\n optional int32 status = 4;\n optional int32 directionType = 5;\n optional int32 joinType = 6;\n optional string detail = 7;\n optional int64 applyTime = 8;\n optional ChannelsUserInfo processInfo = 9;\n optional int64 processTime = 10;\n }\n message ChannelsMemberResponseInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional int32 optType = 3;\n optional int32 optResult = 4;\n optional string joinUserId = 5;\n optional string inviterId = 6;\n optional string detail = 7;\n }\n message ChannelsMembersInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated string userIds = 3;\n }\n message FriendInput {\n optional string targetId = 1;\n optional int32 type = 2;\n optional string info = 3;\n }\n message FriendsOutput {\n repeated FriendOutput list = 1;\n }\n message FriendOutput {\n optional string userId = 1;\n optional int64 operateTime = 2;\n optional string flag = 3;\n }\n message FriendsInput {\n repeated string targetId = 1;\n optional int32 type = 2;\n }\n message FriendsCheckOutput {\n repeated FriendCheckOutput list = 1;\n }\n\n message FriendCheckOutput {\n optional string targetId = 1;\n optional int32 status = 2;\n }\n message FriendProfileInput {\n optional string targetId = 1;\n optional string remarkName = 2;\n repeated ProfileInfo extProfile = 3;\n }\n message FriendProfileOutput {\n repeated string censorFailedFields = 1;\n }\n message FriendQueryInput {\n optional int32 queryType = 1;\n optional ChannelsPageParam page = 2;\n optional int32 friendType= 3;\n }\n message FriendUserInfo {\n optional string userId = 1;\n optional int64 relationTime = 2;\n optional int32 friendType = 3;\n optional int32 flag = 4;\n optional string remarkName = 5;\n optional string name = 6;\n optional string portraitUrl = 7;\n repeated ProfileInfo extProfile = 8;\n \n }\n message FriendInviteInfo {\n optional string userId = 1;\n optional string name = 2;\n optional string portraitUrl = 3;\n optional int32 type = 4;\n optional int32 status = 5;\n optional int64 operateTime = 6;\n optional string info = 7;\n optional int32 friendType = 8;\n }\n message FriendsListInput {\n repeated string targetId = 1;\n optional int32 type = 2;\n }\n message FriendLevelSet {\n optional int32 level = 1;\n }\n\n message FriendPageParam {\n optional int32 size = 1;\n optional string pageToken = 2;\n }\n message FriendUserInfos {\n repeated FriendUserInfo list = 1;\n }\n\n message FriendInviteInfos {\n repeated FriendInviteInfo list = 1;\n }\n \n message FriendApplyEvent {\n optional int32 applyType = 1;\n optional int32 friendType = 2;\n optional string info = 3;\n optional string name = 4;\n optional string portraitUrl = 5;\n }\n message UpdateChannnelInfo {\n optional ChannelsJoinedInfo channelInfo = 1;\n optional ChannelsUserInfo userInfo = 2;\n }\n message UpdateUserInfo {\n optional ChannelsUserInfo updatedUserInfo = 1;\n optional ChannelsUserInfo optUserInfo = 2;\n }\n message ChannelApplyInfo {\n repeated ChannelsInviteStatusInfo statusInfo = 1;\n }\n message ChannelEventData {\n optional ChannelsUserInfo optUserInfo = 1;\n optional ChannelsJoinedInfo channelInfo = 2;\n repeated ChannelsUserInfo userInfos = 3;\n optional ChannelsJoinedInfo channelFullInfo = 4;\n }\n message FriendTypeChangeEvent {\n optional string friendId = 1;\n optional int32 friendType = 2;\n }\n message FriendUpdateEvent {\n optional string remarkname = 1;\n repeated ProfileInfo extProfile = 2;\n }\n message AddUnpushPeriodInput {\n required string startTime = 1;\n required int32 spanMinutes = 2;\n optional int32 level = 3;\n optional string timezone = 4;\n }\n message DeleteUnpushPeriodInput {\n required int32 nothing = 1;\n }\n message QueryUnpushPeriodInput {\n required int32 nothing = 1;\n }\n message QueryUnpushPeriodOutput {\n required int32 isUnpush = 1;\n optional string startTime = 2;\n optional int32 spanMinutes = 3;\n optional int32 level = 4;\n optional string timezone = 5;\n }\n message RelationDel {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated string busChannel = 3;\n optional bool cleanMsg = 4;\n }\n message MsgReadEvent {\n optional string msgId = 1;\n optional int64 msgTime = 2;\n optional int32 totalCnt = 3;\n optional int32 readCnt = 4;\n optional int32 unreadCnt = 5;\n repeated ReceiptUser readList =6;\n }\n message ConvertMsgInput {\n optional int32 businessType = 1;\n optional bytes businessInfo = 2;\n }\n message SpeechToTextInfo {\n optional string msgId = 1;\n optional string objectName = 2;\n optional string content = 3;\n optional int32 sampleRate = 4;\n optional int32 channelNumber = 5;\n optional string format = 6;\n optional string extra = 7;\n }\n message ConvertMsgOutput {\n optional int32 businessType = 1;\n optional bytes businessResult = 2;\n }\n message SpeechToTextResult {\n optional string result = 1;\n optional string message = 2;\n }\n message TransReq {\n repeated TransInfo transInfos = 1;\n optional int32 model = 2;\n optional bool forceTrans = 3;\n }\n message TransResp {\n repeated TransResult results = 1;\n optional int32 model = 2;\n }\n message TransInfo {\n optional string messageUID = 1;\n optional int32 transType = 2;\n optional string text = 3;\n optional string transFileUrl = 4;\n optional string sourceLan = 5;\n optional string targetLan = 6;\n optional int32 inputSource = 7;\n }\n message TransResult {\n optional string messageUID = 1;\n optional string transResult = 2;\n optional string sourceLan = 3;\n optional string targetLan = 4;\n optional int32 code = 5;\n optional int32 inputSource = 6;\n }\n message PullModifyMsgReq { \n optional int64 pullVersion = 1;\n optional bool compress = 2;\n repeated int32 modifyType = 3;\n }\n message PullModifyMsgResp {\n repeated ModifyMsg msg = 1;\n optional int64 nextVersion = 2;\n optional bool finished = 3;\n optional bool compress = 4;\n optional bytes compressedData = 5;\n }\n message ModifyMsg {\n optional int32 modifyType = 1;\n optional DownStreamMessage msg = 2;\n }\n enum JoinType {\n KICK = 0;\n REFUSE = 1;\n COEXIST = 2;\n }\n enum TargetType {\n ROOM =1 ;\n PERSON = 2;\n }\n message SetUserStatusInput {\n optional int32 status=1;\n }\n message MCFollowInput {\n required string state = 1;\n }\n message RtcQueryListInput {\n optional int32 order=1;\n }\n message RtcKeyDeleteInput {\n repeated string key=1;\n }\n message RtcValueInfo {\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo {\n required string userId=1;\n repeated RtcValueInfo userData=2;\n }\n message RtcUserListOutput {\n repeated RtcUserInfo users=1;\n optional string token=2;\n optional string sessionId=3;\n repeated RtcValueInfo roomInfo = 4;\n repeated RtcKVEntity entries = 5;\n optional int64 syncTime = 6;\n optional int32 offlineKickTime = 7;\n }\n message RtcRoomInfoOutput {\n optional string roomId = 1;\n repeated RtcValueInfo roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message RtcInput {\n required int32 roomType=1;\n optional int32 broadcastType=2;\n optional RtcValueInfo extraInnerData = 3;\n optional bool needSysChatroom = 4;\n optional IdentityChangeType identityChangeType = 5;\n optional JoinType joinType = 6;\n repeated RtcValueInfo innerDatas = 7;\n repeated RtcValueInfo outerDatas = 8;\n }\n message RtcQryOutput {\n repeated RtcValueInfo outInfo=1;\n }\n message RtcDataInput {\n required bool interior=1;\n required TargetType target=2;\n repeated string key=3;\n optional string objectName=4;\n optional string content=5;\n }\n message RtcSetDataInput {\n required bool interior=1;\n required TargetType target=2;\n required string key=3;\n required string value=4;\n optional string objectName=5;\n optional string content=6;\n }\n message RtcUserSetDataInput {\n repeated RtcValueInfo valueInfo = 1;\n required string objectName = 2;\n repeated RtcValueInfo content = 3;\n }\n message RtcQryInput {\n required bool isInterior=1;\n required TargetType target=2;\n repeated string key=3;\n }\n message RtcDelDataInput {\n repeated string key=1;\n required bool isInterior=2;\n required TargetType target=3;\n }\n message RtcOutput {\n optional int32 nothing=1;\n optional int64 version=2;\n }\n message RtcTokenOutput {\n required string rtcToken=1;\n }\n message RtcSetOutDataInput {\n required TargetType target=1;\n repeated RtcValueInfo valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message RtcQryUserOutDataInput {\n repeated string userId = 1;\n }\n message RtcUserOutDataOutput {\n repeated RtcUserInfo user = 1;\n }\n message RtcNotifyMsg {\n required int32 type= 1;\n optional int64 time= 2;\n optional string roomId=3;\n }\n message RtcPullKV {\n required int64 timestamp = 1;\n required string roomId = 2;\n }\n message RtcKVEntity {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n }\n message RtcKVOutput {\n repeated RtcKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3; \n }\n enum IdentityChangeType {\n AnchorToViewer = 1;\n ViewerToAnchor = 2;\n }\n message RtcQueryUserJoinedInput {\n required string userId = 1;\n }\n message RtcJoinedInfo {\n required string deviceId = 1;\n required string roomId = 2;\n optional int64 joinTime = 3;\n }\n message RtcQueryUserJoinedOutput {\n repeated RtcJoinedInfo info = 1;\n }\n message RtcViewerJoinedOutput {\n required string rtcToken=1;\n repeated RtcKVEntity entries = 2;\n optional int64 syncTime = 3;\n }\n message RtcInviteInput {\n required string invitedUserId=1;\n optional int32 timeoutTime=2;\n required string invitedRoomId=3;\n required string inviteInfo=4;\n required string inviteSessionId= 5;\n }\n message RtcCancelInviteInput {\n required string invitedUserId=1;\n required string invitedRoomId=2;\n required string inviteInfo=3;\n required string inviteSessionId=4;\n }\n message RtcInviteAnswerInput {\n required string inviteUserId=1;\n required int32 answerCode=2;\n required string inviteRoomId=3;\n required string inviteSessionId=4;\n required string content=5;\n optional string key=6;\n optional string value=7;\n }\n message RtcEndInviteInput {\n required string inviteRoomId=1;\n required string inviteSessionId=2;\n required string inviteContent=3;\n repeated string inviteRoomKeys=4;\n }\n}\n");var Ru,Tu,Iu=function(){return l(function e(t){c(this,e),Object.defineProperty(this,"pbCodec",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.pbCodec=new du(t)},[{key:"encode",value:function(e,t,n){return n?t:this.pbCodec.encode(e,t)}},{key:"decode",value:function(e,t){return this.pbCodec.decode(e,t)}}])}(),Su="rtcRJoin_data",Cu="rtcRExit",Lu="rtcRInfo",Ou="rtcUData",yu="rtcUDel",bu="rtcSetData",Au="userSetData",Nu="rtcQryData",ku="rtcDelData",Pu="rtcToken",Uu="rtcUserState",wu="rtcUList",Du="viewerJoinR",Mu="viewerExitR",xu="rtcPullKv",Vu="rtcIdentityChange",Bu="rtcInvite",Gu="rtcCancelInvite",ju="rtcInviteAnswer",Fu="rtcEndInvite",Hu="rtcQueryJoined",Ju="rtcPullRoomStatus",Ku="reportsdk",Yu="rtcPing";!function(e){e.RtcInput="RtcInput",e.RtcOutput="RtcOutput",e.RtcUserListOutput="RtcUserListOutput",e.SetUserStatusInput="SetUserStatusInput",e.RtcSetDataInput="RtcSetDataInput",e.RtcUserSetDataInput="RtcUserSetDataInput",e.RtcDataInput="RtcDataInput",e.RtcSetOutDataInput="RtcSetOutDataInput",e.MCFollowInput="MCFollowInput",e.RtcTokenOutput="RtcTokenOutput",e.RtcQryOutput="RtcQryOutput",e.RtcQryUserOutDataInput="RtcQryUserOutDataInput",e.RtcUserOutDataOutput="RtcUserOutDataOutput",e.RtcQueryListInput="RtcQueryListInput",e.RtcRoomInfoOutput="RtcRoomInfoOutput",e.RtcValueInfo="RtcValueInfo",e.RtcKeyDeleteInput="RtcKeyDeleteInput",e.RtcNotifyMsg="RtcNotifyMsg",e.RtcPullKV="RtcPullKV",e.RtcKVOutput="RtcKVOutput",e.RtcQueryUserJoinedInput="RtcQueryUserJoinedInput",e.RtcQueryUserJoinedOutput="RtcQueryUserJoinedOutput",e.RtcViewerJoinedOutput="RtcViewerJoinedOutput",e.RtcInviteInput="RtcInviteInput",e.RtcCancelInviteInput="RtcCancelInviteInput",e.RtcInviteAnswerInput="RtcInviteAnswerInput",e.RtcEndInviteInput="RtcEndInviteInput",e.RtcRoomStatusInput="RtcRoomStatusInput",e.RtcRoomStatusOutput="RtcRoomStatusOutput",e.RtcReportSDKInput="RtcReportSDKInput",e.RtcPBPolaris="RCRTCPBPolaris",e.RtcPBR1Info="RCRTCPBR1Info",e.RtcPBR2Info="RCRTCPBR2Info",e.RtcPBR3Info="RCRTCPBR3Info",e.RtcPBR4Info="RCRTCPBR4Info",e.RtcPBStatusInfo="RCRTCPBStatusInfo",e.RtcPBStreamInfo="RCRTCPBStreamInfo",e.AsrTextMsg="AsrTextMsg",e.AsrResTextMsg="AsrResTextMsg"}(Tu||(Tu={})),d(d(d(d(d(d(d(d(d(d(Ru={},Tu.RtcInput,["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType","innerDatas","outerDatas","supportNtf"]),Tu.RtcOutput,["version"]),Tu.RtcUserListOutput,["users","token","sessionId","roomInfo","version"]),Tu.SetUserStatusInput,["status"]),Tu.RtcSetDataInput,["interior","target","key","value","objectName","content"]),Tu.RtcUserSetDataInput,["valueInfo","objectName","content"]),Tu.RtcDataInput,["interior","target","key","objectName","content"]),Tu.RtcSetOutDataInput,["target","valueInfo","objectName","content"]),Tu.MCFollowInput,["state"]),Tu.RtcTokenOutput,["rtcToken"]),d(d(d(d(d(d(d(d(d(d(Ru,Tu.RtcQryOutput,["outInfo"]),Tu.RtcQryUserOutDataInput,["userId"]),Tu.RtcUserOutDataOutput,["user"]),Tu.RtcQueryListInput,["order"]),Tu.RtcRoomInfoOutput,["roomId","roomData","userCount","list"]),Tu.RtcValueInfo,["key","value"]),Tu.RtcKeyDeleteInput,["key"]),Tu.RtcNotifyMsg,["type","time","roomId"]),Tu.RtcPullKV,["timestamp","roomId"]),Tu.RtcKVOutput,["entries","bFullUpdate","syncTime"]),d(d(d(d(d(d(d(d(d(d(Ru,Tu.RtcQueryUserJoinedInput,["userId"]),Tu.RtcQueryUserJoinedOutput,["info"]),Tu.RtcInviteInput,["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"]),Tu.RtcCancelInviteInput,["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"]),Tu.RtcInviteAnswerInput,["inviteUserId","answerCode","inviteRoomId","inviteSessionId","content","key","value"]),Tu.RtcEndInviteInput,["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"]),Tu.RtcRoomStatusInput,["version"]),Tu.RtcRoomStatusOutput,["bFullStatus","version","usersData","roomStatus"]),Tu.RtcReportSDKInput,["sdkInfo"]),Tu.RtcPBPolaris,["type","appKey","sessionId","roomId","roomCreateTime","userId","userRole","joinTime","signalDataCenter","r1Info","r2Info","r3Info","r4Info"]),d(d(d(d(d(d(d(d(Ru,Tu.RtcPBR1Info,["joinTime","rtcVersion","imVersion","platform","device","os","browserName","browserVersion"]),Tu.RtcPBR2Info,["joinTime","sendTime","rtcActionType","rtcActionStatus","trackId"]),Tu.RtcPBR3Info,["info"]),Tu.RtcPBR4Info,["info"]),Tu.RtcPBStatusInfo,["joinTime","receiveTime","totalBitRate","appCPUUsage","systemCPUUsage","systemCPUFrequency","networkStatus","googleRTTNetwork","ipAddress","useReceiveBroadBand","useSendBroadBand","packetLossCount","streams"]),Tu.RtcPBStreamInfo,["trackId","codeName","volume","samplingRate","bitRate","packetLossRate","frameRate","resolution","blockTime","jitterData","nAckCount","pliCount","googleRTTTotalTime","isReceiveFirstFrameRate","codeType","isEnabled"]),Tu.AsrTextMsg,["bms","t","isEnd","msgId","lang"]),Tu.AsrResTextMsg,["type","uid","asr"]);var qu,Wu="\npackage Modules;\nmessage probuf {\n enum JoinType {\n KICK = 0; //踢前一个设备\n REFUSE = 1; //当前加入拒绝\n COEXIST = 2; //两个设备共存\n }\n enum targetType {\n ROOM =1 ;\n PERSON = 2;\n }\n message ".concat(Tu.SetUserStatusInput,"\n {\n optional int32 status=1;\n }\n message ").concat(Tu.MCFollowInput,"\n {\n required string state = 1;\n }\n message ").concat(Tu.RtcQueryListInput,"{\n optional int32 order=1;\n }\n message ").concat(Tu.RtcKeyDeleteInput,"{\n repeated string key=1;\n }\n message ").concat(Tu.RtcValueInfo,"{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ").concat(Tu.RtcValueInfo," userData=2; //用户资源信息\n }\n message ").concat(Tu.RtcRoomStatusInput,"{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ").concat(Tu.RtcRoomStatusOutput,"{ // rtc 和 living room 拉房间资源状态返回的数据\n required bool bFullStatus =1; //标识此次给的数据是否是全量数据\n required int64 version =2; //当前获取后房间的最大版本号\n repeated RtcUserInfo usersData=3;//如果是全量数据,这个不为空,给的是房间全部的人以及发布的资源\n repeated RtcRoomStatus roomStatus=4;//房间增量数据\n }\n message RtcRoomStatus{ //房间状态变动\n required string userId = 1;//用户ID\n required int32 event = 2;//房间状态变更的event(人员加入/退出/离线/发布资源) (0:加入;1:离开;2:离线;3:资源变动) \n required int64 time = 3;//本次变更的版本号\n repeated RtcValueInfo userData = 4;//用户变更的资源(event为0或者3时可能有值)\n optional int32 switchRoleType = 5;//如果是切换角色导致的加入房间或退出房间的类型\n optional string extra = 6;\n }\n message ").concat(Tu.RtcUserListOutput,"{\n repeated RtcUserInfo users=1;\n optional string token=2;\n optional string sessionId=3;\n repeated RtcValueInfo roomInfo = 4; //房间key value\n repeated RtcKVEntity entries = 5;//直播KV属性对象集合\n optional int64 syncTime = 6;//所有属性的最大时间戳(下次拉取KV时用)。\n optional int32 offlineKickTime = 7;//server超时踢人时间,默认60s\n repeated string codeFormat = 8; //当前房间用户支持的编码交集\n optional int64 roomCreateTime = 9;//房间创建时间\n optional int64 userJoinTime = 10;//用户加入房间\n optional int64 version = 11;//当前房间的版本号\n }\n message RtcRoomInfoOutput{\n optional string roomId = 1;\n repeated ").concat(Tu.RtcValueInfo," roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ").concat(Tu.RtcInput,"{\n required int32 roomType=1;\n optional int32 broadcastType=2;\n optional RtcValueInfo extraInnerData = 3;\n optional bool needSysChatroom = 4; //是否需要同步聊天室\n optional IdentityChangeType identityChangeType = 5; //身份变更类型\n optional JoinType joinType = 6; // 加入房间类型\n repeated ").concat(Tu.RtcValueInfo," innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ").concat(Tu.RtcValueInfo," outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ").concat(Tu.RtcQryOutput,"{\n repeated ").concat(Tu.RtcValueInfo," outInfo=1;\n }\n message ").concat(Tu.RtcDataInput,"{\n required bool interior=1;\n required targetType target=2;\n repeated string key=3;\n optional string objectName=4;\n optional string content=5;\n }\n message ").concat(Tu.RtcSetDataInput,"{\n required bool interior=1;\n required targetType target=2;\n required string key=3;\n required string value=4;\n optional string objectName=5;\n optional string content=6;\n }\n message ").concat(Tu.RtcUserSetDataInput," {\n repeated ").concat(Tu.RtcValueInfo," valueInfo = 1;\n required string objectName = 2;\n repeated ").concat(Tu.RtcValueInfo," content = 3;\n }\n message RtcQryInput{\n required bool isInterior=1;\n required targetType target=2;\n repeated string key=3;\n }\n message RtcDelDataInput{\n repeated string key=1;\n required bool isInterior=2;\n required targetType target=3;\n }\n message RtcOutput\n {\n optional int32 nothing=1;\n optional int64 version=2;\n }\n message ").concat(Tu.RtcTokenOutput,"{\n required string rtcToken=1;\n }\n message ").concat(Tu.RtcSetOutDataInput,"{\n required targetType target=1;\n repeated ").concat(Tu.RtcValueInfo," valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ").concat(Tu.RtcQryUserOutDataInput,"{\n repeated string userId = 1;\n }\n message ").concat(Tu.RtcUserOutDataOutput,"{\n repeated RtcUserInfo user = 1;\n }\n message ").concat(Tu.RtcNotifyMsg," \n {\n required int32 type= 1; //(通知类型 1:rtc房间状态KV变更通知)\n optional int64 time= 2; //消息产生时间\n optional string roomId=3; //主播房间id\n }\n message ").concat(Tu.RtcPullKV,"\n {\n required int64 timestamp = 1;\n required string roomId = 2;\n }\n message RtcKVEntity \n {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n }\n message ").concat(Tu.RtcKVOutput,"\n {\n repeated RtcKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3; \n }\n enum IdentityChangeType \n {\n AnchorToViewer = 1; //1为主播变观众\n ViewerToAnchor = 2; //2为观众变主播\n }\n message ").concat(Tu.RtcQueryUserJoinedInput,"\n {\n required string userId = 1;\n }\n message RtcJoinedInfo\n {\n required string deviceId = 1; //设备ID\n required string roomId = 2; //加入的房间ID\n optional int64 joinTime = 3; //加入的时间\n }\n message ").concat(Tu.RtcQueryUserJoinedOutput,"\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ").concat(Tu.RtcViewerJoinedOutput,"\n {\n required string rtcToken=1;\n repeated RtcKVEntity entries = 2;//KV属性对象集合\n optional int64 syncTime = 3;//所有属性的最大时间戳(下次拉取KV时用)。\n optional string sessionId=4;\n optional int64 roomCreateTime = 5;//房间创建时间\n optional int64 userJoinTime = 6;//用户加入房间\n }\n message ").concat(Tu.RtcInviteInput,"\n {\n required string invitedUserId=1; //被邀请的人的uid\n optional int32 timeoutTime=2; //邀请超时时间(秒),默认三十秒\n required string invitedRoomId=3; //被邀请的房间\n required string inviteInfo=4; //邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId= 5; //客户端保证唯一性(建议roomid_userid_时间戳_随机数)\n }\n message ").concat(Tu.RtcCancelInviteInput,"\n {\n required string invitedUserId=1; //被邀请的人的uid\n required string invitedRoomId=2; //被邀请的房间\n required string inviteInfo=3; //取消邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId=4; //邀请的sessionId,客户端发起邀请时产生\n }\n message ").concat(Tu.RtcInviteAnswerInput,"\n {\n required string inviteUserId=1; //邀请的人的uid\n required int32 answerCode=2; //是否接受连麦邀请.0为拒绝,1为接受\n required string inviteRoomId=3; //邀请的房间\n required string inviteSessionId=4; //邀请的sessionId\n required string content=5; //需要转发的content\n optional string key=6; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n optional string value=7; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n }\n message ").concat(Tu.RtcEndInviteInput,"\n {\n required string inviteRoomId=1; //邀请的房间\n required string inviteSessionId=2; //邀请的sessionId\n required string inviteContent=3; //结束连麦的信息(需要透传给房间内其他人)\n repeated string inviteRoomKeys=4; //需要删除连麦的信息的key\n }\n message ").concat(Tu.RtcReportSDKInput,' {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ').concat(Tu.RtcPBPolaris," {\n required string type = 1;//上报数据类型 R1-R4\n required string appKey = 2;\n required string sessionId = 3;//房间通话id\n required string roomId = 4;\n required int64 roomCreateTime = 5;//房间创建时间\n required string userId = 6;\n required int32 userRole = 7;\n required int64 joinTime = 8;\n required string signalDataCenter = 9;//signal数据中心\n optional ").concat(Tu.RtcPBR1Info," r1Info = 10;\n optional ").concat(Tu.RtcPBR2Info," r2Info = 11;\n optional ").concat(Tu.RtcPBR3Info," r3Info = 12;\n optional ").concat(Tu.RtcPBR4Info," r4Info = 13;\n }\n message ").concat(Tu.RtcPBR1Info," {\n required int64 joinTime = 1;//用户加入房间的时间\n required string rtcVersion = 2;//Rtc版本号\n required string imVersion = 3;//IM SDK 版本\n required string platform = 4;//平台(如:Android、iOS、Web)\n required string device = 5; //设备信息(手机名称+型号)\n required string os = 6;//系统版本(手机系统版本)\n optional string browserName = 7; //浏览器名称, 没有用 -1 表示\n optional string browserVersion = 8;//浏览器版本, 没有用 -1 表示\n optional int64 receiveTime = 9; // 发送数据的时间\n }\n message ").concat(Tu.RtcPBR2Info," {\n required int64 joinTime = 1;\n required int64 sendTime = 2;\n required string rtcActionType = 3;//发布类型 subscribe : 订阅 publish : 发布\n required string rtcActionStatus = 4;//发布状态 begin : 开始 tend : 结束\n repeated string trackId = 5;\n optional int64 receiveTime = 6; // 发送数据的时间\n }\n message ").concat(Tu.RtcPBR3Info," {\n required ").concat(Tu.RtcPBStatusInfo," info = 1;\n }\n message ").concat(Tu.RtcPBR4Info," {\n required ").concat(Tu.RtcPBStatusInfo," info = 1;\n }\n message ").concat(Tu.RtcPBStatusInfo," {\n optional int64 joinTime = 1;//用户加入房间的时间\n optional int64 receiveTime = 2;//用户发布数据流的时间(毫秒),暂时由客户端生成,后期如果有问题服务端做兜底处理\n optional int64 totalBitRate = 3;//总码率\n optional float appCPUUsage = 4;//APP CPU占用率\n optional float systemCPUUsage = 5;////系统 CPU占用率\n optional float systemCPUFrequency = 6;//系统CPU频率 (安卓8.0以上)\n optional string networkStatus = 7;//实时网络状态(2g、3g、4g、wifi)\n optional int32 googleRTTNetwork = 8;//Goog rtt 网络延迟\n optional string ipAddress = 9;//ip地址\n optional string useReceiveBroadBand = 10; //可接收带宽(单位: bit)\n optional string useSendBroadBand = 11;//可用发送带宽(单位: bit)\n optional string packetLossCount = 12;//丢包数\n repeated ").concat(Tu.RtcPBStreamInfo," streams = 13;\n }\n message ").concat(Tu.RtcPBStreamInfo," {\n required string trackId = 1;\n optional string codeName = 2;//编解码名称\n optional string volume = 3;//音频播放音量\n optional int32 samplingRate = 4; //音频采样率\n optional float bitRate = 5;//下行码率\n optional float packetLossRate = 6;\n optional int32 frameRate = 7;//视频接收帧率(单位:fps)\n optional string resolution = 8;//视频分辨率(格式:640*480)\n optional int64 blockTime = 9;//接收卡顿(间隔时间, 单位: ms)\n optional int32 jitterData = 10;//jitter数据抖动\n optional string nAckCount = 11;//nack数量\n optional string pliCount = 12; //PLI请求数\n optional int64 googleRTTTotalTime = 13; //googRtt往返时长\n optional int32 isReceiveFirstFrameRate = 14;//第一个关键帧是否正常收到\n optional string codeType = 15;//编码方式\n optional int32 isEnabled = 16; //当前流的状态是否可用\n }\n // ---- 北极星数据上报 -------\n message ").concat(Tu.AsrTextMsg," {\n optional int32 bms = 1; //开始转写的时间(毫秒)\n optional string t = 2; //翻译的内容\n optional bool isEnd = 3; //是否监测到完整语句\n optional string msgId = 4; //该消息的ID, 跟转写的msgId 需要一样;\n optional string lang = 5; //翻译的目标语言码\n }\n message ").concat(Tu.AsrResTextMsg," {\n optional int32 type = 1; //1 为语音识别,后续会扩展其它类型\n required string uid = 2; //对应转写的用户Id\n repeated ").concat(Tu.AsrTextMsg," asr = 3; //识别出的结果列表\n }\n}\n"),zu=function(e,t,n,r,i,a,o){var s=i?Object.keys(i).map(function(t){return e.encode(Tu.RtcValueInfo,{key:t,value:i[t]},!0)}):void 0,c=a?Object.keys(a).map(function(t){return e.encode(Tu.RtcValueInfo,{key:t,value:a[t]},!0)}):void 0;return e.encode(Tu.RtcInput,{roomType:t,broadcastType:n,joinType:r,innerDatas:s,outerDatas:c,supportNtf:o})},Qu=function(e,t){var n=e.decode(Tu.RtcUserListOutput,t),r=n.users,i=n.token,a=n.sessionId,o=n.roomInfo,s=n.entries,c=n.offlineKickTime,u=void 0===c?60:c,l=n.codeFormat,_=n.roomCreateTime,d=n.userJoinTime,f=n.version,h={};return de(r,function(e){var t=e.userId,n=e.userData,r={};de(n,function(e){var t=e.key,n=e.value;r[t]=n}),h[t]=r}),{users:h,token:i,sessionId:a,roomInfo:o,kvEntries:s,offlineKickTime:u,codeFormat:l,roomCreateTime:cr(_),userJoinTime:cr(d),version:f}},Zu=function(e,t,n){var r=t.type,i=t.appKey,a=t.sessionId,o=t.roomId,s=t.roomCreateTime,c=t.userId,u=t.userRole,l=t.joinTime,_=t.signalDataCenter,d=t.r1Info,f=t.r2Info,h=t.r3Info,g=t.r4Info,p={type:r,appKey:i,sessionId:a,roomId:o,roomCreateTime:s,userId:c,userRole:u,joinTime:l,signalDataCenter:_};if(n===Ic.R1&&d){var E=e.encode(Tu.RtcPBR1Info,d,!0);return e.encode(Tu.RtcPBPolaris,Object.assign(Object.assign({},p),{r1Info:E}))}if(n===Ic.R2&&f){var v=e.encode(Tu.RtcPBR2Info,f,!0);return e.encode(Tu.RtcPBPolaris,Object.assign(Object.assign({},p),{r2Info:v}))}if(n===Ic.R3&&h){var m=h.info,R=m.streams,T=Array.isArray(R)&&R.map(function(t){return t&&e.encode(Tu.RtcPBStreamInfo,t,!0)}),I=e.encode(Tu.RtcPBStatusInfo,Object.assign(Object.assign({},m),{streams:T}),!0),S=e.encode(Tu.RtcPBR3Info,{info:I},!0);return e.encode(Tu.RtcPBPolaris,Object.assign(Object.assign({},p),{r3Info:S}))}if(n===Ic.R4&&g){var C=g.info,L=C.streams,O=Array.isArray(L)&&L.map(function(t){return t&&e.encode(Tu.RtcPBStreamInfo,t,!0)}),y=e.encode(Tu.RtcPBStatusInfo,Object.assign(Object.assign({},C),{streams:O}),!0),b=e.encode(Tu.RtcPBR4Info,{info:y},!0);return e.encode(Tu.RtcPBPolaris,Object.assign(Object.assign({},p),{r4Info:b}))}return{}};!function(e){e[e.SUBTITLE=1]="SUBTITLE",e[e.TRANSLATION=2]="TRANSLATION"}(qu||(qu={}));var Xu,$u=function(){return l(function e(t){c(this,e),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"roomCreateTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userJoinTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"codec",{enumerable:!0,configurable:!0,writable:!0,value:new Iu(Wu)})},[{key:"logger",get:function(){return this.context.logger}},{key:"joinRTCRoom",value:function(e,t,n,r,i,a,o){return F(this,void 0,void 0,E().m(function s(){var c,u,l,_,d,f,h,g,p,v,m,R,T,I,S;return E().w(function(s){for(;;)switch(s.n){case 0:return c=zu(this.codec,t,n,r,i,a,o),s.n=1,this.context.rtcSignaling(e,Su,!0,c);case 1:if(u=s.v,l=u.code,_=u.buffer,l!==we||!_){s.n=2;break}return d=Qu(this.codec,_),h=(f=d).users,g=f.token,p=f.sessionId,v=f.roomInfo,m=f.kvEntries,R=f.offlineKickTime,T=f.roomCreateTime,I=f.userJoinTime,S=f.version,this.roomCreateTime=T,this.userJoinTime=I,s.a(2,{code:l,data:{users:h,token:g,sessionId:p,roomInfo:v,kvEntries:m,offlineKickTime:R,version:S}});case 2:return s.a(2,{code:l,data:d})}},s,this)}))}},{key:"quitRTCRoom",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this.codec.encode(Tu.SetUserStatusInput,{status:0}),t.n=1,this.context.rtcSignaling(e,Cu,!0,n);case 1:return r=t.v,i=r.code,t.a(2,i)}},t,this)}))}},{key:"getRTCRoomInfo",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this.codec.encode(Tu.RtcQueryListInput,{order:2}),t.n=1,this.context.rtcSignaling(e,Lu,!0,n);case 1:return r=t.v,i=r.code,a=r.buffer,i===we&&a&&(o=this.codec.decode(Tu.RtcRoomInfoOutput,a)),t.a(2,{code:i,data:o})}},t,this)}))}},{key:"getRTCUserInfoList",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this.codec.encode(Tu.RtcQueryListInput,{order:2}),t.n=1,this.context.rtcSignaling(e,Ou,!0,n);case 1:return r=t.v,i=r.code,a=r.buffer,i===we&&a&&(s=Qu(this.codec,a),o={users:s.users}),t.a(2,{code:i,data:o})}},t,this)}))}},{key:"getRTCUserInfo",value:function(e){throw new Error("Method not implemented.")}},{key:"removeRTCUserInfo",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:return r=this.codec.encode(Tu.RtcKeyDeleteInput,{key:t}),n.n=1,this.context.rtcSignaling(e,yu,!1,r);case 1:return i=n.v,a=i.code,n.a(2,a)}},n,this)}))}},{key:"setRTCData",value:function(e,t,n,r,i,a){return F(this,void 0,void 0,E().m(function o(){var s,c,u;return E().w(function(o){for(;;)switch(o.n){case 0:return s=this.codec.encode(Tu.RtcSetDataInput,{interior:r,target:i,key:t,value:n,objectName:null==a?void 0:a.name,content:null==a?void 0:a.content}),o.n=1,this.context.rtcSignaling(e,bu,!1,s);case 1:return c=o.v,u=c.code,o.a(2,u)}},o,this)}))}},{key:"setRTCTotalRes",value:function(e,t,n,r,i,a){return F(this,void 0,void 0,E().m(function o(){var s,c,u,l,_=this;return E().w(function(o){for(;;)switch(o.n){case 0:return s={objectName:r,content:[],valueInfo:[this.codec.encode(Tu.RtcValueInfo,{key:"uris",value:n},!0)]},t.forEach(function(e){var t=_.codec.encode(Tu.RtcValueInfo,{key:e.name,value:e.content},!0);s.content.push(t)}),i&&s.valueInfo.push(this.codec.encode(Tu.RtcValueInfo,{key:"mcu_uris",value:i},!0)),a&&s.valueInfo.push(this.codec.encode(Tu.RtcValueInfo,{key:"cdn_uris",value:a},!0)),c=this.codec.encode(Tu.RtcUserSetDataInput,s),o.n=1,this.context.rtcSignaling(e,Au,!0,c);case 1:return u=o.v,l=u.code,o.a(2,l)}},o,this)}))}},{key:"setRTCCDNUris",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o;return E().w(function(r){for(;;)switch(r.n){case 0:return i=this.codec.encode(Tu.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(Tu.RtcValueInfo,{key:"cdn_uris",value:n},!0)}),r.n=1,this.context.rtcSignaling(e,Au,!0,i);case 1:return a=r.v,o=a.code,r.a(2,o)}},r,this)}))}},{key:"getRTCData",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l,_;return E().w(function(i){for(;;)switch(i.n){case 0:return a=this.codec.encode(Tu.RtcDataInput,{interior:n,target:r,key:t}),i.n=1,this.context.rtcSignaling(e,Nu,!0,a);case 1:if(o=i.v,s=o.code,c=o.buffer,s===we&&c){i.n=2;break}return i.a(2,{code:s});case 2:return u=this.codec.decode(Tu.RtcQryOutput,c),l=u.outInfo,_={},l.forEach(function(e){_[e.key]=e.value}),i.a(2,{code:s,data:_})}},i,this)}))}},{key:"removeRTCData",value:function(e,t,n,r,i){return F(this,void 0,void 0,E().m(function a(){var o,s,c;return E().w(function(a){for(;;)switch(a.n){case 0:return o=this.codec.encode(Tu.RtcDataInput,{interior:n,target:r,key:t,objectName:(null==i?void 0:i.name)||"",content:(null==i?void 0:i.content)||""}),a.n=1,this.context.rtcSignaling(e,ku,!1,o);case 1:return s=a.v,c=s.code,a.a(2,c)}},a,this)}))}},{key:"setRTCOutData",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)switch(e.n){case 0:throw new Error("JSEngine's method not implemented.");case 1:return e.a(2)}},e)}))}},{key:"getRTCOutData",value:function(e,t){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)switch(e.n){case 0:throw new Error("JSEngine's method not implemented.");case 1:return e.a(2)}},e)}))}},{key:"getRTCToken",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u;return E().w(function(r){for(;;)switch(r.n){case 0:return i=zu(this.codec,t,n),r.n=1,this.context.rtcSignaling(e,Pu,!0,i);case 1:if(a=r.v,o=a.code,s=a.buffer,o===we&&s){r.n=2;break}return r.a(2,{code:o});case 2:return c=this.codec.decode(Tu.RtcTokenOutput,s),u=c.rtcToken,r.a(2,{code:o,data:{rtcToken:u}})}},r,this)}))}},{key:"setRTCState",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:return r=this.codec.encode(Tu.MCFollowInput,{state:t}),n.n=1,this.context.rtcSignaling(e,Uu,!0,r);case 1:return i=n.v,a=i.code,n.a(2,a)}},n,this)}))}},{key:"setRTCStateByHttp",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u;return E().w(function(i){for(;;)switch(i.p=i.n){case 0:return o=Zu(this.codec,n,r),s=e,/^https:\/\//.test(e)||(s="https://".concat(e)),i.p=1,i.n=2,t.httpReq({url:"".concat(s,"/rtc/logserver/polaris"),body:o,method:ne.POST,headers:{jwt:(null===(a=this.context.getNaviInfo())||void 0===a?void 0:a.jwtToken)||""},timeout:2e3});case 2:if((c=i.v).data){i.n=3;break}throw new Error("http request fail");case 3:return u=JSON.parse(c.data).resultCode,i.a(2,u);case 4:return i.p=4,i.v,i.a(2,Tc.REPORT_FAIL)}},i,this,[[1,4]])}))}},{key:"getRTCUserList",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this.codec.encode(Tu.RtcQueryListInput,{order:2}),t.n=1,this.context.rtcSignaling(e,wu,!0,n);case 1:if(r=t.v,i=r.code,a=r.buffer,i===we&&a){t.n=2;break}return t.a(2,{code:i});case 2:return o=Qu(this.codec,a),t.a(2,{code:i,data:o})}},t,this)}))}},{key:"joinLivingRoomAsAudience",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d;return E().w(function(r){for(;;)switch(r.n){case 0:return i=zu(this.codec,t,n),r.n=1,this.context.rtcSignaling(e,Du,!0,i);case 1:if(a=r.v,o=a.code,s=a.buffer,o===we&&s){r.n=2;break}return r.a(2,{code:o});case 2:return c=this.codec.decode(Tu.RtcViewerJoinedOutput,s),u=c.rtcToken,l=c.entries,_=c.roomCreateTime,d=c.userJoinTime,this.roomCreateTime=cr(_),this.userJoinTime=cr(d),r.a(2,{code:o,data:{token:u,kvEntries:l}})}},r,this)}))}},{key:"quitLivingRoomAsAudience",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this.codec.encode(Tu.SetUserStatusInput,{status:0}),t.n=1,this.context.rtcSignaling(e,Mu,!0,n);case 1:return r=t.v,i=r.code,t.a(2,i)}},t,this)}))}},{key:"rtcIdentityChange",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c;return E().w(function(r){for(;;)switch(r.n){case 0:return i=this.codec.encode(Tu.RtcInput,{roomType:ps.LIVE,broadcastType:n,identityChangeType:t,needSysChatroom:!1}),r.n=1,this.context.rtcSignaling(e,Vu,!0,i);case 1:if(a=r.v,o=a.code,s=a.buffer,o===we&&s){r.n=2;break}return r.a(2,{code:o});case 2:return c=Qu(this.codec,s),r.a(2,{code:o,data:c})}},r,this)}))}},{key:"requestRoomPK",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u,l;return E().w(function(t){for(;;)switch(t.n){case 0:return n=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,a=e.inviteTimeout,o=e.inviteInfo,s=e.roomId,c=this.codec.encode(Tu.RtcInviteInput,{invitedRoomId:n,invitedUserId:r,inviteSessionId:i,timeoutTime:a,inviteInfo:o}),t.n=1,this.context.rtcSignaling(s,Bu,!0,c);case 1:return u=t.v,l=u.code,t.a(2,l)}},t,this)}))}},{key:"cancelRoomPK",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u;return E().w(function(t){for(;;)switch(t.n){case 0:return n=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,a=e.inviteInfo,o=e.roomId,s=this.codec.encode(Tu.RtcCancelInviteInput,{invitedRoomId:n,invitedUserId:r,inviteSessionId:i,inviteInfo:a}),t.n=1,this.context.rtcSignaling(o,Gu,!0,s);case 1:return c=t.v,u=c.code,t.a(2,u)}},t,this)}))}},{key:"responseRoomPK",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u,l,_,d;return E().w(function(t){for(;;)switch(t.n){case 0:return n=e.inviteUserId,r=e.inviteRoomId,i=e.inviteSessionId,a=e.content,o=e.key,s=e.value,c=e.agree,u=e.roomId,l=this.codec.encode(Tu.RtcInviteAnswerInput,{inviteUserId:n,inviteRoomId:r,inviteSessionId:i,content:a,key:o,value:s,answerCode:c?1:0}),t.n=1,this.context.rtcSignaling(u,ju,!0,l);case 1:return _=t.v,d=_.code,t.a(2,d)}},t,this)}))}},{key:"endRoomPK",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u;return E().w(function(t){for(;;)switch(t.n){case 0:return n=e.endRoomId,r=e.sessionId,i=e.content,a=e.keys,o=e.roomId,s=this.codec.encode(Tu.RtcEndInviteInput,{inviteRoomId:n,inviteSessionId:r,inviteContent:i,inviteRoomKeys:a}),t.n=1,this.context.rtcSignaling(o,Fu,!0,s);case 1:return c=t.v,u=c.code,t.a(2,u)}},t,this)}))}},{key:"getRTCJoinedUserInfo",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this.codec.encode(Tu.RtcQueryUserJoinedInput,{userId:e}),t.n=1,this.context.rtcSignaling("",Hu,!0,n);case 1:if(r=t.v,i=r.code,a=r.buffer,i===we&&a){t.n=2;break}return t.a(2,{code:i});case 2:return o=this.codec.decode(Tu.RtcQueryUserJoinedOutput,a).info||[],t.a(2,{code:i,data:o.map(function(e){return{deviceId:e.deviceId,roomId:e.roomId,joinTime:cr(e.joinTime)}})})}},t,this)}))}},{key:"pullRTCRoomEntry",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this.codec.encode(Tu.RtcPullKV,{timestamp:0,roomId:e}),t.n=1,this.context.rtcSignaling(e,xu,!0,n);case 1:if(r=t.v,i=r.code,a=r.buffer,i===we){t.n=2;break}return t.a(2,{code:i});case 2:return o=this.codec.decode(Tu.RtcKVOutput,a),s=o.entries,c=o.syncTime,s=(s||[]).map(function(e){return Object.assign(Object.assign({},e),{timestamp:cr(e.timestamp)})}),t.a(2,{code:i,data:{kvEntries:s,syncTime:cr(c)}})}},t,this)}))}},{key:"pullRTCRoomStatus",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s;return E().w(function(n){for(;;)switch(n.n){case 0:return r=this.codec.encode(Tu.RtcRoomStatusInput,{version:t}),n.n=1,this.context.rtcSignaling(e,Ju,!0,r);case 1:if(i=n.v,a=i.code,o=i.buffer,a===we){n.n=2;break}return n.a(2,{code:a});case 2:return s=this.codec.decode(Tu.RtcRoomStatusOutput,o),n.a(2,{code:a,data:s})}},n,this)}))}},{key:"decodeRtcNotify",value:function(e){var t=this.codec.decode(Tu.RtcNotifyMsg,e),n=t.time,r=t.type,i=t.roomId;return{time:cr(n),type:r,roomId:i}}},{key:"getCurrentId",value:function(){return this.context.getCurrentId()}},{key:"getNaviInfo",value:function(){return this.context.getNaviInfo()}},{key:"getConnectionStatus",value:function(){return this.context.getConnectionStatus()}},{key:"getAppkey",value:function(){return this.context.getAppkey()}},{key:"webRtcPing",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c;return E().w(function(r){for(;;)switch(r.n){case 0:return i=this.codec.encode(Tu.RtcInput,{roomType:t,broadcastType:n}),r.n=1,this.context.rtcSignaling(e,Yu,!0,i);case 1:if(a=r.v,o=a.code,s=a.buffer,o===we){r.n=2;break}return r.a(2,{code:o});case 2:return(c=this.codec.decode(Tu.RtcOutput,s)).version=cr(c.version),r.a(2,{code:o,data:c})}},r,this)}))}},{key:"rtcPing",value:function(e,t,n){var r,i;return/Electron/.test(navigator.userAgent)?null===(i=(r=this.context).rtcPingResVersion)||void 0===i?void 0:i.call(r,e,t,n):this.webRtcPing(e,t,n)}},{key:"sendMessage",value:function(e,t,n){return this.context.sendMessage(e,t,n)}},{key:"registerRTCSignalListener",value:function(e){this.context.registerRTCSignalListener(e)}},{key:"registerConnectionStateChangeListener",value:function(e){var t,n;null===(n=(t=this.context).registerConnectionStateChangeListener)||void 0===n||n.call(t,e)}},{key:"registerDisconnectListener",value:function(e){var t,n;null===(n=(t=this.context).registerDisconnectListener)||void 0===n||n.call(t,e)}},{key:"registerDestroyListener",value:function(e){var t,n;null===(n=(t=this.context).registerDestroyListener)||void 0===n||n.call(t,e)}},{key:"registerMessageListener",value:function(e){var t,n;null===(n=(t=this.context).registerMessageListener)||void 0===n||n.call(t,e)}},{key:"getCoreVersion",value:function(){return this.context.getCoreVersion()}},{key:"getPluginContext",value:function(){return this.context}},{key:"reportSDKInfo",value:function(e){var t=this.codec.encode(Tu.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",Ku,!0,t)}},{key:"decodeAsrText",value:function(e,t){var n;try{n=this.codec.decode(Tu.AsrResTextMsg,e)}catch(n){console.error("decodeAsrText error",{error:n,seiFrameData:e.join(","),seiOriginData:t.join(",")})}var r=n||{asr:[]},i=r.type,a=r.uid;return r.asr.map(function(e){var t=e.bms,n=e.t,r=e.isEnd,o=e.msgId,s=e.lang,c={userID:a,timeUTC:t,msg:n,msgId:o,isEnd:r};return i===qu.SUBTITLE?c:Object.assign(Object.assign({},c),{destLangCode:s})})}}])}(),el=function(){function n(e,t,r){var i,a,o;return c(this,n),i=s(this,n,[e]),Object.defineProperty(i,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(i,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_crtRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"_audience",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"_crtAudienceLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),es.setSdpSemantics(r.sdpSemantics||"unified-plan",i._logger),i._service=new Do(i._runtime,i._context,i._options.mediaServer,i._options.timeout),i._context.registerConnectionStateChangeListener(i._onIMStatusChange.bind(i)),i._context.registerDestroyListener(i._onIMUninit.bind(i)),i._context.registerMessageListener(i._handleMessage.bind(i)),null===(o=(a=i._context.getPluginContext()).setOnnavidatachange)||void 0===o||o.call(a,i.naviDataChange.bind(i)),i}return g(n,lu),l(n,[{key:"_handleMessage",value:function(t){if(t.conversationType!==e.RTC_ROOM)return!1;var n=this._logger.createTraceId();this._crtRoom instanceof eu&&this._getJoinedPKRoomList().forEach(function(e){e.__parseInnerMessage(t,n)});return this._logger.info(Ne.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:ke.SUCCESSED,message:t}),n),this._crtRoom?(this._crtRoom.__parseInnerMessage(t,n),!0):(this._logger.warn(Ne.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:ke.FAILED,message:"the crtRoom is empty"}),n),!0)}},{key:"naviDataChange",value:function(e){this._logger.info(Ne.L_RTC_CLIENT_NAVI_CHANGE_O,"on navi change data => ".concat(JSON.stringify(e))),this._service.clearMSList(),this._service.isNededDetector()&&this._service.detectorMediaSever()}},{key:"_getJoinedPKRoomList",value:function(){var e=this._crtRoom.getRoomPKHandler(),t=e.code,n=e.roomPKHandler;if(t===Ae.SUCCESS&&n){var r=n.getJoinedPKRooms()||{};return Object.values(r)}return[]}},{key:"getPluginContext",value:function(){return this._context.getPluginContext()}},{key:"getCurrentId",value:function(){return this._context.getCurrentId()}},{key:"joinCrossRTCRoom",value:function(e,t,n){return F(this,arguments,void 0,function(e,t,n){var r=this;return arguments.length>4&&void 0!==arguments[4]||ps.CROSS_MUTI,E().m(function i(){return E().w(function(i){for(;;)if(0===i.n)return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),i.a(2,r.joinRTCRoomWithOptions(e,{joinType:t,userData:n,mode:ps.CROSS_MUTI}))},i)})()})}},{key:"joinRTCRoom",value:function(e,t,n){return F(this,arguments,void 0,function(e,t,n){var r=this,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:ps.RTC;return E().m(function a(){return E().w(function(a){for(;;)if(0===a.n)return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),a.a(2,r.joinRTCRoomWithOptions(e,{mode:i,joinType:t,userData:n}))},a)})()})}},{key:"joinRTCRoomWithOptions",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s=this;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(Ne.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),r),!this._crtRoom){n.n=1;break}return this._logger.error(Ne.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),n.a(2,{code:Ae.REPERT_JOIN_ROOM});case 1:return i=this._crtRoom=new tu(this._context,this._runtime,e,this._service,this._options,null==t?void 0:t.mode,null==t?void 0:t.encrypt),n.n=2,i.__innerInit((null==t?void 0:t.mode)||ps.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,r,null==t?void 0:t.srcLanguage,null==t?void 0:t.nickName);case 2:if(a=n.v,(o=a.code)===Ae.SUCCESS){n.n=3;break}return this._crtRoom=null,n.a(2,{code:o});case 3:return i.once(Bc,function(){s._crtRoom=null}),n.a(2,{code:o,room:i,userIds:i.getRemoteUserIds(),tracks:i.getRemoteTracks()})}},n,this)}))}},{key:"joinLivingRoom",value:function(e,t,n,r){return F(this,arguments,void 0,function(e,t,n,r){var i=this;return E().m(function a(){var o,s,c,u,l;return E().w(function(a){for(;;)switch(a.n){case 0:if(o=i._logger.createTraceId(),i._logger.info(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:n,outerUserDatas:r}),o),!i._crtRoom){a.n=1;break}return i._logger.error(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly -> roomId: ".concat(e)}),o),a.a(2,{code:Ae.REPERT_JOIN_ROOM});case 1:return s=i._crtRoom=new eu(i._context,i._runtime,e,i._service,i._options,t,!1,!0),a.n=2,s.__innerInit(ps.LIVE,n,t,void 0,r,o);case 2:if(c=a.v,(u=c.code)===Ae.SUCCESS){a.n=3;break}return i._crtRoom=null,a.a(2,{code:u});case 3:return s.once(Bc,function(){i._crtRoom=null}),l={code:u,room:s,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()},s.__getCDNPushMode()===au.MANUAL&&Object.assign(l,{CDNEnable:s.__getCDNEnable()}),a.a(2,l)}},a)})()})}},{key:"getAudienceClient",value:function(e){return this._audience||(this._audience=new iu(this._context,this._runtime,this._options)),this._logger.info(Ne.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}},{key:"_onIMStatusChange",value:function(e,n){if(this._logger.info(Ne.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:e,code:n,desc:t[e]})),e===t.SUSPENDED&&40001===n&&this._service.clearMSList(),e===t.DISCONNECTED){if(this._crtRoom){var r=hc.IM_DISCONNECTED;40002===n?r=hc.OTHER_CLIENT_IM_CONNECTED:n===De&&(r=hc.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:r}]})}}else if(e===t.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof eu)this._getJoinedPKRoomList().forEach(function(e){e.__onReconnected()});this._crtRoom&&this._crtRoom.__onReconnected()}}},{key:"_onIMUninit",value:function(){var e;this._logger.info(Ne.L_RTC_CLIENT_DESTROY_S,JSON.stringify({msg:"TODO -> on IM client ondestroy"})),null===(e=this._crtRoom)||void 0===e||e.__destroy(!0)}},{key:"leaveRoom",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r;return E().w(function(t){for(;;)switch(t.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(Ne.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),r),this._crtRoom){t.n=1;break}return this._logger.warn(Ne.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:ke.FAILED,msg:"Room does not exist, without leave"}),r),t.a(2,{code:Ae.SUCCESS});case 1:return t.n=2,this._crtRoom.__destroy(!0);case 2:return this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(Ne.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:ke.SUCCESSED,roomId:null===(n=this._crtRoom)||void 0===n?void 0:n.getRoomId()}),r),this._crtRoom=null,t.a(2,{code:Ae.SUCCESS})}},t,this)}))}},{key:"joinLivingRoomAsAudience",value:function(e,t,n){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e,livingType:t}),r),this._service.isNededDetector()&&this._service.detectorMediaSever(),!rr(this._context.getNaviInfo())){n.n=1;break}return this._logger.error(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.FAILED,code:Ae.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),r),n.a(2,{code:Ae.PACKAGE_ENVIRONMENT_ERROR});case 1:if(ce("roomId",e,Q,!0)&&ce("livingType",t,function(e){return e===Fc.AUDIO||e===Fc.VIDEO})){n.n=2;break}return this._logger.error(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),r),n.a(2,{code:Ae.PARAMS_ERROR});case 2:if(!this._crtAudienceLivingRoom){n.n=3;break}return this._logger.error(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.FAILED,code:Ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),n.a(2,{code:Ae.REPERT_JOIN_ROOM});case 3:if(this._service.getMsList().length){n.n=4;break}return this._logger.error(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.FAILED,code:Ae.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),r),n.a(2,{code:Ae.NOT_OPEN_VIDEO_AUDIO_SERVER});case 4:return n.n=5,this._context.joinLivingRoomAsAudience(e,ps.LIVE,t);case 5:if(i=n.v,a=i.code,o=i.data,a===we){n.n=6;break}return this._logger.error(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.FAILED,code:a,msg:"signal error -> audience join room"}),r),n.a(2,{code:Ae.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED});case 6:return s=Oo(),c=new su(this._context,this._runtime,this._options,e,o,t,s),this._crtAudienceLivingRoom=c,this._logger.info(Ne.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.SUCCESSED,roomData:o}),r),n.a(2,{room:c,code:Ae.SUCCESS,userIds:c.getRemoteUserIds(),RTCTracks:c.getRemoteRTCTracks(),MCUTracks:c.getRemoteMCUTracks(),CDNUris:c.getCDNInfo()})}},n,this)}))}},{key:"leaveLivingRoomAsAudience",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._logger.createTraceId(),this._logger.info(Ne.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e.getRoomId(),userId:this._context.getCurrentId()}),n),this._crtAudienceLivingRoom){t.n=1;break}return this._logger.warn(Ne.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.FAILED,msg:"Room does not exist, without leave"}),n),t.a(2,{code:Ae.SUCCESS});case 1:if(this._crtAudienceLivingRoom===e){t.n=2;break}return this._logger.error(Ne.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> room"}),n),t.a(2,{code:Ae.PARAMS_ERROR});case 2:return t.n=3,this._crtAudienceLivingRoom.__destroy(!0);case 3:return this._crtAudienceLivingRoom=null,this._logger.info(Ne.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ke.SUCCESSED}),n),t.a(2,{code:Ae.SUCCESS})}},t,this)}))}},{key:"upgradeToAnchorRoom",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s=this;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._logger.createTraceId(),this._logger.info(Ne.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,n),ce("room",e,function(){return e instanceof su},!0)){t.n=1;break}return this._logger.error(Ne.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> room"}),n),t.a(2,{code:Ae.PARAMS_ERROR});case 1:if(r=e.getRoomId(),!this._crtRoom){t.n=2;break}return this._logger.error(Ne.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:r}),n),t.a(2,{code:Ae.REPERT_JOIN_ROOM});case 2:return i=this._crtRoom=new eu(this._context,this._runtime,r,this._service,this._options,e.livingType,!0,!0,e.getClientSessionId()),t.n=3,i.__innerInitByIdentityChange(n);case 3:if((a=t.v)===we){t.n=4;break}return this._crtRoom=null,t.a(2,{code:a});case 4:return i.once(Bc,function(){s._crtRoom=null}),t.n=5,this._crtAudienceLivingRoom.__destroy(!1);case 5:return this._crtAudienceLivingRoom=null,o={room:i,code:Ae.SUCCESS,userIds:i.getRemoteUserIds(),tracks:i.getRemoteTracks()},i.__getCDNPushMode()===au.MANUAL&&Object.assign(o,{CDNEnable:i.__getCDNEnable()}),t.a(2,o)}},t,this)}))}},{key:"downgradeToAudienceRoom",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._logger.createTraceId(),this._logger.info(Ne.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:e._roomId,userId:this._context.getCurrentId()}),n),e.isMainRoom()){t.n=1;break}return this._logger.error(Ne.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),n),t.a(2,{code:Ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM});case 1:if(ce("room",e,function(){return e instanceof eu},!0)){t.n=2;break}return this._logger.error(Ne.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> room"}),n),t.a(2,{code:Ae.PARAMS_ERROR});case 2:if(!this._crtAudienceLivingRoom){t.n=3;break}return this._logger.error(Ne.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),n),t.a(2,{code:Ae.REPERT_JOIN_ROOM});case 3:return t.n=4,this._context.rtcIdentityChange(e._roomId,zc.AnchorToViewer,e.getLivingType());case 4:if(r=t.v,i=r.code,a=r.data,i===we){t.n=5;break}return this._logger.error(Ne.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ke.FAILED,code:Ae.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),n),t.a(2,{code:Ae.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED});case 5:return this._logger.info(Ne.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ke.SUCCESSED,roomData:a}),n),o=e.getClientSessionId(),s=new su(this._context,this._runtime,this._options,e._roomId,a,e.getLivingType(),o),this._crtAudienceLivingRoom=s,this._crtRoom.__destroy(!1),this._crtRoom=null,t.a(2,{room:s,code:Ae.SUCCESS,userIds:s.getRemoteUserIds(),RTCTracks:s.getRemoteRTCTracks(),MCUTracks:s.getRemoteMCUTracks(),CDNUris:s.getCDNInfo()})}},t,this)}))}},{key:"getJoinedRoomInfo",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i,a;return E().w(function(e){for(;;)switch(e.n){case 0:return t=this._logger.createTraceId(),n=this._context.getCurrentId(),this._logger.error(Ne.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:n}),t),e.n=1,this._context.getRTCJoinedUserInfo(n);case 1:if(r=e.v,i=r.code,a=r.data,i===we){e.n=2;break}return this._logger.error(Ne.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:ke.FAILED,code:i}),t),e.a(2,{code:i});case 2:return this._logger.info(Ne.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:ke.SUCCESSED,roomInfo:a}),t),e.a(2,{code:Ae.SUCCESS,data:a})}},e,this)}))}},{key:"generateSummarization",value:function(e,t){return F(this,arguments,void 0,function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0;return E().m(function s(){var c,u,l,_,d,f,h;return E().w(function(s){for(;;)switch(s.n){case 0:if(c=n._logger.createTraceId(),n._logger.info(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_T,JSON.stringify({roomId:e,taskId:t,startTime:r,endTime:i,config:a,contentBlock:o}),c),ce("roomId",e,Q,!0)){s.n=1;break}return n._logger.error(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> roomId"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 1:if(ce("taskId",t,Q,!0)){s.n=2;break}return n._logger.error(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> taskId"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 2:if(W(r)&&!(r<0)){s.n=3;break}return n._logger.error(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> startTime"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 3:if(W(i)&&!(i<0)){s.n=4;break}return n._logger.error(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> endTime"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 4:if(ce("config",a,X,!0)){s.n=5;break}return n._logger.error(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> config"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 5:return u=ur(a),l=u.isValid,_=u.key,l||n._logger.warn(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> config.".concat(_)}),c),s.n=6,n._service.generateSummarization(e,t,r,i,a,o,c);case 6:if(d=s.v,f=d.code,h=d.msg,f===Ae.SUCCESS){s.n=7;break}return n._logger.error(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ke.FAILED,code:f,msg:h}),c),s.a(2,{code:f});case 7:return n._logger.info(Ne.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ke.SUCCESSED}),c),s.a(2,{code:f})}},s)})()})}},{key:"getASRContent",value:function(e,t){return F(this,arguments,void 0,function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0;return E().m(function s(){var c,u,l,_;return E().w(function(s){for(;;)switch(s.n){case 0:if(c=n._logger.createTraceId(),n._logger.info(Ne.L_RTC_CLIENT_GET_ASR_CONTENT_T,JSON.stringify({roomId:e,taskId:t,startTime:r,endTime:i,destLang:o,contentBlock:a}),c),ce("roomId",e,Q,!0)){s.n=1;break}return n._logger.error(Ne.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> roomId"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 1:if(ce("taskId",t,Q,!0)){s.n=2;break}return n._logger.error(Ne.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> taskId"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 2:if(W(r)&&!(r<0)){s.n=3;break}return n._logger.error(Ne.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> startTime"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 3:if(W(i)&&!(i<0)){s.n=4;break}return n._logger.error(Ne.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> endTime"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 4:if(ce("destLang",o,Y,!1)){s.n=5;break}return n._logger.error(Ne.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ke.FAILED,code:Ae.PARAMS_ERROR,msg:"params error -> destLang"}),c),s.a(2,{code:Ae.PARAMS_ERROR});case 5:return s.n=6,n._service.getASRContent(e,t,r,i,a,c,o);case 6:if(u=s.v,l=u.code,_=u.msg,l===Ae.SUCCESS){s.n=7;break}return n._logger.error(Ne.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ke.FAILED,code:l,msg:_}),c),s.a(2,{code:l});case 7:return n._logger.info(Ne.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ke.SUCCESSED}),c),s.a(2,{code:l})}},s)})()})}}],[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=t.logger;if(i.warn(Ne.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"NCRTC Version":"26.1.0",Commit:"ac4bb112f4fbde2c7b94ef9141b75e4e2be81ca7","browserInfo.browser":Zn.browser,"browserInfo.supportsUnifiedPlan":Zn.supportsUnifiedPlan,"browserInfo.version":Zn.version})),se("options",e,K.OBJECT,!0),se("options.mediaServer",e.mediaServer,function(e){return!(!te(e)||"https:"===location.protocol&&!/^https/.test(e))}),se("options.timeout",e.timeout,function(e){return W(e)&&e>=5e3&&e<=3e4}),se("options.pingGap",e.pingGap,function(e){return W(e)&&e>=3e3&&e<=1e4}),e.AAAWorklet){se("options.AAAWorklet",e.AAAWorklet,K.OBJECT,!0);var a=e.AAAWorklet,o=a.scriptUrl,s=a.wasmUrl;se("AAAWorklet.scriptUrl",o,K.STRING,!0),se("AAAWorklet.wasmUrl",s,K.STRING,!0),mn.SCRIPT_URL=o,mn.WASM_URL=s}return e.encryptor&&(se("options.encrypt",e.encryptor,K.OBJECT,!0),se("options.encrypt.decodeAudio",e.encryptor.decodeAudio,function(e){return"function"==typeof e},!0),se("options.encrypt.decodeVideo",e.encryptor.decodeVideo,function(e){return"function"==typeof e},!0),se("options.encrypt.encodeAudio",e.encryptor.encodeAudio,function(e){return"function"==typeof e},!0),se("options.encrypt.encodeVideo",e.encryptor.encodeVideo,function(e){return"function"==typeof e},!0),Wo.init(e.encryptor,i)),n._instance||(n._instance=new n(new $u(t),r,e)),n._instance}}])}();Object.defineProperty(el,"_instance",{enumerable:!0,configurable:!0,writable:!0,value:null}),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE"}(Xu||(Xu={}));var tl,nl,rl={tag:"RCRTC",verify:function(){return"undefined"==typeof isSecureContext||isSecureContext?!!a.VersionManage.validEngine("26.1.0")||(console.error("The current engine version '".concat(a.VersionManage.getInfo().engine,"' error, plugin-rtc required engine version at least '","26.1.0","'.")),!1):(console.error("Please use the https protocol or use `http://localhost` to open the page!"),!1)},setup:function(e){var t=J(e);return t.logger.warn(Ne.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"NCRTC Version":"26.1.0",Commit:"ac4bb112f4fbde2c7b94ef9141b75e4e2be81ca7","browserInfo.browser":Zn.browser,"browserInfo.supportsUnifiedPlan":Zn.supportsUnifiedPlan,"browserInfo.version":Zn.version})),new el(new $u(t),Ue,{})}},il=Fn,al={SUCCESS:0,PARAM_ERROR:80001,SESSION_EXIST:80002,NOT_IN_CALL:80003,MEDIATYPE_INVALID:80004,NOT_VIDEO_CALL:80005,RTC_SERVICE_UNAVAILABLE:80006,USER_LIST_INVAILD:80007,CALL_ID_INVALID:80008,TRANSACTION_ID_INVALID:80009,USER_ID_INVALID:80010,SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:80011,SIGNAL_DISCONNECTED:80012,CAMERA_CLOSED:80100,MICROPHONE_CLOSED:80101,MEDIA_RESOURCE_INVALIED:80102,NOT_INSTALL_RTC_PLUGIN:80103,PLAY_MEDIA_FAILED:80104,VIDEO_VIEW_NOT_SET:80105},ol=al;!function(e){e.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O="L-index_install_call_plus_plugin-O",e.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O="L-callplus_client_set_event_listener-O",e.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O="L-callplus_client_call_event_listener-O",e.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O="L-callplus_client_set_status_report_listener-O",e.L_CALLPLUS_CLIENT_CALL_STATUS_REPORT_LISTENER_O="L-callplus_client_call_status_report_listener-O",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T="L-callplus_client_set_video_config-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R="L-callplus_client_set_video_config-R",e.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O="L-callplus_video_config_set_frame_rate-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O="L-callplus_video_config_set_resolution-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O="L-callplus_video_config_set_bitrate-O",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T="L-callplus_client_set_audio_config-T",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R="L-callplus_client_set_audio_config-R",e.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O="L-callplus_audio_config_set_bitrate-O",e.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O="L-callplus_audio_config_set_sample_rate-O",e.L_CALLPLUS_CLIENT_PREVIEW_T="L-callplus_client_preview-T",e.L_CALLPLUS_CLIENT_PREVIEW_R="L-callplus_client_preview-R",e.L_CALLPLUS_CLIENT_START_CALL_T="L-callplus_client_start_call-T",e.L_CALLPLUS_CLIENT_START_CALL_R="L-callplus_client_start_call-R",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T="L-callplus_client_join_multi_call-T",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R="L-callplus_client_join_multi_call-R",e.L_CALLPLUS_CLIENT_ACCEPT_T="L-callplus_client_accept-T",e.L_CALLPLUS_CLIENT_ACCEPT_R="L-callplus_client_accept-R",e.L_CALLPLUS_CLIENT_HANGUP_T="L-callplus_client_hangup-T",e.L_CALLPLUS_CLIENT_HANGUP_R="L-callplus_client_hangup-R",e.L_CALLPLUS_CLIENT_INVITE_T="L-callplus_client_invite-T",e.L_CALLPLUS_CLIENT_INVITE_R="L-callplus_client_invite-R",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T="L-callplus_client_request_change_media_type-T",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R="L-callplus_client_request_change_media_type-R",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T="L-callplus_client_cancel_change_media_type-T",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R="L-callplus_client_cancel_change_media_type-R",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T="L-callplus_client_reply_change_media_type-T",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R="L-callplus_client_reply_change_media_type-R",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_T="L-callplus_client_get_current_call_session-T",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_R="L-callplus_client_get_current_call_session-R",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_get_available_call_sessions_from_server-T",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_get_available_call_sessions_from_server-R",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T="L-callplus_client_get_call_records-T",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R="L-callplus_client_get_call_records-R",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T="L-callplus_client_delete_call_records_by_callId-T",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R="L-callplus_client_delete_call_records_by_callId-R",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_delete_all_call_records_from_server-T",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_delete_all_call_records_from_server-R",e.L_CALLPLUS_CLIENT_START_CAMERA_T="L-callplus_client_start_camera-T",e.L_CALLPLUS_CLIENT_START_CAMERA_R="L-callplus_client_start_camera-R",e.L_CALLPLUS_CLIENT_STOP_CAMERA_T="L-callplus_client_stop_camera-T",e.L_CALLPLUS_CLIENT_STOP_CAMERA_R="L-callplus_client_stop_camera-R",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T="L-callplus_client_switch_camera-T",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R="L-callplus_client_switch_camera-R",e.L_CALLPLUS_CLIENT_START_MICROPHONE_T="L-callplus_client_start_microphone-T",e.L_CALLPLUS_CLIENT_START_MICROPHONE_R="L-callplus_client_start_microphone-R",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T="L-callplus_client_stop_microphone-T",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R="L-callplus_client_stop_microphone-R",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T="L-callplus_client_switch_microphone-T",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R="L-callplus_client_switch_microphone-R",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T="L-callplus_client_set_video_view-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R="L-callplus_client_set_video_view-R",e.L_RTC_MODULE_SET_VIDEO_VIEW_O="L-rtc_module_set_video_view-O",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T="L-callplus_client_remove_video_view-T",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R="L-callplus_client_remove_video_view-R",e.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O="L-rtc_module_remove_video_view-O",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_T="L-callplus_client_play_media-T",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_R="L-callplus_client_play_media-R",e.L_RTC_MODULE_PLAY_MEDIA_T="L-rtc_module_play_media-T",e.L_RTC_MODULE_PLAY_MEDIA_R="L-rtc_module_play_media-R",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T="L-rtc_module_set_all_remote_audio_enbale-T",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R="L-rtc_module_set_all_remote_audio_enable-R",e.L_RTC_MODULE_SUBSCRIBE_T="L-rtc_module_subscribe-T",e.L_RTC_MODULE_SUBSCRIBE_R="L-rtc_module_subscribe-R",e.L_RTC_MODULE_UNSUBSCRIBE_T="L-rtc_module_unsubscribe-T",e.L_RTC_MODULE_UNSUBSCRIBE_R="L-rtc_module_unsubscribe-R",e.L_RTC_MODULE_PUBLISH_T="L-rtc_module_publish-T",e.L_RTC_MODULE_PUBLISH_R="L-rtc_module_publish-R",e.L_RTC_MODULE_UNPUBLISH_T="L-rtc_module_unpublish-T",e.L_RTC_MODULE_UNPUBLISH_R="L-rtc_module_unpublish-R",e.L_RTC_MODULE_DESTROY_ALL_TRACKS_O="L-rtc_module_destroy_all_tracks-O",e.L_RTC_MODULE_SESSION_CONNECT_T="L-rtc_module_session_connect-T",e.L_RTC_MODULE_SESSION_CONNECT_P="L-rtc_module_session_connect-P",e.L_RTC_MODULE_SESSION_CONNECT_R="L-rtc_module_session_connect-R",e.L_RTC_MODULE_SESSION_CLOSE_T="L-rtc_module_session_close-T",e.L_RTC_MODULE_SESSION_CLOSE_P="L-rtc_module_session_close-P",e.L_RTC_MODULE_SESSION_CLOSE_R="L-rtc_module_session_close-R",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_T="L-rtc_module_create_video_track-T",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_R="L-rtc_module_create_video_track-R",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_T="L-rtc_module_create_audio_track-T",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_R="L-rtc_module_create_audio_track-R",e.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O="L-rtc_module_receive_track_publish-O",e.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O="L-rtc_module_receive_track_unpublish-O",e.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O="L-rtc_module_receive_track_enable_change-O",e.L_RTC_MODULE_RECEIVE_KICK_OFF_O="L-rtc_module_receive_kick_off-O",e.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O="L-rtc_module_receive_peerconnection_except_close-O",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T="L-rtc_module_change_media_type-T",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R="L-rtc_module_change_media_type-R",e.L_RTC_MODULE_JOIN_RTC_ROOM_T="L-rtc_module_join_rtc_room-T",e.L_RTC_MODULE_JOIN_RTC_ROOM_R="L-rtc_module_join_rtc_room-R",e.L_RTC_MODULE_QUIT_RTC_ROOM_T="L-rtc_module_quit_rtc_room-T",e.L_RTC_MODULE_QUIT_RTC_ROOM_R="L-rtc_module_quit_rtc_room-R",e.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P="L-rtc_module_create_call_media_tracks-P",e.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T="L-signal_transporter_single_call-T",e.L_SIGNAL_TRANSPORTER_GROUP_CALL_T="L-signal_transporter_group_call-T",e.L_SIGNAL_TRANSPORTER_INVITE_T="L-signal_transporter_invite-T",e.L_SIGNAL_TRANSPORTER_RING_T="L-signal_transporter_ring-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_T="L-signal_transporter_accept-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_R="L-signal_transporter_accept-R",e.L_SIGNAL_TRANSPORTER_JOIN_CALL_T="L-signal_transporter_join_call-T",e.L_SIGNAL_TRANSPORTER_HANGUP_T="L-signal_transporter_hangup-T",e.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T="L-signal_transporter_call_status_up-T",e.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T="L-signal_transporter_call_event_up-T",e.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T="L-signal_transporter_call_dialog_up-T",e.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T="L-signal_transporter_delete_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T="L-signal_transporter_get_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T="L-signal_transporter_get_call_server_time-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T="L-signal_transporter_get_call_time_info-T",e.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T="L-signal_transporter_get_available_call_list-T",e.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T="L-signal_transporter_clear_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T="L-signal_transporter_get_call_info_by_callId-T",e.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T="L-signal_transporter_user_system_state_up-T",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O="L-signal_transporter_receive_call_signal_data-O",e.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O="L-signal_transporter_im_state_change-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O="L-signal_transporter_receive_invite-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O="L-signal_transporter_receive_call_status-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O="L-signal_transporter_receive_miss_message-O",e.L_CALL_ENGINE_UPDATE_USERS_STATE_O="L-call_engine_update_users_state-O",e.L_CALL_ENGINE_IM_STATE_CHANGE_O="L-call_engine_im_state_change-O",e.L_CALL_ENGINE_CALL_TIMEOUT_O="L-call_engine_call_timeout-O",e.L_CALL_ENGINE_START_CALL_TIMER_O="L-call_engine_start_call_timer-O",e.L_CALL_ENGINE_STOP_CALL_TIMER_O="L-call_engine_stop_call_timer-O",e.L_CALL_ENGINE_UP_ON_PHONE_END_T="L-call_engine_up_on_phone_end-T",e.L_CALL_ENGINE_UP_ON_PHONE_END_R="L-call_engine_up_on_phone_end-R",e.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O="L-call_engine_receive_first_frame_time-O",e.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O="L-call_engine_receive_mediatype_change-O",e.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O="L-call_engine_receive_close_session-O",e.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O="L-call_engine_receive_call_record-O",e.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O="L-call_engine_receive_complementary_data-O",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T="L-call_engine_create_session_by_server-T",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R="L-call_engine_create_session_by_server-R",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T="L-call_engine_up_first_frame_time-T",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R="L-call_engine_up_first_frame_time-R",e.L_TIME_CORRECT_START_O="L-time_correct_start-O",e.L_TIME_CORRECT_STOP_O="L-time_correct_stop-O",e.L_TIME_CORRECT_RESTART_O="L-time_correct_restart-O",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T="L-time_correct_get_call_client_time_by_server-T",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P="L-time_correct_get_call_client_time_by_server-P",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R="L-time_correct_get_call_client_time_by_server-R",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T="L-time_correct_calc_client_start_time-T",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R="L-time_correct_calc_client_start_time-R",e.L_TIME_CORRECT_SET_DELTA_TIME_O="L-time_correct_set_delta_time-O",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T="L-time_correct_loop_correct_client_time-T",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R="L-time_correct_loop_correct_client_time-R",e.L_INNER_SESSION_UPDATE_USER_STATE_O="L-inner_session_update_user_state-O",e.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O="L-inner_session_set_user_device_enable-O",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_T="L-callplus_session_get_create_time-T",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_R="L-callplus_session_get_create_time-R",e.L_CALLPLUS_SESSION_GET_DURATION_T="L-callplus_session_get_duration-T",e.L_CALLPLUS_SESSION_GET_DURATION_R="L-callplus_session_get_duration-R",e.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O="L-callplus_set_android_push_config-O",e.L_ABNORMAL_ADD_CALL_ID_E="L-ABNORMAL_ADD_CALL_ID-E",e.L_ABNORMAL_REMOVE_CALL_IDS_E="L-ABNORMAL_REMOVE_CALL_IDS-E",e.L_ABNORMAL_GET_CALL_IDS_E="L-ABNORMAL_GET_CALL_IDS-E",e.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O="L-set_audio_output_device_id-O"}(tl||(tl={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(nl||(nl={}));var sl,cl=l(function e(t,n,r,i,a){c(this,e),Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_duration",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._callId=this._session.getCallId()},[{key:"getCallId",value:function(){return this._callId}},{key:"getState",value:function(){return this._session.getSessionState()}},{key:"getCallType",value:function(){return this._session.getCallType()}},{key:"getMediaType",value:function(){return this._session.getMediaType()}},{key:"getUserList",value:function(){var e=this;return this._session.getUserList().map(function(t){var n=t.userId,r=t.userState,i=null,a=null;return n===e._context.getCurrentId()?(i=e._rtcModule.getLocalVideoTrack(),a=e._rtcModule.getLocalAudioTrack()):(i=e._rtcModule.getRemoteTrack(n,nl.VIDEO),a=e._rtcModule.getRemoteTrack(n,nl.AUDIO)),{userId:n,state:r,cameraEnable:!!i&&!i.isOwnerMuted(),microphoneEnable:!!a&&!a.isOwnerMuted()}})}},{key:"getCreatorUserId",value:function(){return this._session.getStartCallerId()}},{key:"getInviterUserId",value:function(){return this._session.getCallerId()}},{key:"getCreateTimestamp",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i;return E().w(function(e){for(;;)switch(e.n){case 0:if(t=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",t),!this._startTime){e.n=1;break}return e.a(2,{code:ol.SUCCESS,startTime:this._startTime});case 1:return e.n=2,this._callEngine.getCallStaringTime({callId:this._callId},t);case 2:if(n=e.v,r=n.code,i=n.clientStartTime,r===ol.SUCCESS){e.n=3;break}return this._logger.error(tl.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"errCode: ".concat(r),t),e.a(2,{code:r});case 3:return this._logger.info(tl.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",t),this._startTime=i,e.a(2,{code:ol.SUCCESS,startTime:this._startTime})}},e,this)}))}},{key:"getDuration",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i;return E().w(function(e){for(;;)switch(e.n){case 0:if(t=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_SESSION_GET_DURATION_T,"",t),!this._duration){e.n=1;break}return this._logger.info(tl.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(ol.SUCCESS,", duration: ").concat(this._duration),t),e.a(2,{code:ol.SUCCESS,duration:this._duration});case 1:return e.n=2,this._callEngine.getCallTimeInfo(this._callId,t);case 2:if(n=e.v,r=n.code,i=n.data,r===ol.SUCCESS){e.n=3;break}return this._logger.error(tl.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(r),t),e.a(2,{code:r});case 3:return this._logger.info(tl.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(ol.SUCCESS,", duration: ").concat(i.duration),t),this._duration=i.duration,e.a(2,{code:ol.SUCCESS,duration:this._duration})}},e,this)}))}}]);exports.NCCallType=void 0,(sl=exports.NCCallType||(exports.NCCallType={}))[sl.SINGLE=0]="SINGLE",sl[sl.MULTI=1]="MULTI";var ul,ll=exports.NCCallType;exports.NCCallUserState=void 0,(ul=exports.NCCallUserState||(exports.NCCallUserState={}))[ul.IDLE=0]="IDLE",ul[ul.CALLING=100]="CALLING",ul[ul.INVITED=101]="INVITED",ul[ul.RINGING=102]="RINGING",ul[ul.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",ul[ul.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",ul[ul.CONNECTING=200]="CONNECTING",ul[ul.ONCALL=300]="ONCALL",ul[ul.ONPHONE=301]="ONPHONE",ul[ul.ENDED=1e3]="ENDED",ul[ul.NO_ANSWER=1001]="NO_ANSWER",ul[ul.MISSED=1002]="MISSED",ul[ul.CANCELLED=1003]="CANCELLED",ul[ul.DECLINED=1004]="DECLINED",ul[ul.ERROR=2e3]="ERROR";var _l,dl,fl,hl,gl=exports.NCCallUserState;exports.NCCallState=void 0,(_l=exports.NCCallState||(exports.NCCallState={}))[_l.IDLE=0]="IDLE",_l[_l.CALLING=100]="CALLING",_l[_l.INVITED=101]="INVITED",_l[_l.RINGING=102]="RINGING",_l[_l.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",_l[_l.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",_l[_l.CONNECTING=200]="CONNECTING",_l[_l.ONCALL=300]="ONCALL",_l[_l.ENDED=1e3]="ENDED",_l[_l.NOANSWER=1001]="NOANSWER",_l[_l.MISSED=1002]="MISSED",_l[_l.CANCELED=1003]="CANCELED",_l[_l.DECLINED=1004]="DECLINED",_l[_l.ERROR=2e3]="ERROR",exports.NCCallMediaTypeChangeResult=void 0,(dl=exports.NCCallMediaTypeChangeResult||(exports.NCCallMediaTypeChangeResult={}))[dl.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",dl[dl.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",dl[dl.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",dl[dl.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT",exports.NCCallEndReason=void 0,(fl=exports.NCCallEndReason||(exports.NCCallEndReason={}))[fl.IDLE=0]="IDLE",fl[fl.CALLING=100]="CALLING",fl[fl.INVITED=101]="INVITED",fl[fl.RINGING=102]="RINGING",fl[fl.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",fl[fl.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",fl[fl.CONNECTING=200]="CONNECTING",fl[fl.ONCALL=300]="ONCALL",fl[fl.ON_PHONE=301]="ON_PHONE",fl[fl.ON_PHONE_END=302]="ON_PHONE_END",fl[fl.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",fl[fl.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",fl[fl.ABNORMAL_END=999]="ABNORMAL_END",fl[fl.ENDED=1e3]="ENDED",fl[fl.NO_ANSWER=1001]="NO_ANSWER",fl[fl.MISSED=1002]="MISSED",fl[fl.CANCELLED=1003]="CANCELLED",fl[fl.DECLINED=1004]="DECLINED",fl[fl.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",fl[fl.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",fl[fl.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",fl[fl.PUBLISH_ERR=1106]="PUBLISH_ERR",fl[fl.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",fl[fl.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",fl[fl.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",fl[fl.CONNECTION_ERR=1110]="CONNECTION_ERR",fl[fl.LOGOUT=1111]="LOGOUT",fl[fl.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",fl[fl.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",fl[fl.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",fl[fl.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",fl[fl.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",fl[fl.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",fl[fl.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",fl[fl.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",fl[fl.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",fl[fl.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",fl[fl.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",fl[fl.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",fl[fl.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC",function(e){e[e.START=1]="START",e[e.END=2]="END"}(hl||(hl={}));var pl,El=l(function e(t){c(this,e),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})},[{key:"setDefaultMicrophoneId",value:function(e){return this._audioConfig.microphoneId=e,this}},{key:"setBitrate",value:function(e,t){return!W(e)||!W(t)||t<=0||e<=0||t<e?(this._logger.error(tl.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,"params error -> max: ".concat(t,",min: ").concat(e,", max and min is a number > 0, max should > min")),this):(this._audioConfig.minBitrate=e,this._audioConfig.maxBitrate=t,this)}},{key:"setSampleRate",value:function(e){return W(e)?(this._audioConfig.sampleRate=e,this):(this._logger.error(tl.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,"params error -> sampleRate: ".concat(e)),this)}},{key:"build",value:function(){return this._audioConfig}}]),vl=l(function e(t){c(this,e),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:exports.NCCallVideoResolution.W640_H480,frameRate:exports.NCCallVideoFrameRate.FPS_15}})},[{key:"setFrameRate",value:function(e){return exports.NCCallVideoFrameRate[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(tl.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,"params error -> fps: ".concat(e)),this)}},{key:"setVideoResolution",value:function(e){return exports.NCCallVideoResolution[e]?(this._videoConfig.resolution=e,this):(this._logger.error(tl.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,"params error -> resolution: ".concat(e)),this)}},{key:"setDefaultCameraId",value:function(e){return this._videoConfig.cameraId=e,this}},{key:"setBitrate",value:function(e,t){return!W(e)||!W(t)||t<=0||e<=0||t<e?(this._logger.error(tl.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,"params error -> max: ".concat(t,",min: ").concat(e,", max and min is a number > 0, max should > min")),this):(this._videoConfig.minBitrate=e,this._videoConfig.maxBitrate=t,this)}},{key:"build",value:function(){return this._videoConfig}}]),ml=function(e){return{callId:e.callId,callType:e.callType,callDirection:e.callDir,mediaType:e.mediaType,callerUserId:e.callingUserId,callUserIds:e.callUserIds,sessionState:e.callStatus,userState:e.sessionStatus,startTimestamp:e.startTime,endTimestamp:e.endTime,duration:e.duration,syncTimestamp:e.syncTime,systemState:e.sysStatus,createTimestamp:e.crtTime}},Rl=function(e){var t=e.callId,n=[],r=[],i=[],a=[];return e.callSessionUsers.forEach(function(e){var o=e.userId,s=e.sessionStatus,c=e.sysStatus;switch(s){case gl.INVITED:a.push({callId:t,userId:o,userState:s});break;case gl.RINGING:n.push({callId:t,fromUserId:o});break;case gl.CONNECTING:i.push({fromUserId:o});break;case gl.CANCELLED:case gl.DECLINED:case gl.ENDED:case gl.IDLE:r.push({callId:t,fromUserId:o,userState:s,systemState:c})}}),{ringingData:n,hangupData:r,acceptData:i,otherInvitedData:a}},Tl=function(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()},Il=function(e,t){var n;switch(e){case gl.CALLING:n=exports.NCCallEndReason.CANCELLED;break;case gl.RINGING:case gl.INVITED:n=exports.NCCallEndReason.DECLINED;break;case gl.CONNECTING:n=t?exports.NCCallEndReason.DECLINED:exports.NCCallEndReason.CANCELLED;break;case gl.ONCALL:n=exports.NCCallEndReason.ENDED}return n},Sl=function(e){var t=e.voipCallInfo;return!!t&&1===JSON.parse(t).strategy},Cl=function(e,t){return!e&&0!==e||W(e)&&!(e<=0)?!t&&0!==t||W(t)&&!(t<=0)?e&&t&&t<e?{code:ol.PARAM_ERROR,errorMsg:"params error -> maxBitrate: ".concat(t,", minBitrate: ").concat(e,", maxBitrate should > minBitrate")}:{code:ol.SUCCESS}:{code:ol.PARAM_ERROR,errorMsg:"params error -> maxBitrate: a number of > 0, value: ".concat(t)}:{code:ol.PARAM_ERROR,errorMsg:"params error -> minBitrate: a number of > 0, value: ".concat(e)}},Ll=function(e){var t=[];for(var n in e){var r=e[n],i=r.videoView,a=r.isTiny;t.push({userId:n,videoView:i.nodeName,isTiny:a})}return t},Ol=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.threadId,i=t.apnsCollapseId,a=t.richMediaUri,o=n.channelIdMi,s=n.channelIdHW,c=n.channelIdOPPO,u=n.typeVivo,l=n.fcmChannelId,_=n.fcmCollapseKey,d=n.fcmImageUrl,f=n.importanceHW,h=n.categoryHW,g=n.imageUrlHW,p=n.categoryVivo,E=n.importanceHonor,v=n.imageUrlHonor,m={};r&&(m["thread-id"]=r),m["apns-collapse-id"]=i||e,a&&(m.richMediaUri=a);var R={};s&&(R.channelId=s),g&&(R.image=g),h&&(R.category=h),R.importance=f||"NORMAL";var T,I,S,C,L=[{HW:R},{APNS:m}];return(_||d||l)&&(T={},_&&(T.collapse_key=_),d&&(T.imageUrl=d),l&&(T.channelId=l),L[0].FCM=T),o&&(L[0].MI={channelId:o}),c&&((I={}).channelId=c,L[0].OPPO=I),(u||p)&&(S={},u&&(S.classification=u),p&&(S.category=p),L[0].VIVO=S),(E||v)&&(C={},E&&(C.importance=E),v&&(C.image=v),L[0].HONOR=C),JSON.stringify(L)},yl=function(e,t){var n=e.pushTitle,r=void 0===n?"":n,i=e.iOSConfig,a=e.androidConfig,o=e.disablePushTitle,s=e.templateId,c={pushConfigs:Ol(t,i,a)};return q(o)&&(c.disableTitle=o),r&&(c.title=r),s&&(c.templateId=s),JSON.stringify(c)},bl=function(e){var t=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"],n=Object.keys(e).every(function(e){return t.includes(e)});if(!n)return{code:ol.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var r=0;r<t.length;r++){var i=t[r];if("disablePushTitle"===i){if(!ee(e[i])&&!q(e[i]))return{code:ol.PARAM_ERROR,errorMsg:"".concat(i," type is boolean")}}else if(("pushTitle"===i||"templateId"===i||"pushContent"===i)&&e[i]&&!Y(e[i]))return{code:ol.PARAM_ERROR,errorMsg:"".concat(i," type is string")}}var a=e.iOSConfig,o=e.androidConfig,s=Al(a||{});if(s.code!==ol.SUCCESS)return s;var c=Nl(o||{});return c.code!==ol.SUCCESS?c:{code:ol.SUCCESS}},Al=function(e){var t=e||{},n=t.threadId,r=t.richMediaUri;return n&&!Y(n)?{code:ol.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:r&&!Y(r)?{code:ol.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:ol.SUCCESS}},Nl=function(e){var t=["channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],n=Object.keys(e).every(function(e){return t.includes(e)});if(!n)return{code:ol.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var r=0;r<t.length;r++){var i=t[r];if("importanceHW"===i||"importanceHonor"===i){if(e[i]&&"LOW"!==e[i]&&"NORMAL"!==e[i])return{code:ol.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," value is NORMAL|LOW")}}else if(e[i]&&!Y(e[i]))return{code:ol.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," type is string")}}return{code:ol.SUCCESS}},kl=function(e){return"utf-16"===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf-8")?Pl(e):Ul(e)},Pl=function(e){for(var t=0,n=0,r=e.length;n<r;n++)t+=e.charCodeAt(n)<=65535?2:4;return t},Ul=function(e){for(var t,n=0,r=0,i=e.length;r<i;r++)n+=(t=e.charCodeAt(r))<127?1:t<=2047?2:t<=65535?3:4;return n},wl=/Electron/.test(navigator.userAgent);!function(e){e.L_QS_START_CALL_S="Call-start-S",e.L_QS_ACCEPT_CALL_S="Call-accept-S",e.L_QS_HANGUP_CALL_S="Call-hangup-S",e.L_QS_RECEIVE_CALL_S="Call-recv-S",e.L_QS_ABNORMAL_HANGUP_S="Call-interrupt-S"}(pl||(pl={}));var Dl,Ml,xl,Vl,Bl=l(function e(t){c(this,e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger},[{key:"reportStatisticsData",value:function(e,t,n,r,i,a,o){var s=+new Date,c=r?{mediaType:r.getMediaType(),callType:r.getCallType(),callId:r.getCallId()}:o,u={cr:"unknown",net:"unknown",cod:t,mtp:c.mediaType,ctp:c.callType,cid:c.callId,time:s,uid:this._context.getCurrentId()};i&&Object.assign(u,{ccid:i});var l=null;switch(e){case pl.L_QS_RECEIVE_CALL_S:l=Object.assign(Object.assign({},u),{rf:a});break;case pl.L_QS_ABNORMAL_HANGUP_S:l=Object.assign({},u);break;default:l=Object.assign(Object.assign({},u),{dur:s-n})}this._logger.__statistics(e,JSON.stringify(l))}}]);!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(Dl||(Dl={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(Ml||(Ml={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(xl||(xl={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(Vl||(Vl={}));var Gl,jl=function(){function e(t,n,r,i,a,o,u,l){var _;return c(this,e),_=s(this,e),Object.defineProperty(_,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(_,"_state",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(_,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(_,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(_,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(_,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(_,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(_,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(_,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),_}return g(e,ue),l(e,[{key:"getCallId",value:function(){return this._callId}},{key:"getSessionState",value:function(){return this._state}},{key:"getCallType",value:function(){return this._callType}},{key:"getMediaType",value:function(){return this._mediaType}},{key:"getStartCallerId",value:function(){return this._startCallerId}},{key:"getCallerId",value:function(){return this._callerId}},{key:"getUserList",value:function(){return this._callUsers}},{key:"getReqMediaType",value:function(){return this._reqMediaType}},{key:"getInviterTimerId",value:function(){return this._inviterTimerId}},{key:"getInviteeTimerId",value:function(){return this._inviteeTimerId}},{key:"getAllTimerIds",value:function(){return[this._inviterTimerId,this._inviteeTimerId]}},{key:"updateUserList",value:function(e,t){var n=this,r=[];return e.forEach(function(e){var t=e.userState,i=e.stateTime,a=e.systemState,o=e.userId,s=n._callUsers.findIndex(function(e){return e.userId===o});if(s<0)return n._callUsers.push(e),void r.push(e);var c,u,l,_,d=n._callUsers[s],f=d.stateTime,h=d.systemState,g=d.userState,p=(c=h,u=a,l=!1,_=[exports.NCCallEndReason.INVITED,exports.NCCallEndReason.RINGING,exports.NCCallEndReason.BUSYLINE_RINGING,exports.NCCallEndReason.BUSYLINE_WAIT,exports.NCCallEndReason.CONNECTING,exports.NCCallEndReason.ONCALL],c===exports.NCCallEndReason.ONCALL&&_.includes(u)&&(l=!0),l),E=function(e,t){var n=!1,r=[gl.INVITED,gl.RINGING,gl.BUSYLINE_RINGING,gl.BUSYLINE_WAIT,gl.CONNECTING,gl.ONCALL];return e===gl.ONCALL&&r.includes(t)&&(n=!0),n}(g,t),v=a===exports.NCCallEndReason.ON_PHONE_END&&h!==exports.NCCallEndReason.ON_PHONE&&t!==gl.IDLE;i&&f&&i<f||p&&E||(n._callUsers[s]=e,!v&&r.push(e))}),r}},{key:"setOldDialogData",value:function(e){this._oldDialogData=e}},{key:"updateSessionState",value:function(e){this._state=e}},{key:"updateCallType",value:function(e){this._callType=e}},{key:"updateMediaType",value:function(e){this._mediaType=e}},{key:"updateReqMediaType",value:function(e){this._reqMediaType=e}},{key:"updateTimerId",value:function(e,t){e===Vl.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}},{key:"getOldDialogData",value:function(){return this._oldDialogData}},{key:"setIsLocalClientHangup",value:function(e){this.isLocalClientHangup=e}},{key:"getIsLocalClientHangup",value:function(){return this.isLocalClientHangup}}])}();!function(e){e.START_SINGLE_CALL="startSingleCall",e.START_GROUP_CALL="startGroupCall",e.INVITE_CALL="inviteCall",e.PUB_INVITE_CALL="pubInviteCall",e.RINGING_CALL="ringCall",e.ACCEPT_CALL="acceptCall",e.JOIN_CALL="joinCall",e.HANGUP_CALL="hangupCall",e.STATUS_UP_CALL="statusUpCall",e.STATUS_DOWN_CALL="statusDownCall",e.EVENT_UP_CALL="eventUpCall",e.EVENT_DOWN_CALL="eventDownCall",e.DIALOG_UP_CALL="dialogUpCall",e.DIALOG_DOWN_CALL="dialogDownCall",e.GET_CALL_USER_SESSION_LIST="getCallUSerSessionList",e.SYNC_CALL_LOG="syncCallLog",e.PUB_CALL_LOG="pubCallLog",e.DEL_CALL_LOG="deleteCallLog",e.QRY_CALL_STATE="queryUserHasCall",e.QRY_SRV_TIMESTAMP="getCallSrvTimeStamp",e.GET_CALL_STATE_LIST="getUserCallStateList",e.CLEAR_CALL_LOG="cleanCallLog",e.GET_CALL_SESSION="getCallSession",e.GET_CALL_TIME_INFO="getCallTimeInfo",e.END_ABNORMAL_CALL="endUserAbnormalCalls",e.SYS_STATUS_UP="sysStatusUp",e.UP_CALL_LOG_READED="upCallLogReaded",e.PUB_CALL_LOG_READED="pubCallLogReaded",e.PUB_NACK_SEQ_ID="pubNACKSeqId",e.GET_USER_CALL_SESSION_ID_LIST="getUserCallSessionIdList"}(Gl||(Gl={}));var Fl,Hl,Jl,Kl=function(e,t){return setTimeout(e,t)},Yl=function(e){return new Promise(function(t){setTimeout(t,e)})},ql=[xe,Ve,Be,Ae.SIGNAL_DISCONNECTED,Ae.REQUEST_FAILED],Wl=function(e){return F(void 0,[e],void 0,function(e){var t=e.asyncFn,n=e.fnArgs,r=e.currentRetryTime,i=void 0===r?Date.now():r,a=e.maxDuration,o=void 0===a?6e4:a,s=e.intervals,c=void 0===s?[2e3,4e3,8e3,16e3,32e3,64e3]:s,u=e.index,l=void 0===u?0:u,_=e.onError;return E().m(function e(){var r;return E().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.apply(void 0,C(n));case 1:if(r=e.v,r.code===ol.SUCCESS||!ql.includes(r.code)||Date.now()+2e3-i>o){e.n=3;break}return _&&_(r.code),e.n=2,Yl(2e3);case 2:return e.a(2,Wl({asyncFn:t,fnArgs:n,currentRetryTime:i,maxDuration:o,intervals:c,index:l,onError:_}));case 3:return e.a(2,r)}},e)})()})};!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(Fl||(Fl={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}(Hl||(Hl={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(Jl||(Jl={}));var zl,Ql,Zl=131072,Xl="RC:CallPlusMiss",$l="RC:CallGroupStatusMsg",e_=function(){function e(t,n,r,i,a,o){var u,l,_,d,f,h,g;return c(this,e),u=s(this,e),Object.defineProperty(u,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(u,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(u,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(u,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(u,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(u,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(u,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[Gl.START_SINGLE_CALL,Gl.START_GROUP_CALL,Gl.ACCEPT_CALL,Gl.JOIN_CALL,Gl.EVENT_UP_CALL]}),Object.defineProperty(u,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),null===(_=(l=u._context).registerGroupCallSignalInfoListener)||void 0===_||_.call(l,function(e){return u._onRecvCallSignal(e)}),null===(f=(d=u._context).registerConnectionStateChangeListener)||void 0===f||f.call(d,function(e,t){return u._onIMConnectionStateChange(e)}),null===(g=(h=u._context).registerMessageListener)||void 0===g||g.call(h,function(e){return u._onMessage(e)}),u._sessionId=he(22),u}return g(e,ue),l(e,[{key:"_onMessage",value:function(e){return!![Xl,$l].includes(e.messageType)&&(e.messageType===Xl?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}},{key:"_dealMissMessage",value:function(e){var t=e.content,n=t.callId,r=t.mediaType,i=t.startTime,o=t.callSessionUsers,s=e.targetId,c=e.senderUserId,u=this._context.getCurrentId();if(!localStorage.getItem("missMessageMap-".concat(u,"-").concat(n))){var l={callId:n,callerUserId:c,targetId:s,mediaType:r,firstFrameTime:0,callStartTime:i-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:o.filter(function(e){return e.userId===u})[0].sessionStatus};this._logger.info(tl.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,"receive miss message: ".concat(JSON.stringify(e)));var _=Object.assign(e,{content:l,sentStatus:a.SentStatus.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(_),localStorage.setItem("missMessageMap-".concat(u,"-").concat(n),n)}}},{key:"_dealGroupCallMessage",value:function(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}},{key:"getSessionId",value:function(){return this._sessionId}},{key:"getDeviceId",value:function(){return wl&&"function"==typeof this._context.getDeviceId?this._context.getDeviceId():this._sessionId}},{key:"registerListener",value:function(e){this._listener=e}},{key:"startCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f,h;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=e.clientCallId,i=e.callType,a=e.toUsers,o=e.mediaType,s=e.secretChat,c=e.targetType,u=e.targetId,l=e.nickName,_=e.oldRoomId,d=e.pushExt,f=e.pushContent,h=e.extra,i!==ll.SINGLE){n.n=1;break}return n.a(2,this.startSingleCall({clientCallId:r,toUserId:a[0].userId,mediaType:o,secretChat:s,targetType:c,targetId:u,oldRoomId:_,toOrgId:a[0].orgId||"",pushExt:d,pushContent:f,extra:h},t));case 1:return n.a(2,this.startGroupCall({clientCallId:r,toUsers:a,mediaType:o,targetType:c,targetId:u,nickName:l,oldRoomId:_,pushExt:d,pushContent:f,extra:h},t))}},n,this)}))}},{key:"startSingleCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(this._context.getCurrentId(),Gl.START_SINGLE_CALL,e))},n,this)}))}},{key:"startGroupCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(this._context.getCurrentId(),Gl.START_GROUP_CALL,e))},n,this)}))}},{key:"inviteCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_INVITE_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.callId,Gl.INVITE_CALL,e))},n,this)}))}},{key:"ringingCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_RING_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.callId,Gl.RINGING_CALL,e))},n,this)}))}},{key:"acceptCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_ACCEPT_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.callId,Gl.ACCEPT_CALL,e))},n,this)}))}},{key:"joinCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.callId,Gl.JOIN_CALL,e))},n,this)}))}},{key:"hangupCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:return this._logger.info(tl.L_SIGNAL_TRANSPORTER_HANGUP_T,"params: ".concat(JSON.stringify(e)),t),n.n=1,this._sendCallSignal(e.callId,Gl.HANGUP_CALL,e);case 1:if(r=n.v,(i=r.code)!==ol.NOT_IN_CALL){n.n=2;break}return n.a(2,{code:ol.SUCCESS});case 2:return n.a(2,{code:i})}},n,this)}))}},{key:"statusUpCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,"call status up params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.callId,Gl.STATUS_UP_CALL,e))},n,this)}))}},{key:"eventUpCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.callId,Gl.EVENT_UP_CALL,e))},n,this)}))}},{key:"dialogUpCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.callId,Gl.DIALOG_UP_CALL,e))},n,this)}))}},{key:"deleteCallRecord",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){return E().w(function(r){for(;;)if(0===r.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,"callIds: ".concat(JSON.stringify(t)),n),r.a(2,this._sendCallSignal(e,Gl.DEL_CALL_LOG,{callIds:t}))},r,this)}))}},{key:"syncCallLog",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,"params: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.userId,Gl.SYNC_CALL_LOG,e))},n,this)}))}},{key:"queryUserHasCall",value:function(){return F(this,void 0,void 0,E().m(function e(){var t;return E().w(function(e){for(;;)if(0===e.n)return t=this._context.getCurrentId(),e.a(2,this._sendCallSignal(t,Gl.QRY_CALL_STATE,null))},e,this)}))}},{key:"getCallServerTimestamp",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)if(0===t.n)return n=this._context.getCurrentId(),this._logger.info(tl.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,"userId: ".concat(n),e),t.a(2,this._sendCallSignal(n,Gl.QRY_SRV_TIMESTAMP,null))},t,this)}))}},{key:"getCallTimeInfo",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,"callId: ".concat(e),t),n.a(2,this._sendCallSignal(e,Gl.GET_CALL_TIME_INFO,{callId:e}))},n,this)}))}},{key:"getUserCallStateList",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)if(0===t.n)return n=this._context.getCurrentId(),this._logger.info(tl.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,"userId: ".concat(n),e),t.a(2,this._sendCallSignal(n,Gl.GET_CALL_STATE_LIST,null))},t,this)}))}},{key:"clearCallRecord",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)if(0===t.n)return n=this._context.getCurrentId(),this._logger.info(tl.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,"userId: ".concat(n),e),t.a(2,this._sendCallSignal(n,Gl.CLEAR_CALL_LOG,null))},t,this)}))}},{key:"getCallSession",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,"callId: ".concat(e.callId),t),n.a(2,this._sendCallSignal(e.callId,Gl.GET_CALL_SESSION,e))},n,this)}))}},{key:"sysStatusUp",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return this._logger.info(tl.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,"opts: ".concat(JSON.stringify(e)),t),n.a(2,this._sendCallSignal(e.callId,Gl.SYS_STATUS_UP,e))},n,this)}))}},{key:"upCallLogReaded",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)if(0===t.n)return n=this._context.getCurrentId(),t.a(2,this._sendCallSignal(n,Gl.UP_CALL_LOG_READED,e))},t,this)}))}},{key:"endUserAbnormalCalls",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)if(0===t.n)return t.a(2,this._sendCallSignal(this._context.getCurrentId(),Gl.END_ABNORMAL_CALL,e))},t,this)}))}},{key:"_onIMConnectionStateChange",value:function(e){var n=this._logger.createTraceId();this._logger.info(tl.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,"state: ".concat(e),n),this._listener.onIMStateChange(e),e===t.CONNECTED?this._timeCorrectioner.start(n):this._timeCorrectioner.stop(n)}},{key:"_sendCallSignal",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f;return E().w(function(r){for(;;)switch(r.n){case 0:if(a="",n&&(a=wl?JSON.stringify(n):JSON.stringify(Object.assign(Object.assign({},n),{sessionId:this._sessionId}))),o=null===(i=this._context.sendGroupCallSignalInfo)||void 0===i?void 0:i.bind(this._context)){r.n=1;break}return r.a(2,{code:ol.SIGNAL_DISCONNECTED});case 1:if(!this._needRetryActions.includes(t)){r.n=3;break}return r.n=2,Wl({asyncFn:function(e,t,n){return o(e,t,n).then(function(e){return{code:e.code,data:e.data}})},fnArgs:[e,t,a]});case 2:s=r.v,r.n=5;break;case 3:return r.n=4,o(e,t,a);case 4:c=r.v,s={code:c.code,data:c.data};case 5:if(l=(u=s).code,_=u.data,l===we){r.n=6;break}return r.a(2,{code:l});case 6:if(null!=(d=null==_?void 0:_.value)){r.n=7;break}return r.a(2,{code:ol.PARAM_ERROR});case 7:return f=JSON.parse(d).data,r.a(2,{code:ol.SUCCESS,data:f})}},r,this)}))}},{key:"_onRecvCallSignal",value:function(e){var t=this,n=this._logger.createTraceId();this._logger.info(tl.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,"data: ".concat(e),n),JSON.parse(e).list.forEach(function(e){var r=e.key,i=JSON.parse(e.value);switch(r){case Gl.PUB_INVITE_CALL:t._onPubInviteCall(i,n,!0);break;case Gl.STATUS_DOWN_CALL:t._onStatusDownCall(i,n);break;case Gl.EVENT_DOWN_CALL:t._onEventDownCall(i,n);break;case Gl.DIALOG_DOWN_CALL:t._onDialogDownCall(i,n);break;case Gl.PUB_CALL_LOG:t._onPubCallLog(i,n);break;case Gl.PUB_CALL_LOG_READED:case Gl.PUB_NACK_SEQ_ID:break;default:t._onConpensationData(i,n)}})}},{key:"isValidData",value:function(e){if(t=e,"[object Null]"===Object.prototype.toString.call(t))return!0;var t,n=e===this.getDeviceId();return!(!Y(e)||0!==(null==e?void 0:e.length)&&!n)}},{key:"_onPubInviteCall",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];try{var r=this._context.getCurrentId(),i=e.callSessionUsers.find(function(e){return e.userId===r}),a=this._context.getConnectionStatus();this._logger.info(tl.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"currentUser: ".concat(JSON.stringify(i),", currentUserId: ").concat(r,", state: ").concat(a),t)}catch(e){this._logger.error(tl.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"error: ".concat(e.message),t)}if(this.isValidData(e.toDeviceId||""))this._listener.onInvite(e,n,t),n?this.emit(Fl.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(Fl.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}));else{this._logger.warn(tl.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"not current deviceId -> deviceInfo: ".concat(JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})),t);var o={extra:JSON.stringify(e),reason:Hl.NOT_CURRENT_DEVICEID,refer:n?Jl.PUB_INVITE:Jl.PULL_KV_INVITE};this.emit(Fl.onPubInviteCallMiss,Object.assign(e,o))}}},{key:"_onStatusDownCall",value:function(e,t){if(e.callSessionUsers=e.callSessionUsers.filter(function(e){return Boolean(e.changed)}),this._logger.info(tl.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(tl.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"not current deviceId -> deviceInfo: ".concat(JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})),t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,t,this._sessionId)}},{key:"_onEventDownCall",value:function(e,t){this._listener.onEventDown(e,t)}},{key:"_onDialogDownCall",value:function(e,t){e.dialogType===Ml.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}},{key:"_onPubCallLog",value:function(e,t){this._logger.info(tl.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,"call record: ".concat(JSON.stringify(e)),t),this._listener.onRecvCallEndLog(e,t)}},{key:"_onConpensationData",value:function(e,t){var n=this;this._logger.info(tl.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);var r=e.callId,i=e.callType,a=e.mediaType,o=e.secretChat,s=e.duration,c=e.callStatus,u=e.callingUserId,l=e.callSessionUsers,_=e.toDeviceId,d=e.callDialogEntitys,f=e.extra;l.some(function(e){return e.sessionStatus===gl.INVITED&&e.userId===n._context.getCurrentId()})?this._onPubInviteCall({callId:r,toDeviceId:_,callType:i,mediaType:a,inviteUserId:u,callingUserId:u,callSessionUsers:l,secretChat:o,extra:f},t,!0):this._onStatusDownCall({callId:r,toDeviceId:_,callStatus:c,duration:s,callSessionUsers:l},t),d.length>0&&d.forEach(function(e){return n._onDialogDownCall(e,t)},this)}}])}(),t_=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return e="".concat(e.replace(/-/g,""),"0"),(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),n=t.length+1,r=+e,i=[];do{var a=r%n;r=(r-a)/n,i.unshift(t[a])}while(r);return i.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},n_=function(){function e(t,n){c(this,e),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_localStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._localStore=t.localStorage}return l(e,[{key:"addAbnormallCallId",value:function(t,n){try{var r=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}"),i=r[t];i?i.push(n):i=[n],r[t]=i,this._localStore.setItem(e._STORAGE_KEY,JSON.stringify(r))}catch(e){this._logger.error(tl.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}},{key:"removeAbnormalCallIds",value:function(t,n){try{var r=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}"),i=r[t];i&&((i=i.filter(function(e){return!n.includes(e)})).length>0?r[t]=i:delete r[t],this._localStore.setItem(e._STORAGE_KEY,JSON.stringify(r)))}catch(e){this._logger.error(tl.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}},{key:"getAbnormalCallIds",value:function(t){var n=null;try{var r=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}")[t];r&&(n=r)}catch(e){this._logger.error(tl.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(n)}}])}();Object.defineProperty(n_,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(zl||(zl={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.INVALID_RESPONSE_TIME=80170]="INVALID_RESPONSE_TIME",e[e.NONOPTIMAL_RES_TIME=80171]="NONOPTIMAL_RES_TIME"}(Ql||(Ql={}));var r_,i_,a_,o_=l(function e(t,n,r){c(this,e),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_singleCallDurationEv",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_RTT",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_validMinRTT",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"_validMaxRTT",{enumerable:!0,configurable:!0,writable:!0,value:1e3}),Object.defineProperty(this,"_deltaTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:2e3}),Object.defineProperty(this,"_maxRetryTimes",{enumerable:!0,configurable:!0,writable:!0,value:8}),Object.defineProperty(this,"_startTimes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_retryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_maxRetryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:3})},[{key:"getCallClientTimeByServer",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._logger.info(tl.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,"callId: ".concat(e),t),this._RTT&&!(this._RTT>this._validMinRTT)){n.n=1;break}return n.n=1,this._getDeltaTime(t);case 1:return this._RTT>this._validMaxRTT&&this._logger.error(tl.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(Ql.INVALID_RESPONSE_TIME),t),n.n=2,this._callEngine.getCallTimeInfo(e,t);case 2:if(r=n.v,i=r.code,a=r.data,i===ol.SUCCESS){n.n=3;break}return this._logger.error(tl.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(i),t),n.a(2,{code:i});case 3:return o=a.startTime,s=Math.floor(o-this._deltaTime),c=Date.now(),(u=(c+this._deltaTime-o)/1e3)<0&&(this._logger.warn(tl.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,"invalid duration: ".concat(u),t),u=0),u=Math.floor(u),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(tl.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(Ql.NONOPTIMAL_RES_TIME),t),this._logger.info(tl.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:o,clientStartTime:s,duration:u}),t),n.a(2,{code:i,duration:u,clientStartTime:o?s:o})}},n,this)}))}},{key:"calcClientStartTime",value:function(e,t,n){if(this._logger.info(tl.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,"callId: ".concat(e,", startTime: ").concat(t),n),this._RTT>this._validMaxRTT)return this._logger.error(tl.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,"code: ".concat(Ql.INVALID_RESPONSE_TIME),n),this._loopCorrectClientTime(e,n),{code:Ql.INVALID_RESPONSE_TIME};var r=Math.floor(t-this._deltaTime);return this._logger.info(tl.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:r}),n),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,n)),{code:Ql.SUCCESS,clientStartTime:r}}},{key:"start",value:function(e){var t=this;this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(tl.L_TIME_CORRECT_START_O,"timerId: ".concat(this._timerId)),this._startTimes++,this._getDeltaTime(e),this._timerId=Kl(function(){t._timerId=null,t.start(e)},this._interval))}},{key:"stop",value:function(e){this._logger.info(tl.L_TIME_CORRECT_STOP_O,"timerId: ".concat(this._timerId),e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}},{key:"restart",value:function(e){this._logger.info(tl.L_TIME_CORRECT_RESTART_O,"legal rtt time, RTT: ".concat(this._RTT,", validMinRTT: ").concat(this._validMinRTT),e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}},{key:"getLocalDelayTime",value:function(){return Math.round(this._deltaTime)}},{key:"getRTT",value:function(){return this._RTT}},{key:"_getDeltaTime",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s;return E().w(function(t){for(;;)switch(t.n){case 0:return n=Date.now(),t.n=1,this._callEngine.getCallServerTimestamp(e);case 1:if(r=t.v,i=r.code,a=r.data,o=Date.now(),i===ol.SUCCESS){t.n=2;break}return t.a(2,{code:i});case 2:return((s=o-n)<this._RTT||0===this._RTT)&&s<=this._validMaxRTT&&(this._RTT=s),s<this._validMinRTT&&this.stop(e),this._deltaTime=a-n-this._RTT/2,this._logger.info(tl.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),t.a(2,{code:i,delayTime:this._deltaTime})}},t,this)}))}},{key:"_getDeltaTimeInCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l;return E().w(function(n){for(;;)switch(n.n){case 0:return r=Date.now(),n.n=1,this._callEngine.getCallTimeInfo(e,t);case 1:if(i=n.v,a=i.code,o=i.data,s=Date.now(),a===ol.SUCCESS){n.n=2;break}return n.a(2,{code:a});case 2:if((c=s-r)<this._RTT&&(this._RTT=c),this._deltaTime=o.syncTime-r-this._RTT/2,this._logger.info(tl.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t),u=Math.floor(o.startTime-this._deltaTime),l=Math.floor(o.firstFrametime-this._deltaTime),!(c<this._validMinRTT)){n.n=3;break}return n.a(2,{code:Ql.SUCCESS,clientStartTime:u,clientFirstFrameTime:l});case 3:return n.a(2,{code:Ql.INVALID_RESPONSE_TIME,clientStartTime:u,clientFirstFrameTime:l})}},n,this)}))}},{key:"_loopCorrectClientTime",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s=this;return E().w(function(n){for(;;)switch(n.n){case 0:return this.stop(t),this._logger.info(tl.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,"callId: ".concat(e),t),n.n=1,this._getDeltaTimeInCall(e,t);case 1:if(r=n.v,i=r.code,a=r.clientStartTime,o=r.clientFirstFrameTime,i!==Ql.SUCCESS){n.n=2;break}return this._logger.info(tl.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,"code: ".concat(ol.SUCCESS),t),this._singleCallDurationEv(e,a,o,t),n.a(2);case 2:if(!(this._retryTimesInCall>this._maxRetryTimesInCall&&i===Ql.INVALID_RESPONSE_TIME)){n.n=3;break}return this._logger.info(tl.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,"code: ".concat(Ql.INVALID_RESPONSE_TIME),t),this._singleCallDurationEv(e,a,o,t),n.a(2);case 3:if(!(this._retryTimesInCall>this._maxRetryTimesInCall)){n.n=4;break}return n.a(2);case 4:this._retryTimesInCall++,setTimeout(function(){s._loopCorrectClientTime(e,t)},this._interval);case 5:return n.a(2)}},n,this)}))}}]);!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(r_||(r_={})),function(e){e[e.PUB_INVITE_CALL=0]="PUB_INVITE_CALL",e[e.PULL_KV_INVITE_CALL=1]="PULL_KV_INVITE_CALL",e[e.SYSTEM_PUSH=2]="SYSTEM_PUSH"}(i_||(i_={})),exports.NCCallDirection=void 0,(a_=exports.NCCallDirection||(exports.NCCallDirection={}))[a_.OUT=-1]="OUT",a_[a_.GROUP=0]="GROUP",a_[a_.IN=1]="IN";var s_,c_=exports.NCCallDirection,u_=function(){function n(e,t,r,i,a){var o;return c(this,n),o=s(this,n),Object.defineProperty(o,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(o,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(o,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(o,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(o,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(o,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(o,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(o,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(o,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:null}),o._timeCorrectioner=new o_(o,i,o._onRecvSinCallDuration.bind(o)),o._signalModule=new e_(e,t,r,o._timeCorrectioner,o._logger,o._reportAppEventModule),o._signalModule.registerListener({onInvite:o._onInvite.bind(o),onStatusDown:o._onStatusDown.bind(o),onOtherClientStatusDown:o._onOtherClientStatusDown.bind(o),onEventDown:o._onEventDown.bind(o),onSwitchMediaType:o._onSwitchMediaType.bind(o),onRecvCallEndLog:o._onRecvCallEndLog.bind(o),onIMStateChange:o._onIMStateChange.bind(o)}),o._abnormalModule=new n_(t,i),o}return g(n,ue),l(n,[{key:"startCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f,h,g,p,v,m,R,T,I,S,L=this;return E().w(function(n){for(;;)switch(n.n){case 0:return r=this._context.getCurrentId(),i=e.callType,a=e.mediaType,o=e.toUsers,s=e.targetId,c=e.targetType,u=e.oldRoomId,l=e.pushConfig,_=e.extra,this._clientCallId=e.callId,d=l?yl(l,this._clientCallId):"",n.n=1,this._signalModule.startCall({clientCallId:this._clientCallId,callType:i,mediaType:a,toUsers:o,secretChat:xl.NORMAL,targetType:c,targetId:s,oldRoomId:u,pushExt:d,pushContent:(null==l?void 0:l.pushContent)||"",extra:_},t);case 1:if(f=n.v,h=f.code,g=f.data,h===ol.SUCCESS){n.n=2;break}return n.a(2,{code:h});case 2:return p=g.callId,v=g.busylineUsers,this._abnormalModule.addAbnormallCallId(r,p),this._mainSession=new jl(p,exports.NCCallState.INVITED,i,a,r,r,[],this._logger),i===ll.SINGLE&&(m=this._startTimer(g.callId,gl.NO_ANSWER,t),this._mainSession.updateTimerId(Vl.INVITER,m)),R={userId:r,userState:gl.CALLING,systemState:exports.NCCallEndReason.CALLING,targetType:c,targetId:s},T=o.map(function(e){var t=e.userId,n=e.targetType,r=e.targetId;return{userId:t,userState:gl.INVITED,systemState:exports.NCCallEndReason.INVITED,targetType:n,targetId:r}}),I=[],v&&(I=v.map(function(e){var t=T.find(function(t){return t.userId===e.userId}),n=t.targetType,r=t.targetId;return{userId:e.userId,userState:e.sessionStatus,systemState:exports.NCCallEndReason.BUSYLINE_RINGING,targetType:n,targetId:r}}),T=T.filter(function(e){var t=e.userId;return I.every(function(e){return e.userId!==t})})),S=this.updateUsersState(p,[R].concat(C(T),C(I)),t),setTimeout(function(){S.length>0&&L.reportRemoteUserStateChange(p,S,t)}),n.a(2,{code:h,data:g})}},n,this)}))}},{key:"invite",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f,h;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._mainSession){n.n=1;break}return n.a(2,{code:ol.NOT_IN_CALL});case 1:return i=e.toUsers,a=e.pushConfig,o=e.extra,s=a?yl(a,this._clientCallId):"",c=this._mainSession.getCallId(),n.n=2,this._signalModule.inviteCall({callId:c,toUsers:i,pushExt:s,pushContent:(null==a?void 0:a.pushContent)||"",extra:o},t);case 2:return u=n.v,l=u.code,_=u.data,l===ol.SUCCESS&&(this._mainSession.getCallType()===ll.SINGLE&&(this._mainSession.updateCallType(ll.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),ll.MULTI,t)),d=i.map(function(e){var t=e.userId,n=e.targetType,r=e.targetId;return{userId:t,userState:gl.INVITED,systemState:exports.NCCallEndReason.INVITED,targetType:n,targetId:r}}),f=[],_.busylineUsers&&(f=null===(r=_.busylineUsers)||void 0===r?void 0:r.map(function(e){var t=d.find(function(t){return t.userId===e.userId}),n=t.targetType,r=t.targetId;return{userId:e.userId,userState:e.sessionStatus,systemState:exports.NCCallEndReason.BUSYLINE_RINGING,targetType:n,targetId:r}}),d=d.filter(function(e){var t=e.userId;return f.every(function(e){return e.userId!==t})})),(h=this.updateUsersState(c,[].concat(C(d),C(f)),t)).length>0&&this.reportRemoteUserStateChange(c,h,t)),n.a(2,{code:l,data:_})}},n,this)}))}},{key:"clearAllTimer",value:function(e,t){var n=this;[this._mainSession].concat(C(this._holdSessions)).forEach(function(r){r&&r.getCallId()===e&&r.getAllTimerIds().forEach(function(e){return n._stopTimer.bind(n)(e,t)})})}},{key:"hangup",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c;return E().w(function(n){for(;;)switch(n.n){case 0:return r=e.callId,i=e.systemState,a=e.pushConfig,o=a?yl(a,this._clientCallId):"",n.n=1,this._signalModule.hangupCall({callId:r,sysStatus:i,pushExt:o,pushContent:(null==a?void 0:a.pushContent)||""},t);case 1:return s=n.v,c=s.code,this.endCurrentSession(e.systemState,r,t),n.a(2,{code:c})}},n,this)}))}},{key:"accept",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._mainSession){n.n=1;break}return n.a(2,{code:ol.NOT_IN_CALL});case 1:return r=e.callId,n.n=2,this._signalModule.acceptCall({callId:r},t);case 2:if(i=n.v,a=i.code,this._stopTimer(this._mainSession.getInviteeTimerId(),t),a===ol.SUCCESS){n.n=3;break}return n.a(2,{code:a});case 3:return this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(exports.NCCallState.CONNECTING),n.a(2,{code:a})}},n,this)}))}},{key:"joinCall",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:return r=this._context.getCurrentId(),this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t),n.n=1,this._signalModule.joinCall({callId:e.callId},t);case 1:if(i=n.v,(a=i.code)===ol.SUCCESS){n.n=2;break}return n.a(2,{code:a});case 2:if(this._abnormalModule.addAbnormallCallId(r,e.callId),this._mainSession){n.n=4;break}return n.n=3,this._createSessionByServer(e.callId,t,!0);case 3:n.n=5;break;case 4:this._clearMobileOnPhone(e.callId,t);case 5:return n.a(2,{code:a})}},n,this)}))}},{key:"requestChangeMediaType",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._mainSession){n.n=1;break}return n.a(2,{code:ol.NOT_IN_CALL});case 1:return r={mediaType:e.mediaType},this._mainSession.updateReqMediaType(e.mediaType),i=t_(),n.n=2,this._signalModule.dialogUpCall({transactionId:i,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:Ml.SWITCH_MEDIA_TYPE,action:Dl.REQUEST,extraKeyVal:r},t);case 2:if(a=n.v,(o=a.code)===ol.SUCCESS){n.n=3;break}return n.a(2,{code:o});case 3:return n.a(2,{code:ol.SUCCESS,data:{transactionId:i}})}},n,this)}))}},{key:"responseChangeMediaType",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)switch(n.n){case 0:if(this._mainSession){n.n=1;break}return n.a(2,{code:ol.NOT_IN_CALL});case 1:return n.a(2,this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:Ml.SWITCH_MEDIA_TYPE,action:e.agree?Dl.ACCEPT:Dl.REFUSE},t))}},n,this)}))}},{key:"cancelChangeMediaType",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)switch(n.n){case 0:if(this._mainSession){n.n=1;break}return n.a(2,{code:ol.NOT_IN_CALL});case 1:return n.a(2,this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:Ml.SWITCH_MEDIA_TYPE,action:Dl.CANCEL},t))}},n,this)}))}},{key:"getCallLogList",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l;return E().w(function(n){for(;;)switch(n.n){case 0:return r=this._context.getCurrentId(),i=e.timestamp,a=e.count,o=e.order,n.n=1,this._signalModule.syncCallLog({userId:r,syncTime:i,count:a,order:o},t);case 1:if(s=n.v,c=s.code,u=s.data,c===ol.SUCCESS){n.n=2;break}return n.a(2,{code:c});case 2:return l=u.callLogList.map(function(e){return ml(e)}),n.a(2,{code:ol.SUCCESS,data:{hasMore:Boolean(null==u?void 0:u.hasMore),syncTime:0===o?u.maxTime:u.minTime,list:l}})}},n,this)}))}},{key:"deleteCallLog",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r;return E().w(function(n){for(;;)if(0===n.n)return r=this._context.getCurrentId(),n.a(2,this._signalModule.deleteCallRecord(r,e,t))},n,this)}))}},{key:"getCallServerTimestamp",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._signalModule.getCallServerTimestamp(e);case 1:if(n=t.v,r=n.code,i=n.data,r===ol.SUCCESS){t.n=2;break}return t.a(2,{code:r});case 2:return t.a(2,{code:r,data:i.syncTime})}},t,this)}))}},{key:"getCallTimeInfo",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return n.a(2,this._signalModule.getCallTimeInfo(e,t))},n,this)}))}},{key:"getOpenCallList",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s=this;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this._context.getCurrentId(),t.n=1,this._signalModule.getUserCallStateList(e);case 1:if(r=t.v,i=r.code,a=r.data,i===ol.SUCCESS){t.n=2;break}return t.a(2,{code:i});case 2:return o=a.callStateList.map(function(t){var r=t.callId,i=t.callType,a=t.mediaType,o=t.callingUserId,c=t.callUserIds,u=t.callStatus,l=t.crtTime,_=t.userSessionStatus,d=t.startTime,f=t.syncTime,h=o===n?c_.OUT:c_.IN,g=s._timeCorrectioner.calcClientStartTime(r,d,e).clientStartTime,p=void 0===g?d:g;return{callId:r,callType:i,callDirection:h,mediaType:a,callerUserId:o,callUserIds:c,sessionState:u,userState:_,startTimestamp:d,endTimestamp:0,duration:Math.floor((+new Date-p)/1e3),syncTimestamp:f,systemState:0,createTimestamp:l}}),t.a(2,{code:i,data:o})}},t,this)}))}},{key:"removeAllCallLog",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r;return E().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this._signalModule.clearCallRecord(e);case 1:if(n=t.v,(r=n.code)===ol.SUCCESS){t.n=2;break}return t.a(2,{code:r});case 2:return t.a(2,{code:r})}},t,this)}))}},{key:"getCallSession",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f,h,g;return E().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,this._signalModule.getCallSession(e,t);case 1:if(r=n.v,i=r.code,a=r.data,i===ol.SUCCESS){n.n=2;break}return n.a(2,{code:i});case 2:return o=a.callId,s=a.callingUserId,c=a.callType,u=a.mediaType,l=a.callStatus,_=a.callSessionUsers,d=a.startTime,f=a.duration,h=a.syncTime,g=_.map(function(e){return{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,targetType:e.targetType,targetId:e.targetId,cameraEnable:!1,microphoneEnable:!1}}),n.a(2,{code:i,data:{callId:o,startCallerId:s,callType:c,mediaType:u,sessionState:l,callSessionUsers:g,startTime:d,duration:f,syncTime:h}})}},n,this)}))}},{key:"getHoldSession",value:function(e){var t=this._holdSessions.find(function(t){return t&&t.getCallId()===e});return t?new cl(t,this,this._logger,this._rtcModule,this._context):null}},{key:"getLocalMainSession",value:function(){return this._mainSession?new cl(this._mainSession,this,this._logger,this._rtcModule,this._context):null}},{key:"updateMainSessionState",value:function(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}},{key:"setIsLocalClientHangup",value:function(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}},{key:"updateUsersState",value:function(e,t,n){this._logger.info(tl.L_CALL_ENGINE_UPDATE_USERS_STATE_O,"updateUsersState -> users: ".concat(JSON.stringify(t)),n);var r=[this._mainSession].concat(C(this._holdSessions)).find(function(t){return(null==t?void 0:t.getCallId())===e}),i=[];return r?i.push.apply(i,C(r.updateUserList(t,n))):i.push.apply(i,C(t)),i}},{key:"getCallStaringTime",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return n.a(2,this._timeCorrectioner.getCallClientTimeByServer(e.callId,t))},n,this)}))}},{key:"systemStatusUp",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){return E().w(function(n){for(;;)if(0===n.n)return n.a(2,this._signalModule.sysStatusUp(e,t))},n,this)}))}},{key:"upFirstFrameTime",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s;return E().w(function(t){for(;;)switch(t.n){case 0:if(!(!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==ll.SINGLE||this._isUpFirstFrameTime)){t.n=1;break}return t.a(2,{code:ol.SUCCESS});case 1:return n=Date.now(),r=this._timeCorrectioner.getLocalDelayTime(),i=Math.floor(n+r),this._logger.info(tl.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,"now: ".concat(n,"; delay: ").concat(r,"; streamReadyTime: ").concat(i),e),this._isUpFirstFrameTime=!0,a=this._mainSession.getCallId(),t.n=2,this._signalModule.eventUpCall({callId:a,eventType:zl.FIRST_FRAME,eventArgs:{streamReadyTime:i},eventTime:Date.now()},e);case 2:return o=t.v,s=o.code,this._logger.info(tl.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,"code: ".concat(s),e),t.a(2,{code:s})}},t,this)}))}},{key:"endCurrentSession",value:function(e,t,n){var r=this,i=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){var a=this._mainSession.getUserList().map(function(t){var n=t.userId,a=t.systemState,o=t.targetType,s=t.targetId;return n===i&&(a=e),{userId:n,sessionStatus:gl.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:r._mainSession.getStartCallerId(),sysStatus:a,targetType:o,targetId:s}}),o={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:exports.NCCallState.ENDED,duration:0,callSessionUsers:a};this._onStatusDown(o,n)}}},{key:"startTimeCorrection",value:function(e){this._timeCorrectioner.restart(e)}},{key:"getDelayTimeInfo",value:function(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}},{key:"upgradeMainSession",value:function(e){var t,n=this._holdSessions.findIndex(function(t){return t.getCallId()===e});this._mainSession=null===(t=this._holdSessions.splice(n,1))||void 0===t?void 0:t[0]}},{key:"endCurrentUserAbnormalCalls",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s=this;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this._context.getCurrentId(),t.n=1,this._abnormalModule.getAbnormalCallIds(n);case 1:if(r=t.v){t.n=2;break}return t.a(2,{code:ol.SUCCESS});case 2:return i=r.filter(function(e){var t;return e!==(null===(t=s._mainSession)||void 0===t?void 0:t.getCallId())}),t.n=3,this._signalModule.endUserAbnormalCalls({callIds:i,allDevice:e?1:0});case 3:return a=t.v,(o=a.code)===ol.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(n,i),t.a(2,{code:o})}},t,this)}))}},{key:"setRTCModule",value:function(e){this._rtcModule=e}},{key:"_onIMStateChange",value:function(e){var n=this,r=this._logger.createTraceId(),i=0;e===t.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==exports.NCCallState.ONCALL&&(i=Kl(function(){var e;n._logger.info(tl.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",r),n.endCurrentSession(exports.NCCallEndReason.CONNECTION_ERR,null===(e=n._mainSession)||void 0===e?void 0:e.getCallId(),r)},6e4)),e===t.CONNECTED&&(i&&clearTimeout(i),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}},{key:"_handleCallTimeout",value:function(e,t,n){this._logger.warn(tl.L_CALL_ENGINE_CALL_TIMEOUT_O,"call timeout callId: ".concat(e,", userState: ").concat(t),n);var r=[this._mainSession].concat(C(this._holdSessions)).find(function(t){return t&&t.getCallId()===e});if(r){var i=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:exports.NCCallState.ENDED,duration:0,callSessionUsers:r.getUserList().map(function(e){var n,a,o=e.userId,s=e.targetType,c=e.targetId,u=e.stateTime;return o===i?(n=t===gl.MISSED?exports.NCCallEndReason.MISSED:exports.NCCallEndReason.NO_ANSWER,a=t===gl.MISSED?gl.MISSED:gl.NO_ANSWER):(n=t===gl.MISSED?exports.NCCallEndReason.NO_ANSWER:exports.NCCallEndReason.MISSED,a=t===gl.MISSED?gl.NO_ANSWER:gl.MISSED),{userId:o,sessionStatus:a,statusTime:u?u+1:Date.now(),duration:0,changed:1,inviteUserId:r.getCallerId(),sysStatus:n,targetType:s,targetId:c}})},n)}else this._logger.warn(tl.L_CALL_ENGINE_CALL_TIMEOUT_O,"handleCallTimeout without session, callId: ".concat(e),n)}},{key:"_startTimer",value:function(e,t,n){var r=this,i=Kl(function(){r._handleCallTimeout(e,t,n),r._signalModule.statusUpCall({callId:e,sessionStatus:t},n)},6e4);return this._logger.info(tl.L_CALL_ENGINE_START_CALL_TIMER_O,"callId: ".concat(e,", timerId: ").concat(i),n),i}},{key:"_stopTimer",value:function(e,t){clearTimeout(e),this._logger.info(tl.L_CALL_ENGINE_STOP_CALL_TIMER_O,"timerId: ".concat(e),t)}},{key:"_onInvite",value:function(e,t,n){this._clientCallId=fe();var r=this._context.getCurrentId(),i=e.callSessionUsers,a=e.secretChat,o=e.extra,s=void 0===o?"{}":o;a!==xl.SECRET?(i.some(function(e){return e.userId===r})&&this._selfIsInviteeHandle(e,t,n,s),this._othersIsInviteeHandle(e,n)):this.emit(Fl.onPubInviteCallMiss,Object.assign(e,{extra:JSON.stringify(e),reason:Hl.SECRET_CALL,refer:t?Jl.PUB_INVITE:Jl.PULL_KV_INVITE}))}},{key:"_selfIsInviteeHandle",value:function(e,t,r,i){var a=e.callId,o=e.inviteUserId,s=e.callType,c=e.mediaType,u=e.callSessionUsers,l=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(l,a);var _=new jl(a,exports.NCCallState.RINGING,s,c,o,o,[],this._logger);this._signalModule.ringingCall({callId:a},r);var d=this._startTimer(a,gl.MISSED,r);_.updateTimerId(Vl.INVITEE,d),this._mainSession?(this._holdSessions.push(_),this._mainSession.updateSessionState(exports.NCCallState.BUSYLINE_WAIT)):this._mainSession=_;var f=new cl(_,this,this._logger,this._rtcModule,this._context),h=t?i_.PUB_INVITE_CALL:i_.PULL_KV_INVITE_CALL;this.emit(n.__INNER_INVITE__,f,h);var g=u.map(function(e){return{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,targetType:e.targetType,targetId:e.targetId,stateTime:e.statusTime}}),p=this.updateUsersState(a,g,r);this._reportAppEventModule.onReceivedCall(f,r,JSON.parse(i||"{}").extra),p.length>0&&this.reportRemoteUserStateChange(a,p,r)}},{key:"_othersIsInviteeHandle",value:function(e,t){var n,r,i,a=e.callId,o=e.inviteUserId,s=e.callSessionUsers,c=this._context.getCurrentId(),u=s.filter(function(e){return e.userId!==c&&e.userId!==o&&e.sessionStatus===gl.INVITED});if(u.length){(null===(n=this._mainSession)||void 0===n?void 0:n.getCallType())===ll.SINGLE&&(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===a&&(this._onCallTypeChange(this._mainSession.getCallId(),ll.MULTI,t),null===(i=this._mainSession)||void 0===i||i.updateCallType(ll.MULTI));var l=[],_=[];u.forEach(function(e){var t=e.userId,n=e.sessionStatus,r=e.sysStatus;l.push({callId:a,userId:t,userState:n}),_.push({userId:t,userState:n,systemState:r})}),this._onOtherMemberInvite(l);var d=this.updateUsersState(a,_,t);d.length>0&&this.reportRemoteUserStateChange(a,d,t)}}},{key:"_onHangup",value:function(e,t,n){var r=this;this._mainSession&&e.forEach(function(e){e.callId===r._mainSession.getCallId()&&(e.userState===gl.CANCELLED?r._stopTimer(r._mainSession.getInviteeTimerId(),n):r._stopTimer(r._mainSession.getInviterTimerId(),n))})}},{key:"_onAccept",value:function(e,t){var r,i,a,o,s=null===(r=this._mainSession)||void 0===r?void 0:r.getSessionState(),c=[exports.NCCallState.CONNECTING,exports.NCCallState.ONCALL,exports.NCCallState.BUSYLINE_WAIT];if((null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())!==ll.SINGLE||!s||!c.includes(s)){var u=this._mainSession.getStartCallerId(),l=this._context.getCurrentId();if((null===(a=this._mainSession)||void 0===a?void 0:a.getCallType())===ll.SINGLE&&u===l)e.filter(function(e){return e.fromUserId!==l})&&this.emit(n.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),t);null===(o=this._mainSession)||void 0===o||o.updateSessionState(exports.NCCallState.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),t)}}},{key:"_onStatusDown",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f,h,g,p,v,m;return E().w(function(n){for(;;)switch(n.n){case 0:if(a=e.callStatus,o=e.startTime,(s=e.callId)===(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())){n.n=1;break}return n.a(2);case 1:if(this._callStartMap[s]=this._callStartMap[s]||{},this._callStartMap[s].isReceiveCallStartTime||a!==exports.NCCallState.ONCALL||(this._callStartMap[s].isReceiveCallStartTime=!0,c=this._timeCorrectioner.calcClientStartTime(s,o,t),u=c.code,l=c.clientStartTime,u===Ql.SUCCESS&&(this._callStartMap[s].callStartTime=l,this._reportAppEventModule.onReceivedCallStartTime({callId:s,callStartTime:l},t))),_=!1,d=this._context.getCurrentId(),(f=e.callSessionUsers.map(function(e){return[gl.IDLE,gl.DECLINED,gl.MISSED,gl.NO_ANSWER,gl.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==exports.NCCallEndReason.CANCELLED&&e.userId===d&&(_=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime}})).length&&(h=this.updateUsersState(s,f,t)).length>0&&this.reportRemoteUserStateChange(s,h,t),this._mainSession||this._holdSessions.length){n.n=2;break}return n.a(2);case 2:g=Rl(e),p=g.hangupData,v=g.acceptData,m=g.otherInvitedData,p.length>0&&this._onHangup(p,e.callStatus,t),v.length>0&&this._onAccept(v,t),m.length>0&&(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===ll.MULTI&&this._onOtherMemberInvite(m),(e.callStatus===exports.NCCallState.ENDED||_)&&this._onSessionClose(e,t,_);case 3:return n.a(2)}},n,this)}))}},{key:"_onOtherClientStatusDown",value:function(e,t){var n,r,i,a=e.callId,o=e.callSessionUsers,s=this._context.getCurrentId(),c=o.find(function(e){return e.userId===s});if(c&&(this._mainSession||this._holdSessions.length)){var u=c.userId,l=c.sessionStatus,_=c.statusTime;if(l===gl.CONNECTING){var d=[gl.ONCALL,gl.CONNECTING],f=(null===(n=this._mainSession)||void 0===n?void 0:n.getCallId())===a,h=null===(i=null===(r=this._mainSession)||void 0===r?void 0:r.getUserList().find(function(e){return e.userId===s}))||void 0===i?void 0:i.userState;if(!(f&&h&&d.includes(h))){var g=this.updateUsersState(a,[{userId:u,userState:l,systemState:exports.NCCallEndReason.OTHER_CLIENT_ACCEPT,stateTime:_}],t);g.length>0&&this.reportRemoteUserStateChange(a,g,t),this._onSessionClose(e,t,!1)}}}}},{key:"_onEventDown",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l;return E().w(function(n){for(;;)switch(n.n){case 0:if(i=e.callId,a=e.eventArgs,o=e.eventType,i===(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())&&this._mainSession.getSessionState()===exports.NCCallState.ONCALL){n.n=1;break}return n.a(2);case 1:o===zl.CALL_DURATION&&(s=a.firstFrameTime,c=this._timeCorrectioner.calcClientStartTime(i,s,t),u=c.code,l=c.clientStartTime,this._logger.info(tl.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,"clientFirstFrameTime: ".concat(l),t),u===Ql.SUCCESS&&(this._callStartMap[i].firstFrameTime=l,this._reportAppEventModule.onReceivedCallFirstFrameTime(i,l,t)));case 2:return n.a(2)}},n,this)}))}},{key:"_onRecvSinCallDuration",value:function(e,t,n,r){var i;(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=n,this._reportAppEventModule.onReceivedCallStartTime(Object.assign({callId:e},{callStartTime:t}),r),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,n,r))}},{key:"_onSwitchMediaType",value:function(e,t){var n,r,i,a,o,s=e.callId,c=e.action,u=e.extraKeyVal,l=e.transactionId,_=e.promoterId,d=u.mediaType,f=u.reason,h=null===(n=this._mainSession)||void 0===n?void 0:n.getCallId();if(s===h){var g=(null===(r=this._mainSession)||void 0===r?void 0:r.getOldDialogData())||{},p=g.transactionId,E=g.action,v=g.mediaType;if(p!==l||E!==c||v!==d){if(this._logger.info(tl.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"action: ".concat(c,", reason: ").concat(f),t),null===(i=this._mainSession)||void 0===i||i.setOldDialogData({transactionId:l,action:c,mediaType:d}),c===Dl.REQUEST)this._onRequestChangeMediaType({transactionId:l,userId:_,mediaType:d},t);else{var m=null;switch(f){case Dl.CANCEL:m=exports.NCCallMediaTypeChangeResult.CANCEL_CHANGE_MEDIA_TYPE;break;case Dl.ACCEPT:m=exports.NCCallMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE,null===(a=this._mainSession)||void 0===a||a.updateMediaType(this._mainSession.getReqMediaType()),null===(o=this._mainSession)||void 0===o||o.updateReqMediaType(null);break;case Dl.REFUSE:m=exports.NCCallMediaTypeChangeResult.REFUSE_CHANGE_MEDIA_TYPE;break;case Dl.TIMEOUT:m=exports.NCCallMediaTypeChangeResult.CHANGE_MEDIA_TYPE_TIMEOUT}exports.NCCallMediaTypeChangeResult[m]&&this._receiveMediaTypeChangeResult({transactionId:l,userId:_,mediaType:d},m,t)}c!==Dl.NOTICE||d!==nl.AUDIO||f||this._receiveMediaTypeChangeResult({transactionId:l,userId:_,mediaType:d},exports.NCCallMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(tl.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}else this._logger.info(tl.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"not current session callId: ".concat(h,", recvCallId: ").concat(s),t)}},{key:"_onRecvCallEndLog",value:function(e,t){var n=ml(e);this._reportAppEventModule.onReceivedCallRecord(n,t)}},{key:"_onSessionClose",value:function(e,t,r){var i=this,a=e.callId,o=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(o,[a]);var s=[this._mainSession].concat(C(this._holdSessions)).find(function(e){return e&&e.getCallId()===a});if(s){this._logger.warn(tl.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,"callId: ".concat(a),t),this.emit(n.__INNER_SESSION_CLOSE__,a,t);var c,u=s.getUserList().find(function(e){return e.userId===o});c=r&&e.toDeviceId!==this._signalModule.getDeviceId()?s.getIsLocalClientHangup()?u.systemState:exports.NCCallEndReason.OTHER_CLIENT_HANGUP:u.systemState,this._reportAppEventModule.onCallEnded(new cl(s,this,this._logger,this._rtcModule,this._context),c,t),this._reportCallPlusSummaryMessage(s,a,c),this._mainSession&&this._mainSession.getCallId()===a&&(this._mainSession.getAllTimerIds().forEach(function(e){return i._stopTimer.bind(i)(e,t)}),s.getCallType()===ll.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[a]),this._removeSession(a)}else this._logger.warn(tl.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,"unexpect session callId -> ".concat(a),t)}},{key:"_reportCallPlusSummaryMessage",value:function(t,n,r){var i,o,s,c=this._context.getCurrentId(),u=t.getUserList().filter(function(e){return e.userId!==c})[0].userId,l=t.getStartCallerId();if(!localStorage.getItem("missMessageMap-".concat(c,"-").concat(n))){var _={callId:n,callerUserId:l,targetId:u,mediaType:t.getMediaType(),firstFrameTime:(null===(i=this._callStartMap[n])||void 0===i?void 0:i.firstFrameTime)||0,callStartTime:(null===(o=this._callStartMap[n])||void 0===o?void 0:o.callStartTime)||0,callEndTime:(null===(s=this._callStartMap[n])||void 0===s?void 0:s.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:r};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:_,senderUserId:l,targetId:u,channelId:"",conversationType:e.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:n,messageDirection:l===c?a.MessageDirection.SEND:a.MessageDirection.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:a.ReceivedStatus.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:a.SentStatus.SENT}),localStorage.setItem("missMessageMap-".concat(c,"-").concat(n),n)}}},{key:"_removeSession",value:function(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{var n=this._holdSessions.findIndex(function(t){return(null==t?void 0:t.getCallId())===e});this._holdSessions.splice(n,1)}}},{key:"_createSessionByServer",value:function(e,t){return F(this,arguments,void 0,function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return E().m(function i(){var a,o,s,c,u,l,_,d;return E().w(function(i){for(;;)switch(i.n){case 0:return n._logger.info(tl.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,"callId: ".concat(e),t),i.n=1,n.getCallSession({callId:e},t);case 1:if(a=i.v,o=a.code,s=a.data,o===ol.SUCCESS){i.n=2;break}return n._logger.error(tl.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,"errcode: ".concat(o),t),i.a(2);case 2:n._logger.info(tl.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,"code: ".concat(o,", data: ").concat(JSON.stringify(s)),t),c=s.callType,u=s.mediaType,l=s.callSessionUsers,_=s.startCallerId,n._mainSession=new jl(e,exports.NCCallState.CONNECTING,c,u,_,_,[],n._logger),r&&n._clearMobileOnPhone(e,t),(d=n.updateUsersState(e,l,t)).length>0&&n.reportRemoteUserStateChange(e,d,t);case 3:return i.a(2)}},i)})()})}},{key:"_clearMobileOnPhone",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:if(!(r=[this._mainSession].concat(C(this._holdSessions)).find(function(t){return(null==t?void 0:t.getCallId())===e}))||r.getCallType()!==ll.MULTI){n.n=2;break}return this._logger.info(tl.L_CALL_ENGINE_UP_ON_PHONE_END_T,"callId: ".concat(e),t),n.n=1,this.systemStatusUp({callId:e,sysStatus:exports.NCCallEndReason.ON_PHONE_END,forward:r_.CURRENT},t);case 1:i=n.v,(a=i.code)===ol.SUCCESS?this._logger.info(tl.L_CALL_ENGINE_UP_ON_PHONE_END_R,"callId: ".concat(e),t):this._logger.warn(tl.L_CALL_ENGINE_UP_ON_PHONE_END_R,"callId: ".concat(e,", errCode: ").concat(a),t);case 2:return n.a(2)}},n,this)}))}},{key:"reportRemoteUserStateChange",value:function(e,t,r){var i=this,a=this._context.getCurrentId();t.forEach(function(t){var n=t.userId,o=t.userState,s=t.systemState;n!==a&&i._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:n,userState:o,reason:s},r)}),t.forEach(function(t){var o=t.userId,s=t.systemState;o===a&&s===exports.NCCallEndReason.ABNORMAL_END&&i.emit(n.__INNER_SESSION_CLOSE__,e,r)})}},{key:"_onOtherMemberInvite",value:function(e){var t=this;e.forEach(function(e){var n,r=e.userId,i=e.callId,a=null===(n=t.getLocalMainSession())||void 0===n?void 0:n.getInviterUserId();t._reportAppEventModule.onRemoteUserInvited([r],a,i)})}},{key:"_onRequestChangeMediaType",value:function(e,t){var n,r=e.userId,i=e.transactionId,a=e.mediaType;null===(n=this._mainSession)||void 0===n||n.updateReqMediaType(a),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(r,i,a,t)}},{key:"_receiveMediaTypeChangeResult",value:function(e,t,r){t===exports.NCCallMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE&&this.emit(n.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,r),this._reportAppEventModule.onReceivedChangeMediaTypeResult(Object.assign(Object.assign({},e),{result:t}),r)}},{key:"_onCallTypeChange",value:function(e,t,n){this._reportAppEventModule.onCallTypeChanged(t,e,n)}}])}();Object.defineProperty(u_,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(u_,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(u_,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(u_,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(s_||(s_={}));var l_=function(){function e(t,n,r,i,a,o,u){var l;return c(this,e),l=s(this,e),Object.defineProperty(l,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(l,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(l,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(l,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(l,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(l,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(l,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(l,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(l,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(l,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(l,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(l,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:exports.NCCallVideoResolution.W640_H480,frameRate:exports.NCCallVideoFrameRate.FPS_15}}),Object.defineProperty(l,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(l,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(l,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(l,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(l,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(l,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(l,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(l,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(l,"_preHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),l._isPubTiny=r.isPubTiny||!1,l}return g(e,ue),l(e,[{key:"setCallPlusStatusReportListener",value:function(e){this._callPlusStatusReportListener=e}},{key:"getCameraVideoTrack",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o;return E().w(function(t){for(;;)switch(t.n){case 0:if(!(n=this.getLocalVideoTrack())||this._videoConfigIsChange){t.n=1;break}o={track:n,code:ol.SUCCESS},t.n=3;break;case 1:return t.n=2,this._createVideoTrack(e);case 2:o=t.v;case 3:if(i=(r=o).code,a=r.track,this._videoConfigIsChange=!1,i===ol.SUCCESS){t.n=4;break}return t.a(2,{code:i});case 4:return t.a(2,{code:ol.SUCCESS,track:a})}},t,this)}))}},{key:"getMicrophoneAudioTrack",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o;return E().w(function(t){for(;;)switch(t.n){case 0:if(!(n=this.getLocalAudioTrack())||this._audioConfigIsChange){t.n=1;break}o={track:n,code:ol.SUCCESS},t.n=3;break;case 1:return t.n=2,this._createAudioTrack(e);case 2:o=t.v;case 3:if(i=(r=o).code,a=r.track,this._audioConfigIsChange=!1,i===ol.SUCCESS){t.n=4;break}return t.a(2,{code:i});case 4:return t.a(2,{code:ol.SUCCESS,track:a})}},t,this)}))}},{key:"createCallMediaTracks",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o;return E().w(function(n){for(;;)switch(n.n){case 0:return this._callMediaType=e,n.n=1,this.getMicrophoneAudioTrack(t);case 1:if(r=n.v,(i=r.code)===ol.SUCCESS){n.n=2;break}return n.a(2,{code:i});case 2:if(e!==nl.AUDIO_VIDEO){n.n=4;break}return n.n=3,this.getCameraVideoTrack(t);case 3:a=n.v,(o=a.code)!==ol.SUCCESS&&this._logger.warn(tl.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,"get camera video track error code: ".concat(o),t);case 4:return n.a(2,{code:ol.SUCCESS})}},n,this)}))}},{key:"setVideoConfig",value:function(e){this._videoConfigIsChange=!0,this._videoConfig=e}},{key:"setAudioConfig",value:function(e){this._audioConfigIsChange=!0,this._audioConfig=e}},{key:"setAudioOutputDeviceId",value:function(e){return F(this,void 0,void 0,E().m(function t(){return E().w(function(t){for(;;)switch(t.n){case 0:if("string"==typeof e&&0!==e.length){t.n=1;break}return t.a(2,{code:ol.PARAM_ERROR});case 1:if(this._audioOutputDeviceId!==e){t.n=2;break}return t.a(2,{code:ol.SUCCESS});case 2:return this._audioOutputDeviceId=e,this._room&&this._room.getRemoteTracks().filter(function(e){return e.isAudioTrack()}).forEach(function(t){t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})}),t.a(2,{code:ol.SUCCESS})}},t,this)}))}},{key:"destroyAllTracks",value:function(e){this._logger.info(tl.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach(function(e){e.destroy()}),this._localTracks.length=0}},{key:"setAllRemoteAudioEnable",value:function(e,t){return this._logger.info(tl.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,"enable: ".concat(e),t),q(e)?(this._remoteAudioEnable=e,this._room?(this._room.getRemoteTracks().filter(function(e){return e.isAudioTrack()}).forEach(function(t){e?t.unmute():t.mute()}),this._logger.info(tl.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",t),{code:ol.SUCCESS}):{code:ol.SUCCESS}):(this._logger.error(tl.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"param error, enable: type is boolean, value: ".concat(e)),{code:ol.PARAM_ERROR})}},{key:"destroyTrack",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)switch(t.n){case 0:e.destroy(),n=this._localTracks.findIndex(function(t){return t.getTrackId()===e.getTrackId()}),this._localTracks.splice(n,1);case 1:return t.a(2)}},t,this)}))}},{key:"sessionConnected",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._preHangupCallId=null,this._logger.info(tl.L_RTC_MODULE_SESSION_CONNECT_T,"callId: ".concat(e),t),this._room){n.n=4;break}return n.n=1,this.joinRTCRoom(e,t);case 1:if(r=n.v,i=r.code,a=r.room,i===ol.SUCCESS){n.n=2;break}return n.a(2);case 2:if(this._room=a,!this._preHangupCallId||this._room.getRoomId()!==this._preHangupCallId){n.n=3;break}return this._rtcClient.leaveRoom(this._room),this._releaseStoredData(),n.a(2);case 3:o=this._room.getRemoteUserIds(),this._onSelfJoined(e,o,t);case 4:if(this._callId=e,this._regRTCListeners(),(s=this._room.getRemoteTracks())&&s.length&&this._onRemoteTrackPublish(s),!(this._localTracks.length>0)){n.n=6;break}return this.emit(Fl.onBeforePublish),c=this._isPubTiny?this._localTracks.map(function(e){return e.isVideoTrack()?{track:e,isPubTiny:!0}:e}):this._localTracks,n.n=5,this.publish(c,t);case 5:u=n.v,l=u.code,this.emit(Fl.onPublishRes,l),n.n=7;break;case 6:this._logger.warn(tl.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t);case 7:this._logger.info(tl.L_RTC_MODULE_SESSION_CONNECT_R,"code: ".concat(ol.SUCCESS),t);case 8:return n.a(2)}},n,this)}))}},{key:"sessionClose",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._logger.info(tl.L_RTC_MODULE_SESSION_CLOSE_T,"callId: ".concat(e),t),this._preHangupCallId=e,this.destroyAllTracks(t),i=null===(r=this._room)||void 0===r?void 0:r.getRoomId(),!this._room||e!==i){n.n=3;break}return n.n=1,this._rtcClient.leaveRoom(this._room);case 1:if(a=n.v,o=a.code,this._releaseStoredData(),o===Ae.SUCCESS){n.n=2;break}return this._logger.error(tl.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom failed, code: ".concat(o),t),n.a(2);case 2:this._logger.info(tl.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t),n.n=4;break;case 3:this._logger.warn(tl.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t);case 4:return n.a(2)}},n,this)}))}},{key:"disableVideoTrack",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n;return E().w(function(e){for(;;)switch(e.n){case 0:if(t=this.getLocalVideoTrack()){e.n=1;break}return e.a(2,{code:ol.CAMERA_CLOSED});case 1:return e.n=2,t.mute();case 2:return n=e.v,e.a(2,{code:n,track:t})}},e,this)}))}},{key:"enableVideoTrack",value:function(e){return F(this,void 0,void 0,E().m(function e(){var t,n;return E().w(function(e){for(;;)switch(e.n){case 0:if(t=this.getLocalVideoTrack()){e.n=1;break}return e.a(2,{code:ol.CAMERA_CLOSED});case 1:if(t.isOwnerMuted()){e.n=2;break}return e.a(2,{code:ol.SUCCESS});case 2:return e.n=3,t.unmute();case 3:return n=e.v,e.a(2,{code:n})}},e,this)}))}},{key:"changeVideoDevice",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u,l,_,d;return E().w(function(t){for(;;)switch(t.n){case 0:return n=[],r=[],t.n=1,this._rtcClient.createCameraVideoTrack(s_.NORMAL,this._videoConfig);case 1:if(i=t.v,a=i.code,o=i.track,a===Ae.SUCCESS){t.n=2;break}return t.a(2,{code:a});case 2:if(s=this._videoConfig,c=s.minBitrate,u=s.maxBitrate,(c||u)&&o.setBitrate(u,c),this._localTracks&&this._localTracks.forEach(function(e){e.isVideoTrack()?(e.destroy(),l=e):r.push(e)}),this._localTracks=this._localTracks.filter(function(e){return l&&e.getTrackId()!==l.getTrackId()}),n.push(o),r.push(o),this._localTracks=r,this._onLocalTrackReady(n,e),!this._room){t.n=4;break}return t.n=3,this._room.publish(n);case 3:if(_=t.v,(d=_.code)===Ae.SUCCESS){t.n=4;break}return t.a(2,{code:d});case 4:return t.a(2,{code:ol.SUCCESS,track:o})}},t,this)}))}},{key:"changeAudioDevice",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u;return E().w(function(t){for(;;)switch(t.n){case 0:return n=[],r=[],i=Object.assign(Object.assign({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),t.n=1,this._rtcClient.createMicrophoneAudioTrack(s_.NORMAL,i);case 1:if(a=t.v,o=a.code,s=a.track,o===Ae.SUCCESS){t.n=2;break}return t.a(2,{code:o});case 2:if(this._localTracks&&this._localTracks.forEach(function(e){e.isAudioTrack()||r.push(e)}),n.push(s),r.push(s),this._localTracks=r,this._onLocalTrackReady(n,e),!this._room){t.n=4;break}return t.n=3,this._room.publish(n);case 3:if(c=t.v,(u=c.code)===Ae.SUCCESS){t.n=4;break}return t.a(2,{code:u});case 4:return t.a(2,{code:ol.SUCCESS})}},t,this)}))}},{key:"disableAudioTrack",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n;return E().w(function(e){for(;;)switch(e.n){case 0:if(t=this.getLocalAudioTrack()){e.n=1;break}return e.a(2,{code:ol.MICROPHONE_CLOSED});case 1:return e.n=2,t.mute();case 2:return n=e.v,e.a(2,{code:n,track:t})}},e,this)}))}},{key:"changeMediaType",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._logger.info(tl.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,"mediaType: ".concat(e),t),e!==nl.AUDIO_VIDEO){n.n=2;break}return n.n=1,this._upgradeMediaType(t);case 1:r=n.v,n.n=4;break;case 2:return n.n=3,this._downgradeMediaType(t);case 3:r=n.v;case 4:r.code===ol.SUCCESS&&this._logger.info(tl.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t);case 5:return n.a(2)}},n,this)}))}},{key:"_upgradeMediaType",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u,l,_;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this.getLocalVideoTrack()){t.n=3;break}return t.n=1,this._createVideoTrack(e);case 1:if(r=t.v,i=r.code,a=r.track,i===ol.SUCCESS){t.n=2;break}return this._logger.error(tl.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"create video track errCode: ".concat(i),e),t.a(2,{code:i});case 2:n=a,o=this._videoConfig,s=o.minBitrate,c=o.maxBitrate,(s||c)&&n.setBitrate(c,s);case 3:return u=this._isPubTiny?{track:n,isPubTiny:!0}:n,t.n=4,this.publish([u],e);case 4:return l=t.v,(_=l.code)!==ol.SUCCESS&&this._logger.error(tl.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"publish errCode: ".concat(_),e),t.a(2,{code:_})}},t,this)}))}},{key:"_downgradeMediaType",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:if(!(n=this.getLocalVideoTrack())){t.n=3;break}return t.n=1,this._room.unpublish([n]);case 1:if(r=t.v,(i=r.code)===Ae.SUCCESS){t.n=2;break}return this._logger.error(tl.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"unpublish errCode: ".concat(i),e),t.a(2,{code:i});case 2:this.destroyTrack(n);case 3:return t.a(2,{code:ol.SUCCESS})}},t,this)}))}},{key:"joinRTCRoom",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o;return E().w(function(n){for(;;)switch(n.n){case 0:return this._logger.info(tl.L_RTC_MODULE_JOIN_RTC_ROOM_T,"call: ".concat(e),t),n.n=1,Wl({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:ps.CALL}]});case 1:if(r=n.v,i=r.code,a=r.room,o=r.tracks,i===Ae.SUCCESS){n.n=2;break}return this._logger.error(tl.L_RTC_MODULE_JOIN_RTC_ROOM_R,"callId: ".concat(e,", errCode: ").concat(i),t),this._onRTCMethodFail(exports.NCCallEndReason.JOIN_ROOM_ERR,t),n.a(2,{code:i});case 2:return this._logger.info(tl.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",t),this._callId=e,n.a(2,{code:ol.SUCCESS,room:a,tracks:o})}},n,this)}))}},{key:"subscribeTracks",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._logger.info(tl.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map(function(e){var t=e.track,n=e.subTiny;return{trackId:t.getTrackId(),subTiny:n}})}),t),this._room){n.n=1;break}return n.a(2,{code:ol.SUCCESS});case 1:return n.n=2,Wl({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:function(e){}});case 2:if(r=n.v,(i=r.code)===Ae.SUCCESS){n.n=3;break}return this._reportAppEventModule.onFetchRemoteMediaError(e,i),this._onRTCMethodFail(exports.NCCallEndReason.SUBSCRIBE_ERR,t),this._logger.error(tl.L_RTC_MODULE_SUBSCRIBE_R,"errorCode: ".concat(i),t),n.a(2,{code:i});case 3:return this._logger.info(tl.L_RTC_MODULE_SUBSCRIBE_R,"success",t),n.a(2,{code:ol.SUCCESS})}},n,this)}))}},{key:"unsubscribeTracks",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:if(this._logger.info(tl.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(function(e){return e.getTrackId()})}),t),this._room){n.n=1;break}return n.a(2,{code:ol.SUCCESS});case 1:return n.n=2,this._room.unsubscribe(e);case 2:if(r=n.v,(i=r.code)===Ae.SUCCESS){n.n=3;break}return this._logger.error(tl.L_RTC_MODULE_UNSUBSCRIBE_R,"errorCode: ".concat(i),t),n.a(2,{code:i});case 3:return this._logger.info(tl.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),n.a(2,{code:ol.SUCCESS})}},n,this)}))}},{key:"_releaseStoredData",value:function(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={},this._preHangupCallId=null}},{key:"getRemoteTracks",value:function(){var e=this,t={};return this._room?(this._room.getRemoteUserIds().forEach(function(n){t[n]=e._room.getRemoteTracksByUserId(n)}),t):t}},{key:"getRemoteTrack",value:function(e,t){var n;return null===(n=this._room)||void 0===n?void 0:n.getRemoteTracksByUserId(e).find(function(e){return t===nl.AUDIO?e.isAudioTrack():e.isVideoTrack()})}},{key:"getRTCSessionId",value:function(){return this._room?this._room.getSessionId():null}},{key:"_regRTCListeners",value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(t,n){e._onKickOff(t,e._room.getRoomId(),n),e._releaseStoredData()},onUserJoin:function(t){var n=t.map(function(t){return{callId:e._callId,userId:t}}),r=e._logger.createTraceId();e._onOtherMemJoined(n,r)},onUserLeave:function(t){t.forEach(function(t){delete e._userViewMap[t]})},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:function(t){e._onRemoteTrackReady([t])},onVideoMuteChange:function(t){e._onVideoMuteChagne({fromUserId:t.getUserId(),muted:t.isOwnerMuted(),trackId:t.getTrackId()})},onAudioMuteChange:function(t){e._onAudioMuteChange({fromUserId:t.getUserId(),muted:t.isOwnerMuted(),trackId:t.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange(function(t){e._reportAppEventModule.onUserAudioLevelChanged(t)})}},{key:"_onLocalTrackReady",value:function(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}},{key:"_onRemoteTrackReady",value:function(t){this._reportAppEventModule.onUserMediaAvailable(t),this.emit(e.__INNER_RECEIVE_FIRST_FRAME__)}},{key:"_onKickOff",value:function(t,n,r,i){this._logger.info(tl.L_RTC_MODULE_RECEIVE_KICK_OFF_O,"roonId: ".concat(n,", byServer: ").concat(t,", state: ").concat(r,", kickExtra: ").concat(JSON.stringify(i)));var a=exports.NCCallEndReason.CONNECTION_ERR;if(t)if(i)a=i.kickReasonCode;else switch(r){case hc.SERVER_KICK:a=exports.NCCallEndReason.KICKED_BY_SERVER;break;case hc.OTHER_KICK:a=exports.NCCallEndReason.OTHER_CLIENT_JOINED;break;case hc.IM_DISCONNECTED:a=exports.NCCallEndReason.CONNECTION_ERR;break;case hc.IM_LOGOUT:a=exports.NCCallEndReason.LOGOUT;break;case hc.OTHER_CLIENT_IM_CONNECTED:a=exports.NCCallEndReason.OTHER_CLIENT_LOGIN}this.emit(e.__INNER_ON_KICKOFF__,a,n)}},{key:"_onRTCPeerConnectionCloseByException",value:function(){var t=this._logger.createTraceId();this._logger.info(tl.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",t),this.emit(e.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,t)}},{key:"_onSelfJoined",value:function(t,n,r){return F(this,void 0,void 0,E().m(function i(){return E().w(function(i){for(;;)switch(i.n){case 0:this.emit(e.__INNER_ON_SELF_JOINED__,t,n,r);case 1:return i.a(2)}},i,this)}))}},{key:"_onRemoteTrackPublish",value:function(e){var t=this,n=this._logger.createTraceId();this._logger.info(tl.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(function(e){return e.getTrackId()})}),n);var r=[];e.forEach(function(e){var n,i=e.getUserId();if(e.isAudioTrack())r.push({track:e,subTiny:!1}),t._reportAppEventModule.onRemoteMicrophoneStateChanged(t._callId,e);else if(t._reportAppEventModule.onRemoteCameraStateChanged(t._callId,e),null===(n=t._userViewMap[i])||void 0===n?void 0:n.videoView){var a=t._userViewMap[i].isTiny;r.push({track:e,subTiny:a})}}),r.length&&this.subscribeTracks(r,n)}},{key:"_onTrackUnpublish",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)switch(t.n){case 0:return n=this._logger.createTraceId(),this._logger.info(tl.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(function(e){return e.getTrackId()})}),n),t.n=1,this.unsubscribeTracks(e,n);case 1:return t.a(2)}},t,this)}))}},{key:"_onAudioMuteChange",value:function(e){var t=this._logger.createTraceId();this._logger.info(tl.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);var n=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,n)}},{key:"_onVideoMuteChagne",value:function(e){var t=this._logger.createTraceId();this._logger.info(tl.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);var n=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,n)}},{key:"_trackStatToQualityStats",value:function(e){var t,n,r,i,a,o,s=null!==(t=e.packetsLostRate)&&void 0!==t?t:0,c=null!==(n=e.bitrate)&&void 0!==n?n:0,u=null!==(r=e.jitter)&&void 0!==r?r:0,l=null!==(i=e.rtt)&&void 0!==i?i:0;return"audio"===e.kind?{audioBitRate:c,jitter:u,rtt:l}:{videoPacketLostRate:s,videoBitRate:c,videoWidth:null!==(a=e.frameWidth)&&void 0!==a?a:0,videoHeight:null!==(o=e.frameHeight)&&void 0!==o?o:0,jitter:u,rtt:l}}},{key:"_onRTCStateReport",value:function(e){var t,n=this,r=e.senders,i=e.receivers,a=null!==(t=this._context.getCurrentId())&&void 0!==t?t:"";r.forEach(function(e){var t,r,i,o=e.kind,s=e.packetsLostRate,c=e.rtt;null===(r=null===(t=n._callPlusStatusReportListener)||void 0===t?void 0:t.onSendQualityChanged)||void 0===r||r.call(t,d({},a,n._trackStatToQualityStats(e))),n._callMediaType===nl.AUDIO_VIDEO&&"audio"===o||null===(i=n._callPlusStatusReportListener)||void 0===i||i.onSendPacketLoss(s||0,c||0)}),i.forEach(function(e){var t,r,i,a=e.trackId,o=e.kind,s=e.packetsLostRate,c=e.bitrate,u=il(a).userId;if(null===(r=null===(t=n._callPlusStatusReportListener)||void 0===t?void 0:t.onReceiveQualityChanged)||void 0===r||r.call(t,d({},u,n._trackStatToQualityStats(e))),n._callMediaType!==nl.AUDIO_VIDEO||"audio"!==o){var l={};l[u]={packetLostRate:s||0,bitRate:c},null===(i=n._callPlusStatusReportListener)||void 0===i||i.onReceivePacketLoss(l)}})}},{key:"_onRTCMethodFail",value:function(t,n){this.emit(e.__INNER_RTC_PROCESS_FAILED__,t,n)}},{key:"_onOtherMemJoined",value:function(t,n){this.emit(e.__INNER_ON_OTHER_JOINED__,t,n)}},{key:"_createAudioTrack",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c;return E().w(function(t){for(;;)switch(t.n){case 0:return this._logger.info(tl.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e),n=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),t.n=1,this._rtcClient.createMicrophoneAudioTrack(s_.NORMAL,n);case 1:if(r=t.v,i=r.code,a=r.track,i===Ae.SUCCESS){t.n=2;break}return this._logger.error(tl.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"errCode: ".concat(i),e),t.a(2,{code:i});case 2:return this._logger.info(tl.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e),o=this._audioConfig,s=o.minBitrate,c=o.maxBitrate,(s||c)&&a.setBitrate(c,s),this._localTracks.push(a),this._onLocalTrackReady([a],e),t.a(2,{code:ol.SUCCESS,track:a})}},t,this)}))}},{key:"_createVideoTrack",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s;return E().w(function(t){for(;;)switch(t.n){case 0:return this._logger.info(tl.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e),t.n=1,this._rtcClient.createCameraVideoTrack(s_.NORMAL,this._videoConfig);case 1:if(n=t.v,r=n.code,i=n.track,r===Ae.SUCCESS){t.n=2;break}return this._logger.error(tl.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"errCode: ".concat(r),e),t.a(2,{code:r});case 2:return this._logger.info(tl.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e),a=this._videoConfig,o=a.minBitrate,s=a.maxBitrate,(o||s)&&i.setBitrate(s,o),this._localTracks.push(i),this._onLocalTrackReady([i],e),t.a(2,{code:ol.SUCCESS,track:i})}},t,this)}))}},{key:"getLocalVideoTrack",value:function(){var e;this._localTracks&&(e=I(this._localTracks.filter(function(e){return e.isVideoTrack()}),1)[0]);return e}},{key:"getLocalAudioTrack",value:function(){var e;this._localTracks&&(e=I(this._localTracks.filter(function(e){return e.isAudioTrack()}),1)[0]);return e}},{key:"publish",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i;return E().w(function(n){for(;;)switch(n.n){case 0:return this._logger.info(tl.L_RTC_MODULE_PUBLISH_T,"tracksIds: ".concat(e.map(function(e){return e instanceof Rn?e.getTrackId():e.track.getTrackId()})),t),n.n=1,Wl({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:function(e){}});case 1:if(r=n.v,(i=r.code)===Ae.SUCCESS){n.n=2;break}return this._onRTCMethodFail(exports.NCCallEndReason.PUBLISH_ERR,t),this._logger.error(tl.L_RTC_MODULE_PUBLISH_R,"errCode: ".concat(i),t),n.a(2,{code:i});case 2:return this._logger.info(tl.L_RTC_MODULE_PUBLISH_R,"code: ".concat(ol.SUCCESS),t),n.a(2,{code:ol.SUCCESS})}},n,this)}))}},{key:"publishVideoTrack",value:function(){var e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}},{key:"setVideoView",value:function(e,t){var n=this,r=[];e.forEach(function(e){var t=e.userId,i=e.videoElement,a=e.isTiny,o=void 0!==a&&a;if(n._userViewMap[t]={videoView:i,isTiny:o},t!==n._context.getCurrentId()&&n._room){var s=(n.getRemoteTracks()[t]||[]).map(function(e){return{track:e,subTiny:o}});r.push.apply(r,C(s))}}),this._logger.info(tl.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:Ll(this._userViewMap),needSubTrackIds:r.map(function(e){return e.track.getTrackId()})}),t),r.length&&this.subscribeTracks(r,t)}},{key:"removeVideoView",value:function(e,t){var n=this,r=[];e.forEach(function(e){var t=n.getRemoteTracks()[e];if(t&&t.length){var i=t.filter(function(e){return e.isVideoTrack()});i.length&&r.push(i[0])}delete n._userViewMap[e]}),this._logger.info(tl.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:Ll(this._userViewMap),unsubTracks:r.map(function(e){return e.getTrackId()})}),t),r.length&&this.unsubscribeTracks(r,t)}},{key:"getUserViewMap",value:function(){return this._userViewMap}},{key:"playMedia",value:function(e,t,n,r){return F(this,void 0,void 0,E().m(function i(){var a,o,s,c,u,l;return E().w(function(i){for(;;)switch(i.p=i.n){case 0:if(this._logger.info(tl.L_RTC_MODULE_PLAY_MEDIA_T,"userId: ".concat(e,", mediaType: ").concat(t,", videoView: ").concat(null==n?void 0:n.nodeName),r),o=this._context.getCurrentId(),e!==o||t!==nl.AUDIO){i.n=1;break}return this._logger.error(tl.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",r),i.a(2,{code:ol.PLAY_MEDIA_FAILED});case 1:if(s=null,s=e===o?t===nl.AUDIO?null:this.getLocalVideoTrack():null===(a=this.getRemoteTracks()[e])||void 0===a?void 0:a.filter(function(e){return t===nl.AUDIO?e.isAudioTrack():e.isVideoTrack()})[0]){i.n=2;break}return this._logger.error(tl.L_RTC_MODULE_PLAY_MEDIA_R,"error code: ".concat(ol.MEDIA_RESOURCE_INVALIED),r),i.a(2,{code:ol.MEDIA_RESOURCE_INVALIED});case 2:if(i.p=2,!s.isAudioTrack()){i.n=4;break}return i.n=3,s.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0});case 3:u=i.v,i.n=6;break;case 4:return i.n=5,s.play(n);case 5:u=i.v;case 6:if(c=u.code,s.isAudioTrack()&&!this._remoteAudioEnable&&s.mute(),c===Ae.SUCCESS){i.n=7;break}return this._logger.error(tl.L_RTC_MODULE_PLAY_MEDIA_R,"errCode: ".concat(c),r),i.a(2,{code:c});case 7:return this._logger.info(tl.L_RTC_MODULE_PLAY_MEDIA_R,"success",r),i.a(2,{code:ol.SUCCESS});case 8:return i.p=8,l=i.v,this._logger.error(tl.L_RTC_MODULE_PLAY_MEDIA_R,"errCode: ".concat(ol.PLAY_MEDIA_FAILED,", message: ").concat(l.message,","),r),i.a(2,{code:ol.PLAY_MEDIA_FAILED})}},i,this,[[2,8]])}))}}])}();Object.defineProperty(l_,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(l_,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(l_,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(l_,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(l_,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(l_,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"});var __,d_=l(function e(t){c(this,e),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0})},[{key:"registerEventListener",value:function(e){this._listener=e}},{key:"_callAppListener",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return F(this,void 0,void 0,E().m(function t(){var r,i,a;return E().w(function(t){for(;;)switch(t.p=t.n){case 0:if(i=null===(r=this._listener)||void 0===r?void 0:r[e]){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,i.apply(void 0,n);case 2:t.n=4;break;case 3:t.p=3,a=t.v,console.error(a),this._logger.error(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:a.name,message:a.message}));case 4:return t.a(2)}},t,this,[[1,3]])}))}},{key:"onReceivedCall",value:function(e,t,n){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,n)}},{key:"onRemoteUserInvited",value:function(e,t,n){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:n})),this._callAppListener("onRemoteUserInvited",e,t,n)}},{key:"onCallConnected",value:function(e){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}},{key:"onCallTypeChanged",value:function(e,t,n){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),n),this._callAppListener("onCallTypeChanged",e,t)}},{key:"onRemoteUserStateChanged",value:function(e,t){var n=e.callId,r=e.userId,i=e.userState,a=e.reason;this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:n,userId:r,userState:i,reason:a}),t),this._callAppListener("onRemoteUserStateChanged",n,r,i,a)}},{key:"onCallEnded",value:function(e,t,n){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),n),this._callAppListener("onCallEnded",e,t)}},{key:"onRemoteCameraStateChanged",value:function(e,t){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteCameraStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));var n=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,n,null==t?void 0:t.isOwnerMuted())}},{key:"onRemoteMicrophoneStateChanged",value:function(e,t){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteMicrophoneStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));var n=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,n,null==t?void 0:t.isOwnerMuted())}},{key:"onReceivedCallRecord",value:function(e,t){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}},{key:"onReceivedChangeMediaTypeRequest",value:function(e,t,n,r){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),r),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,n)}},{key:"onReceivedChangeMediaTypeResult",value:function(e,t){var n=e.userId,r=e.transactionId,i=e.mediaType,a=e.result;this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:n,mediaType:i}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:n,transactionId:r,mediaType:i,result:a})}},{key:"onReceivedCallStartTime",value:function(e,t){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}},{key:"onReceivedCallFirstFrameTime",value:function(e,t,n){this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),n),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}},{key:"onUserMediaAvailable",value:function(e,t){var n=this;this._logger.info(tl.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map(function(e){return e.getTrackId()})}),t),e.forEach(function(e){var t=e.getUserId(),r=e.isAudioTrack()?nl.AUDIO:nl.VIDEO;n._callAppListener("onUserMediaAvailable",t,r)})}},{key:"onFetchRemoteMediaError",value:function(e,t){var n=this;e.forEach(function(e){var r=e.track.getUserId();n._callAppListener("onFetchRemoteMediaError",r,t)})}},{key:"onUserAudioLevelChanged",value:function(e){var t=this;e.forEach(function(e){var n=e.track,r=e.audioLevel,i=n.getUserId();t._callAppListener("onUserAudioLevelChanged",i,r)})}},{key:"onReceivedCallPlusSummaryMessage",value:function(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}},{key:"onReceivedGroupCallStatusMessage",value:function(e){this._callAppListener("onReceivedGroupCallStatusMessage",e)}}]);!function(e){e[e.UNKNOW_ERR=41e3]="UNKNOW_ERR",e[e.DB_ERR=41001]="DB_ERR",e[e.JSON_ERR=41002]="JSON_ERR",e[e.INVALID_JSON_ERR=41003]="INVALID_JSON_ERR",e[e.MISSING_PARAMS=41004]="MISSING_PARAMS",e[e.PARAMS_REQUIRED=41005]="PARAMS_REQUIRED",e[e.DATA_FORMAT_ERR=41006]="DATA_FORMAT_ERR",e[e.METHOD_NOT_IMPLEMENTED=41007]="METHOD_NOT_IMPLEMENTED",e[e.CALL_NOT_EXIST=41010]="CALL_NOT_EXIST",e[e.SINGAL_EXCEED_TWO_INVITEE=41011]="SINGAL_EXCEED_TWO_INVITEE",e[e.GROUP_EXCEEDS_QUORUM=41012]="GROUP_EXCEEDS_QUORUM",e[e.OPERATION_EXPIRED=41013]="OPERATION_EXPIRED",e[e.DEVICE_IS_CALLING=41014]="DEVICE_IS_CALLING",e[e.REPORT_STREAM_READY_TIME_IS_INVALID=41018]="REPORT_STREAM_READY_TIME_IS_INVALID",e[e.NOT_CALL_YOURSELF=41019]="NOT_CALL_YOURSELF",e[e.SESSION_STATUS_NOT_EXIST=41020]="SESSION_STATUS_NOT_EXIST",e[e.HANGUP_NOT_ALLOW=41021]="HANGUP_NOT_ALLOW",e[e.ACCEPT_NOT_ALLOW=41022]="ACCEPT_NOT_ALLOW",e[e.OPERATION_NOT_ALLOW=41025]="OPERATION_NOT_ALLOW",e[e.TRANSACTION_ID_ERR=41100]="TRANSACTION_ID_ERR",e[e.UP_VIDEO_CANCELED=41050]="UP_VIDEO_CANCELED",e[e.CURRENT_CALL_IS_AUDIO=41051]="CURRENT_CALL_IS_AUDIO",e[e.CURRENT_CALL_IS_VIDEO=41052]="CURRENT_CALL_IS_VIDEO"}(__||(__={}));var f_,h_=l(function e(t){c(this,e),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})},[{key:"setChannelIdMi",value:function(e){return Y(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdMi type is string, value: ".concat(e)),this)}},{key:"setMiLargeIconUrl",value:function(e){return this._logger.warn(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}},{key:"setChannelIdHW",value:function(e){return Y(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdHW type is string, value: ".concat(e)),this)}},{key:"setCategoryHW",value:function(e){return Y(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: categoryHW type is string, value: ".concat(e)),this)}},{key:"setImportanceHW",value:function(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: importanceHW value is NORMAL|LOW, value: ".concat(e)),this):(this._androidPushConfig.importanceHW=e,this)}},{key:"setImageUrlHW",value:function(e){return Y(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: imageUrlHW type is string, value: ".concat(e)),this)}},{key:"setChannelIdOPPO",value:function(e){return Y(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdOPPO type is string, value: ".concat(e)),this)}},{key:"setTypeVivo",value:function(e){return Y(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: typeVivo type is string, value: ".concat(e)),this)}},{key:"setCategoryVivo",value:function(e){return Y(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: categoryVivo type is string, value: ".concat(e)),this)}},{key:"setFcmChannelId",value:function(e){return Y(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmChannelId type is string, value: ".concat(e)),this)}},{key:"setFcmCollapseKey",value:function(e){return Y(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmCollapseKey type is string, value: ".concat(e)),this)}},{key:"setFcmImageUrl",value:function(e){return Y(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmImageUrl type is string, value: ".concat(e)),this)}},{key:"setimportanceHonor",value:function(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: importanceHonor value is NORMAL|LOW, value: ".concat(e)),this):(this._androidPushConfig.importanceHonor=e,this)}},{key:"setimageUrlHonor",value:function(e){return Y(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(tl.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: imageUrlHonor type is string, value: ".concat(e)),this)}},{key:"build",value:function(){return this._androidPushConfig}}]),g_=l(function e(t,n,r,i){var a=this;c(this,e),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_rtcPluginContext",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:exports.NCCallVideoResolution.W640_H480,frameRate:exports.NCCallVideoFrameRate.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatistics",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_isLaunchHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_needHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._rtcPluginContext.logger,this._rtcPluginContext.registerMessageType("RC:CallPlusMiss",!0,!1,[]),this._reportAppEventModule=new d_(this._logger),this._callPlusStatistics=new Bl(this._rtcPluginContext),this._callEngine=new u_(this._rtcPluginContext,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new l_(this._rtcPluginContext,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule,this._rtcClient),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(l_.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(l_.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(l_.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(l_.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(l_.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(l_.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(u_.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(u_.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(u_.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(u_.__INNER_INVITE__,function(e,t){a._callPlusStatistics.reportStatisticsData(pl.L_QS_RECEIVE_CALL_S,ol.SUCCESS,+new Date,e,"",t)})},[{key:"_rtcProcessFailHandle",value:function(e,t){var n=this._callEngine.getLocalMainSession();if(n){var r=n.getCallId();this._callEngine.systemStatusUp({callId:r,sysStatus:e,forward:r_.CURRENT},t),this._callPlusStatistics.reportStatisticsData(pl.L_QS_ABNORMAL_HANGUP_S,ol.SUCCESS,+new Date,n),this.__innerHangup({callId:r,systemState:e},t)}}},{key:"_peerConnectionAbnormalClose",value:function(e){var t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:exports.NCCallEndReason.CONNECTION_ERR,forward:r_.CURRENT},e),this._callEngine.endCurrentSession(exports.NCCallEndReason.CONNECTION_ERR,t.getCallId(),e))}},{key:"_selfJoinedHandle",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s;return E().w(function(r){for(;;)switch(r.n){case 0:i=this._rtcPluginContext.getCurrentId(),((null==(a=this._callEngine.getLocalMainSession())?void 0:a.getCallType())===ll.MULTI||t.length)&&this._callEngine.updateMainSessionState(exports.NCCallState.ONCALL),o=[i].concat(C(t)).map(function(e){return{userId:e,userState:gl.ONCALL,systemState:exports.NCCallEndReason.ONCALL}}),s=this._callEngine.updateUsersState(e,o,n),this._reportAppEventModule.onCallConnected(a),s.length>0&&this._callEngine.reportRemoteUserStateChange(e,s,n),this._callEngine.startTimeCorrection(n);case 1:return r.a(2)}},r,this)}))}},{key:"_otherJoinedHandle",value:function(e,t){var n,r="",i=e.map(function(e){return r=e.callId,{userId:e.userId,userState:gl.ONCALL,systemState:exports.NCCallEndReason.ONCALL}}),a=this._callEngine.updateUsersState(r,i,t);a.length>0&&this._callEngine.reportRemoteUserStateChange(r,a,t),(null===(n=this._callEngine.getLocalMainSession())||void 0===n?void 0:n.getState())!==exports.NCCallState.ONCALL&&this._callEngine.updateMainSessionState(exports.NCCallState.ONCALL)}},{key:"_receiveFirstFrameHandle",value:function(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==exports.NCCallState.ONCALL&&this._callEngine.updateMainSessionState(exports.NCCallState.ONCALL),this._callEngine.upFirstFrameTime(e)}},{key:"_kickoffHandle",value:function(e,t,n){if(e!==exports.NCCallEndReason.CONNECTION_ERR){var r=this._callEngine.getLocalMainSession();if(r){var i=r.getCallId();this._callPlusStatistics.reportStatisticsData(pl.L_QS_ABNORMAL_HANGUP_S,ol.SUCCESS,+new Date,r,this._clientCallId),this._callEngine.systemStatusUp({callId:i,sysStatus:e,forward:r_.CURRENT},n),this._callEngine.endCurrentSession(e,t,n)}}else this._callEngine.endCurrentSession(e,t,n)}},{key:"_sessionCloseHandle",value:function(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}},{key:"setCallPlusEventListener",value:function(e){this._logger.info(tl.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}},{key:"setStatusReportListener",value:function(e){this._logger.info(tl.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}},{key:"setVideoView",value:function(e){var t=this._logger.createTraceId();if(this._logger.info(tl.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map(function(e){var t=e.userId,n=e.videoElement,r=e.isTiny;return{userId:t,elementName:null==n?void 0:n.nodeName,isTiny:r}})}),t),!Z(e))return this._logger.error(tl.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, list: not empty array, value: ".concat(JSON.stringify(e)),t),{code:ol.PARAM_ERROR};var n,r=_(e);try{for(r.s();!(n=r.n()).done;){var i=n.value,a=i.userId,o=i.videoElement;if(!Q(a))return this._logger.error(tl.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, userId: not empty string, value: ".concat(a),t),{code:ol.PARAM_ERROR};if(!Tl(o))return this._logger.error(tl.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, videoElement: need a video element, value: ".concat(o instanceof HTMLElement?o.nodeName:o),t),{code:ol.PARAM_ERROR}}}catch(e){r.e(e)}finally{r.f()}return this._logger.info(tl.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",t),this._rtcModule.setVideoView(e,t),{code:ol.SUCCESS}}},{key:"removeVideoView",value:function(e){var t=this._logger.createTraceId();return this._logger.info(tl.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),Z(e)&&e.every(function(e){return Q(e)})?(this._logger.info(tl.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:ol.SUCCESS}):(this._logger.error(tl.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),t),{code:ol.PARAM_ERROR})}},{key:"playMedia",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:t}),r),Q(e)){n.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"params err, userId: not empty string, value: ".concat(e),r),n.a(2,{code:ol.PARAM_ERROR});case 1:if(!ee(nl[t])){n.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"params err, mediaType is illegal, value: ".concat(t),r),n.a(2,{code:ol.PARAM_ERROR});case 2:if(t!==nl.AUDIO||e!==this._rtcPluginContext.getCurrentId()){n.n=3;break}return this._logger.info(tl.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",r),n.a(2,{code:ol.SUCCESS});case 3:if(i=this._rtcModule.getUserViewMap()[e]||{},a=i.videoView,t===nl.AUDIO||a){n.n=4;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"errCode: ".concat(ol.VIDEO_VIEW_NOT_SET,", video view not set"),r),n.a(2,{code:ol.VIDEO_VIEW_NOT_SET});case 4:return n.a(2,this._rtcModule.playMedia(e,t,a,r))}},n,this)}))}},{key:"createVideoConfigBuilder",value:function(){return new vl(this._logger)}},{key:"setVideoConfig",value:function(e){this._logger.info(tl.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));var t=e.frameRate,n=e.resolution,r=e.maxBitrate,i=e.minBitrate;if(!exports.NCCallVideoFrameRate[t])return this._logger.error(tl.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"param error, frameRate is illegal, value: ".concat(t)),{code:ol.PARAM_ERROR};if(!exports.NCCallVideoResolution[n])return this._logger.error(tl.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"param error, resolution is illegal, value: ".concat(n)),{code:ol.PARAM_ERROR};var a=Cl(i,r),o=a.code,s=a.errorMsg;return o!==ol.SUCCESS&&this._logger.error(tl.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,s),this._logger.info(tl.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=Object.assign({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:ol.SUCCESS}}},{key:"createAudioConfigBuilder",value:function(){return new El(this._logger)}},{key:"createAndroidPushConfigBuilder",value:function(){return new h_(this._logger)}},{key:"setAudioConfig",value:function(e){this._logger.info(tl.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(e));var t=e.sampleRate,n=e.minBitrate,r=e.maxBitrate;if(t&&!W(t))return this._logger.error(tl.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"param error, sampleRate: type is number, value: ".concat(t)),{code:ol.PARAM_ERROR};var i=Cl(n,r),a=i.code,o=i.errorMsg;return a!==ol.SUCCESS&&this._logger.error(tl.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,o),this._logger.info(tl.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=Object.assign({},e),this._rtcModule.setAudioConfig(this._audioConfig),{code:ol.SUCCESS}}},{key:"setAudioOutputDeviceId",value:function(e){return this._logger.info(tl.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}},{key:"startCall",value:function(e){return F(this,arguments,void 0,function(e){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ll.SINGLE,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:nl.AUDIO_VIDEO,a=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;return E().m(function c(){var u,l,_,d,f,h,g,p,v,m,R;return E().w(function(c){for(;;)switch(c.n){case 0:if(n._clientCallId=fe(),u=+new Date,l=n._logger.createTraceId(),n._logger.info(tl.L_CALLPLUS_CLIENT_START_CALL_T,"userIds: ".concat(e.join(","),", callType: ").concat(r,", mediaType: ").concat(i,", pushConfig: ").concat(a,", extra: ").concat(o),l),n._rtcPluginContext.getConnectionStatus()===t.CONNECTED){c.n=1;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(ol.SIGNAL_DISCONNECTED),l),c.a(2,{code:ol.SIGNAL_DISCONNECTED});case 1:if((_=n._rtcPluginContext.getNaviInfo())&&Sl(_)){c.n=2;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(ol.RTC_SERVICE_UNAVAILABLE),l),c.a(2,{code:ol.RTC_SERVICE_UNAVAILABLE});case 2:if(Z(e)&&e.every(function(e){return Q(e)})){c.n=3;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),l),c.a(2,{code:ol.PARAM_ERROR});case 3:if(!ee(ll[r])){c.n=4;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"params err, callType is illegal, value: ".concat(r),l),c.a(2,{code:ol.PARAM_ERROR});case 4:if(!ee(nl[i])){c.n=5;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"params err, mediaType is illegal, value: ".concat(i),l),c.a(2,{code:ol.PARAM_ERROR});case 5:if(!a){c.n=6;break}if((d=bl(a)).code===ol.SUCCESS){c.n=6;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"params err, pushConfig is illegal, msg: ".concat(d.errorMsg),l),c.a(2,{code:ol.PARAM_ERROR});case 6:if(!o){c.n=8;break}if(Y(o)){c.n=7;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra is illegal, type: string, value: ".concat(o),l),c.a(2,{code:ol.PARAM_ERROR});case 7:if(!(kl(o)>Zl)){c.n=8;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",l),c.a(2,{code:ol.PARAM_ERROR});case 8:if(!(e.length>1&&r===ll.SINGLE)){c.n=9;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"params err, You can only call one person in a single call, userIds: ".concat(e.join(",")),l),c.a(2,{code:ol.PARAM_ERROR});case 9:if(!s||Y(s)){c.n=10;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"params err, targetId is illegal, type: string, value: ".concat(s),l),c.a(2,{code:ol.PARAM_ERROR});case 10:if(!n._callEngine.getLocalMainSession()){c.n=11;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(ol.SESSION_EXIST,", session exist"),l),c.a(2,{code:ol.SESSION_EXIST});case 11:return c.n=12,n._rtcModule.createCallMediaTracks(i,l);case 12:if(f=c.v,(h=f.code)===ol.SUCCESS){c.n=13;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"create meida tracks error code: ".concat(h),l),c.a(2,{code:h});case 13:return c.n=14,n._callEngine.startCall({toUsers:e.map(function(e){return{userId:e}}),callType:r,mediaType:i,callId:n._clientCallId,pushConfig:a,extra:JSON.stringify({userId:n._rtcPluginContext.getCurrentId(),extra:o}),targetId:s},l);case 14:if(g=c.v,p=g.code,v=g.data,n._callPlusStatistics.reportStatisticsData(pl.L_QS_START_CALL_S,p,u,null,n._clientCallId,null,{mediaType:i,callType:r,callId:(null==v?void 0:v.callId)||""}),p===ol.SUCCESS){c.n=15;break}return n._rtcModule.destroyAllTracks(l),n._logger.error(tl.L_CALLPLUS_CLIENT_START_CALL_R,"signal error code: ".concat(p),l),c.a(2,{code:p});case 15:if(m=v.callId,R=v.clientCallId,n._needHangupCallId!==R){c.n=16;break}return n._callEngine.clearAllTimer(m,l),n._callEngine.hangup({callId:m,systemState:exports.NCCallEndReason.CANCELLED},l),n._logger.info(tl.L_CALLPLUS_CLIENT_START_CALL_R,"the ".concat(m," call has been hangup"),l),c.a(2,{code:ol.SUCCESS});case 16:return r===ll.MULTI&&n._rtcModule.sessionConnected(m,l),n._logger.info(tl.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:v,code:p}),l),c.a(2,{code:ol.SUCCESS,callId:m})}},c)})()})}},{key:"joinMultiCall",value:function(e){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,"callId: ".concat(e),r),this._rtcPluginContext.getConnectionStatus()===t.CONNECTED){n.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(ol.SIGNAL_DISCONNECTED),r),n.a(2,{code:ol.SIGNAL_DISCONNECTED});case 1:if((i=this._rtcPluginContext.getNaviInfo())&&Sl(i)){n.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(ol.RTC_SERVICE_UNAVAILABLE),r),n.a(2,{code:ol.RTC_SERVICE_UNAVAILABLE});case 2:if(Q(e)){n.n=3;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"params err, callId: not empty string, value: ".concat(e),r),n.a(2,{code:ol.PARAM_ERROR});case 3:return n.n=4,this._callEngine.getCallSession({callId:e},r);case 4:if(a=n.v,o=a.code,s=a.data,o===ol.SUCCESS){n.n=5;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"get call data error, code: ".concat(o),r),n.a(2,{code:o});case 5:if(c=s.mediaType,!(u=this._callEngine.getLocalMainSession())||u.getCallId()===e){n.n=6;break}return n.a(2,{code:ol.SESSION_EXIST});case 6:return n.n=7,this._rtcModule.createCallMediaTracks(c,r);case 7:if(l=n.v,(_=l.code)===ol.SUCCESS){n.n=8;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"create meida tracks error code: ".concat(_),r),n.a(2,{code:_});case 8:return n.n=9,this._callEngine.joinCall({callId:e,mediaType:c},r);case 9:if(d=n.v,(f=d.code)===ol.SUCCESS){n.n=10;break}return this._rtcModule.destroyAllTracks(r),this._logger.error(tl.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"signal error code: ".concat(f),r),n.a(2,{code:f});case 10:return this._logger.info(tl.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(ol.SUCCESS),r),n.n=11,this._rtcModule.sessionConnected(e,r);case 11:return n.a(2,{code:ol.SUCCESS})}},n,this)}))}},{key:"invite",value:function(e,t,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l;return E().w(function(r){for(;;)switch(r.n){case 0:if(a=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_INVITE_T,"callId: ".concat(e.join(","),", pushConfig: ").concat(t,", extra: ").concat(n),a),Z(e)&&e.every(function(e){return Q(e)})){r.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_INVITE_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),a),r.a(2,{code:ol.PARAM_ERROR});case 1:if(!t){r.n=2;break}if((o=bl(t)).code===ol.SUCCESS){r.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_INVITE_R,"params err, pushConfig is illegal, msg: ".concat(o.errorMsg),a),r.a(2,{code:ol.PARAM_ERROR});case 2:if(!n){r.n=4;break}if(Y(n)){r.n=3;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra is illegal, value: ".concat(n),a),r.a(2,{code:ol.PARAM_ERROR});case 3:if(!(kl(n)>Zl)){r.n=4;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",a),r.a(2,{code:ol.PARAM_ERROR});case 4:return r.n=5,this._callEngine.invite({toUsers:e.map(function(e){return{userId:e}}),pushConfig:t,extra:JSON.stringify({userId:this._rtcPluginContext.getCurrentId(),extra:n})},a);case 5:if(s=r.v,c=s.code,u=s.data,c===ol.SUCCESS){r.n=6;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_INVITE_R,"signal error code: ".concat(c),a),r.a(2,{code:c});case 6:return l=[],(null===(i=u.busylineUsers)||void 0===i?void 0:i.length)&&l.push.apply(l,C(u.busylineUsers.map(function(e){return{userId:e.userId,state:e.sessionStatus}}))),this._logger.info(tl.L_CALLPLUS_CLIENT_INVITE_R,"success busyUsers: ".concat(JSON.stringify(l)),a),r.a(2,{code:ol.SUCCESS,busyUsers:l})}},r,this)}))}},{key:"accept",value:function(e,n){return F(this,void 0,void 0,E().m(function r(){var i,a,o,s,c,u,l,_,d,f,h,g,p;return E().w(function(r){for(;;)switch(r.n){case 0:if(i=+new Date,a=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_ACCEPT_T,"callId: ".concat(e,", pushConfig: ").concat(n),a),this._rtcPluginContext.getConnectionStatus()===t.CONNECTED){r.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode: ".concat(ol.SIGNAL_DISCONNECTED),a),r.a(2,{code:ol.SIGNAL_DISCONNECTED});case 1:if((o=this._rtcPluginContext.getNaviInfo())&&Sl(o)){r.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode: ".concat(ol.RTC_SERVICE_UNAVAILABLE),a),r.a(2,{code:ol.RTC_SERVICE_UNAVAILABLE});case 2:if(Q(e)){r.n=3;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"params err, callId: not empty string, value: ".concat(e),a),r.a(2,{code:ol.PARAM_ERROR});case 3:if(!n){r.n=4;break}if((s=bl(n)).code===ol.SUCCESS){r.n=4;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"params err, pushConfig is illegal, msg: ".concat(s.errorMsg),a),r.a(2,{code:ol.PARAM_ERROR});case 4:if(c=this._callEngine.getLocalMainSession(),u=this._callEngine.getHoldSession(e),c||u){r.n=5;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode : ".concat(ol.NOT_IN_CALL,", session not exist"),a),r.a(2,{code:ol.NOT_IN_CALL});case 5:if(e!==(null==u?void 0:u.getCallId())){r.n=8;break}return r.n=6,this.hangup(c.getCallId());case 6:if(l=r.v,(_=l.code)===ol.SUCCESS){r.n=7;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"hangup mainSession error code: ".concat(_),a),r.a(2,{code:_});case 7:this._callEngine.upgradeMainSession(e),c=this._callEngine.getLocalMainSession();case 8:return d=c.getMediaType(),r.n=9,this._rtcModule.createCallMediaTracks(d,a);case 9:if(f=r.v,(h=f.code)===ol.SUCCESS){r.n=10;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"create meida tracks error code: ".concat(h),a),r.a(2,{code:h});case 10:return r.n=11,this._callEngine.accept({callId:e},a);case 11:if(g=r.v,p=g.code,this._callPlusStatistics.reportStatisticsData(pl.L_QS_ACCEPT_CALL_S,p,i,c),p===ol.SUCCESS){r.n=12;break}return this._rtcModule.destroyAllTracks(a),this._logger.error(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"signal error code: ".concat(p),a),r.a(2,{code:p});case 12:return this._logger.info(tl.L_CALLPLUS_CLIENT_ACCEPT_R,"success",a),this._rtcModule.sessionConnected(e,a),r.a(2,{code:ol.SUCCESS})}},r,this)}))}},{key:"__innerHangup",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o;return E().w(function(n){for(;;)switch(n.n){case 0:return i=e.callId,this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(i,t),n.n=1,this._callEngine.hangup(e,t);case 1:if(a=n.v,(o=a.code)!==__.CALL_NOT_EXIST){n.n=2;break}return n.a(2,{code:ol.SUCCESS});case 2:if(o!==ol.SUCCESS||i!==(null===(r=this._callEngine.getLocalMainSession())||void 0===r?void 0:r.getCallId())){n.n=3;break}return n.n=3,this._rtcModule.sessionClose(i,t);case 3:return n.a(2,{code:o})}},n,this)}))}},{key:"hangup",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a,o,s,c,u,l,_,d,f,h,g;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=+new Date,i=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_HANGUP_T,"callId: ".concat(e,", pushConfig: ").concat(t),i),a=this._callEngine.getLocalMainSession()){n.n=1;break}return n.a(2,{code:ol.NOT_IN_CALL});case 1:if(!e||Y(e)){n.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_HANGUP_R,"params err, callId: type is string, value: ".concat(e),i),n.a(2,{code:ol.PARAM_ERROR});case 2:if(!t){n.n=3;break}if((o=bl(t)).code===ol.SUCCESS){n.n=3;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_HANGUP_R,"params err, pushConfig is illegal, msg: ".concat(o.errorMsg),i),n.a(2,{code:ol.PARAM_ERROR});case 3:if(s=a.getCallId(),!e||e===s||this._callEngine.getHoldSession(e)){n.n=4;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_HANGUP_R,"params err, callId is invalid, value: ".concat(e),i),n.a(2,{code:ol.CALL_ID_INVALID});case 4:return this._isLaunchHangup=!0,this._needHangupCallId=e||s,c=this._callEngine.getHoldSession(this._needHangupCallId),u=c||a,l=this._rtcPluginContext.getCurrentId(),_=a.getUserList().filter(function(e){return e.userId===l})[0].state,d=[a.getCreatorUserId(),a.getInviterUserId()].includes(l),f=Il(_,d)||exports.NCCallEndReason.ENDED,n.n=5,this.__innerHangup({callId:this._needHangupCallId,systemState:f,pushConfig:t},i);case 5:if(h=n.v,g=h.code,this._callPlusStatistics.reportStatisticsData(pl.L_QS_HANGUP_CALL_S,g,r,u,this._clientCallId),g===ol.SUCCESS){n.n=6;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_HANGUP_R,"signal error code : ".concat(g),i),n.a(2,{code:g});case 6:return this._needHangupCallId=null,this._logger.info(tl.L_CALLPLUS_CLIENT_HANGUP_R,"success",i),n.a(2,{code:ol.SUCCESS})}},n,this)}))}},{key:"requestChangeMediaType",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a,o,s,c,u=this;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,"mediaType: ".concat(e),n),!ee(nl[e])){t.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"params err, mediaType is illegal, value: ".concat(e),n),t.a(2,{code:ol.PARAM_ERROR});case 1:if(r=this.getCurrentCallSession(),i=null==r?void 0:r.getMediaType(),e!==i){t.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"error code: ".concat(ol.MEDIATYPE_INVALID),n),t.a(2,{code:ol.MEDIATYPE_INVALID});case 2:if(this._callEngine.getLocalMainSession()){t.n=3;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"error code : ".concat(ol.NOT_IN_CALL,", session not exist"),n),t.a(2,{code:ol.NOT_IN_CALL});case 3:return a=null==r?void 0:r.getUserList().filter(function(e){return e.userId!==u._rtcPluginContext.getCurrentId()}).map(function(e){return e.userId}),t.n=4,this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:a||[]},n);case 4:if(o=t.v,s=o.code,c=o.data,s===ol.SUCCESS){t.n=5;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"signal error code: ".concat(s),n),t.a(2,{code:s});case 5:return this._logger.info(tl.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"success transactionId: ".concat(c.transactionId),n),t.a(2,{code:ol.SUCCESS,transactionId:c.transactionId})}},t,this)}))}},{key:"cancelChangeMediaType",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,"transactionId: ".concat(e),n),Q(e)){t.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"param error, transactionId: not empty string, value: ".concat(e),n),t.a(2,{code:ol.PARAM_ERROR});case 1:if(this._callEngine.getLocalMainSession()){t.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"error code : ".concat(ol.NOT_IN_CALL,", session not exist"),n),t.a(2,{code:ol.NOT_IN_CALL});case 2:return t.n=3,this._callEngine.cancelChangeMediaType({transactionId:e},n);case 3:if(r=t.v,(i=r.code)===ol.SUCCESS){t.n=4;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"signal error code: ".concat(i),n),t.a(2,{code:i});case 4:return this._logger.info(tl.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",n),t.a(2,{code:ol.SUCCESS})}},t,this)}))}},{key:"replyChangeMediaType",value:function(e,t){return F(this,void 0,void 0,E().m(function n(){var r,i,a;return E().w(function(n){for(;;)switch(n.n){case 0:if(r=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,"transactionId: ".concat(e),r),Q(e)){n.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"param error, transactionId: not empty string, value: ".concat(e),r),n.a(2,{code:ol.PARAM_ERROR});case 1:if(q(t)){n.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"param error, isAgree: type is boolean, value: ".concat(t),r),n.a(2,{code:ol.PARAM_ERROR});case 2:if(this._callEngine.getLocalMainSession()){n.n=3;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"error code : ".concat(ol.NOT_IN_CALL,", session not exist"),r),n.a(2,{code:ol.NOT_IN_CALL});case 3:return n.n=4,this._callEngine.responseChangeMediaType({transactionId:e,agree:t},r);case 4:if(i=n.v,(a=i.code)===ol.SUCCESS){n.n=5;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"signal error: ".concat(a),r),n.a(2,{code:a});case 5:return this._logger.info(tl.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",r),n.a(2,{code:ol.SUCCESS})}},n,this)}))}},{key:"getCurrentCallSession",value:function(){return this._callEngine.getLocalMainSession()}},{key:"getAvailableCallRecordsFromServer",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i;return E().w(function(e){for(;;)switch(e.n){case 0:return t=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",t),e.n=1,this._callEngine.getOpenCallList(t);case 1:if(n=e.v,r=n.code,i=n.data,r===ol.SUCCESS){e.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,"signal error code: ".concat(r),t),e.a(2,{code:r});case 2:return this._logger.info(tl.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,"success, data: ".concat(JSON.stringify(i)),t),e.a(2,{code:ol.SUCCESS,records:i})}},e,this)}))}},{key:"getCallRecords",value:function(e,t){return F(this,arguments,void 0,function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E().m(function i(){var a,o,s,c;return E().w(function(i){for(;;)switch(i.n){case 0:if(a=n._logger.createTraceId(),n._logger.info(tl.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,"startTimestamp: ".concat(e,", count: ").concat(t),a),W(e)&&e>=0){i.n=1;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"params error, startTimestamp: is a number >= 0, value: ".concat(e),a),i.a(2,{code:ol.PARAM_ERROR});case 1:if(W(t)&&t>0){i.n=2;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"params error, count: is a number >= 0, value: ".concat(t),a),i.a(2,{code:ol.PARAM_ERROR});case 2:return i.n=3,n._callEngine.getCallLogList({timestamp:e,count:t,order:r},a);case 3:if(o=i.v,s=o.code,c=o.data,s===ol.SUCCESS){i.n=4;break}return n._logger.error(tl.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"signal error code: ".concat(s),a),i.a(2,{code:s});case 4:return n._logger.info(tl.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",a),i.a(2,{code:ol.SUCCESS,result:c})}},i)})()})}},{key:"deleteCallRecordsFromServer",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,"callIds: ".concat(e.join(",")),n),Z(e)&&e.every(function(e){return Q(e)})){t.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"params err, callIds: not empty array, callId: not empty string, callIds: ".concat(JSON.stringify(e)),n),t.a(2,{code:ol.PARAM_ERROR});case 1:return t.n=2,this._callEngine.deleteCallLog(e,n);case 2:if(r=t.v,(i=r.code)===ol.SUCCESS){t.n=3;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"signal error code: ".concat(i),n),t.a(2,{code:i});case 3:return this._logger.info(tl.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",n),t.a(2,{code:ol.SUCCESS})}},t,this)}))}},{key:"deleteAllCallRecordsFromServer",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r;return E().w(function(e){for(;;)switch(e.n){case 0:return t=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",t),e.n=1,this._callEngine.removeAllCallLog(t);case 1:if(n=e.v,(r=n.code)===ol.SUCCESS){e.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"signal error code: ".concat(r),t),e.a(2,{code:r});case 2:return this._logger.info(tl.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",t),e.a(2,{code:ol.SUCCESS})}},e,this)}))}},{key:"startCamera",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i,a,o,s,c,u;return E().w(function(e){for(;;)switch(e.n){case 0:return n=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_START_CAMERA_T,"",n),e.n=1,this._rtcModule.getCameraVideoTrack(n);case 1:if(r=e.v,i=r.code,a=r.track,i===ol.SUCCESS){e.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_START_CAMERA_R,"create video track error code: ".concat(i),n),e.a(2,{code:i});case 2:if((null==a?void 0:a.isPublished())||(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==exports.NCCallState.ONCALL){e.n=5;break}return e.n=3,this._rtcModule.publishVideoTrack();case 3:if(o=e.v,(s=o.code)===Ae.SUCCESS){e.n=4;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_START_CAMERA_R,"publish error code: ".concat(s),n),e.a(2,{code:s});case 4:case 7:return this._logger.info(tl.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",n),e.a(2,{code:ol.SUCCESS});case 5:return e.n=6,this._rtcModule.enableVideoTrack(n);case 6:if(c=e.v,(u=c.code)===Ae.SUCCESS||u===ol.SUCCESS){e.n=7;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_START_CAMERA_R,"signal error code: ".concat(u),n),e.a(2,{code:u})}},e,this)}))}},{key:"stopCamera",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i;return E().w(function(e){for(;;)switch(e.n){case 0:return t=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",t),e.n=1,this._rtcModule.disableVideoTrack();case 1:if(n=e.v,r=n.code,i=n.track,r===ol.SUCCESS||r===Ae.SUCCESS){e.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"error code: ".concat(r),t),e.a(2,{code:r});case 2:return this._rtcModule.destroyTrack(i),this._logger.info(tl.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",t),e.a(2,{code:ol.SUCCESS})}},e,this)}))}},{key:"switchCamera",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i,a;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,"cameraId: ".concat(e),n),Q(e)){t.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"param error, cameraId: not empty string, value: ".concat(e),n),t.a(2,{code:ol.PARAM_ERROR});case 1:if(r=this._callEngine.getLocalMainSession()){t.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"errCode: ".concat(ol.NOT_IN_CALL),n),t.a(2,{code:ol.NOT_IN_CALL});case 2:if(r.getMediaType()!==nl.AUDIO){t.n=3;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"errCode: ".concat(ol.NOT_VIDEO_CALL),n),t.a(2,{code:ol.NOT_VIDEO_CALL});case 3:return this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig),t.n=4,this._rtcModule.changeVideoDevice(n);case 4:if(i=t.v,(a=i.code)===ol.SUCCESS){t.n=5;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"call client changeVideoDevice error code: ".concat(a),n),t.a(2,{code:a});case 5:return this._logger.info(tl.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",n),t.a(2,{code:ol.SUCCESS})}},t,this)}))}},{key:"startMicrophone",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r,i,a;return E().w(function(e){for(;;)switch(e.n){case 0:return t=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",t),e.n=1,this._rtcModule.getMicrophoneAudioTrack(t);case 1:if(n=e.v,r=n.code,i=n.track,r===ol.SUCCESS){e.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"create microphone audio track error code: ".concat(r),t),e.a(2,{code:r});case 2:if(i.isOwnerMuted()){e.n=3;break}return this._logger.info(tl.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",t),e.a(2,{code:ol.SUCCESS});case 3:return e.n=4,i.unmute();case 4:if((a=e.v)===Ae.SUCCESS){e.n=5;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"signal error code: ".concat(r),t),e.a(2,{code:a});case 5:return this._logger.info(tl.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",t),e.a(2,{code:ol.SUCCESS})}},e,this)}))}},{key:"stopMicrophone",value:function(){return F(this,void 0,void 0,E().m(function e(){var t,n,r;return E().w(function(e){for(;;)switch(e.n){case 0:return t=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",t),e.n=1,this._rtcModule.disableAudioTrack();case 1:if(n=e.v,(r=n.code)===ol.SUCCESS||r===Ae.SUCCESS){e.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"signal error code: ".concat(r),t),e.a(2,{code:r});case 2:return this._logger.info(tl.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",t),e.a(2,{code:ol.SUCCESS})}},e,this)}))}},{key:"isMicrophoneEnabled",value:function(){var e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}},{key:"setAllRemoteAudioEnable",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n;return E().w(function(t){for(;;)if(0===t.n)return n=this._logger.createTraceId(),t.a(2,this._rtcModule.setAllRemoteAudioEnable(e,n))},t,this)}))}},{key:"getVersion",value:function(){return"26.1.0"}},{key:"getCameras",value:function(){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return e.a(2,_n())},e)}))}},{key:"getMicrophones",value:function(){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return e.a(2,dn())},e)}))}},{key:"getSpeakers",value:function(){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return e.a(2,fn())},e)}))}},{key:"getRTCSessionId",value:function(){return this._rtcModule.getRTCSessionId()}},{key:"switchMicrophone",value:function(e){return F(this,void 0,void 0,E().m(function t(){var n,r,i;return E().w(function(t){for(;;)switch(t.n){case 0:if(n=this._logger.createTraceId(),this._logger.info(tl.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,"microphoneId: ".concat(e),n),Q(e)){t.n=1;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"param error, microphoneId: not empty string, value: ".concat(e),n),t.a(2,{code:ol.PARAM_ERROR});case 1:if(this._callEngine.getLocalMainSession()){t.n=2;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"errCode: ".concat(ol.NOT_IN_CALL),n),t.a(2,{code:ol.NOT_IN_CALL});case 2:return this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig),t.n=3,this._rtcModule.changeAudioDevice(n);case 3:if(r=t.v,(i=r.code)===ol.SUCCESS){t.n=4;break}return this._logger.error(tl.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"call client changeAudioDevice error code: ".concat(i),n),t.a(2,{code:i});case 4:return this._logger.info(tl.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",n),t.a(2,{code:ol.SUCCESS})}},t,this)}))}}]),p_=l(function e(t){c(this,e),Object.defineProperty(this,"_rc",{enumerable:!0,configurable:!0,writable:!0,value:t})},[{key:"setDefaultMicrophoneId",value:function(e){return this._rc.setDefaultMicrophoneId(e),this}},{key:"setBitrate",value:function(e,t){return this._rc.setBitrate(e,t),this}},{key:"setSampleRate",value:function(e){return this._rc.setSampleRate(e),this}},{key:"build",value:function(){return this._rc.build()}}]),E_=l(function e(t){c(this,e),Object.defineProperty(this,"_rc",{enumerable:!0,configurable:!0,writable:!0,value:t})},[{key:"setFrameRate",value:function(e){return this._rc.setFrameRate(e),this}},{key:"setVideoResolution",value:function(e){return this._rc.setVideoResolution(e),this}},{key:"setDefaultCameraId",value:function(e){return this._rc.setDefaultCameraId(e),this}},{key:"setBitrate",value:function(e,t){return this._rc.setBitrate(e,t),this}},{key:"build",value:function(){return this._rc.build()}}]),v_=l(function e(t){c(this,e),Object.defineProperty(this,"_rc",{enumerable:!0,configurable:!0,writable:!0,value:t})},[{key:"setChannelIdHW",value:function(e){return this._rc.setChannelIdHW(e),this}},{key:"setCategoryHW",value:function(e){return this._rc.setCategoryHW(e),this}},{key:"setImportanceHW",value:function(e){return this._rc.setImportanceHW(e),this}},{key:"setImageUrlHW",value:function(e){return this._rc.setImageUrlHW(e),this}},{key:"setFcmChannelId",value:function(e){return this._rc.setFcmChannelId(e),this}},{key:"setFcmCollapseKey",value:function(e){return this._rc.setFcmCollapseKey(e),this}},{key:"setFcmImageUrl",value:function(e){return this._rc.setFcmImageUrl(e),this}},{key:"build",value:function(){var e=this._rc.build();return{channelIdHW:e.channelIdHW,categoryHW:e.categoryHW,importanceHW:e.importanceHW,imageUrlHW:e.imageUrlHW,fcmChannelId:e.fcmChannelId,fcmCollapseKey:e.fcmCollapseKey,fcmImageUrl:e.fcmImageUrl}}}]);exports.NCCallMediaType=void 0,(f_=exports.NCCallMediaType||(exports.NCCallMediaType={}))[f_.AUDIO=0]="AUDIO",f_[f_.VIDEO=1]="VIDEO";var m_=l(function e(t){c(this,e),Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:t})},[{key:"getCallId",value:function(){return this._session.getCallId()}},{key:"getCallState",value:function(){return this._session.getState()}},{key:"getCallType",value:function(){return this._session.getCallType()}},{key:"getMediaType",value:function(){return this._session.getMediaType()===nl.AUDIO?exports.NCCallMediaType.AUDIO:exports.NCCallMediaType.VIDEO}},{key:"getParticipants",value:function(){return this._session.getUserList().map(function(e){return{userId:e.userId,userState:e.state,isCameraEnabled:e.cameraEnable,isMicrophoneEnabled:e.microphoneEnable}})}},{key:"getCallerUserId",value:function(){return this._session.getCreatorUserId()}},{key:"getInvitorUserId",value:function(){return this._session.getInviterUserId()}},{key:"getStartTime",value:function(){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return e.a(2,this._session.getCreateTimestamp())},e,this)}))}},{key:"getDuration",value:function(){return F(this,void 0,void 0,E().m(function e(){return E().w(function(e){for(;;)if(0===e.n)return e.a(2,this._session.getDuration())},e,this)}))}}]);function R_(e){return{logOutputLevel:e.logOutputLevel,isPubTiny:e.isPubLowResolutionStream}}function T_(e){var t=e.mediaType===nl.AUDIO?exports.NCCallMediaType.AUDIO:exports.NCCallMediaType.VIDEO;return{callId:e.callId,callType:e.callType,callDirection:e.callDirection,mediaType:t,callerUserId:e.callerUserId,participants:e.callUserIds,callState:e.sessionState,currentUserState:e.userState,startTime:e.startTimestamp,endTime:e.endTimestamp,duration:e.duration,syncTime:e.syncTimestamp,callEndReason:e.systemState,creationTime:e.createTimestamp}}function I_(e){return e===exports.NCCallMediaType.AUDIO?nl.AUDIO:nl.AUDIO_VIDEO}function S_(e){return e===nl.AUDIO?exports.NCCallMediaType.AUDIO:exports.NCCallMediaType.VIDEO}function C_(e,t,n){var r,i={onReceivedCall:function(t,n){return e.onCallReceived(new m_(t),n)},onCallEnded:function(t,n){return e.onCallEnded(new m_(t),n)},onCallConnected:function(t){return e.onCallConnected(new m_(t))},onReceivedCallPlusSummaryMessage:function(t){var r,i,a=null!==(r=null==n?void 0:n())&&void 0!==r?r:"";null===(i=e.onLocalCallLogReceived)||void 0===i||i.call(e,function(e,t){var n=e.content,r=e.messageDirection,i=e.sentTime,a=n.callId,o=n.callerUserId,s=n.targetId,c=n.callStartTime,u=n.callEndTime,l=n.mediaType,_=n.hangupReason,d=u>0&&c>0?Math.max(0,Math.floor((u-c)/1e3)):0,f=1===r?exports.NCCallDirection.OUT:exports.NCCallDirection.IN,h=l===nl.AUDIO?exports.NCCallMediaType.AUDIO:exports.NCCallMediaType.VIDEO,g="number"==typeof i?i:0;return{callId:a,callType:exports.NCCallType.SINGLE,callDirection:f,mediaType:h,callerUserId:o,participants:[t,s].filter(Boolean),callState:exports.NCCallState.ENDED,currentUserState:exports.NCCallUserState.ENDED,startTime:c,endTime:u,duration:d,syncTime:g,callEndReason:_,creationTime:g}}(t,a))},onReceivedCallRecord:function(t){var n;return null===(n=e.onServerCallLogReceived)||void 0===n?void 0:n.call(e,T_(t))},onReceivedChangeMediaTypeRequest:function(t,n,r){var i;return null===(i=e.onMediaTypeChangeRequestReceived)||void 0===i?void 0:i.call(e,t,n,S_(r))},onReceivedChangeMediaTypeResult:function(t){var n;return null===(n=e.onMediaTypeChangeResultReceived)||void 0===n?void 0:n.call(e,{userId:t.userId,transactionId:t.transactionId,mediaType:S_(t.mediaType),result:t.result})},onRemoteCameraStateChanged:e.onRemoteCameraStateChanged,onRemoteMicrophoneStateChanged:e.onRemoteMicrophoneStateChanged,onRemoteUserInvited:null!==(r=e.onRemoteUserInvited)&&void 0!==r?r:function(){},onRemoteUserStateChanged:e.onRemoteUserStateChanged,onUserMediaAvailable:function(t,n){var r;return null===(r=e.onUserMediaAvailable)||void 0===r?void 0:r.call(e,t,S_(n))},onReceivedCallStartTime:function(t){var n;return null===(n=e.onStartTimeReceived)||void 0===n?void 0:n.call(e,Object.assign(Object.assign({},t),{callType:t.callType}))}};return t&&(i.onUserAudioLevelChanged=t),i}a.VersionManage.add("nexconncall","26.1.0");var L_={tag:"NexconnCall",verify:function(){return!!a.VersionManage.validEngine("26.1.0")||(console.error("The current engine version '".concat(a.VersionManage.getInfo().engine,"' error, plugin-call-plus required engine version at least '","26.1.0","'.")),!1)},setup:function(e){return J(e)}},O_=function(){function e(t,n){c(this,e),Object.defineProperty(this,"_client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callEventsListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_connectionQualityListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rtcPluginContext",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.rtcPluginContext=i.__install__(L_,void 0);var r=i.__install__(rl,void 0),a=R_(n);this.rtcPluginContext.logger.setOutputLevel(n.logOutputLevel),this._client=new g_(t,a,this.rtcPluginContext,r)}return l(e,[{key:"getCurrentRtcUserId",value:function(){var e,t;return null!==(t=null===(e=this.rtcPluginContext)||void 0===e?void 0:e.getCurrentId())&&void 0!==t?t:""}},{key:"applyClientStatusReportListener",value:function(e){var t;this._client.setStatusReportListener((t=e,{onSendPacketLoss:function(){},onReceivePacketLoss:function(){},onSendQualityChanged:function(e){var n;null===(n=t.onSendQualityChanged)||void 0===n||n.call(t,e)},onReceiveQualityChanged:function(e){var n;null===(n=t.onReceiveQualityChanged)||void 0===n||n.call(t,e)}}))}},{key:"applyClientCallPlusEventListener",value:function(e,t){var n=this,r=t?function(e,n){var r;return null===(r=t.onAudioVolumeChanged)||void 0===r?void 0:r.call(t,d({},e,n))}:void 0;this._client.setCallPlusEventListener(C_(e,r,function(){return n.getCurrentRtcUserId()}))}},{key:"setCallEventsListener",value:function(e){this._callEventsListener=e,this.applyClientCallPlusEventListener(e,this._connectionQualityListener)}},{key:"setConnectionQualityListener",value:function(e){this._connectionQualityListener=e,this.applyClientStatusReportListener(e),this._callEventsListener&&this.applyClientCallPlusEventListener(this._callEventsListener,e)}},{key:"setVideoView",value:function(e){return this._client.setVideoView(e.map(function(e){return{userId:e.userId,videoElement:e.videoElement,isTiny:e.useTinyStream}}))}},{key:"removeVideoView",value:function(e){return this._client.removeVideoView(e)}},{key:"playMedia",value:function(e,t){return this._client.playMedia(e,I_(t))}},{key:"createVideoConfigBuilder",value:function(){return new E_(this._client.createVideoConfigBuilder())}},{key:"setVideoConfig",value:function(e){return this._client.setVideoConfig(e)}},{key:"createAudioConfigBuilder",value:function(){return new p_(this._client.createAudioConfigBuilder())}},{key:"createAndroidPushConfigBuilder",value:function(){return new v_(this._client.createAndroidPushConfigBuilder())}},{key:"setAudioConfig",value:function(e){return this._client.setAudioConfig(e)}},{key:"startCall",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:exports.NCCallType.SINGLE,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:exports.NCCallMediaType.VIDEO,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=Array.isArray(e)?e:[e];return this._client.startCall(o,t,I_(n),r,i,a)}},{key:"joinCall",value:function(e){return this._client.joinMultiCall(e)}},{key:"inviteToCall",value:function(e,t,n){return this._client.invite(e,t,n).then(function(e){var t;return Object.assign(Object.assign({},e),{busyUsers:null===(t=e.busyUsers)||void 0===t?void 0:t.map(function(e){return{userId:e.userId,userState:e.state}})})})}},{key:"acceptCall",value:function(e,t){return this._client.accept(e,t)}},{key:"endCall",value:function(e,t){return this._client.hangup(e,t)}},{key:"requestChangeMediaType",value:function(e){return this._client.requestChangeMediaType(I_(e))}},{key:"cancelChangeMediaType",value:function(e){return this._client.cancelChangeMediaType(e)}},{key:"replyChangeMediaType",value:function(e,t){return this._client.replyChangeMediaType(e,t)}},{key:"getCurrentCallSession",value:function(){var e=this._client.getCurrentCallSession();return e?new m_(e):null}},{key:"getOngoingCallLogs",value:function(){return this._client.getAvailableCallRecordsFromServer().then(function(e){var t;return Object.assign(Object.assign({},e),{records:null===(t=e.records)||void 0===t?void 0:t.map(T_)})})}},{key:"getHistoryCallLogs",value:function(e,t,n){return this._client.getCallRecords(e,t,null!=n?n:0).then(function(e){return e.result?Object.assign(Object.assign({},e),{result:{hasMore:e.result.hasMore,callLogList:e.result.list.map(T_),syncTime:e.result.syncTime}}):e})}},{key:"deleteCallLogsForMe",value:function(e){return this._client.deleteCallRecordsFromServer(e)}},{key:"deleteAllCallLogsForMe",value:function(){return this._client.deleteAllCallRecordsFromServer()}},{key:"enableCamera",value:function(e){return e?this._client.startCamera():this._client.stopCamera()}},{key:"switchCamera",value:function(e){return this._client.switchCamera(e)}},{key:"enableMicrophone",value:function(e){return e?this._client.startMicrophone():this._client.stopMicrophone()}},{key:"getAudioInputDevices",value:function(){return this._client.getMicrophones()}},{key:"selectAudioInputDevice",value:function(e){return this._client.switchMicrophone(e)}},{key:"getAudioOutputDevices",value:function(){return this._client.getSpeakers()}},{key:"selectAudioOutputDevice",value:function(e){return this._client.setAudioOutputDeviceId(e)}},{key:"getVersion",value:function(){return this._client.getVersion()}},{key:"getVideoInputDevices",value:function(){return this._client.getCameras()}},{key:"isMicrophoneEnabled",value:function(){return this._client.isMicrophoneEnabled()}}],[{key:"init",value:function(t){var n,r=R_(t),i=(n=r)?X(n)?{isLegal:!0}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};if(!i.isLegal)throw new Error("[CallPlusLib installer steup]".concat(i.msg));return e._instance||(e._instance=new e(Ue,t)),e._instance}}])}();Object.defineProperty(O_,"_instance",{enumerable:!0,configurable:!0,writable:!0,value:null});var y_=Object.freeze({__proto__:null,NCCallEngine:O_,NCCallSession:m_,NCAudioConfigBuilder:p_,NCVideoConfigBuilder:E_,NCAndroidPushConfigBuilder:v_,NCCallCode:al,get NCCallDirection(){return exports.NCCallDirection},get NCCallMediaTypeChangeResult(){return exports.NCCallMediaTypeChangeResult},get NCCallMediaType(){return exports.NCCallMediaType},get NCCallEndReason(){return exports.NCCallEndReason},get NCCallState(){return exports.NCCallState},get NCCallType(){return exports.NCCallType},get NCCallUserState(){return exports.NCCallUserState},get NCCallVideoFrameRate(){return exports.NCCallVideoFrameRate},get NCCallVideoResolution(){return exports.NCCallVideoResolution}});exports.NC=y_,exports.NCAndroidPushConfigBuilder=v_,exports.NCAudioConfigBuilder=p_,exports.NCCallCode=al,exports.NCCallEngine=O_,exports.NCCallSession=m_,exports.NCVideoConfigBuilder=E_;