@byteplus/rtc 4.49.14 → 4.49.16

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.min.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright (c) 2020 The BytePlusRTC project authors. All Rights Reserved.
3
3
  * @brief BytePlusRTC Advance API
4
- * version: 4.49.14
4
+ * version: 4.49.16
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).BytePlusRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function t(e){var t,n,i,o=2;for("undefined"!=typeof Symbol&&(n=Symbol.asyncIterator,i=Symbol.iterator);o--;){if(n&&null!=(t=e[n]))return t.call(e);if(i&&null!=(t=e[i]))return new r(t.call(e));n="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}function r(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(r=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new r(e)}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(){o=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(w){u=function(e,t,r){return e[t]=r}}function d(e,t,r,i){var o=t&&t.prototype instanceof f?t:f,a=Object.create(o.prototype),s=new A(i||[]);return n(a,"_invoke",{value:b(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(w){return{type:"throw",arg:w}}}e.wrap=d;var h={};function f(){}function p(){}function v(){}var _={};u(_,a,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(R([])));y&&y!==t&&r.call(y,a)&&(_=y);var g=v.prototype=f.prototype=Object.create(_);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function i(n,o,a,s){var c=l(e[n],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function b(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=k(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function k(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method))return h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function R(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return p.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=u(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},S(E.prototype),u(E.prototype,s,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new E(d(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(g),u(g,c,"Generator"),u(g,a,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=R,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:R(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function a(e){return(a="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})(e)}function s(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void r(u)}s.done?t(c):Promise.resolve(c).then(n,i)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){s(o,n,i,a,c,"next",e)}function c(e){s(o,n,i,a,c,"throw",e)}a(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(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&&v(e,t)}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function _(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(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 m(e)}function g(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=p(e);if(t){var i=p(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return y(this,r)}}function S(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}function E(){return E="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=S(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},E.apply(this,arguments)}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(c){s=!0,i=c}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||T(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 k(e){return function(e){if(Array.isArray(e))return I(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||T(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 T(e,t){if(e){if("string"==typeof e)return I(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function A(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=T(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},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 o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}var R=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}(R||{}),C=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(C||{}),w=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(w||{}),O=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(O||{}),x=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(x||{}),N=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(N||{}),P=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(P||{}),D=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(D||{}),M=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e}(M||{}),L=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(L||{}),U=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(U||{}),V=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(V||{}),F=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(F||{}),B=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(B||{}),j=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(j||{}),G=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(G||{}),H=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(H||{}),z=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(z||{}),K=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(K||{}),X=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(X||{}),W=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e}(W||{}),q=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(q||{}),Y=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(Y||{}),J=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(J||{}),Q=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(Q||{}),Z=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Z||{}),$=function(e){return e.H264="H264",e.H265="H265",e}($||{}),ee=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:R,AudioSourceType:C,UserOfflineReason:w,ChannelProfile:O,SubscribeMode:x,SubscribeState:N,PublishState:P,MirrorMode:D,VideoRenderMode:M,StreamIndex:L,MediaType:U,StreamRemoveReason:V,ConnectionState:F,MirrorType:B,LogChannel:j,USER_ONLINE_STATUS:G,PublicStreamType:H,PublicInterpolationMode:z,SubscribeFallbackOption:K,RemoteUserPriority:X,NetworkQuality:W,FallbackOrRecoverReason:q,RoomProfileType:Y,AudioProfileType:J,RTCAutoPlayPolicy:Q,AAC_PROFILE:Z,TRANSCODING_VIDEO_CODEC:$},Symbol.toStringTag,{value:"Module"})),te=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(te||{}),re=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(re||{}),ne=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(ne||{}),ie=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:te,AudioMixingType:re,AudioMixingState:ne},Symbol.toStringTag,{value:"Module"})),oe=function(e){return e.onTrackEnded="onTrackEnded",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onServerParamsSetResult="onServerParamsSetResult",e}(oe||{}),ae="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},se=function(e){return e&&e.Math==Math&&e},ce=se("object"==typeof globalThis&&globalThis)||se("object"==typeof window&&window)||se("object"==typeof self&&self)||se("object"==typeof ae&&ae)||function(){return this}()||Function("return this")(),ue={},de=function(e){try{return!!e()}catch(t){return!0}},le=!de((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),he=!de((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),fe=he,pe=Function.prototype.call,ve=fe?pe.bind(pe):function(){return pe.apply(pe,arguments)},_e={},me={}.propertyIsEnumerable,ye=Object.getOwnPropertyDescriptor,ge=ye&&!me.call({1:2},1);_e.f=ge?function(e){var t=ye(this,e);return!!t&&t.enumerable}:me;var Se,Ee,be=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},ke=he,Te=Function.prototype,Ie=Te.call,Ae=ke&&Te.bind.bind(Ie,Ie),Re=ke?Ae:function(e){return function(){return Ie.apply(e,arguments)}},Ce=Re,we=Ce({}.toString),Oe=Ce("".slice),xe=function(e){return Oe(we(e),8,-1)},Ne=de,Pe=xe,De=Object,Me=Re("".split),Le=Ne((function(){return!De("z").propertyIsEnumerable(0)}))?function(e){return"String"==Pe(e)?Me(e,""):De(e)}:De,Ue=function(e){return null==e},Ve=Ue,Fe=TypeError,Be=function(e){if(Ve(e))throw Fe("Can't call method on "+e);return e},je=Le,Ge=Be,He=function(e){return je(Ge(e))},ze="object"==typeof document&&document.all,Ke={all:ze,IS_HTMLDDA:void 0===ze&&void 0!==ze},Xe=Ke.all,We=Ke.IS_HTMLDDA?function(e){return"function"==typeof e||e===Xe}:function(e){return"function"==typeof e},qe=We,Ye=Ke.all,Je=Ke.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:qe(e)||e===Ye}:function(e){return"object"==typeof e?null!==e:qe(e)},Qe=ce,Ze=We,$e=function(e){return Ze(e)?e:void 0},et=function(e,t){return arguments.length<2?$e(Qe[e]):Qe[e]&&Qe[e][t]},tt=Re({}.isPrototypeOf),rt=et("navigator","userAgent")||"",nt=ce,it=rt,ot=nt.process,at=nt.Deno,st=ot&&ot.versions||at&&at.version,ct=st&&st.v8;ct&&(Ee=(Se=ct.split("."))[0]>0&&Se[0]<4?1:+(Se[0]+Se[1])),!Ee&&it&&(!(Se=it.match(/Edge\/(\d+)/))||Se[1]>=74)&&(Se=it.match(/Chrome\/(\d+)/))&&(Ee=+Se[1]);var ut=Ee,dt=ut,lt=de,ht=!!Object.getOwnPropertySymbols&&!lt((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&dt&&dt<41})),ft=ht&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,pt=et,vt=We,_t=tt,mt=Object,yt=ft?function(e){return"symbol"==typeof e}:function(e){var t=pt("Symbol");return vt(t)&&_t(t.prototype,mt(e))},gt=String,St=function(e){try{return gt(e)}catch(t){return"Object"}},Et=We,bt=St,kt=TypeError,Tt=function(e){if(Et(e))return e;throw kt(bt(e)+" is not a function")},It=Tt,At=Ue,Rt=function(e,t){var r=e[t];return At(r)?void 0:It(r)},Ct=ve,wt=We,Ot=Je,xt=TypeError,Nt={exports:{}},Pt=ce,Dt=Object.defineProperty,Mt=function(e,t){try{Dt(Pt,e,{value:t,configurable:!0,writable:!0})}catch(r){Pt[e]=t}return t},Lt=Mt,Ut="__core-js_shared__",Vt=ce[Ut]||Lt(Ut,{}),Ft=Vt;(Nt.exports=function(e,t){return Ft[e]||(Ft[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Bt=Be,jt=Object,Gt=function(e){return jt(Bt(e))},Ht=Gt,zt=Re({}.hasOwnProperty),Kt=Object.hasOwn||function(e,t){return zt(Ht(e),t)},Xt=Re,Wt=0,qt=Math.random(),Yt=Xt(1..toString),Jt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Yt(++Wt+qt,36)},Qt=ce,Zt=Nt.exports,$t=Kt,er=Jt,tr=ht,rr=ft,nr=Zt("wks"),ir=Qt.Symbol,or=ir&&ir.for,ar=rr?ir:ir&&ir.withoutSetter||er,sr=function(e){if(!$t(nr,e)||!tr&&"string"!=typeof nr[e]){var t="Symbol."+e;tr&&$t(ir,e)?nr[e]=ir[e]:nr[e]=rr&&or?or(t):ar(t)}return nr[e]},cr=ve,ur=Je,dr=yt,lr=Rt,hr=function(e,t){var r,n;if("string"===t&&wt(r=e.toString)&&!Ot(n=Ct(r,e)))return n;if(wt(r=e.valueOf)&&!Ot(n=Ct(r,e)))return n;if("string"!==t&&wt(r=e.toString)&&!Ot(n=Ct(r,e)))return n;throw xt("Can't convert object to primitive value")},fr=TypeError,pr=sr("toPrimitive"),vr=function(e,t){if(!ur(e)||dr(e))return e;var r,n=lr(e,pr);if(n){if(void 0===t&&(t="default"),r=cr(n,e,t),!ur(r)||dr(r))return r;throw fr("Can't convert object to primitive value")}return void 0===t&&(t="number"),hr(e,t)},_r=vr,mr=yt,yr=function(e){var t=_r(e,"string");return mr(t)?t:t+""},gr=Je,Sr=ce.document,Er=gr(Sr)&&gr(Sr.createElement),br=function(e){return Er?Sr.createElement(e):{}},kr=br,Tr=!le&&!de((function(){return 7!=Object.defineProperty(kr("div"),"a",{get:function(){return 7}}).a})),Ir=le,Ar=ve,Rr=_e,Cr=be,wr=He,Or=yr,xr=Kt,Nr=Tr,Pr=Object.getOwnPropertyDescriptor;ue.f=Ir?Pr:function(e,t){if(e=wr(e),t=Or(t),Nr)try{return Pr(e,t)}catch(r){}if(xr(e,t))return Cr(!Ar(Rr.f,e,t),e[t])};var Dr={},Mr=le&&de((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Lr=Je,Ur=String,Vr=TypeError,Fr=function(e){if(Lr(e))return e;throw Vr(Ur(e)+" is not an object")},Br=le,jr=Tr,Gr=Mr,Hr=Fr,zr=yr,Kr=TypeError,Xr=Object.defineProperty,Wr=Object.getOwnPropertyDescriptor,qr="enumerable",Yr="configurable",Jr="writable";Dr.f=Br?Gr?function(e,t,r){if(Hr(e),t=zr(t),Hr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&Jr in r&&!r.writable){var n=Wr(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:Yr in r?r.configurable:n.configurable,enumerable:qr in r?r.enumerable:n.enumerable,writable:!1})}return Xr(e,t,r)}:Xr:function(e,t,r){if(Hr(e),t=zr(t),Hr(r),jr)try{return Xr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw Kr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var Qr=Dr,Zr=be,$r=le?function(e,t,r){return Qr.f(e,t,Zr(1,r))}:function(e,t,r){return e[t]=r,e},en={exports:{}},tn=le,rn=Kt,nn=Function.prototype,on=tn&&Object.getOwnPropertyDescriptor,an=rn(nn,"name"),sn={EXISTS:an,PROPER:an&&"something"===function(){}.name,CONFIGURABLE:an&&(!tn||tn&&on(nn,"name").configurable)},cn=We,un=Vt,dn=Re(Function.toString);cn(un.inspectSource)||(un.inspectSource=function(e){return dn(e)});var ln,hn,fn,pn=un.inspectSource,vn=We,_n=ce.WeakMap,mn=vn(_n)&&/native code/.test(String(_n)),yn=Nt.exports,gn=Jt,Sn=yn("keys"),En=function(e){return Sn[e]||(Sn[e]=gn(e))},bn={},kn=mn,Tn=ce,In=Je,An=$r,Rn=Kt,Cn=Vt,wn=En,On=bn,xn="Object already initialized",Nn=Tn.TypeError,Pn=Tn.WeakMap;if(kn||Cn.state){var Dn=Cn.state||(Cn.state=new Pn);Dn.get=Dn.get,Dn.has=Dn.has,Dn.set=Dn.set,ln=function(e,t){if(Dn.has(e))throw Nn(xn);return t.facade=e,Dn.set(e,t),t},hn=function(e){return Dn.get(e)||{}},fn=function(e){return Dn.has(e)}}else{var Mn=wn("state");On[Mn]=!0,ln=function(e,t){if(Rn(e,Mn))throw Nn(xn);return t.facade=e,An(e,Mn,t),t},hn=function(e){return Rn(e,Mn)?e[Mn]:{}},fn=function(e){return Rn(e,Mn)}}var Ln={set:ln,get:hn,has:fn,enforce:function(e){return fn(e)?hn(e):ln(e,{})},getterFor:function(e){return function(t){var r;if(!In(t)||(r=hn(t)).type!==e)throw Nn("Incompatible receiver, "+e+" required");return r}}},Un=de,Vn=We,Fn=Kt,Bn=le,jn=sn.CONFIGURABLE,Gn=pn,Hn=Ln.enforce,zn=Ln.get,Kn=Object.defineProperty,Xn=Bn&&!Un((function(){return 8!==Kn((function(){}),"length",{value:8}).length})),Wn=String(String).split("String"),qn=en.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Fn(e,"name")||jn&&e.name!==t)&&(Bn?Kn(e,"name",{value:t,configurable:!0}):e.name=t),Xn&&r&&Fn(r,"arity")&&e.length!==r.arity&&Kn(e,"length",{value:r.arity});try{r&&Fn(r,"constructor")&&r.constructor?Bn&&Kn(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(i){}var n=Hn(e);return Fn(n,"source")||(n.source=Wn.join("string"==typeof t?t:"")),e};Function.prototype.toString=qn((function(){return Vn(this)&&zn(this).source||Gn(this)}),"toString");var Yn=We,Jn=Dr,Qn=en.exports,Zn=Mt,$n=function(e,t,r,n){n||(n={});var i=n.enumerable,o=void 0!==n.name?n.name:t;if(Yn(r)&&Qn(r,o,n),n.global)i?e[t]=r:Zn(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch(a){}i?e[t]=r:Jn.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},ei={},ti=Math.ceil,ri=Math.floor,ni=Math.trunc||function(e){var t=+e;return(t>0?ri:ti)(t)},ii=function(e){var t=+e;return t!=t||0===t?0:ni(t)},oi=ii,ai=Math.max,si=Math.min,ci=function(e,t){var r=oi(e);return r<0?ai(r+t,0):si(r,t)},ui=ii,di=Math.min,li=function(e){return e>0?di(ui(e),9007199254740991):0},hi=li,fi=function(e){return hi(e.length)},pi=He,vi=ci,_i=fi,mi=function(e){return function(t,r,n){var i,o=pi(t),a=_i(o),s=vi(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},yi={includes:mi(!0),indexOf:mi(!1)},gi=Kt,Si=He,Ei=yi.indexOf,bi=bn,ki=Re([].push),Ti=function(e,t){var r,n=Si(e),i=0,o=[];for(r in n)!gi(bi,r)&&gi(n,r)&&ki(o,r);for(;t.length>i;)gi(n,r=t[i++])&&(~Ei(o,r)||ki(o,r));return o},Ii=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ai=Ti,Ri=Ii.concat("length","prototype");ei.f=Object.getOwnPropertyNames||function(e){return Ai(e,Ri)};var Ci={};Ci.f=Object.getOwnPropertySymbols;var wi=et,Oi=ei,xi=Ci,Ni=Fr,Pi=Re([].concat),Di=wi("Reflect","ownKeys")||function(e){var t=Oi.f(Ni(e)),r=xi.f;return r?Pi(t,r(e)):t},Mi=Kt,Li=Di,Ui=ue,Vi=Dr,Fi=function(e,t,r){for(var n=Li(t),i=Vi.f,o=Ui.f,a=0;a<n.length;a++){var s=n[a];Mi(e,s)||r&&Mi(r,s)||i(e,s,o(t,s))}},Bi=de,ji=We,Gi=/#|\.prototype\./,Hi=function(e,t){var r=Ki[zi(e)];return r==Wi||r!=Xi&&(ji(t)?Bi(t):!!t)},zi=Hi.normalize=function(e){return String(e).replace(Gi,".").toLowerCase()},Ki=Hi.data={},Xi=Hi.NATIVE="N",Wi=Hi.POLYFILL="P",qi=Hi,Yi=ce,Ji=ue.f,Qi=$r,Zi=$n,$i=Mt,eo=Fi,to=qi,ro=function(e,t){var r,n,i,o,a,s=e.target,c=e.global,u=e.stat;if(r=c?Yi:u?Yi[s]||$i(s,{}):(Yi[s]||{}).prototype)for(n in t){if(o=t[n],i=e.dontCallGetSet?(a=Ji(r,n))&&a.value:r[n],!to(c?n:s+(u?".":"#")+n,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;eo(o,i)}(e.sham||i&&i.sham)&&Qi(o,"sham",!0),Zi(r,n,o,e)}},no=xe,io=Array.isArray||function(e){return"Array"==no(e)},oo=TypeError,ao=function(e){if(e>9007199254740991)throw oo("Maximum allowed index exceeded");return e},so=yr,co=Dr,uo=be,lo=function(e,t,r){var n=so(t);n in e?co.f(e,n,uo(0,r)):e[n]=r},ho={};ho[sr("toStringTag")]="z";var fo="[object z]"===String(ho),po=fo,vo=We,_o=xe,mo=sr("toStringTag"),yo=Object,go="Arguments"==_o(function(){return arguments}()),So=po?_o:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=yo(e),mo))?r:go?_o(t):"Object"==(n=_o(t))&&vo(t.callee)?"Arguments":n},Eo=Re,bo=de,ko=We,To=So,Io=pn,Ao=function(){},Ro=[],Co=et("Reflect","construct"),wo=/^\s*(?:class|function)\b/,Oo=Eo(wo.exec),xo=!wo.exec(Ao),No=function(e){if(!ko(e))return!1;try{return Co(Ao,Ro,e),!0}catch(t){return!1}},Po=function(e){if(!ko(e))return!1;switch(To(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return xo||!!Oo(wo,Io(e))}catch(t){return!0}};Po.sham=!0;var Do=!Co||bo((function(){var e;return No(No.call)||!No(Object)||!No((function(){e=!0}))||e}))?Po:No,Mo=io,Lo=Do,Uo=Je,Vo=sr("species"),Fo=Array,Bo=function(e){var t;return Mo(e)&&(t=e.constructor,(Lo(t)&&(t===Fo||Mo(t.prototype))||Uo(t)&&null===(t=t[Vo]))&&(t=void 0)),void 0===t?Fo:t},jo=function(e,t){return new(Bo(e))(0===t?0:t)},Go=de,Ho=ut,zo=sr("species"),Ko=function(e){return Ho>=51||!Go((function(){var t=[];return(t.constructor={})[zo]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Xo=ro,Wo=de,qo=io,Yo=Je,Jo=Gt,Qo=fi,Zo=ao,$o=lo,ea=jo,ta=Ko,ra=ut,na=sr("isConcatSpreadable"),ia=ra>=51||!Wo((function(){var e=[];return e[na]=!1,e.concat()[0]!==e})),oa=ta("concat"),aa=function(e){if(!Yo(e))return!1;var t=e[na];return void 0!==t?!!t:qo(e)};Xo({target:"Array",proto:!0,arity:1,forced:!ia||!oa},{concat:function(e){var t,r,n,i,o,a=Jo(this),s=ea(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(aa(o=-1===t?a:arguments[t]))for(i=Qo(o),Zo(c+i),r=0;r<i;r++,c++)r in o&&$o(s,c,o[r]);else Zo(c+1),$o(s,c++,o);return s.length=c,s}});var sa=So,ca=fo?{}.toString:function(){return"[object "+sa(this)+"]"};fo||$n(Object.prototype,"toString",ca,{unsafe:!0});var ua={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},da=br("span").classList,la=da&&da.constructor&&da.constructor.prototype,ha=la===Object.prototype?void 0:la,fa=xe,pa=Re,va=function(e){if("Function"===fa(e))return pa(e)},_a=Tt,ma=he,ya=va(va.bind),ga=function(e,t){return _a(e),void 0===t?e:ma?ya(e,t):function(){return e.apply(t,arguments)}},Sa=ga,Ea=Le,ba=Gt,ka=fi,Ta=jo,Ia=Re([].push),Aa=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,f,p=ba(c),v=Ea(p),_=Sa(u,d),m=ka(v),y=0,g=l||Ta,S=t?g(c,m):r||a?g(c,0):void 0;m>y;y++)if((s||y in v)&&(f=_(h=v[y],y,p),e))if(t)S[y]=f;else if(f)switch(e){case 3:return!0;case 5:return h;case 6:return y;case 2:Ia(S,h)}else switch(e){case 4:return!1;case 7:Ia(S,h)}return o?-1:n||i?i:S}},Ra={forEach:Aa(0),map:Aa(1),filter:Aa(2),some:Aa(3),every:Aa(4),find:Aa(5),findIndex:Aa(6),filterReject:Aa(7)},Ca=de,wa=function(e,t){var r=[][e];return!!r&&Ca((function(){r.call(null,t||function(){return 1},1)}))},Oa=Ra.forEach,xa=wa("forEach")?[].forEach:function(e){return Oa(this,e,arguments.length>1?arguments[1]:void 0)},Na=ce,Pa=ua,Da=ha,Ma=xa,La=$r,Ua=function(e){if(e&&e.forEach!==Ma)try{La(e,"forEach",Ma)}catch(t){e.forEach=Ma}};for(var Va in Pa)Pa[Va]&&Ua(Na[Va]&&Na[Va].prototype);Ua(Da);var Fa={},Ba=Ti,ja=Ii,Ga=Object.keys||function(e){return Ba(e,ja)},Ha=le,za=Mr,Ka=Dr,Xa=Fr,Wa=He,qa=Ga;Fa.f=Ha&&!za?Object.defineProperties:function(e,t){Xa(e);for(var r,n=Wa(t),i=qa(t),o=i.length,a=0;o>a;)Ka.f(e,r=i[a++],n[r]);return e};var Ya,Ja=et("document","documentElement"),Qa=Fr,Za=Fa,$a=Ii,es=bn,ts=Ja,rs=br,ns=En("IE_PROTO"),is=function(){},os=function(e){return"<script>"+e+"</"+"script>"},as=function(e){e.write(os("")),e.close();var t=e.parentWindow.Object;return e=null,t},ss=function(){try{Ya=new ActiveXObject("htmlfile")}catch(n){}var e,t;ss="undefined"!=typeof document?document.domain&&Ya?as(Ya):((t=rs("iframe")).style.display="none",ts.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(os("document.F=Object")),e.close(),e.F):as(Ya);for(var r=$a.length;r--;)delete ss.prototype[$a[r]];return ss()};es[ns]=!0;var cs=Object.create||function(e,t){var r;return null!==e?(is.prototype=Qa(e),r=new is,is.prototype=null,r[ns]=e):r=ss(),void 0===t?r:Za.f(r,t)},us=sr,ds=cs,ls=Dr.f,hs=us("unscopables"),fs=Array.prototype;null==fs[hs]&&ls(fs,hs,{configurable:!0,value:ds(null)});var ps=function(e){fs[hs][e]=!0},vs=yi.includes,_s=ps;ro({target:"Array",proto:!0,forced:de((function(){return!Array(1).includes()}))},{includes:function(e){return vs(this,e,arguments.length>1?arguments[1]:void 0)}}),_s("includes");var ms=Je,ys=xe,gs=sr("match"),Ss=function(e){var t;return ms(e)&&(void 0!==(t=e[gs])?!!t:"RegExp"==ys(e))},Es=Ss,bs=TypeError,ks=function(e){if(Es(e))throw bs("The method doesn't accept regular expressions");return e},Ts=So,Is=String,As=function(e){if("Symbol"===Ts(e))throw TypeError("Cannot convert a Symbol value to a string");return Is(e)},Rs=sr("match"),Cs=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Rs]=!1,"/./"[e](t)}catch(n){}}return!1},ws=ro,Os=ks,xs=Be,Ns=As,Ps=Cs,Ds=Re("".indexOf);ws({target:"String",proto:!0,forced:!Ps("includes")},{includes:function(e){return!!~Ds(Ns(xs(this)),Ns(Os(e)),arguments.length>1?arguments[1]:void 0)}});var Ms,Ls,Us=Fr,Vs=function(){var e=Us(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Fs=de,Bs=ce.RegExp,js=Fs((function(){var e=Bs("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),Gs=js||Fs((function(){return!Bs("a","y").sticky})),Hs=js||Fs((function(){var e=Bs("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),zs={BROKEN_CARET:Hs,MISSED_STICKY:Gs,UNSUPPORTED_Y:js},Ks=de,Xs=ce.RegExp,Ws=Ks((function(){var e=Xs(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),qs=de,Ys=ce.RegExp,Js=qs((function(){var e=Ys("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),Qs=ve,Zs=Re,$s=As,ec=Vs,tc=zs,rc=Nt.exports,nc=cs,ic=Ln.get,oc=Ws,ac=Js,sc=rc("native-string-replace",String.prototype.replace),cc=RegExp.prototype.exec,uc=cc,dc=Zs("".charAt),lc=Zs("".indexOf),hc=Zs("".replace),fc=Zs("".slice),pc=(Ls=/b*/g,Qs(cc,Ms=/a/,"a"),Qs(cc,Ls,"a"),0!==Ms.lastIndex||0!==Ls.lastIndex),vc=tc.BROKEN_CARET,_c=void 0!==/()??/.exec("")[1];(pc||_c||vc||oc||ac)&&(uc=function(e){var t,r,n,i,o,a,s,c=this,u=ic(c),d=$s(e),l=u.raw;if(l)return l.lastIndex=c.lastIndex,t=Qs(uc,l,d),c.lastIndex=l.lastIndex,t;var h=u.groups,f=vc&&c.sticky,p=Qs(ec,c),v=c.source,_=0,m=d;if(f&&(p=hc(p,"y",""),-1===lc(p,"g")&&(p+="g"),m=fc(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==dc(d,c.lastIndex-1))&&(v="(?: "+v+")",m=" "+m,_++),r=new RegExp("^(?:"+v+")",p)),_c&&(r=new RegExp("^"+v+"$(?!\\s)",p)),pc&&(n=c.lastIndex),i=Qs(cc,f?r:c,m),f?i?(i.input=fc(i.input,_),i[0]=fc(i[0],_),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:pc&&i&&(c.lastIndex=c.global?i.index+i[0].length:n),_c&&i&&i.length>1&&Qs(sc,i[0],r,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(i[o]=void 0)})),i&&h)for(i.groups=a=nc(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=i[s[1]];return i});var mc=uc;ro({target:"RegExp",proto:!0,forced:/./.exec!==mc},{exec:mc});var yc=va,gc=$n,Sc=mc,Ec=de,bc=sr,kc=$r,Tc=bc("species"),Ic=RegExp.prototype,Ac=function(e,t,r,n){var i=bc(e),o=!Ec((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),a=o&&!Ec((function(){var t=!1,r=/a/;return"split"===e&&((r={}).constructor={},r.constructor[Tc]=function(){return r},r.flags="",r[i]=/./[i]),r.exec=function(){return t=!0,null},r[i](""),!t}));if(!o||!a||r){var s=yc(/./[i]),c=t(i,""[e],(function(e,t,r,n,i){var a=yc(e),c=t.exec;return c===Sc||c===Ic.exec?o&&!i?{done:!0,value:s(t,r,n)}:{done:!0,value:a(r,t,n)}:{done:!1}}));gc(String.prototype,e,c[0]),gc(Ic,i,c[1])}n&&kc(Ic[i],"sham",!0)},Rc=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},Cc=ve,wc=Fr,Oc=We,xc=xe,Nc=mc,Pc=TypeError,Dc=function(e,t){var r=e.exec;if(Oc(r)){var n=Cc(r,e,t);return null!==n&&wc(n),n}if("RegExp"===xc(e))return Cc(Nc,e,t);throw Pc("RegExp#exec called on incompatible receiver")},Mc=ve,Lc=Fr,Uc=Ue,Vc=Be,Fc=Rc,Bc=As,jc=Rt,Gc=Dc;Ac("search",(function(e,t,r){return[function(t){var r=Vc(this),n=Uc(t)?void 0:jc(t,e);return n?Mc(n,t,r):new RegExp(t)[e](Bc(r))},function(e){var n=Lc(this),i=Bc(e),o=r(t,n,i);if(o.done)return o.value;var a=n.lastIndex;Fc(a,0)||(n.lastIndex=0);var s=Gc(n,i);return Fc(n.lastIndex,a)||(n.lastIndex=a),null===s?-1:s.index}]}));var Hc=he,zc=Function.prototype,Kc=zc.apply,Xc=zc.call,Wc="object"==typeof Reflect&&Reflect.apply||(Hc?Xc.bind(Kc):function(){return Xc.apply(Kc,arguments)}),qc=Re([].slice),Yc=ro,Jc=et,Qc=Wc,Zc=ve,$c=Re,eu=de,tu=io,ru=We,nu=Je,iu=yt,ou=qc,au=ht,su=Jc("JSON","stringify"),cu=$c(/./.exec),uu=$c("".charAt),du=$c("".charCodeAt),lu=$c("".replace),hu=$c(1..toString),fu=/[\uD800-\uDFFF]/g,pu=/^[\uD800-\uDBFF]$/,vu=/^[\uDC00-\uDFFF]$/,_u=!au||eu((function(){var e=Jc("Symbol")();return"[null]"!=su([e])||"{}"!=su({a:e})||"{}"!=su(Object(e))})),mu=eu((function(){return'"\\udf06\\ud834"'!==su("\udf06\ud834")||'"\\udead"'!==su("\udead")})),yu=function(e,t){var r=ou(arguments),n=t;if((nu(t)||void 0!==e)&&!iu(e))return tu(t)||(t=function(e,t){if(ru(n)&&(t=Zc(n,this,e,t)),!iu(t))return t}),r[1]=t,Qc(su,null,r)},gu=function(e,t,r){var n=uu(r,t-1),i=uu(r,t+1);return cu(pu,e)&&!cu(vu,i)||cu(vu,e)&&!cu(pu,n)?"\\u"+hu(du(e,0),16):e};su&&Yc({target:"JSON",stat:!0,arity:3,forced:_u||mu},{stringify:function(e,t,r){var n=ou(arguments),i=Qc(_u?yu:su,null,n);return mu&&"string"==typeof i?lu(i,fu,gu):i}});var Su=Ra.map;ro({target:"Array",proto:!0,forced:!Ko("map")},{map:function(e){return Su(this,e,arguments.length>1?arguments[1]:void 0)}});var Eu=Re,bu=ii,ku=As,Tu=Be,Iu=Eu("".charAt),Au=Eu("".charCodeAt),Ru=Eu("".slice),Cu=function(e){return function(t,r){var n,i,o=ku(Tu(t)),a=bu(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Au(o,a))<55296||n>56319||a+1===s||(i=Au(o,a+1))<56320||i>57343?e?Iu(o,a):n:e?Ru(o,a,a+2):i-56320+(n-55296<<10)+65536}},wu={codeAt:Cu(!1),charAt:Cu(!0)},Ou=wu.charAt,xu=function(e,t,r){return t+(r?Ou(e,t).length:1)},Nu=ve,Pu=Fr,Du=Ue,Mu=li,Lu=As,Uu=Be,Vu=Rt,Fu=xu,Bu=Dc;Ac("match",(function(e,t,r){return[function(t){var r=Uu(this),n=Du(t)?void 0:Vu(t,e);return n?Nu(n,t,r):new RegExp(t)[e](Lu(r))},function(e){var n=Pu(this),i=Lu(e),o=r(t,n,i);if(o.done)return o.value;if(!n.global)return Bu(n,i);var a=n.unicode;n.lastIndex=0;for(var s,c=[],u=0;null!==(s=Bu(n,i));){var d=Lu(s[0]);c[u]=d,""===d&&(n.lastIndex=Fu(i,Mu(n.lastIndex),a)),u++}return 0===u?null:c}]}));var ju="\t\n\v\f\r                 \u2028\u2029\ufeff",Gu=Be,Hu=As,zu=Re("".replace),Ku="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Xu=RegExp("^"+Ku+Ku+"*"),Wu=RegExp(Ku+Ku+"*$"),qu=function(e){return function(t){var r=Hu(Gu(t));return 1&e&&(r=zu(r,Xu,"")),2&e&&(r=zu(r,Wu,"")),r}},Yu={start:qu(1),end:qu(2),trim:qu(3)},Ju=ce,Qu=de,Zu=Re,$u=As,ed=Yu.trim,td=ju,rd=Ju.parseInt,nd=Ju.Symbol,id=nd&&nd.iterator,od=/^[+-]?0x/i,ad=Zu(od.exec),sd=8!==rd(td+"08")||22!==rd(td+"0x16")||id&&!Qu((function(){rd(Object(id))}))?function(e,t){var r=ed($u(e));return rd(r,t>>>0||(ad(od,r)?16:10))}:rd;ro({global:!0,forced:parseInt!=sd},{parseInt:sd});var cd,ud,dd,ld={},hd=!de((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),fd=Kt,pd=We,vd=Gt,_d=hd,md=En("IE_PROTO"),yd=Object,gd=yd.prototype,Sd=_d?yd.getPrototypeOf:function(e){var t=vd(e);if(fd(t,md))return t[md];var r=t.constructor;return pd(r)&&t instanceof r?r.prototype:t instanceof yd?gd:null},Ed=de,bd=We,kd=Je,Td=Sd,Id=$n,Ad=sr("iterator"),Rd=!1;[].keys&&("next"in(dd=[].keys())?(ud=Td(Td(dd)))!==Object.prototype&&(cd=ud):Rd=!0),(!kd(cd)||Ed((function(){var e={};return cd[Ad].call(e)!==e})))&&(cd={}),bd(cd[Ad])||Id(cd,Ad,(function(){return this}));var Cd={IteratorPrototype:cd,BUGGY_SAFARI_ITERATORS:Rd},wd=Dr.f,Od=Kt,xd=sr("toStringTag"),Nd=function(e,t,r){e&&!r&&(e=e.prototype),e&&!Od(e,xd)&&wd(e,xd,{configurable:!0,value:t})},Pd=Cd.IteratorPrototype,Dd=cs,Md=be,Ld=Nd,Ud=ld,Vd=function(){return this},Fd=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Dd(Pd,{next:Md(+!n,r)}),Ld(e,i,!1),Ud[i]=Vd,e},Bd=We,jd=String,Gd=TypeError,Hd=Re,zd=Fr,Kd=function(e){if("object"==typeof e||Bd(e))return e;throw Gd("Can't set "+jd(e)+" as a prototype")},Xd=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Hd(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return zd(r),Kd(n),t?e(r,n):r.__proto__=n,r}}():void 0),Wd=ro,qd=ve,Yd=We,Jd=Fd,Qd=Sd,Zd=Xd,$d=Nd,el=$r,tl=$n,rl=ld,nl=sn.PROPER,il=sn.CONFIGURABLE,ol=Cd.IteratorPrototype,al=Cd.BUGGY_SAFARI_ITERATORS,sl=sr("iterator"),cl="keys",ul="values",dl="entries",ll=function(){return this},hl=function(e,t,r,n,i,o,a){Jd(r,t,n);var s,c,u,d=function(e){if(e===i&&v)return v;if(!al&&e in f)return f[e];switch(e){case cl:case ul:case dl:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,f=e.prototype,p=f[sl]||f["@@iterator"]||i&&f[i],v=!al&&p||d(i),_="Array"==t&&f.entries||p;if(_&&(s=Qd(_.call(new e)))!==Object.prototype&&s.next&&(Qd(s)!==ol&&(Zd?Zd(s,ol):Yd(s[sl])||tl(s,sl,ll)),$d(s,l,!0)),nl&&i==ul&&p&&p.name!==ul&&(il?el(f,"name",ul):(h=!0,v=function(){return qd(p,this)})),i)if(c={values:d(ul),keys:o?v:d(cl),entries:d(dl)},a)for(u in c)(al||h||!(u in f))&&tl(f,u,c[u]);else Wd({target:t,proto:!0,forced:al||h},c);return f[sl]!==v&&tl(f,sl,v,{name:i}),rl[t]=v,c},fl=function(e,t){return{value:e,done:t}},pl=He,vl=ps,_l=ld,ml=Ln,yl=Dr.f,gl=hl,Sl=fl,El=le,bl="Array Iterator",kl=ml.set,Tl=ml.getterFor(bl),Il=gl(Array,"Array",(function(e,t){kl(this,{type:bl,target:pl(e),index:0,kind:t})}),(function(){var e=Tl(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,Sl(void 0,!0)):Sl("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values"),Al=_l.Arguments=_l.Array;if(vl("keys"),vl("values"),vl("entries"),El&&"values"!==Al.name)try{yl(Al,"name",{value:"values"})}catch(TQ){}var Rl={exports:{}},Cl={},wl=ci,Ol=fi,xl=lo,Nl=Array,Pl=Math.max,Dl=function(e,t,r){for(var n=Ol(e),i=wl(t,n),o=wl(void 0===r?n:r,n),a=Nl(Pl(o-i,0)),s=0;i<o;i++,s++)xl(a,s,e[i]);return a.length=s,a},Ml=xe,Ll=He,Ul=ei.f,Vl=Dl,Fl="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Cl.f=function(e){return Fl&&"Window"==Ml(e)?function(e){try{return Ul(e)}catch(TQ){return Vl(Fl)}}(e):Ul(Ll(e))};var Bl=de((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),jl=de,Gl=Je,Hl=xe,zl=Bl,Kl=Object.isExtensible,Xl=jl((function(){Kl(1)}))||zl?function(e){return!!Gl(e)&&((!zl||"ArrayBuffer"!=Hl(e))&&(!Kl||Kl(e)))}:Kl,Wl=!de((function(){return Object.isExtensible(Object.preventExtensions({}))})),ql=ro,Yl=Re,Jl=bn,Ql=Je,Zl=Kt,$l=Dr.f,eh=ei,th=Cl,rh=Xl,nh=Wl,ih=!1,oh=Jt("meta"),ah=0,sh=function(e){$l(e,oh,{value:{objectID:"O"+ah++,weakData:{}}})},ch=Rl.exports={enable:function(){ch.enable=function(){},ih=!0;var e=eh.f,t=Yl([].splice),r={};r[oh]=1,e(r).length&&(eh.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===oh){t(n,i,1);break}return n},ql({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:th.f}))},fastKey:function(e,t){if(!Ql(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Zl(e,oh)){if(!rh(e))return"F";if(!t)return"E";sh(e)}return e[oh].objectID},getWeakData:function(e,t){if(!Zl(e,oh)){if(!rh(e))return!0;if(!t)return!1;sh(e)}return e[oh].weakData},onFreeze:function(e){return nh&&ih&&rh(e)&&!Zl(e,oh)&&sh(e),e}};Jl[oh]=!0;var uh=ld,dh=sr("iterator"),lh=Array.prototype,hh=function(e){return void 0!==e&&(uh.Array===e||lh[dh]===e)},fh=So,ph=Rt,vh=Ue,_h=ld,mh=sr("iterator"),yh=function(e){if(!vh(e))return ph(e,mh)||ph(e,"@@iterator")||_h[fh(e)]},gh=ve,Sh=Tt,Eh=Fr,bh=St,kh=yh,Th=TypeError,Ih=function(e,t){var r=arguments.length<2?kh(e):t;if(Sh(r))return Eh(gh(r,e));throw Th(bh(e)+" is not iterable")},Ah=ve,Rh=Fr,Ch=Rt,wh=function(e,t,r){var n,i;Rh(e);try{if(!(n=Ch(e,"return"))){if("throw"===t)throw r;return r}n=Ah(n,e)}catch(TQ){i=!0,n=TQ}if("throw"===t)throw r;if(i)throw n;return Rh(n),r},Oh=ga,xh=ve,Nh=Fr,Ph=St,Dh=hh,Mh=fi,Lh=tt,Uh=Ih,Vh=yh,Fh=wh,Bh=TypeError,jh=function(e,t){this.stopped=e,this.result=t},Gh=jh.prototype,Hh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),f=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),v=Oh(t,d),_=function(e){return n&&Fh(n,"normal",e),new jh(!0,e)},m=function(e){return l?(Nh(e),p?v(e[0],e[1],_):v(e[0],e[1])):p?v(e,_):v(e)};if(h)n=e.iterator;else if(f)n=e;else{if(!(i=Vh(e)))throw Bh(Ph(e)+" is not iterable");if(Dh(i)){for(o=0,a=Mh(e);a>o;o++)if((s=m(e[o]))&&Lh(Gh,s))return s;return new jh(!1)}n=Uh(e,i)}for(c=h?e.next:n.next;!(u=xh(c,n)).done;){try{s=m(u.value)}catch(TQ){Fh(n,"throw",TQ)}if("object"==typeof s&&s&&Lh(Gh,s))return s}return new jh(!1)},zh=tt,Kh=TypeError,Xh=function(e,t){if(zh(t,e))return e;throw Kh("Incorrect invocation")},Wh=sr("iterator"),qh=!1;try{var Yh=0,Jh={next:function(){return{done:!!Yh++}},return:function(){qh=!0}};Jh[Wh]=function(){return this},Array.from(Jh,(function(){throw 2}))}catch(TQ){}var Qh=function(e,t){if(!t&&!qh)return!1;var r=!1;try{var n={};n[Wh]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(TQ){}return r},Zh=We,$h=Je,ef=Xd,tf=function(e,t,r){var n,i;return ef&&Zh(n=t.constructor)&&n!==r&&$h(i=n.prototype)&&i!==r.prototype&&ef(e,i),e},rf=ro,nf=ce,of=Re,af=qi,sf=$n,cf=Rl.exports,uf=Hh,df=Xh,lf=We,hf=Ue,ff=Je,pf=de,vf=Qh,_f=Nd,mf=tf,yf=function(e,t,r){var n=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),o=n?"set":"add",a=nf[e],s=a&&a.prototype,c=a,u={},d=function(e){var t=of(s[e]);sf(s,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!ff(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return i&&!ff(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!ff(e))&&t(this,0===e?0:e)}:function(e,r){return t(this,0===e?0:e,r),this})};if(af(e,!lf(a)||!(i||s.forEach&&!pf((function(){(new a).entries().next()})))))c=r.getConstructor(t,e,n,o),cf.enable();else if(af(e,!0)){var l=new c,h=l[o](i?{}:-0,1)!=l,f=pf((function(){l.has(1)})),p=vf((function(e){new a(e)})),v=!i&&pf((function(){for(var e=new a,t=5;t--;)e[o](t,t);return!e.has(-0)}));p||((c=t((function(e,t){df(e,s);var r=mf(new a,e,c);return hf(t)||uf(t,r[o],{that:r,AS_ENTRIES:n}),r}))).prototype=s,s.constructor=c),(f||v)&&(d("delete"),d("has"),n&&d("get")),(v||h)&&d(o),i&&s.clear&&delete s.clear}return u[e]=c,rf({global:!0,constructor:!0,forced:c!=a},u),_f(c,e),i||r.setStrong(c,e,n),c},gf=$n,Sf=function(e,t,r){for(var n in t)gf(e,n,t[n],r);return e},Ef=et,bf=Dr,kf=le,Tf=sr("species"),If=function(e){var t=Ef(e),r=bf.f;kf&&t&&!t[Tf]&&r(t,Tf,{configurable:!0,get:function(){return this}})},Af=Dr.f,Rf=cs,Cf=Sf,wf=ga,Of=Xh,xf=Ue,Nf=Hh,Pf=hl,Df=fl,Mf=If,Lf=le,Uf=Rl.exports.fastKey,Vf=Ln.set,Ff=Ln.getterFor,Bf={getConstructor:function(e,t,r,n){var i=e((function(e,i){Of(e,o),Vf(e,{type:t,index:Rf(null),first:void 0,last:void 0,size:0}),Lf||(e.size=0),xf(i)||Nf(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=Ff(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=Uf(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),Lf?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=Uf(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return Cf(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,Lf?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),Lf?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=wf(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),Cf(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),Lf&&Af(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=Ff(t),o=Ff(n);Pf(e,t,(function(e,t){Vf(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?Df("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,Df(void 0,!0))}),r?"entries":"values",!r,!0),Mf(t)}};yf("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Bf);var jf=wu.charAt,Gf=As,Hf=Ln,zf=hl,Kf=fl,Xf="String Iterator",Wf=Hf.set,qf=Hf.getterFor(Xf);zf(String,"String",(function(e){Wf(this,{type:Xf,string:Gf(e),index:0})}),(function(){var e,t=qf(this),r=t.string,n=t.index;return n>=r.length?Kf(void 0,!0):(e=jf(r,n),t.index+=e.length,Kf(e,!1))}));var Yf=ce,Jf=ua,Qf=ha,Zf=Il,$f=$r,ep=sr,tp=ep("iterator"),rp=ep("toStringTag"),np=Zf.values,ip=function(e,t){if(e){if(e[tp]!==np)try{$f(e,tp,np)}catch(TQ){e[tp]=np}if(e[rp]||$f(e,rp,t),Jf[t])for(var r in Zf)if(e[r]!==Zf[r])try{$f(e,r,Zf[r])}catch(TQ){e[r]=Zf[r]}}};for(var op in Jf)ip(Yf[op]&&Yf[op].prototype,op);ip(Qf,"DOMTokenList");var ap=Gt,sp=Ga;ro({target:"Object",stat:!0,forced:de((function(){sp(1)}))},{keys:function(e){return sp(ap(e))}});var cp=ro,up=le,dp=Dr.f;cp({target:"Object",stat:!0,forced:Object.defineProperty!==dp,sham:!up},{defineProperty:dp});var lp=Dr.f,hp=function(e,t,r){r in e||lp(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},fp=As,pp=function(e,t){return void 0===e?arguments.length<2?"":t:fp(e)},vp=Je,_p=$r,mp=Error,yp=Re("".replace),gp=String(mp("zxcasd").stack),Sp=/\n\s*at [^:]*:[^\n]*/,Ep=Sp.test(gp),bp=function(e,t){if(Ep&&"string"==typeof e&&!mp.prepareStackTrace)for(;t--;)e=yp(e,Sp,"");return e},kp=be,Tp=!de((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",kp(1,7)),7!==e.stack)})),Ip=et,Ap=Kt,Rp=$r,Cp=tt,wp=Xd,Op=Fi,xp=hp,Np=tf,Pp=pp,Dp=function(e,t){vp(t)&&"cause"in t&&_p(e,"cause",t.cause)},Mp=bp,Lp=Tp,Up=le,Vp=ro,Fp=Wc,Bp=function(e,t,r,n){var i="stackTraceLimit",o=n?2:1,a=e.split("."),s=a[a.length-1],c=Ip.apply(null,a);if(c){var u=c.prototype;if(Ap(u,"cause")&&delete u.cause,!r)return c;var d=Ip("Error"),l=t((function(e,t){var r=Pp(n?t:e,void 0),i=n?new c(e):new c;return void 0!==r&&Rp(i,"message",r),Lp&&Rp(i,"stack",Mp(i.stack,2)),this&&Cp(u,this)&&Np(i,this,l),arguments.length>o&&Dp(i,arguments[o]),i}));l.prototype=u,"Error"!==s?wp?wp(l,d):Op(l,d,{name:!0}):Up&&i in c&&(xp(l,c,i),xp(l,c,"prepareStackTrace")),Op(l,c);try{u.name!==s&&Rp(u,"name",s),u.constructor=l}catch(TQ){}return l}},jp="WebAssembly",Gp=ce.WebAssembly,Hp=7!==Error("e",{cause:7}).cause,zp=function(e,t){var r={};r[e]=Bp(e,t,Hp),Vp({global:!0,constructor:!0,arity:1,forced:Hp},r)},Kp=function(e,t){if(Gp&&Gp[e]){var r={};r[e]=Bp("WebAssembly."+e,t,Hp),Vp({target:jp,stat:!0,constructor:!0,arity:1,forced:Hp},r)}};zp("Error",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("EvalError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("RangeError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("ReferenceError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("SyntaxError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("TypeError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("URIError",(function(e){return function(t){return Fp(e,this,arguments)}})),Kp("CompileError",(function(e){return function(t){return Fp(e,this,arguments)}})),Kp("LinkError",(function(e){return function(t){return Fp(e,this,arguments)}})),Kp("RuntimeError",(function(e){return function(t){return Fp(e,this,arguments)}}));var Xp=Tt,Wp=Gt,qp=Le,Yp=fi,Jp=TypeError,Qp=function(e){return function(t,r,n,i){Xp(r);var o=Wp(t),a=qp(o),s=Yp(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw Jp("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},Zp={left:Qp(!1),right:Qp(!0)},$p="process"==xe(ce.process),ev=Zp.left,tv=ut,rv=$p;ro({target:"Array",proto:!0,forced:!wa("reduce")||!rv&&tv>79&&tv<83},{reduce:function(e){var t=arguments.length;return ev(this,e,t,t>1?arguments[1]:void 0)}});var nv=le,iv=Re,ov=ve,av=de,sv=Ga,cv=Ci,uv=_e,dv=Gt,lv=Le,hv=Object.assign,fv=Object.defineProperty,pv=iv([].concat),vv=!hv||av((function(){if(nv&&1!==hv({b:1},hv(fv({},"a",{enumerable:!0,get:function(){fv(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=hv({},e)[r]||sv(hv({},t)).join("")!=n}))?function(e,t){for(var r=dv(e),n=arguments.length,i=1,o=cv.f,a=uv.f;n>i;)for(var s,c=lv(arguments[i++]),u=o?pv(sv(c),o(c)):sv(c),d=u.length,l=0;d>l;)s=u[l++],nv&&!ov(a,c,s)||(r[s]=c[s]);return r}:hv,_v=vv;ro({target:"Object",stat:!0,arity:2,forced:Object.assign!==_v},{assign:_v});var mv,yv=ro,gv=va,Sv=ue.f,Ev=li,bv=As,kv=ks,Tv=Be,Iv=Cs,Av=gv("".endsWith),Rv=gv("".slice),Cv=Math.min,wv=Iv("endsWith");yv({target:"String",proto:!0,forced:!!(wv||(mv=Sv(String.prototype,"endsWith"),!mv||mv.writable))&&!wv},{endsWith:function(e){var t=bv(Tv(this));kv(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Cv(Ev(r),n),o=bv(e);return Av?Av(t,o,i):Rv(t,i-o.length,i)===o}});var Ov=le,xv=io,Nv=TypeError,Pv=Object.getOwnPropertyDescriptor,Dv=Ov&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(TQ){return TQ instanceof TypeError}}()?function(e,t){if(xv(e)&&!Pv(e,"length").writable)throw Nv("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},Mv=ro,Lv=Gt,Uv=fi,Vv=Dv,Fv=ao,Bv=de((function(){return 4294967297!==[].push.call({length:4294967296},1)})),jv=!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(TQ){return TQ instanceof TypeError}}();Mv({target:"Array",proto:!0,arity:1,forced:Bv||jv},{push:function(e){var t=Lv(this),r=Uv(t),n=arguments.length;Fv(r+n);for(var i=0;i<n;i++)t[r]=arguments[i],r++;return Vv(t,r),r}});var Gv=!0,Hv=!0;function zv(e,t,r){var n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function Kv(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get:function(){return this["_on"+t]},set:function(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 Xv(e){return"boolean"!=typeof e?new Error("Argument type: "+a(e)+". Please use a boolean."):(Gv=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Wv(e){return"boolean"!=typeof e?new Error("Argument type: "+a(e)+". Please use a boolean."):(Hv=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function qv(){if("object"===("undefined"==typeof window?"undefined":a(window))){if(Gv)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Yv(e,t){Hv&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Jv(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=zv(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=zv(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=zv(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function Qv(e){return"[object Object]"===Object.prototype.toString.call(e)}function Zv(e){return Qv(e)?Object.keys(e).reduce((function(t,r){var n=Qv(e[r]),i=n?Zv(e[r]):e[r],o=n&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,h({},r,i))}),{}):e}function $v(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((function(n){n.endsWith("Id")?$v(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach((function(t){$v(e,e.get(t),r)}))})))}function e_(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&$v(e,r,i)}))})),i}var t_=ro,r_=Ra.find,n_=ps,i_="find",o_=!0;i_ in[]&&Array(1).find((function(){o_=!1})),t_({target:"Array",proto:!0,forced:o_},{find:function(e){return r_(this,e,arguments.length>1?arguments[1]:void 0)}}),n_(i_);var a_=ro,s_=io,c_=Do,u_=Je,d_=ci,l_=fi,h_=He,f_=lo,p_=sr,v_=qc,__=Ko("slice"),m_=p_("species"),y_=Array,g_=Math.max;a_({target:"Array",proto:!0,forced:!__},{slice:function(e,t){var r,n,i,o=h_(this),a=l_(o),s=d_(e,a),c=d_(void 0===t?a:t,a);if(s_(o)&&(r=o.constructor,(c_(r)&&(r===y_||s_(r.prototype))||u_(r)&&null===(r=r[m_]))&&(r=void 0),r===y_||void 0===r))return v_(o,s,c);for(n=new(void 0===r?y_:r)(g_(c-s,0)),i=0;s<c;s++,i++)s in o&&f_(n,i,o[s]);return n.length=i,n}});var S_=ro,E_=yi.indexOf,b_=wa,k_=va([].indexOf),T_=!!k_&&1/k_([1],1,-0)<0,I_=b_("indexOf");S_({target:"Array",proto:!0,forced:T_||!I_},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return T_?k_(this,e,t)||0:E_(this,e,t)}});var A_=St,R_=TypeError,C_=function(e,t){if(!delete e[t])throw R_("Cannot delete property "+A_(t)+" of "+A_(e))},w_=ro,O_=Gt,x_=ci,N_=ii,P_=fi,D_=Dv,M_=ao,L_=jo,U_=lo,V_=C_,F_=Ko("splice"),B_=Math.max,j_=Math.min;w_({target:"Array",proto:!0,forced:!F_},{splice:function(e,t){var r,n,i,o,a,s,c=O_(this),u=P_(c),d=x_(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=j_(B_(N_(t),0),u-d)),M_(u+r-n),i=L_(c,n),o=0;o<n;o++)(a=d+o)in c&&U_(i,o,c[a]);if(i.length=n,r<n){for(o=d;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:V_(c,s);for(o=u;o>u-n+r;o--)V_(c,o-1)}else if(r>n)for(o=u-n;o>d;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:V_(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return D_(c,u-n+r),i}});var G_,H_,z_,K_,X_=Do,W_=St,q_=TypeError,Y_=function(e){if(X_(e))return e;throw q_(W_(e)+" is not a constructor")},J_=Fr,Q_=Y_,Z_=Ue,$_=sr("species"),em=function(e,t){var r,n=J_(e).constructor;return void 0===n||Z_(r=J_(n)[$_])?t:Q_(r)},tm=TypeError,rm=function(e,t){if(e<t)throw tm("Not enough arguments");return e},nm=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),im=ce,om=Wc,am=ga,sm=We,cm=Kt,um=de,dm=Ja,lm=qc,hm=br,fm=rm,pm=nm,vm=$p,_m=im.setImmediate,mm=im.clearImmediate,ym=im.process,gm=im.Dispatch,Sm=im.Function,Em=im.MessageChannel,bm=im.String,km=0,Tm={},Im="onreadystatechange";try{G_=im.location}catch(TQ){}var Am=function(e){if(cm(Tm,e)){var t=Tm[e];delete Tm[e],t()}},Rm=function(e){return function(){Am(e)}},Cm=function(e){Am(e.data)},wm=function(e){im.postMessage(bm(e),G_.protocol+"//"+G_.host)};_m&&mm||(_m=function(e){fm(arguments.length,1);var t=sm(e)?e:Sm(e),r=lm(arguments,1);return Tm[++km]=function(){om(t,void 0,r)},H_(km),km},mm=function(e){delete Tm[e]},vm?H_=function(e){ym.nextTick(Rm(e))}:gm&&gm.now?H_=function(e){gm.now(Rm(e))}:Em&&!pm?(K_=(z_=new Em).port2,z_.port1.onmessage=Cm,H_=am(K_.postMessage,K_)):im.addEventListener&&sm(im.postMessage)&&!im.importScripts&&G_&&"file:"!==G_.protocol&&!um(wm)?(H_=wm,im.addEventListener("message",Cm,!1)):H_=Im in hm("script")?function(e){dm.appendChild(hm("script")).onreadystatechange=function(){dm.removeChild(this),Am(e)}}:function(e){setTimeout(Rm(e),0)});var Om,xm,Nm,Pm,Dm,Mm,Lm,Um,Vm={set:_m,clear:mm},Fm=ce,Bm=/ipad|iphone|ipod/i.test(rt)&&void 0!==Fm.Pebble,jm=/web0s(?!.*chrome)/i.test(rt),Gm=ce,Hm=ga,zm=ue.f,Km=Vm.set,Xm=nm,Wm=Bm,qm=jm,Ym=$p,Jm=Gm.MutationObserver||Gm.WebKitMutationObserver,Qm=Gm.document,Zm=Gm.process,$m=Gm.Promise,ey=zm(Gm,"queueMicrotask"),ty=ey&&ey.value;ty||(Om=function(){var e,t;for(Ym&&(e=Zm.domain)&&e.exit();xm;){t=xm.fn,xm=xm.next;try{t()}catch(TQ){throw xm?Pm():Nm=void 0,TQ}}Nm=void 0,e&&e.enter()},Xm||Ym||qm||!Jm||!Qm?!Wm&&$m&&$m.resolve?((Lm=$m.resolve(void 0)).constructor=$m,Um=Hm(Lm.then,Lm),Pm=function(){Um(Om)}):Ym?Pm=function(){Zm.nextTick(Om)}:(Km=Hm(Km,Gm),Pm=function(){Km(Om)}):(Dm=!0,Mm=Qm.createTextNode(""),new Jm(Om).observe(Mm,{characterData:!0}),Pm=function(){Mm.data=Dm=!Dm}));var ry=ty||function(e){var t={fn:e,next:void 0};Nm&&(Nm.next=t),xm||(xm=t,Pm()),Nm=t},ny=ce,iy=function(e){try{return{error:!1,value:e()}}catch(TQ){return{error:!0,value:TQ}}},oy=function(){this.head=null,this.tail=null};oy.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var ay=oy,sy=ce.Promise,cy="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,uy=!cy&&!$p&&"object"==typeof window&&"object"==typeof document,dy=ce,ly=sy,hy=We,fy=qi,py=pn,vy=sr,_y=uy,my=cy,yy=ut;ly&&ly.prototype;var gy=vy("species"),Sy=!1,Ey=hy(dy.PromiseRejectionEvent),by={CONSTRUCTOR:fy("Promise",(function(){var e=py(ly),t=e!==String(ly);if(!t&&66===yy)return!0;if(!yy||yy<51||!/native code/.test(e)){var r=new ly((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[gy]=n,!(Sy=r.then((function(){}))instanceof n))return!0}return!t&&(_y||my)&&!Ey})),REJECTION_EVENT:Ey,SUBCLASSING:Sy},ky={},Ty=Tt,Iy=TypeError,Ay=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Iy("Bad Promise constructor");t=e,r=n})),this.resolve=Ty(t),this.reject=Ty(r)};ky.f=function(e){return new Ay(e)};var Ry,Cy,wy,Oy=ro,xy=$p,Ny=ce,Py=ve,Dy=$n,My=Xd,Ly=Nd,Uy=If,Vy=Tt,Fy=We,By=Je,jy=Xh,Gy=em,Hy=Vm.set,zy=ry,Ky=function(e,t){var r=ny.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},Xy=iy,Wy=ay,qy=Ln,Yy=sy,Jy=ky,Qy="Promise",Zy=by.CONSTRUCTOR,$y=by.REJECTION_EVENT,eg=by.SUBCLASSING,tg=qy.getterFor(Qy),rg=qy.set,ng=Yy&&Yy.prototype,ig=Yy,og=ng,ag=Ny.TypeError,sg=Ny.document,cg=Ny.process,ug=Jy.f,dg=ug,lg=!!(sg&&sg.createEvent&&Ny.dispatchEvent),hg="unhandledrejection",fg=function(e){var t;return!(!By(e)||!Fy(t=e.then))&&t},pg=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&gg(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(ag("Promise-chain cycle")):(n=fg(r))?Py(n,r,c,u):c(r)):u(o)}catch(TQ){d&&!i&&d.exit(),u(TQ)}},vg=function(e,t){e.notified||(e.notified=!0,zy((function(){for(var r,n=e.reactions;r=n.get();)pg(r,e);e.notified=!1,t&&!e.rejection&&mg(e)})))},_g=function(e,t,r){var n,i;lg?((n=sg.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),Ny.dispatchEvent(n)):n={promise:t,reason:r},!$y&&(i=Ny["on"+e])?i(n):e===hg&&Ky("Unhandled promise rejection",r)},mg=function(e){Py(Hy,Ny,(function(){var t,r=e.facade,n=e.value;if(yg(e)&&(t=Xy((function(){xy?cg.emit("unhandledRejection",n,r):_g(hg,r,n)})),e.rejection=xy||yg(e)?2:1,t.error))throw t.value}))},yg=function(e){return 1!==e.rejection&&!e.parent},gg=function(e){Py(Hy,Ny,(function(){var t=e.facade;xy?cg.emit("rejectionHandled",t):_g("rejectionhandled",t,e.value)}))},Sg=function(e,t,r){return function(n){e(t,n,r)}},Eg=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,vg(e,!0))},bg=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw ag("Promise can't be resolved itself");var n=fg(t);n?zy((function(){var r={done:!1};try{Py(n,t,Sg(bg,r,e),Sg(Eg,r,e))}catch(TQ){Eg(r,TQ,e)}})):(e.value=t,e.state=1,vg(e,!1))}catch(TQ){Eg({done:!1},TQ,e)}}};if(Zy&&(og=(ig=function(e){jy(this,og),Vy(e),Py(Ry,this);var t=tg(this);try{e(Sg(bg,t),Sg(Eg,t))}catch(TQ){Eg(t,TQ)}}).prototype,(Ry=function(e){rg(this,{type:Qy,done:!1,notified:!1,parent:!1,reactions:new Wy,rejection:!1,state:0,value:void 0})}).prototype=Dy(og,"then",(function(e,t){var r=tg(this),n=ug(Gy(this,ig));return r.parent=!0,n.ok=!Fy(e)||e,n.fail=Fy(t)&&t,n.domain=xy?cg.domain:void 0,0==r.state?r.reactions.add(n):zy((function(){pg(n,r)})),n.promise})),Cy=function(){var e=new Ry,t=tg(e);this.promise=e,this.resolve=Sg(bg,t),this.reject=Sg(Eg,t)},Jy.f=ug=function(e){return e===ig||undefined===e?new Cy(e):dg(e)},Fy(Yy)&&ng!==Object.prototype)){wy=ng.then,eg||Dy(ng,"then",(function(e,t){var r=this;return new ig((function(e,t){Py(wy,r,e,t)})).then(e,t)}),{unsafe:!0});try{delete ng.constructor}catch(TQ){}My&&My(ng,og)}Oy({global:!0,constructor:!0,wrap:!0,forced:Zy},{Promise:ig}),Ly(ig,Qy,!1),Uy(Qy);var kg=sy,Tg=by.CONSTRUCTOR||!Qh((function(e){kg.all(e).then(void 0,(function(){}))})),Ig=ve,Ag=Tt,Rg=ky,Cg=iy,wg=Hh;ro({target:"Promise",stat:!0,forced:Tg},{all:function(e){var t=this,r=Rg.f(t),n=r.resolve,i=r.reject,o=Cg((function(){var r=Ag(t.resolve),o=[],a=0,s=1;wg(e,(function(e){var c=a++,u=!1;s++,Ig(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var Og=ro,xg=by.CONSTRUCTOR,Ng=sy,Pg=et,Dg=We,Mg=$n,Lg=Ng&&Ng.prototype;if(Og({target:"Promise",proto:!0,forced:xg,real:!0},{catch:function(e){return this.then(void 0,e)}}),Dg(Ng)){var Ug=Pg("Promise").prototype.catch;Lg.catch!==Ug&&Mg(Lg,"catch",Ug,{unsafe:!0})}var Vg=ve,Fg=Tt,Bg=ky,jg=iy,Gg=Hh;ro({target:"Promise",stat:!0,forced:Tg},{race:function(e){var t=this,r=Bg.f(t),n=r.reject,i=jg((function(){var i=Fg(t.resolve);Gg(e,(function(e){Vg(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var Hg=ve,zg=ky;ro({target:"Promise",stat:!0,forced:by.CONSTRUCTOR},{reject:function(e){var t=zg.f(this);return Hg(t.reject,void 0,e),t.promise}});var Kg=Fr,Xg=Je,Wg=ky,qg=function(e,t){if(Kg(e),Xg(t)&&t.constructor===e)return t;var r=Wg.f(e);return(0,r.resolve)(t),r.promise},Yg=ro,Jg=by.CONSTRUCTOR,Qg=qg;et("Promise"),Yg({target:"Promise",stat:!0,forced:Jg},{resolve:function(e){return Qg(this,e)}});var Zg=$p,$g=en.exports,eS=Dr,tS=function(e,t,r){return r.get&&$g(r.get,t,{getter:!0}),r.set&&$g(r.set,t,{setter:!0}),eS.f(e,t,r)},rS=le,nS=de,iS=Fr,oS=cs,aS=pp,sS=Error.prototype.toString,cS=nS((function(){if(rS){var e=oS(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==sS.call(e))return!0}return"2: 1"!==sS.call({message:1,name:2})||"Error"!==sS.call({})}))?function(){var e=iS(this),t=aS(e.name,"Error"),r=aS(e.message);return t?r?t+": "+r:t:r}:sS,uS={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}},dS=ro,lS=function(e){try{if(Zg)return Function('return require("'+e+'")')()}catch(TQ){}},hS=et,fS=de,pS=cs,vS=be,_S=Dr.f,mS=$n,yS=tS,gS=Kt,SS=Xh,ES=Fr,bS=cS,kS=pp,TS=uS,IS=bp,AS=Ln,RS=le,CS="DOMException",wS="DATA_CLONE_ERR",OS=hS("Error"),xS=hS(CS)||function(){try{(new(hS("MessageChannel")||lS("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(TQ){if(TQ.name==wS&&25==TQ.code)return TQ.constructor}}(),NS=xS&&xS.prototype,PS=OS.prototype,DS=AS.set,MS=AS.getterFor(CS),LS="stack"in OS(CS),US=function(e){return gS(TS,e)&&TS[e].m?TS[e].c:0},VS=function(){SS(this,FS);var e=arguments.length,t=kS(e<1?void 0:arguments[0]),r=kS(e<2?void 0:arguments[1],"Error"),n=US(r);if(DS(this,{type:CS,name:r,message:t,code:n}),RS||(this.name=r,this.message=t,this.code=n),LS){var i=OS(t);i.name=CS,_S(this,"stack",vS(1,IS(i.stack,1)))}},FS=VS.prototype=pS(PS),BS=function(e){return{enumerable:!0,configurable:!0,get:e}},jS=function(e){return BS((function(){return MS(this)[e]}))};RS&&(yS(FS,"code",jS("code")),yS(FS,"message",jS("message")),yS(FS,"name",jS("name"))),_S(FS,"constructor",vS(1,VS));var GS=fS((function(){return!(new xS instanceof OS)})),HS=GS||fS((function(){return PS.toString!==bS||"2: 1"!==String(new xS(1,2))})),zS=GS||fS((function(){return 25!==new xS(1,"DataCloneError").code}));GS||25!==xS.DATA_CLONE_ERR||NS.DATA_CLONE_ERR;dS({global:!0,constructor:!0,forced:GS},{DOMException:GS?VS:xS});var KS=hS(CS),XS=KS.prototype;for(var WS in HS&&xS===KS&&mS(XS,"toString",bS),zS&&RS&&xS===KS&&yS(XS,"code",BS((function(){return US(ES(this).name)}))),TS)if(gS(TS,WS)){var qS=TS[WS],YS=qS.s,JS=vS(6,qS.c);gS(KS,YS)||_S(KS,YS,JS),gS(XS,YS)||_S(XS,YS,JS)}var QS=ro,ZS=ce,$S=et,eE=be,tE=Dr.f,rE=Kt,nE=Xh,iE=tf,oE=pp,aE=uS,sE=bp,cE=le,uE="DOMException",dE=$S("Error"),lE=$S(uE),hE=function(){nE(this,fE);var e=arguments.length,t=oE(e<1?void 0:arguments[0]),r=oE(e<2?void 0:arguments[1],"Error"),n=new lE(t,r),i=dE(t);return i.name=uE,tE(n,"stack",eE(1,sE(i.stack,1))),iE(n,this,hE),n},fE=hE.prototype=lE.prototype,pE="stack"in dE(uE),vE="stack"in new lE(1,2),_E=lE&&cE&&Object.getOwnPropertyDescriptor(ZS,uE),mE=!(!_E||_E.writable&&_E.configurable),yE=pE&&!mE&&!vE;QS({global:!0,constructor:!0,forced:yE},{DOMException:yE?hE:lE});var gE=$S(uE),SE=gE.prototype;if(SE.constructor!==gE)for(var EE in tE(SE,"constructor",eE(1,gE)),aE)if(rE(aE,EE)){var bE=aE[EE],kE=bE.s;rE(gE,kE)||tE(gE,kE,eE(6,bE.c))}var TE="DOMException";Nd(et(TE),TE);var IE=Ra.filter;ro({target:"Array",proto:!0,forced:!Ko("filter")},{filter:function(e){return IE(this,e,arguments.length>1?arguments[1]:void 0)}});var AE=Re,RE=Gt,CE=Math.floor,wE=AE("".charAt),OE=AE("".replace),xE=AE("".slice),NE=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,PE=/\$([$&'`]|\d{1,2})/g,DE=Wc,ME=ve,LE=Re,UE=Ac,VE=de,FE=Fr,BE=We,jE=Ue,GE=ii,HE=li,zE=As,KE=Be,XE=xu,WE=Rt,qE=function(e,t,r,n,i,o){var a=r+e.length,s=n.length,c=PE;return void 0!==i&&(i=RE(i),c=NE),OE(o,c,(function(o,c){var u;switch(wE(c,0)){case"$":return"$";case"&":return e;case"`":return xE(t,0,r);case"'":return xE(t,a);case"<":u=i[xE(c,1,-1)];break;default:var d=+c;if(0===d)return o;if(d>s){var l=CE(d/10);return 0===l?o:l<=s?void 0===n[l-1]?wE(c,1):n[l-1]+wE(c,1):o}u=n[d-1]}return void 0===u?"":u}))},YE=Dc,JE=sr("replace"),QE=Math.max,ZE=Math.min,$E=LE([].concat),eb=LE([].push),tb=LE("".indexOf),rb=LE("".slice),nb="$0"==="a".replace(/./,"$0"),ib=!!/./[JE]&&""===/./[JE]("a","$0"),ob=!VE((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));UE("replace",(function(e,t,r){var n=ib?"$":"$0";return[function(e,r){var n=KE(this),i=jE(e)?void 0:WE(e,JE);return i?ME(i,e,n,r):ME(t,zE(n),e,r)},function(e,i){var o=FE(this),a=zE(e);if("string"==typeof i&&-1===tb(i,n)&&-1===tb(i,"$<")){var s=r(t,o,a,i);if(s.done)return s.value}var c=BE(i);c||(i=zE(i));var u=o.global;if(u){var d=o.unicode;o.lastIndex=0}for(var l=[];;){var h=YE(o,a);if(null===h)break;if(eb(l,h),!u)break;""===zE(h[0])&&(o.lastIndex=XE(a,HE(o.lastIndex),d))}for(var f,p="",v=0,_=0;_<l.length;_++){for(var m=zE((h=l[_])[0]),y=QE(ZE(GE(h.index),a.length),0),g=[],S=1;S<h.length;S++)eb(g,void 0===(f=h[S])?f:String(f));var E=h.groups;if(c){var b=$E([m],g,y,a);void 0!==E&&eb(b,E);var k=zE(DE(i,void 0,b))}else k=qE(m,a,y,g,E,i);y>=v&&(p+=rb(a,v,y)+k,v=y+m.length)}return p+rb(a,v)}]}),!ob||!nb||ib);var ab=ve,sb=Kt,cb=tt,ub=Vs,db=RegExp.prototype,lb=function(e){var t=e.flags;return void 0!==t||"flags"in db||sb(e,"flags")||!cb(db,e)?t:ab(ub,e)},hb=le,fb=ce,pb=Re,vb=qi,_b=tf,mb=$r,yb=ei.f,gb=tt,Sb=Ss,Eb=As,bb=lb,kb=zs,Tb=hp,Ib=$n,Ab=de,Rb=Kt,Cb=Ln.enforce,wb=If,Ob=Ws,xb=Js,Nb=sr("match"),Pb=fb.RegExp,Db=Pb.prototype,Mb=fb.SyntaxError,Lb=pb(Db.exec),Ub=pb("".charAt),Vb=pb("".replace),Fb=pb("".indexOf),Bb=pb("".slice),jb=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Gb=/a/g,Hb=/a/g,zb=new Pb(Gb)!==Gb,Kb=kb.MISSED_STICKY,Xb=kb.UNSUPPORTED_Y,Wb=hb&&(!zb||Kb||Ob||xb||Ab((function(){return Hb[Nb]=!1,Pb(Gb)!=Gb||Pb(Hb)==Hb||"/a/i"!=Pb(Gb,"i")})));if(vb("RegExp",Wb)){for(var qb=function(e,t){var r,n,i,o,a,s,c=gb(Db,this),u=Sb(e),d=void 0===t,l=[],h=e;if(!c&&u&&d&&e.constructor===qb)return e;if((u||gb(Db,e))&&(e=e.source,d&&(t=bb(h))),e=void 0===e?"":Eb(e),t=void 0===t?"":Eb(t),h=e,Ob&&"dotAll"in Gb&&(n=!!t&&Fb(t,"s")>-1)&&(t=Vb(t,/s/g,"")),r=t,Kb&&"sticky"in Gb&&(i=!!t&&Fb(t,"y")>-1)&&Xb&&(t=Vb(t,/y/g,"")),xb&&(o=function(e){for(var t,r=e.length,n=0,i="",o=[],a={},s=!1,c=!1,u=0,d="";n<=r;n++){if("\\"===(t=Ub(e,n)))t+=Ub(e,++n);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:Lb(jb,Bb(e,n+1))&&(n+=2,c=!0),i+=t,u++;continue;case">"===t&&c:if(""===d||Rb(a,d))throw new Mb("Invalid capture group name");a[d]=!0,o[o.length]=[d,u],c=!1,d="";continue}c?d+=t:i+=t}return[i,o]}(e),e=o[0],l=o[1]),a=_b(Pb(e,t),c?this:Db,qb),(n||i||l.length)&&(s=Cb(a),n&&(s.dotAll=!0,s.raw=qb(function(e){for(var t,r=e.length,n=0,i="",o=!1;n<=r;n++)"\\"!==(t=Ub(e,n))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+Ub(e,++n);return i}(e),r)),i&&(s.sticky=!0),l.length&&(s.groups=l)),e!==h)try{mb(a,"source",""===h?"(?:)":h)}catch(TQ){}return a},Yb=yb(Pb),Jb=0;Yb.length>Jb;)Tb(qb,Pb,Yb[Jb++]);Db.constructor=qb,qb.prototype=Db,Ib(fb,"RegExp",qb,{constructor:!0})}wb("RegExp");var Qb=le,Zb=Ws,$b=xe,ek=tS,tk=Ln.get,rk=RegExp.prototype,nk=TypeError;Qb&&Zb&&ek(rk,"dotAll",{configurable:!0,get:function(){if(this!==rk){if("RegExp"===$b(this))return!!tk(this).dotAll;throw nk("Incompatible receiver, RegExp required")}}});var ik=le,ok=zs.MISSED_STICKY,ak=xe,sk=tS,ck=Ln.get,uk=RegExp.prototype,dk=TypeError;ik&&ok&&sk(uk,"sticky",{configurable:!0,get:function(){if(this!==uk){if("RegExp"===ak(this))return!!ck(this).sticky;throw dk("Incompatible receiver, RegExp required")}}});var lk=sn.PROPER,hk=$n,fk=Fr,pk=As,vk=de,_k=lb,mk="toString",yk=RegExp.prototype.toString,gk=vk((function(){return"/a/b"!=yk.call({source:"a",flags:"b"})})),Sk=lk&&yk.name!=mk;(gk||Sk)&&hk(RegExp.prototype,mk,(function(){var e=fk(this);return"/"+pk(e.source)+"/"+pk(_k(e))}),{unsafe:!0});var Ek=ro,bk=de,kk=He,Tk=ue.f,Ik=le,Ak=bk((function(){Tk(1)}));Ek({target:"Object",stat:!0,forced:!Ik||Ak,sham:!Ik},{getOwnPropertyDescriptor:function(e,t){return Tk(kk(e),t)}});var Rk=qv;function Ck(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==a(e)||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach((function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var n="object"===a(e[r])?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",r)]=n.ideal,t.optional.push(o),(o={})[i("max",r)]=n.ideal,t.optional.push(o)):(o[i("",r)]=n.ideal,t.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[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"===a(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===a(e.video)){var s=e.video.facingMode;s=s&&("object"===a(s)?s:{ideal:s});var c,u=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||u))if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?c=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(c=["front"]),c)return r.mediaDevices.enumerateDevices().then((function(t){var r=(t=t.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return c.some((function(t){return e.label.toLowerCase().includes(t)}))}));return!r&&t.length&&c.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=s.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),Rk("chrome: "+JSON.stringify(e)),i(e)}));e.video=n(e.video)}return Rk("chrome: "+JSON.stringify(e)),i(e)},o=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:function(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return s(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Promise.reject(o(e))}))}))}}}}function wk(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Ok(e){if("object"===a(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find((function(e){return e.track&&e.track.id===n.track.id})):{track:n.track};var o=new Event("track");o.track=n.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],r.dispatchEvent(o)})),t.stream.getTracks().forEach((function(n){var i;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find((function(e){return e.track&&e.track.id===n.id})):{track:n};var o=new Event("track");o.track=n,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],r.dispatchEvent(o)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Kv(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function xk(e){if("object"===a(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var 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()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r=t._senders.find((function(t){return t.track===e}));r&&t._senders.splice(t._senders.indexOf(r),1)}))}}else if("object"===a(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=s.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Nk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){return new Map(Object.keys(e).map((function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Promise((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function Pk(e){if("object"===a(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return e_(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),Kv(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return e_(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Dk(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((function(t){return e._shimmedLocalStreams[t][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){if(t.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var n=this.getSenders();r.apply(this,arguments);var i=this.getSenders().filter((function(e){return-1===n.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(i)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((function(r){var n=t._shimmedLocalStreams[r].indexOf(e);-1!==n&&t._shimmedLocalStreams[r].splice(n,1),1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function Mk(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Dk(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map((function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){if(r.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;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,r){var n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find((function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var o=this.getSenders().find((function(e){return e.track===t}));if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var a=this._streams[r.id];if(a)a.addTrack(t),Promise.resolve().then((function(){n.dispatchEvent(new Event("negotiationneeded"))}));else{var s=new e.MediaStream([t]);this._streams[r.id]=s,this._reverseStreams[s.id]=r,this.addStream(s)}return this.getSenders().find((function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=h({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=this;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");this._streams=this._streams||{},Object.keys(this._streams).forEach((function(n){r._streams[n].getTracks().find((function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function Lk(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=h({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function Uk(e,t){Kv(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var Vk,Fk,Bk=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:wk,shimOnTrack:Ok,shimGetSendersWithDtmf:xk,shimGetStats:Nk,shimSenderReceiverGetStats:Pk,shimAddTrackRemoveTrackWithNative:Dk,shimAddTrackRemoveTrack:Mk,shimPeerConnection:Lk,fixNegotiationNeeded:Uk,shimGetUserMedia:Ck,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}},Symbol.toStringTag,{value:"Module"})),jk=ro,Gk=ve,Hk=We,zk=Fr,Kk=As,Xk=(Vk=!1,(Fk=/[ac]/).exec=function(){return Vk=!0,/./.exec.apply(this,arguments)},!0===Fk.test("abc")&&Vk),Wk=/./.test;jk({target:"RegExp",proto:!0,forced:!Xk},{test:function(e){var t=zk(this),r=Kk(e),n=t.exec;if(!Hk(n))return Gk(Wk,t,r);var i=Gk(n,t,r);return null!==i&&(zk(i),!0)}});var qk=ce,Yk=de,Jk=As,Qk=Yu.trim,Zk=Re("".charAt),$k=qk.parseFloat,eT=qk.Symbol,tT=eT&&eT.iterator,rT=1/$k("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0||tT&&!Yk((function(){$k(Object(tT))}))?function(e){var t=Qk(Jk(e)),r=$k(t);return 0===r&&"-"==Zk(t,0)?-0:r}:$k;ro({global:!0,forced:parseFloat!=rT},{parseFloat:rT});var nT=ro,iT=sy,oT=de,aT=et,sT=We,cT=em,uT=qg,dT=$n,lT=iT&&iT.prototype;if(nT({target:"Promise",proto:!0,real:!0,forced:!!iT&&oT((function(){lT.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=cT(this,aT("Promise")),r=sT(e);return this.then(r?function(r){return uT(t,e()).then((function(){return r}))}:e,r?function(r){return uT(t,e()).then((function(){throw r}))}:e)}}),sT(iT)){var hT=aT("Promise").prototype.finally;lT.finally!==hT&&dT(lT,"finally",hT,{unsafe:!0})}function fT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){Yv("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===a(e)&&"object"===a(e.audio)&&(e=JSON.parse(JSON.stringify(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var s=n.prototype.getSettings;n.prototype.getSettings=function(){var e=s.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var c=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===a(e)&&(e=JSON.parse(JSON.stringify(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),c.apply(this,[e])}}}}function pT(e){"object"===a(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function vT(e,t){if("object"===a(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=h({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(n){if("TypeError"!==n.name)throw n;e.forEach((function(t,n){e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function _T(e){if("object"===a(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.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 mT(e){if("object"===a(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),Kv(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function yT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;Yv("removeStream","removeTrack"),this.getSenders().forEach((function(r){r.track&&e.getTracks().includes(r.track)&&t.removeTrack(r)}))})}function gT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function ST(e){if("object"===a(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=k(e)).length>0;r&&e.forEach((function(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")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===Object.keys(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function ET(e){if("object"===a(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}}function bT(e){if("object"===a(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function kT(e){if("object"===a(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var TT=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:pT,shimPeerConnection:vT,shimSenderGetStats:_T,shimReceiverGetStats:mT,shimRemoveStream:yT,shimRTCDataChannel:gT,shimAddTransceiver:ST,shimGetParameters:ET,shimCreateOffer:bT,shimCreateAnswer:kT,shimGetUserMedia:fT,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function IT(e){if("object"===a(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)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(n){return t.call(r,n,e)})),e.getVideoTracks().forEach((function(n){return t.call(r,n,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){r._localStreams?r._localStreams.includes(e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._localStreams||(this._localStreams=[]);var r=this._localStreams.indexOf(e);if(-1!==r){this._localStreams.splice(r,1);var n=e.getTracks();this.getSenders().forEach((function(e){n.includes(e.track)&&t.removeTrack(e)}))}})}}function AT(e){if("object"===a(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:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){if(t._remoteStreams||(t._remoteStreams=[]),!t._remoteStreams.includes(e)){t._remoteStreams.push(e);var r=new Event("addstream");r.stream=e,t.dispatchEvent(r)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}}))}),t.apply(e,arguments)}}}function RT(e){if("object"===a(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};var c=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=c,c=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=c,c=function(e,t,r){var n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=c}}function CT(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(wT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function wT(e){return e&&void 0!==e.video?Object.assign({},e,{video:Zv(e.video)}):e}function OT(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(Yv("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(JSON.stringify(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function xT(e){"object"===a(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function NT(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var r=this.getTransceivers().find((function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveAudio||r||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var n=this.getTransceivers().find((function(e){return"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",{direction:"recvonly"})}return t.apply(this,arguments)}}function PT(e){"object"!==a(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var DT=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:IT,shimRemoteStreamsAPI:AT,shimCallbacksAPI:RT,shimGetUserMedia:CT,shimConstraints:wT,shimRTCIceServerUrls:OT,shimTrackEventTransceiver:xT,shimCreateOfferLegacy:NT,shimAudioContext:PT},Symbol.toStringTag,{value:"Module"})),MT=ve;ro({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return MT(URL.prototype.toString,this)}});var LT=Re(1..valueOf),UT=le,VT=ce,FT=Re,BT=qi,jT=$n,GT=Kt,HT=tf,zT=tt,KT=yt,XT=vr,WT=de,qT=ei.f,YT=ue.f,JT=Dr.f,QT=LT,ZT=Yu.trim,$T="Number",eI=VT.Number,tI=eI.prototype,rI=VT.TypeError,nI=FT("".slice),iI=FT("".charCodeAt),oI=function(e){var t=XT(e,"number");return"bigint"==typeof t?t:aI(t)},aI=function(e){var t,r,n,i,o,a,s,c,u=XT(e,"number");if(KT(u))throw rI("Cannot convert a Symbol value to a number");if("string"==typeof u&&u.length>2)if(u=ZT(u),43===(t=iI(u,0))||45===t){if(88===(r=iI(u,2))||120===r)return NaN}else if(48===t){switch(iI(u,1)){case 66:case 98:n=2,i=49;break;case 79:case 111:n=8,i=55;break;default:return+u}for(a=(o=nI(u,2)).length,s=0;s<a;s++)if((c=iI(o,s))<48||c>i)return NaN;return parseInt(o,n)}return+u};if(BT($T,!eI(" 0o1")||!eI("0b1")||eI("+0x1"))){for(var sI,cI=function(e){var t=arguments.length<1?0:eI(oI(e)),r=this;return zT(tI,r)&&WT((function(){QT(r)}))?HT(Object(t),r,cI):t},uI=UT?qT(eI):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),dI=0;uI.length>dI;dI++)GT(eI,sI=uI[dI])&&!GT(cI,sI)&&JT(cI,sI,YT(eI,sI));cI.prototype=tI,tI.constructor=cI,jT(VT,$T,cI,{constructor:!0})}var lI=sn.PROPER,hI=de,fI=ju,pI=Yu.trim;ro({target:"String",proto:!0,forced:function(e){return hI((function(){return!!fI[e]()||"​…᠎"!=="​…᠎"[e]()||lI&&fI[e].name!==e}))}("trim")},{trim:function(){return pI(this)}});var vI,_I,mI={exports:{}};vI=mI,(_I={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=_I.generateIdentifier(),_I.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},_I.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},_I.getDescription=function(e){var t=_I.splitSections(e);return t&&t[0]},_I.getMediaSections=function(e){var t=_I.splitSections(e);return t.shift(),t},_I.matchPrefix=function(e,t){return _I.splitLines(e).filter((function(e){return 0===e.indexOf(t)}))},_I.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=parseInt(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},_I.writeCandidate=function(e){var t=[];t.push(e.foundation);var r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),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(" ")},_I.parseIceOptions=function(e){return e.substr(14).split(" ")},_I.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},_I.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},_I.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]}},_I.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},_I.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<n.length;i++)r[(t=n[i].trim().split("="))[0].trim()]=t[1];return r},_I.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var n=[];Object.keys(e.parameters).forEach((function(t){void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},_I.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},_I.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},_I.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},_I.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},_I.getMid=function(e){var t=_I.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},_I.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},_I.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:_I.matchPrefix(e+t,"a=fingerprint:").map(_I.parseFingerprint)}},_I.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},_I.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)}},_I.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===a(e.keyParams)?_I.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},_I.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}},_I.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},_I.getCryptoParameters=function(e,t){return _I.matchPrefix(e+t,"a=crypto:").map(_I.parseCryptoLine)},_I.getIceParameters=function(e,t){var r=_I.matchPrefix(e+t,"a=ice-ufrag:")[0],n=_I.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},_I.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},_I.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=_I.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=_I.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a=_I.parseRtpMap(o),s=_I.matchPrefix(e,"a=fmtp:"+i+" ");switch(a.parameters=s.length?_I.parseFmtp(s[0]):{},a.rtcpFeedback=_I.matchPrefix(e,"a=rtcp-fb:"+i+" ").map(_I.parseRtcpFb),t.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(a.name.toUpperCase())}}}return _I.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(_I.parseExtmap(e))})),t},_I.writeRtpDescription=function(e,t){var r="";r+="m="+e+" ",r+=t.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.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",t.codecs.forEach((function(e){r+=_I.writeRtpMap(e),r+=_I.writeFmtp(e),r+=_I.writeRtcpFb(e)}));var n=0;return t.codecs.forEach((function(e){e.maxptime>n&&(n=e.maxptime)})),n>0&&(r+="a=maxptime:"+n+"\r\n"),t.headerExtensions&&t.headerExtensions.forEach((function(e){r+=_I.writeExtmap(e)})),r},_I.parseRtpEncodingParameters=function(e){var t,r=[],n=_I.parseRtpParameters(e),i=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),a=_I.matchPrefix(e,"a=ssrc:").map((function(e){return _I.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),s=a.length>0&&a[0].ssrc,c=_I.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));c.length>0&&c[0].length>1&&c[0][0]===s&&(t=c[0][1]),n.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&t&&(n.rtx={ssrc:t}),r.push(n),i&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:s,mechanism:o?"red+ulpfec":"red"},r.push(n))}})),0===r.length&&s&&r.push({ssrc:s});var u=_I.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=u}))),r},_I.parseRtcpParameters=function(e){var t={},r=_I.matchPrefix(e,"a=ssrc:").map((function(e){return _I.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var n=_I.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=n.length>0,t.compound=0===n.length;var i=_I.matchPrefix(e,"a=rtcp-mux");return t.mux=i.length>0,t},_I.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},_I.parseMsid=function(e){var t,r=_I.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var n=_I.matchPrefix(e,"a=ssrc:").map((function(e){return _I.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return n.length>0?{stream:(t=n[0].value.split(" "))[0],track:t[1]}:void 0},_I.parseSctpDescription=function(e){var t,r=_I.parseMLine(e),n=_I.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=parseInt(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=_I.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:parseInt(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=_I.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:t}}},_I.writeSctpDescription=function(e,t){var r=[];return r="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&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},_I.generateSessionId=function(){return Math.random().toString().substr(2,21)},_I.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||_I.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},_I.getDirection=function(e,t){for(var r=_I.splitLines(e),n=0;n<r.length;n++)switch(r[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[n].substr(2)}return t?_I.getDirection(t):"sendrecv"},_I.getKind=function(e){return _I.splitLines(e)[0].split(" ")[0].substr(2)},_I.isRejected=function(e){return"0"===e.split(" ",2)[1]},_I.parseMLine=function(e){var t=_I.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},_I.parseOLine=function(e){var t=_I.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:parseInt(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},_I.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=_I.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},vI.exports=_I;var yI=mI.exports,gI=e({__proto__:null,default:yI},[mI.exports]);function SI(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===a(e)&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var r=new t(e),n=yI.parseCandidate(e.candidate),i=Object.assign(r,n);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,Kv(e,"icecandidate",(function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function EI(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||Kv(e,"icecandidate",(function(e){if(e.candidate){var t=yI.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function bI(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=yI.splitSections(e.sdp);return t.shift(),t.some((function(e){var t=yI.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=yI.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};Object.defineProperty(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return a.apply(this,arguments)}}}function kI(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e,this),e},Kv(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.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 r.apply(e,arguments)}}}function TI(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(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((function(e){var r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function II(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var n=t.sdp.split("\n").filter((function(e){return"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 r.apply(this,arguments)}}}function AI(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.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():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function RI(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==a(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var CI=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:SI,shimRTCIceCandidateRelayProtocol:EI,shimMaxMessageSize:bI,shimSendThrowTypeError:kI,shimConnectionState:TI,removeExtmapAllowMixed:II,shimAddIceCandidateNullOrEmpty:AI,shimParameterlessSetLocalDescription:RI},Symbol.toStringTag,{value:"Module"}));!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=qv,i=Jv(t),o={browserDetails:i,commonShim:CI,extractVersion:zv,disableLog:Xv,disableWarnings:Wv,sdp:gI};switch(i.browser){case"chrome":if(!Bk||!Lk||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=Bk,AI(t,i),RI(t),Ck(t,i),wk(t),Lk(t,i),Ok(t),Mk(t,i),xk(t),Nk(t),Pk(t),Uk(t,i),SI(t),EI(t),TI(t),bI(t,i),kI(t),II(t,i);break;case"firefox":if(!TT||!vT||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=TT,AI(t,i),RI(t),fT(t,i),vT(t,i),pT(t),yT(t),_T(t),mT(t),gT(t),ST(t),ET(t),bT(t),kT(t),SI(t),TI(t),bI(t,i),kI(t);break;case"safari":if(!DT||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=DT,AI(t,i),RI(t),OT(t),NT(t),RT(t),IT(t),AT(t),xT(t),CT(t),PT(t),SI(t),EI(t),bI(t,i),kI(t),II(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var wI=Dl,OI=Math.floor,xI=function(e,t){var r=e.length,n=OI(r/2);return r<8?NI(e,t):PI(e,xI(wI(e,0,n),t),xI(wI(e,n),t),t)},NI=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},PI=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},DI=xI,MI=rt.match(/firefox\/(\d+)/i),LI=!!MI&&+MI[1],UI=/MSIE|Trident/.test(rt),VI=rt.match(/AppleWebKit\/(\d+)\./),FI=!!VI&&+VI[1],BI=ro,jI=Re,GI=Tt,HI=Gt,zI=fi,KI=C_,XI=As,WI=de,qI=DI,YI=wa,JI=LI,QI=UI,ZI=ut,$I=FI,eA=[],tA=jI(eA.sort),rA=jI(eA.push),nA=WI((function(){eA.sort(void 0)})),iA=WI((function(){eA.sort(null)})),oA=YI("sort"),aA=!WI((function(){if(ZI)return ZI<70;if(!(JI&&JI>3)){if(QI)return!0;if($I)return $I<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)eA.push({k:t+n,v:r})}for(eA.sort((function(e,t){return t.v-e.v})),n=0;n<eA.length;n++)t=eA[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));BI({target:"Array",proto:!0,forced:nA||!iA||!oA||!aA},{sort:function(e){void 0!==e&&GI(e);var t=HI(this);if(aA)return void 0===e?tA(t):tA(t,e);var r,n,i=[],o=zI(t);for(n=0;n<o;n++)n in t&&rA(i,t[n]);for(qI(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:XI(t)>XI(r)?1:-1}}(e)),r=zI(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)KI(t,n++);return t}});var sA,cA,uA,dA={exports:{}},lA="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,hA=lA,fA=le,pA=ce,vA=We,_A=Je,mA=Kt,yA=So,gA=St,SA=$r,EA=$n,bA=Dr.f,kA=tt,TA=Sd,IA=Xd,AA=sr,RA=Jt,CA=Ln.enforce,wA=Ln.get,OA=pA.Int8Array,xA=OA&&OA.prototype,NA=pA.Uint8ClampedArray,PA=NA&&NA.prototype,DA=OA&&TA(OA),MA=xA&&TA(xA),LA=Object.prototype,UA=pA.TypeError,VA=AA("toStringTag"),FA=RA("TYPED_ARRAY_TAG"),BA="TypedArrayConstructor",jA=hA&&!!IA&&"Opera"!==yA(pA.opera),GA=!1,HA={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},zA={BigInt64Array:8,BigUint64Array:8},KA=function(e){var t=TA(e);if(_A(t)){var r=wA(t);return r&&mA(r,BA)?r.TypedArrayConstructor:KA(t)}},XA=function(e){if(!_A(e))return!1;var t=yA(e);return mA(HA,t)||mA(zA,t)};for(sA in HA)(uA=(cA=pA[sA])&&cA.prototype)?CA(uA).TypedArrayConstructor=cA:jA=!1;for(sA in zA)(uA=(cA=pA[sA])&&cA.prototype)&&(CA(uA).TypedArrayConstructor=cA);if((!jA||!vA(DA)||DA===Function.prototype)&&(DA=function(){throw UA("Incorrect invocation")},jA))for(sA in HA)pA[sA]&&IA(pA[sA],DA);if((!jA||!MA||MA===LA)&&(MA=DA.prototype,jA))for(sA in HA)pA[sA]&&IA(pA[sA].prototype,MA);if(jA&&TA(PA)!==MA&&IA(PA,MA),fA&&!mA(MA,VA))for(sA in GA=!0,bA(MA,VA,{get:function(){return _A(this)?this[FA]:void 0}}),HA)pA[sA]&&SA(pA[sA],FA,sA);var WA={NATIVE_ARRAY_BUFFER_VIEWS:jA,TYPED_ARRAY_TAG:GA&&FA,aTypedArray:function(e){if(XA(e))return e;throw UA("Target is not a typed array")},aTypedArrayConstructor:function(e){if(vA(e)&&(!IA||kA(DA,e)))return e;throw UA(gA(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,n){if(fA){if(r)for(var i in HA){var o=pA[i];if(o&&mA(o.prototype,e))try{delete o.prototype[e]}catch(TQ){try{o.prototype[e]=t}catch(a){}}}MA[e]&&!r||EA(MA,e,r?t:jA&&xA[e]||t,n)}},exportTypedArrayStaticMethod:function(e,t,r){var n,i;if(fA){if(IA){if(r)for(n in HA)if((i=pA[n])&&mA(i,e))try{delete i[e]}catch(TQ){}if(DA[e]&&!r)return;try{return EA(DA,e,r?t:jA&&DA[e]||t)}catch(TQ){}}for(n in HA)!(i=pA[n])||i[e]&&!r||EA(i,e,t)}},getTypedArrayConstructor:KA,isView:function(e){if(!_A(e))return!1;var t=yA(e);return"DataView"===t||mA(HA,t)||mA(zA,t)},isTypedArray:XA,TypedArray:DA,TypedArrayPrototype:MA},qA=ce,YA=de,JA=Qh,QA=WA.NATIVE_ARRAY_BUFFER_VIEWS,ZA=qA.ArrayBuffer,$A=qA.Int8Array,eR=!QA||!YA((function(){$A(1)}))||!YA((function(){new $A(-1)}))||!JA((function(e){new $A,new $A(null),new $A(1.5),new $A(e)}),!0)||YA((function(){return 1!==new $A(new ZA(2),1,void 0).length})),tR=ii,rR=li,nR=RangeError,iR=function(e){if(void 0===e)return 0;var t=tR(e),r=rR(t);if(t!==r)throw nR("Wrong length or index");return r},oR=Array,aR=Math.abs,sR=Math.pow,cR=Math.floor,uR=Math.log,dR=Math.LN2,lR=Gt,hR=ci,fR=fi,pR=function(e){for(var t=lR(this),r=fR(t),n=arguments.length,i=hR(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:hR(o,r);a>i;)t[i++]=e;return t},vR=ce,_R=Re,mR=le,yR=lA,gR=sn,SR=$r,ER=Sf,bR=de,kR=Xh,TR=ii,IR=li,AR=iR,RR={pack:function(e,t,r){var n,i,o,a=oR(r),s=8*r-t-1,c=(1<<s)-1,u=c>>1,d=23===t?sR(2,-24)-sR(2,-77):0,l=e<0||0===e&&1/e<0?1:0,h=0;for((e=aR(e))!=e||e===1/0?(i=e!=e?1:0,n=c):(n=cR(uR(e)/dR),e*(o=sR(2,-n))<1&&(n--,o*=2),(e+=n+u>=1?d/o:d*sR(2,1-u))*o>=2&&(n++,o/=2),n+u>=c?(i=0,n=c):n+u>=1?(i=(e*o-1)*sR(2,t),n+=u):(i=e*sR(2,u-1)*sR(2,t),n=0));t>=8;)a[h++]=255&i,i/=256,t-=8;for(n=n<<t|i,s+=t;s>0;)a[h++]=255&n,n/=256,s-=8;return a[--h]|=128*l,a},unpack:function(e,t){var r,n=e.length,i=8*n-t-1,o=(1<<i)-1,a=o>>1,s=i-7,c=n-1,u=e[c--],d=127&u;for(u>>=7;s>0;)d=256*d+e[c--],s-=8;for(r=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)r=256*r+e[c--],s-=8;if(0===d)d=1-a;else{if(d===o)return r?NaN:u?-1/0:1/0;r+=sR(2,t),d-=a}return(u?-1:1)*r*sR(2,d-t)}},CR=Sd,wR=Xd,OR=ei.f,xR=Dr.f,NR=pR,PR=Dl,DR=Nd,MR=gR.PROPER,LR=gR.CONFIGURABLE,UR=Ln.get,VR=Ln.set,FR="ArrayBuffer",BR="DataView",jR="Wrong index",GR=vR.ArrayBuffer,HR=GR,zR=HR&&HR.prototype,KR=vR.DataView,XR=KR&&KR.prototype,WR=Object.prototype,qR=vR.Array,YR=vR.RangeError,JR=_R(NR),QR=_R([].reverse),ZR=RR.pack,$R=RR.unpack,eC=function(e){return[255&e]},tC=function(e){return[255&e,e>>8&255]},rC=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},nC=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},iC=function(e){return ZR(e,23,4)},oC=function(e){return ZR(e,52,8)},aC=function(e,t){xR(e.prototype,t,{get:function(){return UR(this)[t]}})},sC=function(e,t,r,n){var i=AR(r),o=UR(e);if(i+t>o.byteLength)throw YR(jR);var a=UR(o.buffer).bytes,s=i+o.byteOffset,c=PR(a,s,s+t);return n?c:QR(c)},cC=function(e,t,r,n,i,o){var a=AR(r),s=UR(e);if(a+t>s.byteLength)throw YR(jR);for(var c=UR(s.buffer).bytes,u=a+s.byteOffset,d=n(+i),l=0;l<t;l++)c[u+l]=d[o?l:t-l-1]};if(yR){var uC=MR&&GR.name!==FR;if(bR((function(){GR(1)}))&&bR((function(){new GR(-1)}))&&!bR((function(){return new GR,new GR(1.5),new GR(NaN),1!=GR.length||uC&&!LR})))uC&&LR&&SR(GR,"name",FR);else{(HR=function(e){return kR(this,zR),new GR(AR(e))}).prototype=zR;for(var dC,lC=OR(GR),hC=0;lC.length>hC;)(dC=lC[hC++])in HR||SR(HR,dC,GR[dC]);zR.constructor=HR}wR&&CR(XR)!==WR&&wR(XR,WR);var fC=new KR(new HR(2)),pC=_R(XR.setInt8);fC.setInt8(0,2147483648),fC.setInt8(1,2147483649),!fC.getInt8(0)&&fC.getInt8(1)||ER(XR,{setInt8:function(e,t){pC(this,e,t<<24>>24)},setUint8:function(e,t){pC(this,e,t<<24>>24)}},{unsafe:!0})}else zR=(HR=function(e){kR(this,zR);var t=AR(e);VR(this,{bytes:JR(qR(t),0),byteLength:t}),mR||(this.byteLength=t)}).prototype,XR=(KR=function(e,t,r){kR(this,XR),kR(e,zR);var n=UR(e).byteLength,i=TR(t);if(i<0||i>n)throw YR("Wrong offset");if(i+(r=void 0===r?n-i:IR(r))>n)throw YR("Wrong length");VR(this,{buffer:e,byteLength:r,byteOffset:i}),mR||(this.buffer=e,this.byteLength=r,this.byteOffset=i)}).prototype,mR&&(aC(HR,"byteLength"),aC(KR,"buffer"),aC(KR,"byteLength"),aC(KR,"byteOffset")),ER(XR,{getInt8:function(e){return sC(this,1,e)[0]<<24>>24},getUint8:function(e){return sC(this,1,e)[0]},getInt16:function(e){var t=sC(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=sC(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return nC(sC(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return nC(sC(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return $R(sC(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return $R(sC(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){cC(this,1,e,eC,t)},setUint8:function(e,t){cC(this,1,e,eC,t)},setInt16:function(e,t){cC(this,2,e,tC,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){cC(this,2,e,tC,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){cC(this,4,e,rC,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){cC(this,4,e,rC,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){cC(this,4,e,iC,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){cC(this,8,e,oC,t,arguments.length>2?arguments[2]:void 0)}});DR(HR,FR),DR(KR,BR);var vC={ArrayBuffer:HR,DataView:KR},_C=Je,mC=Math.floor,yC=Number.isInteger||function(e){return!_C(e)&&isFinite(e)&&mC(e)===e},gC=ii,SC=RangeError,EC=function(e){var t=gC(e);if(t<0)throw SC("The argument can't be less than 0");return t},bC=RangeError,kC=function(e,t){var r=EC(e);if(r%t)throw bC("Wrong offset");return r},TC=So,IC=Re("".slice),AC=function(e){return"Big"===IC(TC(e),0,3)},RC=vr,CC=TypeError,wC=function(e){var t=RC(e,"number");if("number"==typeof t)throw CC("Can't convert number to bigint");return BigInt(t)},OC=ga,xC=ve,NC=Y_,PC=Gt,DC=fi,MC=Ih,LC=yh,UC=hh,VC=AC,FC=WA.aTypedArrayConstructor,BC=wC,jC=ro,GC=ce,HC=ve,zC=le,KC=eR,XC=WA,WC=vC,qC=Xh,YC=be,JC=$r,QC=yC,ZC=li,$C=iR,ew=kC,tw=yr,rw=Kt,nw=So,iw=Je,ow=yt,aw=cs,sw=tt,cw=Xd,uw=ei.f,dw=function(e){var t,r,n,i,o,a,s,c,u=NC(this),d=PC(e),l=arguments.length,h=l>1?arguments[1]:void 0,f=void 0!==h,p=LC(d);if(p&&!UC(p))for(c=(s=MC(d,p)).next,d=[];!(a=xC(c,s)).done;)d.push(a.value);for(f&&l>2&&(h=OC(h,arguments[2])),r=DC(d),n=new(FC(u))(r),i=VC(n),t=0;r>t;t++)o=f?h(d[t],t):d[t],n[t]=i?BC(o):+o;return n},lw=Ra.forEach,hw=If,fw=Dr,pw=ue,vw=tf,_w=Ln.get,mw=Ln.set,yw=Ln.enforce,gw=fw.f,Sw=pw.f,Ew=Math.round,bw=GC.RangeError,kw=WC.ArrayBuffer,Tw=kw.prototype,Iw=WC.DataView,Aw=XC.NATIVE_ARRAY_BUFFER_VIEWS,Rw=XC.TYPED_ARRAY_TAG,Cw=XC.TypedArray,ww=XC.TypedArrayPrototype,Ow=XC.aTypedArrayConstructor,xw=XC.isTypedArray,Nw="BYTES_PER_ELEMENT",Pw="Wrong length",Dw=function(e,t){Ow(e);for(var r=0,n=t.length,i=new e(n);n>r;)i[r]=t[r++];return i},Mw=function(e,t){gw(e,t,{get:function(){return _w(this)[t]}})},Lw=function(e){var t;return sw(Tw,e)||"ArrayBuffer"==(t=nw(e))||"SharedArrayBuffer"==t},Uw=function(e,t){return xw(e)&&!ow(t)&&t in e&&QC(+t)&&t>=0},Vw=function(e,t){return t=tw(t),Uw(e,t)?YC(2,e[t]):Sw(e,t)},Fw=function(e,t,r){return t=tw(t),!(Uw(e,t)&&iw(r)&&rw(r,"value"))||rw(r,"get")||rw(r,"set")||r.configurable||rw(r,"writable")&&!r.writable||rw(r,"enumerable")&&!r.enumerable?gw(e,t,r):(e[t]=r.value,e)};zC?(Aw||(pw.f=Vw,fw.f=Fw,Mw(ww,"buffer"),Mw(ww,"byteOffset"),Mw(ww,"byteLength"),Mw(ww,"length")),jC({target:"Object",stat:!0,forced:!Aw},{getOwnPropertyDescriptor:Vw,defineProperty:Fw}),dA.exports=function(e,t,r){var n=e.match(/\d+$/)[0]/8,i=e+(r?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=GC[i],c=s,u=c&&c.prototype,d={},l=function(e,t){gw(e,t,{get:function(){return function(e,t){var r=_w(e);return r.view[o](t*n+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var o=_w(e);r&&(i=(i=Ew(i))<0?0:i>255?255:255&i),o.view[a](t*n+o.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};Aw?KC&&(c=t((function(e,t,r,i){return qC(e,u),vw(iw(t)?Lw(t)?void 0!==i?new s(t,ew(r,n),i):void 0!==r?new s(t,ew(r,n)):new s(t):xw(t)?Dw(c,t):HC(dw,c,t):new s($C(t)),e,c)})),cw&&cw(c,Cw),lw(uw(s),(function(e){e in c||JC(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,r,i){qC(e,u);var o,a,s,d=0,h=0;if(iw(t)){if(!Lw(t))return xw(t)?Dw(c,t):HC(dw,c,t);o=t,h=ew(r,n);var f=t.byteLength;if(void 0===i){if(f%n)throw bw(Pw);if((a=f-h)<0)throw bw(Pw)}else if((a=ZC(i)*n)+h>f)throw bw(Pw);s=a/n}else s=$C(t),o=new kw(a=s*n);for(mw(e,{buffer:o,byteOffset:h,byteLength:a,length:s,view:new Iw(o)});d<s;)l(e,d++)})),cw&&cw(c,Cw),u=c.prototype=aw(ww)),u.constructor!==c&&JC(u,"constructor",c),yw(u).TypedArrayConstructor=c,Rw&&JC(u,Rw,i);var h=c!=s;d[i]=c,jC({global:!0,constructor:!0,forced:h,sham:!Aw},d),Nw in c||JC(c,Nw,n),Nw in u||JC(u,Nw,n),hw(i)}):dA.exports=function(){},(0,dA.exports)("Uint8",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var Bw=fi,jw=ii,Gw=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("at",(function(e){var t=Gw(this),r=Bw(t),n=jw(e),i=n>=0?n:r+n;return i<0||i>=r?void 0:t[i]}));var Hw=Gt,zw=ci,Kw=fi,Xw=C_,Ww=Math.min,qw=[].copyWithin||function(e,t){var r=Hw(this),n=Kw(r),i=zw(e,n),o=zw(t,n),a=arguments.length>2?arguments[2]:void 0,s=Ww((void 0===a?n:zw(a,n))-o,n-i),c=1;for(o<i&&i<o+s&&(c=-1,o+=s-1,i+=s-1);s-- >0;)o in r?r[i]=r[o]:Xw(r,i),i+=c,o+=c;return r},Yw=WA,Jw=Re(qw),Qw=Yw.aTypedArray;(0,Yw.exportTypedArrayMethod)("copyWithin",(function(e,t){return Jw(Qw(this),e,t,arguments.length>2?arguments[2]:void 0)}));var Zw=Ra.every,$w=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("every",(function(e){return Zw($w(this),e,arguments.length>1?arguments[1]:void 0)}));var eO=pR,tO=wC,rO=So,nO=ve,iO=de,oO=WA.aTypedArray,aO=WA.exportTypedArrayMethod,sO=Re("".slice),cO=iO((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}));aO("fill",(function(e){var t=arguments.length;oO(this);var r="Big"===sO(rO(this),0,3)?tO(e):+e;return nO(eO,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),cO);var uO=fi,dO=function(e,t){for(var r=0,n=uO(t),i=new e(n);n>r;)i[r]=t[r++];return i},lO=em,hO=WA.aTypedArrayConstructor,fO=WA.getTypedArrayConstructor,pO=function(e){return hO(lO(e,fO(e)))},vO=dO,_O=pO,mO=Ra.filter,yO=function(e,t){return vO(_O(e),t)},gO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("filter",(function(e){var t=mO(gO(this),e,arguments.length>1?arguments[1]:void 0);return yO(this,t)}));var SO=Ra.find,EO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("find",(function(e){return SO(EO(this),e,arguments.length>1?arguments[1]:void 0)}));var bO=Ra.findIndex,kO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("findIndex",(function(e){return bO(kO(this),e,arguments.length>1?arguments[1]:void 0)}));var TO=ga,IO=Le,AO=Gt,RO=fi,CO=function(e){var t=1==e;return function(r,n,i){for(var o,a=AO(r),s=IO(a),c=TO(n,i),u=RO(s);u-- >0;)if(c(o=s[u],u,a))switch(e){case 0:return o;case 1:return u}return t?-1:void 0}},wO={findLast:CO(0),findLastIndex:CO(1)},OO=wO.findLast,xO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("findLast",(function(e){return OO(xO(this),e,arguments.length>1?arguments[1]:void 0)}));var NO=wO.findLastIndex,PO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("findLastIndex",(function(e){return NO(PO(this),e,arguments.length>1?arguments[1]:void 0)}));var DO=Ra.forEach,MO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("forEach",(function(e){DO(MO(this),e,arguments.length>1?arguments[1]:void 0)}));var LO=yi.includes,UO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("includes",(function(e){return LO(UO(this),e,arguments.length>1?arguments[1]:void 0)}));var VO=yi.indexOf,FO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("indexOf",(function(e){return VO(FO(this),e,arguments.length>1?arguments[1]:void 0)}));var BO=ce,jO=de,GO=Re,HO=WA,zO=Il,KO=sr("iterator"),XO=BO.Uint8Array,WO=GO(zO.values),qO=GO(zO.keys),YO=GO(zO.entries),JO=HO.aTypedArray,QO=HO.exportTypedArrayMethod,ZO=XO&&XO.prototype,$O=!jO((function(){ZO[KO].call([1])})),ex=!!ZO&&ZO.values&&ZO[KO]===ZO.values&&"values"===ZO.values.name,tx=function(){return WO(JO(this))};QO("entries",(function(){return YO(JO(this))}),$O),QO("keys",(function(){return qO(JO(this))}),$O),QO("values",tx,$O||!ex,{name:"values"}),QO(KO,tx,$O||!ex,{name:"values"});var rx=WA.aTypedArray,nx=WA.exportTypedArrayMethod,ix=Re([].join);nx("join",(function(e){return ix(rx(this),e)}));var ox=Wc,ax=He,sx=ii,cx=fi,ux=wa,dx=Math.min,lx=[].lastIndexOf,hx=!!lx&&1/[1].lastIndexOf(1,-0)<0,fx=ux("lastIndexOf"),px=hx||!fx?function(e){if(hx)return ox(lx,this,arguments)||0;var t=ax(this),r=cx(t),n=r-1;for(arguments.length>1&&(n=dx(n,sx(arguments[1]))),n<0&&(n=r+n);n>=0;n--)if(n in t&&t[n]===e)return n||0;return-1}:lx,vx=Wc,_x=px,mx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("lastIndexOf",(function(e){var t=arguments.length;return vx(_x,mx(this),t>1?[e,arguments[1]]:[e])}));var yx=Ra.map,gx=pO,Sx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("map",(function(e){return yx(Sx(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(gx(e))(t)}))}));var Ex=Zp.left,bx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("reduce",(function(e){var t=arguments.length;return Ex(bx(this),e,t,t>1?arguments[1]:void 0)}));var kx=Zp.right,Tx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("reduceRight",(function(e){var t=arguments.length;return kx(Tx(this),e,t,t>1?arguments[1]:void 0)}));var Ix=WA.aTypedArray,Ax=WA.exportTypedArrayMethod,Rx=Math.floor;Ax("reverse",(function(){for(var e,t=this,r=Ix(t).length,n=Rx(r/2),i=0;i<n;)e=t[i],t[i++]=t[--r],t[r]=e;return t}));var Cx=ce,wx=ve,Ox=WA,xx=fi,Nx=kC,Px=Gt,Dx=de,Mx=Cx.RangeError,Lx=Cx.Int8Array,Ux=Lx&&Lx.prototype,Vx=Ux&&Ux.set,Fx=Ox.aTypedArray,Bx=Ox.exportTypedArrayMethod,jx=!Dx((function(){var e=new Uint8ClampedArray(2);return wx(Vx,e,{length:1,0:3},1),3!==e[1]})),Gx=jx&&Ox.NATIVE_ARRAY_BUFFER_VIEWS&&Dx((function(){var e=new Lx(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));Bx("set",(function(e){Fx(this);var t=Nx(arguments.length>1?arguments[1]:void 0,1),r=Px(e);if(jx)return wx(Vx,this,r,t);var n=this.length,i=xx(r),o=0;if(i+t>n)throw Mx("Wrong length");for(;o<i;)this[t+o]=r[o++]}),!jx||Gx);var Hx=pO,zx=qc,Kx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("slice",(function(e,t){for(var r=zx(Kx(this),e,t),n=Hx(this),i=0,o=r.length,a=new n(o);o>i;)a[i]=r[i++];return a}),de((function(){new Int8Array(1).slice()})));var Xx=Ra.some,Wx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("some",(function(e){return Xx(Wx(this),e,arguments.length>1?arguments[1]:void 0)}));var qx=va,Yx=de,Jx=Tt,Qx=DI,Zx=LI,$x=UI,eN=ut,tN=FI,rN=WA.aTypedArray,nN=WA.exportTypedArrayMethod,iN=ce.Uint16Array,oN=iN&&qx(iN.prototype.sort),aN=!(!oN||Yx((function(){oN(new iN(2),null)}))&&Yx((function(){oN(new iN(2),{})}))),sN=!!oN&&!Yx((function(){if(eN)return eN<74;if(Zx)return Zx<67;if($x)return!0;if(tN)return tN<602;var e,t,r=new iN(516),n=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,n[e]=e-2*t+3;for(oN(r,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(r[e]!==n[e])return!0}));nN("sort",(function(e){return void 0!==e&&Jx(e),sN?oN(this,e):Qx(rN(this),function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?-1:t!=t?1:0===t&&0===r?1/t>0&&1/r<0?1:-1:t>r}}(e))}),!sN||aN);var cN=Wc,uN=WA,dN=de,lN=qc,hN=ce.Int8Array,fN=uN.aTypedArray,pN=uN.exportTypedArrayMethod,vN=[].toLocaleString,_N=!!hN&&dN((function(){vN.call(new hN(1))}));pN("toLocaleString",(function(){return cN(vN,_N?lN(fN(this)):fN(this),lN(arguments))}),dN((function(){return[1,2].toLocaleString()!=new hN([1,2]).toLocaleString()}))||!dN((function(){hN.prototype.toLocaleString.call([1,2])})));var mN=WA.exportTypedArrayMethod,yN=de,gN=Re,SN=ce.Uint8Array,EN=SN&&SN.prototype||{},bN=[].toString,kN=gN([].join);yN((function(){bN.call({})}))&&(bN=function(){return kN(this)});var TN=EN.toString!=bN;mN("toString",bN,TN);var IN=fi,AN=function(e,t){for(var r=IN(e),n=new t(r),i=0;i<r;i++)n[i]=e[r-i-1];return n},RN=WA.aTypedArray,CN=WA.getTypedArrayConstructor;(0,WA.exportTypedArrayMethod)("toReversed",(function(){return AN(RN(this),CN(this))}));var wN=Tt,ON=dO,xN=WA.aTypedArray,NN=WA.getTypedArrayConstructor,PN=WA.exportTypedArrayMethod,DN=Re(WA.TypedArrayPrototype.sort);PN("toSorted",(function(e){void 0!==e&&wN(e);var t=xN(this),r=ON(NN(t),t);return DN(r,e)}));var MN=fi,LN=ii,UN=RangeError,VN=function(e,t,r,n){var i=MN(e),o=LN(r),a=o<0?i+o:o;if(a>=i||a<0)throw UN("Incorrect index");for(var s=new t(i),c=0;c<i;c++)s[c]=c===a?n:e[c];return s},FN=AC,BN=ii,jN=wC,GN=WA.aTypedArray,HN=WA.getTypedArrayConstructor,zN=WA.exportTypedArrayMethod,KN=!!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(TQ){return 8===TQ}}();zN("with",{with:function(e,t){var r=GN(this),n=BN(e),i=FN(r)?jN(t):+t;return VN(r,HN(r),n,i)}}.with,!KN);var XN=ro,WN=Ra.findIndex,qN=ps,YN="findIndex",JN=!0;YN in[]&&Array(1).findIndex((function(){JN=!1})),XN({target:"Array",proto:!0,forced:JN},{findIndex:function(e){return WN(this,e,arguments.length>1?arguments[1]:void 0)}}),qN(YN);var QN=ro,ZN=va,$N=ue.f,eP=li,tP=As,rP=ks,nP=Be,iP=Cs,oP=ZN("".startsWith),aP=ZN("".slice),sP=Math.min,cP=iP("startsWith"),uP=!cP&&!!function(){var e=$N(String.prototype,"startsWith");return e&&!e.writable}();QN({target:"String",proto:!0,forced:!uP&&!cP},{startsWith:function(e){var t=tP(nP(this));rP(e);var r=eP(sP(arguments.length>1?arguments[1]:void 0,t.length)),n=tP(e);return oP?oP(t,n,r):aP(t,r,r+n.length)===n}});var dP=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e}(dP||{}),lP=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(lP||{}),hP=l((function e(t,r,n){u(this,e),h(this,"code",void 0),h(this,"message",void 0),h(this,"error",void 0),this.code=t,this.message=r,this.error=n})),fP=le,pP=Re,vP=Ga,_P=He,mP=pP(_e.f),yP=pP([].push),gP=function(e){return function(t){for(var r,n=_P(t),i=vP(n),o=i.length,a=0,s=[];o>a;)r=i[a++],fP&&!mP(n,r)||yP(s,e?[r,n[r]]:n[r]);return s}},SP={entries:gP(!0),values:gP(!1)}.entries;ro({target:"Object",stat:!0},{entries:function(e){return SP(e)}});var EP=ii,bP=As,kP=Be,TP=RangeError,IP=Re,AP=li,RP=As,CP=function(e){var t=bP(kP(this)),r="",n=EP(e);if(n<0||n==1/0)throw TP("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},wP=Be,OP=IP(CP),xP=IP("".slice),NP=Math.ceil,PP=function(e){return function(t,r,n){var i,o,a=RP(wP(t)),s=AP(r),c=a.length,u=void 0===n?" ":RP(n);return s<=c||""==u?a:((o=OP(u,NP((i=s-c)/u.length))).length>i&&(o=xP(o,0,i)),e?a+o:o+a)}},DP={start:PP(!1),end:PP(!0)},MP=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(rt),LP=DP.end;ro({target:"String",proto:!0,forced:MP},{padEnd:function(e){return LP(this,e,arguments.length>1?arguments[1]:void 0)}});var UP=sd;ro({target:"Number",stat:!0,forced:Number.parseInt!=UP},{parseInt:UP});var VP=Fr,FP=wh,BP=ga,jP=ve,GP=Gt,HP=function(e,t,r,n){try{return n?t(VP(r)[0],r[1]):t(r)}catch(TQ){FP(e,"throw",TQ)}},zP=hh,KP=Do,XP=fi,WP=lo,qP=Ih,YP=yh,JP=Array,QP=function(e){var t=GP(e),r=KP(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=BP(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=YP(t),f=0;if(!h||this===JP&&zP(h))for(a=XP(t),s=r?new this(a):JP(a);a>f;f++)l=o?i(t[f],f):t[f],WP(s,f,l);else for(d=(u=qP(t,h)).next,s=r?new this:[];!(c=jP(d,u)).done;f++)l=o?HP(u,i,[c.value,f],!0):c.value,WP(s,f,l);return s.length=f,s},ZP=QP;ro({target:"Array",stat:!0,forced:!Qh((function(e){Array.from(e)}))},{from:ZP});var $P,eD=Math.log,tD=Math.LOG10E;ro({target:"Math",stat:!0},{log10:Math.log10||function(e){return eD(e)*tD}});var rD=new Uint8Array(16);function nD(){if(!$P&&!($P="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $P(rD)}var iD=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function oD(e){return"string"==typeof e&&iD.test(e)}for(var aD,sD=[],cD=0;cD<256;++cD)sD.push((cD+256).toString(16).substr(1));function uD(e,t,r){var n=(e=e||{}).random||(e.rng||nD)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(sD[e[t+0]]+sD[e[t+1]]+sD[e[t+2]]+sD[e[t+3]]+"-"+sD[e[t+4]]+sD[e[t+5]]+"-"+sD[e[t+6]]+sD[e[t+7]]+"-"+sD[e[t+8]]+sD[e[t+9]]+"-"+sD[e[t+10]]+sD[e[t+11]]+sD[e[t+12]]+sD[e[t+13]]+sD[e[t+14]]+sD[e[t+15]]).toLowerCase();if(!oD(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var dD=new TextDecoder,lD=new TextEncoder,hD=function(){return uD()},fD=function(){return Date.now()};function pD(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,d=0,l=n;d<l.length;d++){var h=l[d];c.set(h,u),u+=h.length}return c}var vD=function(){return"undefined"==typeof window},_D=function(){function e(){u(this,e)}var t,r;return l(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){return window.btoa([e,t,r].filter((function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=Object.entries(t);n<i.length;n++){var o=b(i[n],2),s=o[0],c=o[1];null!==c&&"object"===a(c)?e.merge(t[s],r[s]):void 0!==r[s]&&(t[s]=r[s])}}},{key:"ab2str",value:function(e){return dD.decode(e)}},{key:"ab2obj",value:function(t){try{var r=e.ab2str(t);return JSON.parse(r)}catch(n){return{}}}},{key:"str2ab",value:function(e){return lD.encode(e).buffer}},{key:"ab2b64str",value:(r=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,"+t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function mD(){var e="none";return vD()||(null!==window.navigator.userAgent.match("Firefox")?e="mozilla":null!==window.navigator.userAgent.match("Chrome")?(e="chrome-stable",null!==window.navigator.userAgent.match("Electron")&&(e="electron")):(null!==window.navigator.userAgent.match("Safari")||null!==window.navigator.userAgent.match("AppleWebKit"))&&(e="safari")),e}var yD=function(){if("chrome-stable"===mD()){var e=window.navigator.userAgent.match(/Chrome\/([\d.]+)/);if(e&&e.length>1)if(Number(e[1].split(".")[0])<114)return!0}return!1}(),gD="mozilla"===mD(),SD="safari"===mD(),ED=0,bD=!vD()&&(null===(aD=navigator.userAgent.match(/version\/(\d+)/i))||void 0===aD?void 0:aD[1]);SD&&bD&&(ED=+bD);var kD=ED,TD=!vD()&&!!/(iPhone|iPad|iPod)/i.exec(navigator.userAgent);!vD()&&/(iPhone|iPod)/i.exec(navigator.userAgent);var ID=!vD()&&(!!/(iPad)/i.exec(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&"ontouchend"in document),AD=!vD()&&/MicroMessenger/i.test(navigator.userAgent),RD=!vD()&&/Android/i.test(navigator.userAgent),CD=!vD()&&navigator.userAgent.toLowerCase().includes("mobile"),wD=!vD()&&/chrome\/(86)|(87)|(88)|(89)|(90)|(91)|(92)/i.test(navigator.userAgent);function OD(){for(var e=(+"".concat(Math.random()).slice(-7).padEnd(7,"0")).toString(2).padEnd(28,"1").split(""),t=[];e.length;)t.push(e.splice(0,7));return t.map((function(e,r){var n=r===t.length-1?"0":"1";return Number.parseInt(n+e.join(""),2)}))}var xD=function(){return Math.floor(65535*Math.random())};function ND(e){return"string"==typeof e&&e.indexOf("__web__rtc__rtt__")>-1}function PD(e){return e.map((function e(t){if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var r=ArrayBuffer.isView(t)?t.buffer:t,n=r.byteLength,i=[];if(n>10){var o=new DataView(r),a=Array.from({length:5}).map((function(e,t){return o.getUint8(t)})),s=Array.from({length:5}).map((function(e,t){return n-1-t})).reverse().map((function(e){return o.getUint8(e)}));i=[].concat(k(a),["..."],k(s))}else i=Array.from(new Uint8Array(r));return"".concat(t.constructor.name,"(").concat(n,") [").concat(i.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return t.map(e);if("[object Object]"===Object.prototype.toString.call(t)){var c={};for(var u in t)c[u]=e(t[u]);return c}return t}))}var DD=function(){var e=c(o().mark((function e(){var t,r,n,i=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),MD=function(e){return new Promise((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function LD(e){return+Math.max(-127,10*Math.log10(Math.pow(e/255,2))).toFixed(2)}function UD(e){return(e&U.AUDIO)===U.AUDIO}function VD(e){return(e&U.VIDEO)===U.VIDEO}function FD(e){var t={};return Object.keys(e).forEach((function(r){"object"===a(e[r])?t[r]=FD(e[r]):r.startsWith("_")||(t[r]=e[r])})),t}function BD(e){var t=new DataView(e.buffer);if(t.byteLength<=4||65535!==t.getUint16(0))return{seiCount:1,seis:[e]};for(var r={seiCount:0,seis:[]},n=!1,i=2;i<t.byteLength;){var o=t.getUint16(i);if(i+=2,t.byteLength-i<o){n=!0;break}var a=new Uint8Array(e.buffer,i,o);if(i+=o,t.byteLength-i>0&&t.byteLength-i<=2){n=!0;break}r.seiCount++,r.seis.push(a)}return n&&(r.seiCount=1,r.seis=[e]),r}function jD(e){return null==e?"undefined | null":"string"==typeof e?e:JSON.stringify({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function GD(e,t){if("boolean"!=typeof e)throw new hP(dP.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function HD(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i=new hP(dP.INVALID_PARAMS,"Invalid ".concat(t,": the value range is [").concat(r,", ").concat(n,"]. integer only"));throw i}}function zD(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new hP(dP.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!JD(e,r,n))throw new hP(dP.INVALID_PARAMS,"Invalid ".concat(t,": The value should be string type. Length of the string: [").concat(r,",").concat(n,"]"))}function KD(e,t,r){if(!r.includes(e))throw new hP(dP.INVALID_PARAMS,"Invalid ".concat(t,": The value can only be set as ").concat(JSON.stringify(r)))}function XD(e){if(!(e instanceof MediaStreamTrack))throw new hP(dP.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function WD(e,t){if(QD(e))throw new hP(dP.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function qD(e,t){if(!(e instanceof ArrayBuffer))throw new hP(dP.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function YD(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=Object.keys(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function JD(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;return"string"==typeof e&&e.length<=r&&e.length>=t}function QD(e){return null==e}function ZD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new hP(dP.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function $D(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new hP(dP.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function eM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new hP(dP.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function tM(e){WD(e,"userInfo"),$D(e.userId),QD(e.extraInfo)||zD(e.extraInfo,"userInfo.extraInfo",1,200)}function rM(e){WD(e,"roomConfig"),GD(e.isAutoPublish,"roomConfig.isAutoPublish"),GD(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),GD(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo")}function nM(e){WD(e,"videoPlayerOption")}function iM(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new hP(dP.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:_D.str2ab(JSON.stringify(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new hP(dP.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function oM(e){return![oe.onRemoteStreamStats,oe.onLocalStreamStats,oe.onAudioVolumeIndication,oe.onLocalAudioPropertiesReport,oe.onRemoteAudioPropertiesReport].includes(e)}function aM(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new hP(dP.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}var sM={},cM=sr;sM.f=cM;var uM=ce,dM=Kt,lM=sM,hM=Dr.f,fM=ve,pM=et,vM=sr,_M=$n,mM=ro,yM=ce,gM=ve,SM=Re,EM=le,bM=ht,kM=de,TM=Kt,IM=tt,AM=Fr,RM=He,CM=yr,wM=As,OM=be,xM=cs,NM=Ga,PM=ei,DM=Cl,MM=Ci,LM=ue,UM=Dr,VM=Fa,FM=_e,BM=$n,jM=Nt.exports,GM=bn,HM=Jt,zM=sr,KM=sM,XM=function(e){var t=uM.Symbol||(uM.Symbol={});dM(t,e)||hM(t,e,{value:lM.f(e)})},WM=function(){var e=pM("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=vM("toPrimitive");t&&!t[n]&&_M(t,n,(function(e){return fM(r,this)}),{arity:1})},qM=Nd,YM=Ln,JM=Ra.forEach,QM=En("hidden"),ZM="Symbol",$M=YM.set,eL=YM.getterFor(ZM),tL=Object.prototype,rL=yM.Symbol,nL=rL&&rL.prototype,iL=yM.TypeError,oL=yM.QObject,aL=LM.f,sL=UM.f,cL=DM.f,uL=FM.f,dL=SM([].push),lL=jM("symbols"),hL=jM("op-symbols"),fL=jM("wks"),pL=!oL||!oL.prototype||!oL.prototype.findChild,vL=EM&&kM((function(){return 7!=xM(sL({},"a",{get:function(){return sL(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=aL(tL,t);n&&delete tL[t],sL(e,t,r),n&&e!==tL&&sL(tL,t,n)}:sL,_L=function(e,t){var r=lL[e]=xM(nL);return $M(r,{type:ZM,tag:e,description:t}),EM||(r.description=t),r},mL=function(e,t,r){e===tL&&mL(hL,t,r),AM(e);var n=CM(t);return AM(r),TM(lL,n)?(r.enumerable?(TM(e,QM)&&e[QM][n]&&(e[QM][n]=!1),r=xM(r,{enumerable:OM(0,!1)})):(TM(e,QM)||sL(e,QM,OM(1,{})),e[QM][n]=!0),vL(e,n,r)):sL(e,n,r)},yL=function(e,t){AM(e);var r=RM(t),n=NM(r).concat(bL(r));return JM(n,(function(t){EM&&!gM(gL,r,t)||mL(e,t,r[t])})),e},gL=function(e){var t=CM(e),r=gM(uL,this,t);return!(this===tL&&TM(lL,t)&&!TM(hL,t))&&(!(r||!TM(this,t)||!TM(lL,t)||TM(this,QM)&&this[QM][t])||r)},SL=function(e,t){var r=RM(e),n=CM(t);if(r!==tL||!TM(lL,n)||TM(hL,n)){var i=aL(r,n);return!i||!TM(lL,n)||TM(r,QM)&&r[QM][n]||(i.enumerable=!0),i}},EL=function(e){var t=cL(RM(e)),r=[];return JM(t,(function(e){TM(lL,e)||TM(GM,e)||dL(r,e)})),r},bL=function(e){var t=e===tL,r=cL(t?hL:RM(e)),n=[];return JM(r,(function(e){!TM(lL,e)||t&&!TM(tL,e)||dL(n,lL[e])})),n};bM||(rL=function(){if(IM(nL,this))throw iL("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?wM(arguments[0]):void 0,t=HM(e),r=function(e){this===tL&&gM(r,hL,e),TM(this,QM)&&TM(this[QM],t)&&(this[QM][t]=!1),vL(this,t,OM(1,e))};return EM&&pL&&vL(tL,t,{configurable:!0,set:r}),_L(t,e)},BM(nL=rL.prototype,"toString",(function(){return eL(this).tag})),BM(rL,"withoutSetter",(function(e){return _L(HM(e),e)})),FM.f=gL,UM.f=mL,VM.f=yL,LM.f=SL,PM.f=DM.f=EL,MM.f=bL,KM.f=function(e){return _L(zM(e),e)},EM&&(sL(nL,"description",{configurable:!0,get:function(){return eL(this).description}}),BM(tL,"propertyIsEnumerable",gL,{unsafe:!0}))),mM({global:!0,constructor:!0,wrap:!0,forced:!bM,sham:!bM},{Symbol:rL}),JM(NM(fL),(function(e){XM(e)})),mM({target:ZM,stat:!0,forced:!bM},{useSetter:function(){pL=!0},useSimple:function(){pL=!1}}),mM({target:"Object",stat:!0,forced:!bM,sham:!EM},{create:function(e,t){return void 0===t?xM(e):yL(xM(e),t)},defineProperty:mL,defineProperties:yL,getOwnPropertyDescriptor:SL}),mM({target:"Object",stat:!0,forced:!bM},{getOwnPropertyNames:EL}),WM(),qM(rL,ZM),GM[QM]=!0;var kL=ht&&!!Symbol.for&&!!Symbol.keyFor,TL=ro,IL=et,AL=Kt,RL=As,CL=Nt.exports,wL=kL,OL=CL("string-to-symbol-registry"),xL=CL("symbol-to-string-registry");TL({target:"Symbol",stat:!0,forced:!wL},{for:function(e){var t=RL(e);if(AL(OL,t))return OL[t];var r=IL("Symbol")(t);return OL[t]=r,xL[r]=t,r}});var NL=ro,PL=Kt,DL=yt,ML=St,LL=kL,UL=(0,Nt.exports)("symbol-to-string-registry");NL({target:"Symbol",stat:!0,forced:!LL},{keyFor:function(e){if(!DL(e))throw TypeError(ML(e)+" is not a symbol");if(PL(UL,e))return UL[e]}});var VL=Ci,FL=Gt;ro({target:"Object",stat:!0,forced:!ht||de((function(){VL.f(1)}))},{getOwnPropertySymbols:function(e){var t=VL.f;return t?t(FL(e)):[]}});var BL={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,f=d.length;for(u=0;u<f;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(BL);var jL=BL.exports,GL="@byted/ve-rtc",HL="@byted/ve-rtc-cache-size",zL=function(){function e(){u(this,e),h(this,"storeKey",void 0),h(this,"logLevel",void 0),h(this,"LogfileSize",void 0),h(this,"db",void 0),h(this,"logId",void 0),h(this,"cacheLog",void 0),h(this,"cachedSize",void 0),h(this,"preCacheTime",void 0),h(this,"timer",void 0),h(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return l(e,[{key:"_createStore",value:function(){var e=this;if(!vD()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(GL);try{localStorage.removeItem(HL)}catch(TQ){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(HL);t?this.cachedSize=+t:this.values().then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(TQ){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(HL,"".concat(this.cachedSize))}catch(TQ){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(GL,e).objectStore(GL)}},{key:"set",value:function(e){var t=this;return new Promise((function(r,n){if("none"===t.logLevel)return r();if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+="\n\n".concat(t.logId,": ").concat(e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var i=t._getStore("readwrite");if(!i)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var o=i.get(t.storeKey);o.onsuccess=function(){try{var a="".concat(o.result||"").concat(t.cacheLog),s=e?"".concat(a?"\n\n":"").concat(t.logId,": ").concat(e):"";i.put("".concat(a).concat(s),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize(["".concat(t.cacheLog).concat(s)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(c){if(!e)return n(c);t.cacheLog+="\n\n".concat(t.logId,": ").concat(e),t.logId++,n(c)}},o.onerror=function(r){if(!e)return n(r);t.cacheLog+="\n\n".concat(t.logId,": ").concat(e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Promise((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new Promise((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return this.keys().then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new Promise((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new Promise((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,"+(t||""),r.click()}))}}]),e}(),KL=new zL,XL="[VERTC]",WL=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],qL=!vD()&&window.location.search.includes("_rtc_debug_"),YL=function(){function e(t,r,n){u(this,e),h(this,"_indent",void 0),h(this,"_module",void 0),h(this,"_id",void 0),this._module=t,this._indent=r}return l(e,[{key:"print",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var o=n.shift();try{var a=[].concat(n),s="".concat(o).replace(/\%o/gi,(function(){var e=a.shift();return JSON.stringify(e)}));KL.set("".concat(XL,"[").concat(this._module,".").concat(e,"] ").concat(s," ").concat(a.map((function(e){return JSON.stringify(e)})).join(", ")))}catch(TQ){}if(qL){for(var c="",u=0;u<this._indent;u++)c+=" ";(t=console).log.apply(t,["%c".concat(JL(),"-").concat(XL).concat(c,"[").concat(this._module,".").concat(e,"] ").concat(o),"color:".concat(WL[this._indent],";")].concat(n))}}}]),e}(),JL=function(){var e=new Date;return e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()},QL=new YL("VERTC",0),ZL=function(e){f(r,e);var t=g(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(n=E(p(r.prototype),"emit",this)).call.apply(n,[this,e].concat(o))}catch(TQ){return QL.print("safaEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,TQ),console.error(TQ),Boolean(t)}}}]),r}(BL.exports.EventEmitter),$L=Kt,eU=function(e){return void 0!==e&&($L(e,"value")||$L(e,"writable"))},tU=ve,rU=Je,nU=Fr,iU=eU,oU=ue,aU=Sd;ro({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return nU(t)===o?t[r]:(n=oU.f(t,r))?iU(n)?n.value:void 0===n.get?void 0:tU(n.get,o):rU(i=aU(t))?e(i,r,o):void 0}});var sU=ce,cU=Nd;ro({global:!0},{Reflect:{}}),cU(sU.Reflect,"Reflect",!0);var uU=ve,dU=Fr,lU=Je,hU=eU,fU=Dr,pU=ue,vU=Sd,_U=be;ro({target:"Reflect",stat:!0,forced:de((function(){var e=function(){},t=fU.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=pU.f(dU(t),r);if(!c){if(lU(o=vU(t)))return e(o,r,n,s);c=_U(0)}if(hU(c)){if(!1===c.writable||!lU(s))return!1;if(i=pU.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,fU.f(s,r,i)}else fU.f(s,r,_U(0,n))}else{if(void 0===(a=c.set))return!1;uU(a,s,n)}return!0}});var mU=ro,yU=Gt,gU=fi,SU=Dv,EU=C_,bU=ao,kU=1!==[].unshift(0),TU=!function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(TQ){return TQ instanceof TypeError}}();mU({target:"Array",proto:!0,arity:1,forced:kU||TU},{unshift:function(e){var t=yU(this),r=gU(t),n=arguments.length;if(n){bU(r+n);for(var i=r;i--;){var o=i+n;i in t?t[o]=t[i]:EU(t,o)}for(var a=0;a<n;a++)t[a]=arguments[a]}return SU(t,r+n)}}),(0,dA.exports)("Uint16",(function(e){return function(t,r,n){return e(this,t,r,n)}})),(0,dA.exports)("Int32",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var IU={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==a(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return[].concat.apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(IU);var AU={},RU={},CU={},wU=IU;function OU(e){for(var t=e.length;--t>=0;)e[t]=0}var xU=256,NU=286,PU=30,DU=15,MU=[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],LU=[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],UU=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],VU=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],FU=new Array(576);OU(FU);var BU=new Array(60);OU(BU);var jU=new Array(512);OU(jU);var GU=new Array(256);OU(GU);var HU=new Array(29);OU(HU);var zU,KU,XU,WU=new Array(PU);function qU(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function YU(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function JU(e){return e<256?jU[e]:jU[256+(e>>>7)]}function QU(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function ZU(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,QU(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function $U(e,t,r){ZU(e,r[2*t],r[2*t+1])}function eV(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function tV(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=DU;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=eV(o[s]++,s))}}function rV(e){var t;for(t=0;t<NU;t++)e.dyn_ltree[2*t]=0;for(t=0;t<PU;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.last_lit=e.matches=0}function nV(e){e.bi_valid>8?QU(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function iV(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function oV(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&iV(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!iV(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function aV(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?$U(e,i,t):($U(e,(o=GU[i])+xU+1,t),0!==(a=MU[o])&&ZU(e,i-=HU[o],a),$U(e,o=JU(--n),r),0!==(a=LU[o])&&ZU(e,n-=WU[o],a))}while(s<e.last_lit);$U(e,256,t)}function sV(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)oV(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],oV(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,oV(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,p=t.stat_desc.max_length,v=0;for(o=0;o<=DU;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>p&&(o=p,v++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=f&&(a=h[n-f]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==v){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,v-=2}while(v>0);for(o=p;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),tV(o,u,e.bl_count)}function cV(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function uV(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{$U(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&($U(e,i,e.bl_tree),s--),$U(e,16,e.bl_tree),ZU(e,s-3,2)):s<=10?($U(e,17,e.bl_tree),ZU(e,s-3,3)):($U(e,18,e.bl_tree),ZU(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}OU(WU);var dV=!1;function lV(e,t,r,n){ZU(e,0+(n?1:0),3),function(e,t,r,n){nV(e),n&&(QU(e,r),QU(e,~r)),wU.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}CU._tr_init=function(e){dV||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(HU[n]=r,e=0;e<1<<MU[n];e++)GU[r++]=n;for(GU[r-1]=n,i=0,n=0;n<16;n++)for(WU[n]=i,e=0;e<1<<LU[n];e++)jU[i++]=n;for(i>>=7;n<PU;n++)for(WU[n]=i<<7,e=0;e<1<<LU[n]-7;e++)jU[256+i++]=n;for(t=0;t<=DU;t++)o[t]=0;for(e=0;e<=143;)FU[2*e+1]=8,e++,o[8]++;for(;e<=255;)FU[2*e+1]=9,e++,o[9]++;for(;e<=279;)FU[2*e+1]=7,e++,o[7]++;for(;e<=287;)FU[2*e+1]=8,e++,o[8]++;for(tV(FU,287,o),e=0;e<PU;e++)BU[2*e+1]=5,BU[2*e]=eV(e,5);zU=new qU(FU,MU,257,NU,DU),KU=new qU(BU,LU,0,PU,DU),XU=new qU(new Array(0),UU,0,19,7)}(),dV=!0),e.l_desc=new YU(e.dyn_ltree,zU),e.d_desc=new YU(e.dyn_dtree,KU),e.bl_desc=new YU(e.bl_tree,XU),e.bi_buf=0,e.bi_valid=0,rV(e)},CU._tr_stored_block=lV,CU._tr_flush_block=function(e,t,r,n){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&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<xU;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),sV(e,e.l_desc),sV(e,e.d_desc),a=function(e){var t;for(cV(e,e.dyn_ltree,e.l_desc.max_code),cV(e,e.dyn_dtree,e.d_desc.max_code),sV(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*VU[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?lV(e,t,r,n):4===e.strategy||o===i?(ZU(e,2+(n?1:0),3),aV(e,FU,BU)):(ZU(e,4+(n?1:0),3),function(e,t,r,n){var i;for(ZU(e,t-257,5),ZU(e,r-1,5),ZU(e,n-4,4),i=0;i<n;i++)ZU(e,e.bl_tree[2*VU[i]+1],3);uV(e,e.dyn_ltree,t-1),uV(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),aV(e,e.dyn_ltree,e.dyn_dtree)),rV(e),n&&nV(e)},CU._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(GU[r]+xU+1)]++,e.dyn_dtree[2*JU(t)]++),e.last_lit===e.lit_bufsize-1},CU._tr_align=function(e){ZU(e,2,3),$U(e,256,FU),function(e){16===e.bi_valid?(QU(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 hV=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var fV=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var pV,vV=function(e,t,r,n){var i=fV,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},_V={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"},mV=IU,yV=CU,gV=hV,SV=vV,EV=_V,bV=-2,kV=258,TV=262,IV=103,AV=113,RV=666;function CV(e,t){return e.msg=EV[t],t}function wV(e){return(e<<1)-(e>4?9:0)}function OV(e){for(var t=e.length;--t>=0;)e[t]=0}function xV(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(mV.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function NV(e,t){yV._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,xV(e.strm)}function PV(e,t){e.pending_buf[e.pending++]=t}function DV(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function MV(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-TV?e.strstart-(e.w_size-TV):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+kV,f=u[o+a-1],p=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===f&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=kV-(h-o),o=h-kV,n>a){if(e.match_start=t,a=n,n>=s)break;f=u[o+a-1],p=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function LV(e){var t,r,n,i,o,a,s,c,u,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-TV)){mV.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,d=void 0,(d=a.avail_in)>u&&(d=u),r=0===d?0:(a.avail_in-=d,mV.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=gV(a.adler,s,d,c):2===a.state.wrap&&(a.adler=SV(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<TV&&0!==e.strm.avail_in)}function UV(e,t){for(var r,n;;){if(e.lookahead<TV){if(LV(e),e.lookahead<TV&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-TV&&(e.match_length=MV(e,r)),e.match_length>=3)if(n=yV._tr_tally(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=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=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=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=yV._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(NV(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(NV(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(NV(e,!1),0===e.strm.avail_out)?1:2}function VV(e,t){for(var r,n,i;;){if(e.lookahead<TV){if(LV(e),e.lookahead<TV&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=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!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-TV&&(e.match_length=MV(e,r),e.match_length<=5&&(1===e.strategy||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,n=yV._tr_tally(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=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=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++,n&&(NV(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=yV._tr_tally(e,0,e.window[e.strstart-1]))&&NV(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&&(n=yV._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(NV(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(NV(e,!1),0===e.strm.avail_out)?1:2}function FV(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function BV(){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=8,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 mV.Buf16(1146),this.dyn_dtree=new mV.Buf16(122),this.bl_tree=new mV.Buf16(78),OV(this.dyn_ltree),OV(this.dyn_dtree),OV(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new mV.Buf16(16),this.heap=new mV.Buf16(573),OV(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new mV.Buf16(573),OV(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function jV(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:AV,e.adler=2===t.wrap?0:1,t.last_flush=0,yV._tr_init(t),0):CV(e,bV)}function GV(e){var t,r=jV(e);return 0===r&&((t=e.state).window_size=2*t.w_size,OV(t.head),t.max_lazy_match=pV[t.level].max_lazy,t.good_match=pV[t.level].good_length,t.nice_match=pV[t.level].nice_length,t.max_chain_length=pV[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function HV(e,t,r,n,i,o){if(!e)return bV;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return CV(e,bV);8===n&&(n=9);var s=new BV;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,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 mV.Buf8(2*s.w_size),s.head=new mV.Buf16(s.hash_size),s.prev=new mV.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new mV.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,GV(e)}pV=[new FV(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(LV(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,NV(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-TV&&(NV(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(NV(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(NV(e,!1),e.strm.avail_out),1)})),new FV(4,4,8,4,UV),new FV(4,5,16,8,UV),new FV(4,6,32,32,UV),new FV(4,4,16,16,VV),new FV(8,16,32,32,VV),new FV(8,16,128,128,VV),new FV(8,32,128,256,VV),new FV(32,128,258,1024,VV),new FV(32,258,258,4096,VV)],RU.deflateInit=function(e,t){return HV(e,t,8,15,8,0)},RU.deflateInit2=HV,RU.deflateReset=GV,RU.deflateResetKeep=jV,RU.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?bV:(e.state.gzhead=t,0):bV},RU.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?CV(e,bV):bV;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===RV&&4!==t)return CV(e,0===e.avail_out?-5:bV);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,PV(n,31),PV(n,139),PV(n,8),n.gzhead?(PV(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)),PV(n,255&n.gzhead.time),PV(n,n.gzhead.time>>8&255),PV(n,n.gzhead.time>>16&255),PV(n,n.gzhead.time>>24&255),PV(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),PV(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(PV(n,255&n.gzhead.extra.length),PV(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=SV(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(PV(n,0),PV(n,0),PV(n,0),PV(n,0),PV(n,0),PV(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),PV(n,3),n.status=AV);else{var a=8+(n.w_bits-8<<4)<<8;a|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=AV,DV(n,a),0!==n.strstart&&(DV(n,e.adler>>>16),DV(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=SV(e.adler,n.pending_buf,n.pending-i,i)),xV(e),i=n.pending,n.pending!==n.pending_buf_size));)PV(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=SV(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=SV(e.adler,n.pending_buf,n.pending-i,i)),xV(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,PV(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=SV(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=SV(e.adler,n.pending_buf,n.pending-i,i)),xV(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,PV(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=SV(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=IV)}else n.status=IV;if(n.status===IV&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&xV(e),n.pending+2<=n.pending_buf_size&&(PV(n,255&e.adler),PV(n,e.adler>>8&255),e.adler=0,n.status=AV)):n.status=AV),0!==n.pending){if(xV(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&wV(t)<=wV(r)&&4!==t)return CV(e,-5);if(n.status===RV&&0!==e.avail_in)return CV(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==RV){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(LV(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=yV._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(NV(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(NV(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(NV(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=kV){if(LV(e),e.lookahead<=kV&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+kV;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=kV-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=yV._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=yV._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(NV(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(NV(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(NV(e,!1),0===e.strm.avail_out)?1:2}(n,t):pV[n.level].func(n,t);if(3!==s&&4!==s||(n.status=RV),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?yV._tr_align(n):5!==t&&(yV._tr_stored_block(n,0,0,!1),3===t&&(OV(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),xV(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(PV(n,255&e.adler),PV(n,e.adler>>8&255),PV(n,e.adler>>16&255),PV(n,e.adler>>24&255),PV(n,255&e.total_in),PV(n,e.total_in>>8&255),PV(n,e.total_in>>16&255),PV(n,e.total_in>>24&255)):(DV(n,e.adler>>>16),DV(n,65535&e.adler)),xV(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},RU.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==IV&&t!==AV&&t!==RV?CV(e,bV):(e.state=null,t===AV?CV(e,-3):0):bV},RU.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return bV;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return bV;for(1===o&&(e.adler=gV(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(OV(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new mV.Buf8(r.w_size),mV.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=d,e.next_in=0,e.input=t,LV(r);r.lookahead>=3;){n=r.strstart,i=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=2,LV(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=s,e.input=c,e.avail_in=a,r.wrap=o,0},RU.deflateInfo="pako deflate (from Nodeca project)";var zV={},KV=IU,XV=!0,WV=!0;try{String.fromCharCode.apply(null,[0])}catch(IQ){XV=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(IQ){WV=!1}for(var qV=new KV.Buf8(256),YV=0;YV<256;YV++)qV[YV]=YV>=252?6:YV>=248?5:YV>=240?4:YV>=224?3:YV>=192?2:1;function JV(e,t){if(t<65534&&(e.subarray&&WV||!e.subarray&&XV))return String.fromCharCode.apply(null,KV.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}qV[254]=qV[254]=1,zV.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new KV.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},zV.buf2binstring=function(e){return JV(e,e.length)},zV.binstring2buf=function(e){for(var t=new KV.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},zV.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=qV[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return JV(s,n)},zV.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+qV[e[r]]>t?r:t};var QV=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},ZV=RU,$V=IU,eF=zV,tF=_V,rF=QV,nF=Object.prototype.toString;function iF(e){if(!(this instanceof iF))return new iF(e);this.options=$V.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new rF,this.strm.avail_out=0;var r=ZV.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(tF[r]);if(t.header&&ZV.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?eF.string2buf(t.dictionary):"[object ArrayBuffer]"===nF.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=ZV.deflateSetDictionary(this.strm,n)))throw new Error(tF[r]);this._dict_set=!0}}function oF(e,t){var r=new iF(t);if(r.push(e,!0),r.err)throw r.msg||tF[r.err];return r.result}iF.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=eF.string2buf(e):"[object ArrayBuffer]"===nF.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new $V.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=ZV.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(eF.buf2binstring($V.shrinkBuf(i.output,i.next_out))):this.onData($V.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=ZV.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},iF.prototype.onData=function(e){this.chunks.push(e)},iF.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=$V.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},AU.Deflate=iF,AU.deflate=oF,AU.deflateRaw=function(e,t){return(t=t||{}).raw=!0,oF(e,t)},AU.gzip=function(e,t){return(t=t||{}).gzip=!0,oF(e,t)};var aF={},sF=le,cF=tS,uF=Vs,dF=de,lF=ce.RegExp,hF=lF.prototype;sF&&dF((function(){var e=!0;try{lF(".","d")}catch(TQ){e=!1}var t={},r="",n=e?"dgimsy":"gimsy",i=function(e,n){Object.defineProperty(t,e,{get:function(){return r+=n,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(o.hasIndices="d"),o)i(a,o[a]);return Object.getOwnPropertyDescriptor(hF,"flags").get.call(t)!==n||r!==n}))&&cF(hF,"flags",{configurable:!0,get:uF});var fF={},pF=IU,vF=15,_F=[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],mF=[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],yF=[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],gF=[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],SF=IU,EF=hV,bF=vV,kF=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,A=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,f=r.hold,p=r.bits,v=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,y=(1<<r.distbits)-1;e:do{p<15&&(f+=I[n++]<<p,p+=8,f+=I[n++]<<p,p+=8),g=v[f&m];t:for(;;){if(f>>>=S=g>>>24,p-=S,0===(S=g>>>16&255))A[o++]=65535&g;else{if(!(16&S)){if(0==(64&S)){g=v[(65535&g)+(f&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}E=65535&g,(S&=15)&&(p<S&&(f+=I[n++]<<p,p+=8),E+=f&(1<<S)-1,f>>>=S,p-=S),p<15&&(f+=I[n++]<<p,p+=8,f+=I[n++]<<p,p+=8),g=_[f&y];r:for(;;){if(f>>>=S=g>>>24,p-=S,!(16&(S=g>>>16&255))){if(0==(64&S)){g=_[(65535&g)+(f&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(b=65535&g,p<(S&=15)&&(f+=I[n++]<<p,(p+=8)<S&&(f+=I[n++]<<p,p+=8)),(b+=f&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(f>>>=S,p-=S,b>(S=o-a)){if((S=b-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=u-S,S<E){E-=S;do{A[o++]=h[k++]}while(--S);k=o-b,T=A}}else if(l<S){if(k+=u+l-S,(S-=l)<E){E-=S;do{A[o++]=h[k++]}while(--S);if(k=0,l<E){E-=S=l;do{A[o++]=h[k++]}while(--S);k=o-b,T=A}}}else if(k+=l-S,S<E){E-=S;do{A[o++]=h[k++]}while(--S);k=o-b,T=A}for(;E>2;)A[o++]=T[k++],A[o++]=T[k++],A[o++]=T[k++],E-=3;E&&(A[o++]=T[k++],E>1&&(A[o++]=T[k++]))}else{k=o-b;do{A[o++]=A[k++],A[o++]=A[k++],A[o++]=A[k++],E-=3}while(E>2);E&&(A[o++]=A[k++],E>1&&(A[o++]=A[k++]))}break}}break}}while(n<i&&o<s);n-=E=p>>3,f&=(1<<(p-=E<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=f,r.bits=p},TF=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,f,p,v,_,m=s.bits,y=0,g=0,S=0,E=0,b=0,k=0,T=0,I=0,A=0,R=0,C=null,w=0,O=new pF.Buf16(16),x=new pF.Buf16(16),N=null,P=0;for(y=0;y<=vF;y++)O[y]=0;for(g=0;g<n;g++)O[t[r+g]]++;for(b=m,E=vF;E>=1&&0===O[E];E--);if(b>E&&(b=E),0===E)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<E&&0===O[S];S++);for(b<S&&(b=S),I=1,y=1;y<=vF;y++)if(I<<=1,(I-=O[y])<0)return-1;if(I>0&&(0===e||1!==E))return-1;for(x[1]=0,y=1;y<vF;y++)x[y+1]=x[y]+O[y];for(g=0;g<n;g++)0!==t[r+g]&&(a[x[t[r+g]]++]=g);if(0===e?(C=N=a,f=19):1===e?(C=_F,w-=257,N=mF,P-=257,f=256):(C=yF,N=gF,f=-1),R=0,g=0,y=S,h=o,k=b,T=0,d=-1,l=(A=1<<b)-1,1===e&&A>852||2===e&&A>592)return 1;for(;;){p=y-T,a[g]<f?(v=0,_=a[g]):a[g]>f?(v=N[P+a[g]],_=C[w+a[g]]):(v=96,_=0),c=1<<y-T,S=u=1<<k;do{i[h+(R>>T)+(u-=c)]=p<<24|v<<16|_|0}while(0!==u);for(c=1<<y-1;R&c;)c>>=1;if(0!==c?(R&=c-1,R+=c):R=0,g++,0==--O[y]){if(y===E)break;y=t[r+a[g]]}if(y>b&&(R&l)!==d){for(0===T&&(T=b),h+=S,I=1<<(k=y-T);k+T<E&&!((I-=O[k+T])<=0);)k++,I<<=1;if(A+=1<<k,1===e&&A>852||2===e&&A>592)return 1;i[d=R&l]=b<<24|k<<16|h-o|0}}return 0!==R&&(i[h+R]=y-T<<24|64<<16|0),s.bits=b,0},IF=-2,AF=12,RF=30;function CF(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function wF(){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 SF.Buf16(320),this.work=new SF.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function OF(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new SF.Buf32(852),t.distcode=t.distdyn=new SF.Buf32(592),t.sane=1,t.back=-1,0):IF}function xF(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,OF(e)):IF}function NF(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?IF:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,xF(e))):IF}function PF(e,t){var r,n;return e?(n=new wF,e.state=n,n.window=null,0!==(r=NF(e,t))&&(e.state=null),r):IF}var DF,MF,LF=!0;function UF(e){if(LF){var t;for(DF=new SF.Buf32(512),MF=new SF.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(TF(1,e.lens,0,288,DF,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;TF(2,e.lens,0,32,MF,0,e.work,{bits:5}),LF=!1}e.lencode=DF,e.lenbits=9,e.distcode=MF,e.distbits=5}function VF(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new SF.Buf8(o.wsize)),n>=o.wsize?(SF.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),SF.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(SF.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}fF.inflateReset=xF,fF.inflateReset2=NF,fF.inflateResetKeep=OF,fF.inflateInit=function(e){return PF(e,15)},fF.inflateInit2=PF,fF.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A=0,R=new SF.Buf8(4),C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return IF;(r=e.state).mode===AF&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,k=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===u){r.check=0,R[0]=255&u,R[1]=u>>>8&255,r.check=bF(r.check,R,2,0),u=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=RF;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=RF;break}if(d-=4,b=8+(15&(u>>>=4)),0===r.wbits)r.wbits=b;else if(b>r.wbits){e.msg="invalid window size",r.mode=RF;break}r.dmax=1<<b,e.adler=r.check=1,r.mode=512&u?10:AF,u=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.flags=u,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=RF;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=RF;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(R[0]=255&u,R[1]=u>>>8&255,r.check=bF(r.check,R,2,0)),u=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.time=u),512&r.flags&&(R[0]=255&u,R[1]=u>>>8&255,R[2]=u>>>16&255,R[3]=u>>>24&255,r.check=bF(r.check,R,4,0)),u=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(R[0]=255&u,R[1]=u>>>8&255,r.check=bF(r.check,R,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&r.flags){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(R[0]=255&u,R[1]=u>>>8&255,r.check=bF(r.check,R,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((f=r.length)>s&&(f=s),f&&(r.head&&(b=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),SF.arraySet(r.head.extra,n,o,f,b)),512&r.flags&&(r.check=bF(r.check,n,f,o)),s-=f,o+=f,r.length-=f),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;f=0;do{b=n[o+f++],r.head&&b&&r.length<65536&&(r.head.name+=String.fromCharCode(b))}while(b&&f<s);if(512&r.flags&&(r.check=bF(r.check,n,f,o)),s-=f,o+=f,b)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===s)break e;f=0;do{b=n[o+f++],r.head&&b&&r.length<65536&&(r.head.comment+=String.fromCharCode(b))}while(b&&f<s);if(512&r.flags&&(r.check=bF(r.check,n,f,o)),s-=f,o+=f,b)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=RF;break}u=0,d=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=AF;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=CF(u),u=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=AF;case AF:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(UF(r),r.mode=20,6===t){u>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=RF}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=RF;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(f=r.length){if(f>s&&(f=s),f>c&&(f=c),0===f)break e;SF.arraySet(i,n,o,f,a),s-=f,o+=f,c-=f,a+=f,r.length-=f;break}r.mode=AF;break;case 17:for(;d<14;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=RF;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[C[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[C[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T={bits:r.lenbits},k=TF(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=RF;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(A=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(y<16)u>>>=_,d-=_,r.lens[r.have++]=y;else{if(16===y){for(I=_+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=RF;break}b=r.lens[r.have-1],f=3+(3&u),u>>>=2,d-=2}else if(17===y){for(I=_+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,b=0,f=3+(7&(u>>>=_)),u>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,b=0,f=11+(127&(u>>>=_)),u>>>=7,d-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=RF;break}for(;f--;)r.lens[r.have++]=b}}if(r.mode===RF)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=RF;break}if(r.lenbits=9,T={bits:r.lenbits},k=TF(1,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=RF;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=TF(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=RF;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,kF(e,h),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,r.mode===AF&&(r.back=-1);break}for(r.back=0;m=(A=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(g=_,S=m,E=y;m=(A=r.lencode[E+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&A,!(g+(_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,r.length=y,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=AF;break}if(64&m){e.msg="invalid literal/length code",r.mode=RF;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(A=r.distcode[u&(1<<r.distbits)-1])>>>16&255,y=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(g=_,S=m,E=y;m=(A=r.distcode[E+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&A,!(g+(_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=RF;break}r.offset=y,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=RF;break}r.mode=25;case 25:if(0===c)break e;if(f=h-c,r.offset>f){if((f=r.offset-f)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=RF;break}f>r.wnext?(f-=r.wnext,p=r.wsize-f):p=r.wnext-f,f>r.length&&(f=r.length),v=r.window}else v=i,p=a-r.offset,f=r.length;f>c&&(f=c),c-=f,r.length-=f;do{i[a++]=v[p++]}while(--f);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=r.flags?bF(r.check,i,h,a-h):EF(r.check,i,h,a-h)),h=c,(r.flags?u:CF(u))!==r.check){e.msg="incorrect data check",r.mode=RF;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=RF;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case RF:k=-3;break e;case 31:return-4;default:return IF}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<RF&&(r.mode<27||4!==t))&&VF(e,e.output,e.next_out,h-e.avail_out),l-=e.avail_in,h-=e.avail_out,e.total_in+=l,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=r.flags?bF(r.check,i,h,e.next_out-h):EF(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===AF?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===k&&(k=-5),k},fF.inflateEnd=function(e){if(!e||!e.state)return IF;var t=e.state;return t.window&&(t.window=null),e.state=null,0},fF.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?IF:(r.head=t,t.done=!1,0):IF},fF.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?IF:11===r.mode&&EF(1,t,n,0)!==r.check?-3:VF(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):IF},fF.inflateInfo="pako inflate (from Nodeca project)";var FF={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_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};var BF=fF,jF=IU,GF=zV,HF=FF,zF=_V,KF=QV,XF=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},WF=Object.prototype.toString;function qF(e){if(!(this instanceof qF))return new qF(e);this.options=jF.assign({chunkSize:16384,windowBits:0,to:""},e||{});var 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&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new KF,this.strm.avail_out=0;var r=BF.inflateInit2(this.strm,t.windowBits);if(r!==HF.Z_OK)throw new Error(zF[r]);if(this.header=new XF,BF.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=GF.string2buf(t.dictionary):"[object ArrayBuffer]"===WF.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=BF.inflateSetDictionary(this.strm,t.dictionary))!==HF.Z_OK))throw new Error(zF[r])}function YF(e,t){var r=new qF(t);if(r.push(e,!0),r.err)throw r.msg||zF[r.err];return r.result}qF.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?HF.Z_FINISH:HF.Z_NO_FLUSH,"string"==typeof e?s.input=GF.binstring2buf(e):"[object ArrayBuffer]"===WF.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new jF.Buf8(c),s.next_out=0,s.avail_out=c),(r=BF.inflate(s,HF.Z_NO_FLUSH))===HF.Z_NEED_DICT&&u&&(r=BF.inflateSetDictionary(this.strm,u)),r===HF.Z_BUF_ERROR&&!0===d&&(r=HF.Z_OK,d=!1),r!==HF.Z_STREAM_END&&r!==HF.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==HF.Z_STREAM_END&&(0!==s.avail_in||n!==HF.Z_FINISH&&n!==HF.Z_SYNC_FLUSH)||("string"===this.options.to?(i=GF.utf8border(s.output,s.next_out),o=s.next_out-i,a=GF.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&jF.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(jF.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==HF.Z_STREAM_END);return r===HF.Z_STREAM_END&&(n=HF.Z_FINISH),n===HF.Z_FINISH?(r=BF.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===HF.Z_OK):n!==HF.Z_SYNC_FLUSH||(this.onEnd(HF.Z_OK),s.avail_out=0,!0)},qF.prototype.onData=function(e){this.chunks.push(e)},qF.prototype.onEnd=function(e){e===HF.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=jF.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},aF.Inflate=qF,aF.inflate=YF,aF.inflateRaw=function(e,t){return(t=t||{}).raw=!0,YF(e,t)},aF.ungzip=YF;var JF={};(0,IU.assign)(JF,AU,aF,FF);var QF=JF,ZF="BytePlusRTC",$F=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},eB=function(){function e(t){u(this,e),h(this,"storeName",void 0),h(this,"pendingList",[]),this.storeName=t,!vD()&&$F()&&this._checkAndCreateStore(t)}var t,r;return l(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?$F().open(ZF,r):$F().open(ZF);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=c(o().mark((function e(t){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,a=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:s=e.sent,i(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),a();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(a){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new Promise((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",value:(r=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new Promise((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new Promise((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();h(eB,"db",void 0),h(eB,"state","init");var tB=function(e){return e.RTC="rtc",e}(tB||{}),rB=function(e){return e.W_5="5",e}(rB||{}),nB=function(e){return e.IOS="ios",e.ANDROID="android",e.WEB="web",e.WINDOWS="windows",e.MAC="mac",e.LINUX="linux",e}(nB||{}),iB=function(e){return e.REQUEST="request",e.RESPONSE="response",e}(iB||{}),oB=function(e){return e.WEBSOCKET_RECONNECTING="websocket reconnecting",e.PEERCONNECTION_RECONNECTING="peerconnection reconnecting",e.DISCONNECTED="DISCONNECTED",e.LAN="LAN",e.WIFI="WIFI",e.W_2="2G",e.W_3="3G",e.W_4="4G",e.W_5="5G",e.UNKNOWN="UNKNOWN",e}(oB||{}),aB=function(e){return e.WEBSOCKET="websocket",e.NETWORKCHANGED="networkChanged",e.PEERCONNECTION="peerconnection",e}(aB||{}),sB=function(e){return e.WEBSOCKET_RECONNECTED="websocket reconnected",e.PEERCONNECTION_RECONNECTED="peerconnection reconnected",e}(sB||{}),cB=function(e){return e.WEBSOCKET="websocket",e.NETWORKCHANGED="networkChanged",e.PEERCONNECTION="peerconnection",e}(cB||{}),uB=function(e){return e.REQUEST="request",e.RESPONSE="response",e.KCP_REQUEST="kcp request",e.KCP_RESPONSE="kcp response",e.QUIC_REQUEST="quic request",e.QUIC_RESPONSE="quic response",e}(uB||{}),dB=function(e){return e.NEW="NEW",e.CHECKING="CHECKING",e.CONNECTED="CONNECTED",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.DISCONNECTED="DISCONNECTED",e.CLOSED="CLOSED",e.DATACHANNEL_CONNECTING="DATACHANNEL_CONNECTING",e.DATACHANNEL_OPEN="DATACHANNEL_OPEN",e.DATACHANNEL_CLOSING="DATACHANNEL_CLOSING",e.DATACHANNEL_CLOSED="DATACHANNEL_CLOSED",e}(dB||{}),lB=function(e){return e.SUCCEED="succeed",e.MESSAGE_ID_ERROR="message id error",e.ZIP_FAILED="zip failed",e.UNZIP_FAILED="unzip failed",e.MESSAGE_KEY_EMPTY="message key empty",e.MESSAGE_KEY_PARSE_FAILED="message key parse failed",e.MESSAGE_KEY_INVALID="message key invalid",e.ENCRYPT_FAILED="encrypt failed",e.DECRYPT_FAILED="decrypt failed",e.MESSAGE_TOO_BIG="message too big",e.INVALID_DATA="invalid data",e.MESSAGE_PARSE_FAILED="message parse failed",e}(lB||{}),hB=function(e){return e.UP="up",e.DOWN="down",e.DIRECT="direct",e}(hB||{}),fB=function(e){return e.UP="up",e.DOWN="down",e.PRE="pre",e}(fB||{}),pB=function(e){return e.UP="up",e.DOWN="down",e.PRE="pre",e}(pB||{}),vB=function(e){return e.W_0="0",e.W_1="1",e}(vB||{}),_B=function(e){return e.UP="up",e.DOWN="down",e}(_B||{}),mB=function(e){return e.ANSWER="answer",e.INCRANSWER="incranswer",e}(mB||{}),yB=function(e){return e.UP="up",e.DOWN="down",e}(yB||{}),gB=function(e){return e.SUCCESS="success",e.FAIL="fail",e}(gB||{}),SB=function(e){return e.W_0="0",e.W_1="1",e}(SB||{}),EB=function(e){return e.LEAVE_ROOM="leave room",e.ACK_FAILED="ack failed",e.SET_ANSWER_SDP_FAILED="set answer sdp failed",e.ICE_FAILED="ice failed",e.STREAM_FAILED="stream failed",e.NETWORK_RECONNECTED="network reconnected",e.JOIN_ROOM_ACK_FAILED="join room ack failed",e.UNKNOWN="unknown",e}(EB||{}),bB=function(e){return e.SUCCESS="success",e.FAIL="fail",e.IGNORE="ignore",e}(bB||{}),kB=function(e){return e.LEAVE_ROOM="leave room",e.ACK_FAILED="ack failed",e.SET_ANSWER_SDP_FAILED="set answer sdp failed",e.ICE_FAILED="ice failed",e.STREAM_FAILED="stream failed",e.NETWORK_RECONNECTED="network reconnected",e.ON_STREAM_REMOVE="on stream remove",e.PUBLISH_MUTE="publish mute",e.UNKNOWN="unknown",e.ON_STREAM_REMOVE_CLIENT_UNPUBLISHED="on stream remove:client unpublished",e.ON_STREAM_REMOVE_PUBLISH_FAILED="on stream remove:publish failed",e.ON_STREAM_REMOVE_STREAM_REMOVED="on stream remove:stream removed",e.ON_STREAM_REMOVE_CLIENT_DISCONNECTED="on stream remove:client disconnected",e.ON_STREAM_REMOVE_CLIENT_REPUBLISH="on stream remove:client republish",e}(kB||{}),TB=function(e){return e.PLAYOUT_DEVICE_SWITCH="playout_device_switch",e.RECORD_DEVICE_SWITCH="record_device_switch",e.UNKNOWN="unknown",e}(TB||{}),IB=function(e){return e.BEGIN_SEND="begin_send",e.SENT_END="sent_end",e.BEGIN_RECV="begin_recv",e.RECV_END="recv_end",e}(IB||{}),AB=function(e){return e.AUDIO="audio",e.VIDEO="video",e.SCREEN_VIDEO="screen_video",e.SCREEN_AUDIO="screen_audio",e}(AB||{}),RB=function(e){return e.LOGIN="login",e.PUBLISHER="publisher",e.UNMUTE="unmute",e.ENABLE="enable",e.PUSH="push",e.PUBLISH="publish",e.ONDEMAND="ondemand",e.SUBSCRIBE="subscribe",e.PUSH_TRACK="push_track",e.REMOTE_UNMUTE="remote_unmute",e.P2P="p2p",e}(RB||{}),CB=function(e){return e.TIMEOUT="timeout",e.AUDIENCE="audience",e.MUTE="mute",e.DISABLE="disable",e.STOP_PUSH="stop_push",e.UNPUBLISH="unpublish",e.NO_DEMAND="no_demand",e.LEAVE_ROOM="leave_room",e.UNSUBSCRIBE="unsubscribe",e.REMOVE_TRACK="remove_track",e.REMOTE_MUTE="remote_mute",e.USER_LEAVE="user_leave",e}(CB||{}),wB=function(e){return e.BEGIN="begin",e.END="end",e}(wB||{}),OB=function(e){return e.BEGIN="begin",e.END="end",e}(OB||{}),xB=function(e){return e.LEAVE_ROOM="leave_room",e.ACK_FAILED="ack_failed",e.TOKEN_ERROR="token_error",e.SIGNALING_ERROR="signaling_error",e.TIMEOUT_10="timeout_10",e.TIMEOUT_60="timeout_60",e}(xB||{}),NB=function(e){return e.P2P="p2p",e.P2P_OUTSIDE_ROOM="p2p_outside_room",e.P2SERVER="p2server",e}(NB||{}),PB=function(e){return e.START="start",e.START_CAPTURE_RESULT="start_capture_result",e.STARTED="started",e.RUNNING_FAILED="running_failed",e.STOP="stop",e.STOPPED="stopped",e}(PB||{}),DB=function(e){return e.SUCCESS="success",e.CAMERA_DEVICE_NO_PERMISSION="camera_device_no_permission",e.CAMERA_DEVICE_BUSY="camera_device_busy",e.CAMERA_DEVICE_FAILURE="camera_device_failure",e.CAMERA_DEVICE_NOT_FOUND="camera_device_not_found",e.CAMERA_DEVICE_DISCONNECTED="camera_device_disconnected",e.TIMEOUT="timeout",e.ABORT="abort",e}(DB||{}),MB=function(){function e(t){u(this,e),h(this,"_event_key",void 0),h(this,"_device_id",void 0),h(this,"_rtc_app_id",void 0),h(this,"_product_line",void 0),h(this,"_report_version",void 0),h(this,"_os",void 0),h(this,"_rtc_sdk_version",void 0),h(this,"_rtc_timestamp",void 0),h(this,"_rtc_sdk_git_commit",void 0),h(this,"_report_id",void 0),h(this,"_connection_id",void 0),h(this,"_rtc_sid",void 0),h(this,"_engine_session_id",void 0),h(this,"_rtc_business_id",void 0),h(this,"_app_state",void 0),h(this,"_project_key",void 0),h(this,"_network_type",void 0),h(this,"_app_version",void 0),h(this,"_aid",void 0),h(this,"_device_model",void 0),h(this,"_device_brand",void 0),h(this,"_common_extra_info",void 0),h(this,"_had_selected_p2p",void 0),h(this,"_rtc_env_type",void 0),h(this,"_room_id",void 0),h(this,"_user_id",void 0),h(this,"_rtc_session_id",void 0),h(this,"_user_agent",void 0),h(this,"_auto_play_policy",void 0),h(this,"_platform",void 0),h(this,"_product",void 0),h(this,"_log_cache_key",void 0),h(this,"_overSea","0"),this.monitor=t}return l(e,[{key:"setStats",value:function(e){var t=this;Object.keys(e).forEach((function(r){t["_"+r]=e[r]})),this.monitor.StartUp()}},{key:"event_key",get:function(){return this._event_key}},{key:"device_id",get:function(){return this._device_id}},{key:"rtc_app_id",get:function(){return this._rtc_app_id}},{key:"product_line",get:function(){return this._product_line}},{key:"report_version",get:function(){return this._report_version}},{key:"os",get:function(){return this._os}},{key:"rtc_sdk_version",get:function(){return this._rtc_sdk_version}},{key:"rtc_timestamp",get:function(){return this._rtc_timestamp}},{key:"rtc_sdk_git_commit",get:function(){return this._rtc_sdk_git_commit}},{key:"report_id",get:function(){return this._report_id}},{key:"connection_id",get:function(){return this._connection_id}},{key:"rtc_sid",get:function(){return this._rtc_sid}},{key:"engine_session_id",get:function(){return this._engine_session_id}},{key:"rtc_business_id",get:function(){return this._rtc_business_id}},{key:"app_state",get:function(){return this._app_state}},{key:"project_key",get:function(){return this._project_key}},{key:"network_type",get:function(){return this._network_type}},{key:"app_version",get:function(){return this._app_version}},{key:"aid",get:function(){return this._aid}},{key:"device_model",get:function(){return this._device_model}},{key:"device_brand",get:function(){return this._device_brand}},{key:"common_extra_info",get:function(){return this._common_extra_info}},{key:"had_selected_p2p",get:function(){return this._had_selected_p2p}},{key:"rtc_env_type",get:function(){return this._rtc_env_type}},{key:"room_id",get:function(){return this._room_id}},{key:"user_id",get:function(){return this._user_id}},{key:"rtc_session_id",get:function(){return this._rtc_session_id}},{key:"user_agent",get:function(){return this._user_agent}},{key:"auto_play_policy",get:function(){return this._auto_play_policy}},{key:"platform",get:function(){return this._platform||"web"}},{key:"product",get:function(){return this._product||"webrtc"}},{key:"log_cache_key",get:function(){return this._log_cache_key}},{key:"overSea",get:function(){return this._overSea}}]),e}(),LB="ReportErrorBuffer",UB=function(){function e(){u(this,e),h(this,"_buffer",new eB(LB))}var t,r;return l(e,[{key:"set",value:(r=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,LB);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(LB);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),VB=function(e){f(n,e);var t,r=g(n);function n(){var e;return u(this,n),h(m(e=r.call(this)),"report_id",void 0),h(m(e),"report_common",void 0),h(m(e),"modify_ids",void 0),h(m(e),"dataBuffer",void 0),h(m(e),"posting",void 0),h(m(e),"sucSendTimer",void 0),h(m(e),"preSucTime",void 0),h(m(e),"errSendTimer",void 0),h(m(e),"errSendDelay",void 0),h(m(e),"errSendBuffer",void 0),h(m(e),"commonStats",void 0),h(m(e),"_retryCount",0),e.report_id=0,e.dataBuffer=[],e.posting=!1,e.report_common={},e.modify_ids={},e.preSucTime=0,e.errSendDelay=100,e.commonStats=new MB(m(e)),vD()||window.addEventListener("beforeunload",(function(){clearTimeout(e.errSendTimer),clearTimeout(e.sucSendTimer),e.send(null,!0)})),e}return l(n,[{key:"push",value:function(e,t){t?this.send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send()))}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new UB,this.loadErrorBuffer()}},{key:"unshift",value:function(e){this.dataBuffer=e.concat(this.dataBuffer)}},{key:"send",value:function(e,t){var r=this;if(e||this.dataBuffer.length){var n={data:e||this.dataBuffer.splice(0,4e3),header:i(i({},this.report_common),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},o=new XMLHttpRequest;o.timeout=1e4,o.onreadystatechange=function(){if(4===o.readyState){var i,a,s,c;if(e||(r.posting=!1),200===o.status||304===o.status)try{i=JSON.parse(o.responseText)}catch(TQ){a=TQ}if(i&&0===i.StatusCode){if(!e&&!t)!vD()&&location.search.includes("_rtc_autotest_")&&r.safeEmit("report_event",n),null===(s=r.errSendBuffer)||void 0===s||s.set([]),r.sucSend()}else if(setTimeout((function(){var e;r.rtcError("reportor error, res:".concat(null===(e=i)||void 0===e?void 0:e.toString()," err:").concat(a),o.status,a)}),0),e)r.send(e);else r.unshift(n.data),null===(c=r.errSendBuffer)||void 0===c||c.set(k(r.dataBuffer)),t?r.send():r.errSend()}};var a=dj.LOG_SERVER_URL;if(o.open("POST",a,!0),e||(this.posting=!0),!vD()&&location.search.includes("_rtc_debug_"))o.send(JSON.stringify(n));else{var s=QF.gzip(JSON.stringify(n));o.setRequestHeader("Content-Encoding","gzip"),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),o.send(s)}}}},{key:"sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=setTimeout(this.send.bind(this),2e3)}},{key:"errSend",value:function(){var e=this;this.errSendTimer=setTimeout((function(){e.send(),e.errSendTimer=null}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=c(o().mark((function e(){var t,r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"StartUp",value:function(){var e=this.report_common,t=this.commonStats,r=t.event_key,n=t.device_id,i=t.rtc_app_id,o=t.product_line,a=t.report_version,s=t.os,c=t.rtc_sdk_version,u=t.rtc_timestamp,d=t.rtc_sdk_git_commit,l=t.report_id,h=t.rtc_sid,f=t.engine_session_id,p=t.rtc_business_id,v=t.project_key,_=t.network_type,m=t.app_version,y=t.aid,g=t.device_model,S=t.device_brand,E=t.common_extra_info,b=t.had_selected_p2p,k=t.rtc_env_type,T=t.user_agent,I=t.auto_play_policy,A=t.platform,R=t.product,C=t.log_cache_key,w=t.overSea;Object.assign(e,{event_key:r,device_id:n,rtc_app_id:i,product_line:o,report_version:a,os:s,rtc_sdk_version:c,rtc_timestamp:u,rtc_sdk_git_commit:d,report_id:l,rtc_sid:h,engine_session_id:f,rtc_business_id:p,project_key:v,network_type:_,app_version:m,aid:y,device_model:g,device_brand:S,common_extra_info:E,had_selected_p2p:b,rtc_env_type:k,user_agent:T,auto_play_policy:I,platform:A,product:R,log_cache_key:C,extra_is_oversea:w}),this.modify_ids.room_id=this.commonStats.room_id,this.modify_ids.user_id=this.commonStats.user_id,this.modify_ids.rtc_session_id=this.commonStats.rtc_session_id,this.modify_ids.connection_id=this.commonStats.connection_id,this.modify_ids.app_state=this.commonStats.app_state}},{key:"rtcSdkApiCall",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_sdk_api_call",report_id:this.report_id++,rtc_timestamp:Date.now(),sdk_api_name:e,error_code:t,message:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});n.streamId&&(o.stream_id=n.streamId),this.push(o)}},{key:"rtcSdkCallback",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_sdk_callback",report_id:this.report_id++,rtc_timestamp:Date.now(),sdk_callback_name:e,error_code:t,message:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcGetConfig",value:function(e,t,r,n,o,a,s){var c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},u=i(i({event_key:"rtc_get_config",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r,host:n,type:o,config_id:a,enable_cloud_proxy:s},this.modify_ids),{},{common_extra_info:JSON.stringify(c)});this.push(u)}},{key:"rtcReconnect",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"rtc_reconnect",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reconnect_id:r,reconnect_type:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcReconnected",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"rtc_reconnected",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,reconnect_type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcGetAccess",value:function(e,t,r,n,o,a){var s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},c=i(i({event_key:"rtc_get_access",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r,type:n,host:o,connect_session_id:a},this.modify_ids),{},{common_extra_info:JSON.stringify(s)});this.push(c)}},{key:"rtcPreIceState",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_pre_ice_state",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,ice_state:t},this.modify_ids),{},{connection_id:r,common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcNodeChange",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_node_change",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reason:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcSignalingMsgError",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_signaling_msg_error",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reason:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcSignaling",value:function(e,t,r,n,o,a,s){var c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},u=i(i({event_key:"rtc_signaling",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,signaling_event:r,signaling_type:n,stream_id:o,stream_user_id:a,direction:s},this.modify_ids),{},{common_extra_info:JSON.stringify(c)});this.push(u)}},{key:"rtcJoinRoom",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"rtc_join_room",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,deviceModel:t,deviceManufacturer:r,elapse:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcLeaveRoom",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_leave_room",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcBeginCreateOffer",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_begin_create_offer",report_id:this.report_id++,rtc_timestamp:Date.now(),direction:e,stream_id:t,stream_user_id:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcCreateOffer",value:function(e,t,r,n,o){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=i(i({event_key:"rtc_create_offer",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,direction:t,stream_id:r,stream_user_id:n,elapse:o},this.modify_ids),{},{common_extra_info:JSON.stringify(a)});this.push(s)}},{key:"rtcSetDescription",value:function(e,t,r,n,o,a,s,c){var u=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{},d=i(i({event_key:"rtc_set_description",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,is_local:r,direction:n,stream_id:o,stream_user_id:a,elapse:s},this.modify_ids),{},{connection_id:c,common_extra_info:JSON.stringify(u)});this.push(d)}},{key:"rtcRecvAnswer",value:function(e,t,r,n,o,a,s){var c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},u=i(i({event_key:"rtc_recv_answer",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,answer_type:t,sequence_id:r,message:n,direction:o,stream_id:a,stream_user_id:s},this.modify_ids),{},{common_extra_info:JSON.stringify(c)});this.push(u)}},{key:"firstRemoteAudioRender",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"first_remote_audio_render",report_id:this.report_id++,rtc_timestamp:Date.now(),stream_id:e,stream_user_id:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"firstRemoteVideoRender",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"first_remote_video_render",report_id:this.report_id++,rtc_timestamp:Date.now(),stream_id:e,stream_user_id:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcPublishStat",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"rtc_publish_stat",report_id:this.report_id++,rtc_timestamp:Date.now(),result:e,is_screen:t,start:r,message:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcSubscribeStat",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"rtc_subscribe_stat",report_id:this.report_id++,rtc_timestamp:Date.now(),result:e,start:t,message:r,stream_user_id:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcAudioDevice",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_audio_device",report_id:this.report_id++,rtc_timestamp:Date.now(),audio_event:e,message:t,error_code:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcMediaStatistics",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_media_statistics",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcMessageStatistics",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_message_statistics",report_id:this.report_id++,rtc_timestamp:Date.now(),dc_user_message:e,dc_room_message:t,media_server_ip:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcError",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"rtc_error",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,error_code:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcInvokeStatus",value:function(e,t,r,n,o){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"",c=i(i({event_key:"rtc_invoke_status",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,error_code:t,sdk_api_name:r,stream_id:n,elapse:o},this.modify_ids),{},{connection_id:s,common_extra_info:JSON.stringify(a),direction:a.direction});this.push(c)}},{key:"rtcFirstFrame",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i(i(i({event_key:"rtc_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcMuteRemote",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"rtc_mute_remote",report_id:this.report_id++,rtc_timestamp:Date.now(),mute_info:e,media_type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"sdkInitEngine",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"sdk_init_engine",report_id:this.report_id++,rtc_timestamp:Date.now(),start:e,type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"joinRoom",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"join_room",report_id:this.report_id++,rtc_timestamp:Date.now(),type:e,start:t,result:r,reason:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"p2pConnectionStatus",value:function(e,t,r,n,o){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=i(i({event_key:"p2p_connection_status",report_id:this.report_id++,rtc_timestamp:Date.now(),room_id:e,user_id:t,peer_user_id:r,status:n,elapse:o},this.modify_ids),{},{common_extra_info:JSON.stringify(a)});this.push(s)}},{key:"p2pConnectClosed",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i(i({event_key:"p2p_connect_closed",report_id:this.report_id++,rtc_timestamp:Date.now(),p2p_selected:e},this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcDeviceError",value:function(e,t,r,n,o,a,s,c,u,d,l,h,f,p,v,_){var m=arguments.length>16&&void 0!==arguments[16]?arguments[16]:{},y=i(i({event_key:"rtc_device_error",report_id:this.report_id++,rtc_timestamp:Date.now(),device_type:e,device_stage:t,error_code:r,system_error_code:n,system_api:o,call_parameters:a,location:s,message:c,media_device_id:u,media_device_name:d,elapse:l,scenario:h,event_session_id:f,device_pid:p,device_vid:v,media_mode:_},this.modify_ids),{},{common_extra_info:JSON.stringify(m)});this.push(y)}},{key:"rtcVideoDevice",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"rtc_video_device",report_id:this.report_id++,rtc_timestamp:Date.now(),media_device_id:e,media_device_name:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcVideoCaptureEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i(i(i({event_key:"rtc_video_capture_event",report_id:this.report_id++,rtc_timestamp:Date.now()},e),this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcEncodeFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_encode_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcFirstFrameEncoded",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_first_frame_encoded",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcSendFirstPacket",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_send_first_packet",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcRecvFirstPacket",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_recv_first_packet",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcRecvFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_recv_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcDecodeFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_decode_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}}]),n}(ZL),FB=new VB,BB=new VB,jB=new VB,GB=FB.commonStats,HB=BB.commonStats,zB=jB.commonStats;function KB(e){GB.setStats({app_state:e}),HB.setStats({app_state:e}),zB.setStats({app_state:e})}!vD()&&(KB("active"),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?KB("active"):"hidden"===document.visibilityState&&KB("background")})));var XB={default:FB,rtm:BB,outsideRoom:jB},WB=function(e,t,r){FB.rtcSdkApiCall(e,t,r)},qB=function(e,t,r){FB.rtcSdkCallback(e,t,r)};function YB(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return function(t,n,i){if("function"==typeof i.value){var o=i.value;i.value=function(){for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];var s={};r.forEach((function(e,t){s[e]=i[t]})),"joinRoom"===n&&GB.setStats({room_id:i[1]}),XB[e].rtcSdkApiCall(n,0,JSON.stringify(PD(i)),s);var c=o.apply(this,i);return"function"==typeof(null==c?void 0:c.then)?c.then((function(t){return XB[e].rtcSdkCallback(n,0,JSON.stringify(PD([t||{}]))),t})).catch((function(t){throw XB[e].rtcSdkCallback(n,t.code,JSON.stringify(t.message)),t})):(XB[e].rtcSdkCallback(n,0,JSON.stringify(PD([c||{}]))),c)}}}}function JB(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e===oe.onUserMessageReceivedOutsideRoom||e===oe.onUserBinaryMessageReceivedOutsideRoom;(n?BB:FB).rtcSdkCallback(e,r,JSON.stringify(t))}function QB(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};(n?BB:FB).rtcInvokeStatus(JSON.stringify(t),r,e,"",0,o,i)}var ZB="BytePlus",$B="RTC_DEVICE_ID",ej="RTC_ACCESS_NODE",tj="RTC_ACCESS_URLS",rj="engine_BAC",nj=function(){function e(){u(this,e)}return l(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(n){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,JSON.stringify(n)),!0}catch(i){return!1}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),ij=function(e){f(r,e);var t=g(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"getDeviceId",value:function(){if(vD())return"";var e=this.get($B);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return[GB,HB,zB].forEach((function(t){return t.setStats({device_id:e})})),this.set($B,e),e}},{key:"getAccessNode",value:function(e){return this.get("".concat(ej,"_").concat(e,"-").concat(ZB))}},{key:"setAccessNode",value:function(e,t,r){return this.set("".concat(ej,"_").concat(e,"-").concat(ZB),t,1e3*r)}},{key:"clearAccessNode",value:function(e){this.delete("".concat(ej,"_").concat(e,"-").concat(ZB))}},{key:"getAccessUrls",value:function(){return this.get("".concat(tj,"-").concat(ZB))}},{key:"setAccessUrls",value:function(e){var t=e.map((function(e){var t=e.host,r=e.path;return"https://".concat(t).concat(r)}));return this.set("".concat(tj,"-").concat(ZB),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(tj,"-").concat(ZB))}},{key:"getAudioProfile",value:function(){return this.get(rj)}},{key:"setAudioProfile",value:function(e){return this.set(rj,e)}}]),r}(nj),oj=new ij,aj="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function sj(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var cj="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",uj="rtc.rtcplus.com".split(","),dj={VERSION:"4.49.14",ICE_CONFIG_REQUEST_URLS_INTERNAL:aj.map(sj),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:cj,CONFIG_REQUEST_DOMAINS:uj,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,ENABLE_REPORT_ERROR_BUFFER:!1};function lj(e,t){if(FB.rtcSdkApiCall("setParameter",0,"key: ".concat(e,", value: ").concat(t)),"VERSION"!==e){if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(dj.ICE_CONFIG_REQUEST_URLS=t.map(sj));if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t)if("LOG_SERVER_URL"!==e||t!==j.overseas)if("LOG_SERVER_URL"!==e||t!==j.domestic)if("LOG_SERVER_URL"!==e||"string"!=typeof t){if("OVERSEA"===e)return GB.setStats({overSea:t?"1":"0"}),void(dj.OVERSEA=t);"DEVICE_ID"===e&&oj.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&FB.enableErrorBuffer(),dj[e]=t}else dj.LOG_SERVER_URL=t;else dj.LOG_SERVER_URL=cj;else dj.LOG_SERVER_URL="https://web-log-report.rtcplus.com/video/v1/webrtc_log/";else GB.setStats({product:t});else GB.setStats({platform:t})}}function hj(e){return"DEVICE_ID"===e?oj.getDeviceId():dj[e]}function fj(e,t,r){var n,i,o,a,s,c,u,d,l;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||z.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:l.map((function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var pj,vj={width:640,height:360,frameRate:15,maxKbps:600},_j={width:1920,height:1080,frameRate:15,maxKbps:3e3},mj=function(e){return e.streamRemovedBySchedule308="stream removed",e.clientRePublish="client republish",e.publishStreamFaied="publish failed",e.clientUnPublish="client unpublished",e.clientDisconnected="client disconnected",e.videoMuted="video muted",e}(mj||{}),yj=function(e){return e.PushLimitWarn="PushLimitWarn",e}(yj||{}),gj=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SCENE_CONFIG="onSceneConfig",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e}(gj||{}),Sj=function(e){return e.RSCP="RSCP",e.RTT="RTT",e}(Sj||{}),Ej=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(Ej||{}),bj=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(bj||{}),kj=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(kj||{}),Tj=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(Tj||{}),Ij=function(e){return e[e.P2P=0]="P2P",e[e.SIGNAL=1]="SIGNAL",e[e.BROADCAST=2]="BROADCAST",e[e.BUSINESS_SERVER=3]="BUSINESS_SERVER",e}(Ij||{}),Aj=function(e){return e[e.SUCCESS=0]="SUCCESS",e[e.TIMEOUT=1]="TIMEOUT",e[e.BROKEN=2]="BROKEN",e[e.NO_RECEIVER=3]="NO_RECEIVER",e[e.NO_RELAYPATH=4]="NO_RELAYPATH",e[e.SEND_TO_SERVER_ERROR=17]="SEND_TO_SERVER_ERROR",e[e.SERVER_RESPONSE_ERROR=18]="SERVER_RESPONSE_ERROR",e[e.NOT_JOIN=100]="NOT_JOIN",e[e.INIT=101]="INIT",e[e.NO_CONNECTION=102]="NO_CONNECTION",e[e.NOT_LOGIN=105]="NOT_LOGIN",e[e.SERVER_PARAMS_NOTSET=106]="SERVER_PARAMS_NOTSET",e[e.UNKNOWN=1e3]="UNKNOWN",e}(Aj||{}),Rj=(h(pj={},0,[0,"success"]),h(pj,1,[dP.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),h(pj,2,[dP.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),h(pj,3,[dP.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),h(pj,4,[dP.USER_MESSAGE_NO_RELAYPATH,"cannot find relay path."]),h(pj,17,[dP.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),h(pj,18,[dP.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),h(pj,100,[dP.USER_MESSAGE_NOT_JOIN,"not join room"]),h(pj,101,[dP.USER_MESSAGE_INIT,"not init."]),h(pj,102,[dP.USER_MESSAGE_NO_CONNECTION,"no connection."]),h(pj,105,[dP.USER_MESSAGE_NOT_LOGIN,"not login."]),h(pj,106,[dP.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),h(pj,1e3,[dP.USER_MESSAGE_UNKNOWN,"unknown."]),pj),Cj=["msg"],wj=new YL("DataChannelSignaling",3),Oj=["onSpeakerChange"],xj=function(e){return e[e.C2S=0]="C2S",e[e.C2C=1]="C2C",e[e.C2GW=2]="C2GW",e[e.C2CDirect=3]="C2CDirect",e[e.C2RTM=4]="C2RTM",e}(xj||{}),Nj=6e4,Pj=function(e){f(a,e);var t,r,n=g(a);function a(e){var t;return u(this,a),h(m(t=n.call(this)),"_singlingCache",new Map),h(m(t),"_p2pCache",new Map),h(m(t),"_rttIds",{}),h(m(t),"_p2pMessageId",0),h(m(t),"_clearDataChannelListener",void 0),t._dataChannel=e,t._clearDataChannelListener=t._handleHandler(),window.__rtc_mock_signaling__=t.emit.bind(m(t)),t}return l(a,[{key:"destroy",value:function(){this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=0,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n=this;return FB.rtcSignaling(0,JSON.stringify(t),"call-".concat(e),"Send",t.streamId,t.streamUserId,hB.UP),new Promise((function(i,o){var a=n._genHeader(r);a.id=OD();var s=a.id.join("-"),c=setTimeout((function(){n._singlingCache.delete(s),o(new hP(dP.TIME_OUT,"".concat(e," message time out")))}),Nj);n._singlingCache.set(s,{signalingType:e,success:function(e){clearTimeout(c),i(e)},error:function(e){clearTimeout(c),o(e)}}),wj.print("Signal",">>>>>> [".concat(e,"][").concat(s,"]"),t),n._sendMessage(e,a,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(r=c(o().mark((function e(t,r){var n,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,a=_(t,Cj),s=n instanceof ArrayBuffer,e.t0=this,e.t1=i,e.t2=i({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:Tj.SEND,type:Ij.P2P,err:Aj.SUCCESS},a),e.t3={},e.t4=s,!s){e.next=13;break}return e.next=10,_D.ab2b64str(n);case 10:e.t5=e.sent,e.next=14;break;case 13:e.t5=n;case 14:return e.t6=e.t5,e.t7={binary:e.t4,msg:e.t6},e.t8=(0,e.t1)(e.t2,e.t3,e.t7),e.t9=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t8,e.t9));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_sendP2PMessage",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ND(e.msg)?this._rttIds[e.id]=e.id:e.dir===Tj.SEND&&wj.print("_sendP2PMessage [DC Signaling p2p >>]",JSON.stringify(e)),new Promise((function(n,o){var a=t._genHeader(i(i({needAck:!0,functionType:1},r),{},{id:OD()}));if(e.dir===Tj.SEND){var s=setTimeout((function(){t._p2pCache.delete(e.id),o(new hP(dP.TIME_OUT,"P2P message timeout"))}),Nj);t._p2pCache.set(e.id,{success:function(e,t){clearTimeout(s),n(t)},error:function(e){clearTimeout(s);var t=b(Rj[e.err]||[dP.USER_MESSAGE_UNKNOWN,"err: ".concat(e.err,", msg: ").concat(e.msg)],2),r=t[0],n=t[1];o({err:e.err,code:r,message:e.msg||n})}})}t._sendMessage("p2p",a,e)}))}},{key:"_sendMessage",value:function(e,t,r){if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new hP(dP.SIGNALING_CHANNEL_NOT_OPEN,"DataChannel not open");var n=t.version+(+t.zip<<5)+(+t.encrypt<<6),i=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),o=_D.str2ab(JSON.stringify([e,r])),a=pD(Uint8Array,[n,i].concat(k(t.id||[])),new Uint8Array(o));this._dataChannel.send(a.buffer)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(128!=(128&t[r])){r++;break}o.id=Array.from(t.slice(2,r))}return{header:o,data:t.slice(r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n=this._genHeader({needAck:!0,direction:1,id:e.split("-").map((function(e){return+e}))});Oj.includes(t)||wj.print("Signal",">>>>>> [".concat(t,"-res][").concat(e,"]")),this._sendMessage("".concat(t,"-res"),n,r)}},{key:"_handleMessage",value:(t=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,k,T,I,A,R,C,w,O,x,N,P,D,M,L;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=this._dispartData(t),d=u.data,(l=u.header).zip&&((h=new QF.Inflate).push(d,!0),d=h.result),f=_D.ab2str(d),p=[],e.prev=6,p=JSON.parse(f),e.next=14;break;case 10:return e.prev=10,e.t0=e.catch(6),e.t0 instanceof Error&&FB.rtcSignalingMsgError(-1,e.t0.message,lB.MESSAGE_PARSE_FAILED),e.abrupt("return");case 14:e.t1=l.functionType,e.next=0===e.t1?17:1===e.t1?34:2===e.t1?83:101;break;case 17:if(v=(null===(r=l.id)||void 0===r?void 0:r.join("-"))||"",1!==l.direction){e.next=22;break}this._handleAckMessage(v,p[0]||{},f),e.next=33;break;case 22:if(!Array.isArray(p)){e.next=33;break}if(_=p[0],p=p[1],Oj.includes(_)||wj.print("Signal","<<<<<< ".concat(_),p,v),this._feedbackSignaling(v,_,_===gj.ON_CUSTOM_MESSAGE?i(i({},p),{},{message:""}):""),!p.binary||"string"!=typeof p.message){e.next=31;break}return e.next=30,_D.b64str2ab(p.message);case 30:p.message=e.sent;case 31:this.emit(_,i({},p)),FB.rtcSignaling(0,f,"on-".concat(_),"Recv",p.streamId,p.clientId,hB.DOWN);case 33:return e.abrupt("break",102);case 34:Array.isArray(p)&&(p=p[1]),m=null===(n=p)||void 0===n?void 0:n.id,this._rttIds[m]||(null===(a=p)||void 0===a?void 0:a.dir)===Tj.FEEDBACK||ND(null===(s=p)||void 0===s?void 0:s.msg)?delete this._rttIds[m]:wj.print("Signal","<<<<<< p2p response",p),e.t2=p.dir,e.next=e.t2===Tj.SEND?40:e.t2===Tj.FEEDBACK?78:81;break;case 40:if(ND(null===(c=p)||void 0===c?void 0:c.msg)){e.next=76;break}if(g=(y=p).binary,S=y.msg,E=y.room,k=y.to,T=y.from,I=""===E?g?gj.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:gj.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:g?gj.USER_BINARY_MESSAGE_RECEIVED:gj.USER_MESSAGE_RECEIVED,k){e.next=60;break}if(e.t3=this,e.t4=gj.ON_CUSTOM_MESSAGE,e.t5=T,e.t6=g,!g){e.next=54;break}return e.next=51,_D.b64str2ab(S);case 51:e.t7=e.sent,e.next=55;break;case 54:e.t7=S;case 55:e.t8=e.t7,e.t9={clientId:e.t5,binary:e.t6,message:e.t8},e.t3.emit.call(e.t3,e.t4,e.t9),e.next=76;break;case 60:if(e.t10=this,e.t11=I,e.t12=i,e.t13=i({},p),e.t14={},!g){e.next=71;break}return e.next=68,_D.b64str2ab(S);case 68:e.t15=e.sent,e.next=72;break;case 71:e.t15=S;case 72:e.t16=e.t15,e.t17={msg:e.t16},e.t18=(0,e.t12)(e.t13,e.t14,e.t17),e.t10.emit.call(e.t10,e.t11,e.t18);case 76:return this._sendP2PMessage(i(i({},p),{},{dir:Tj.FEEDBACK,msg:""})),e.abrupt("break",82);case 78:return(A=this._p2pCache.get(p.id))&&(this._p2pCache.delete(p.id),p.err===Aj.SUCCESS?A.success(p.id,p):A.error(p)),e.abrupt("break",82);case 81:return e.abrupt("break",82);case 82:return e.abrupt("break",102);case 83:if(1!==l.direction){e.next=88;break}C=(null===(R=l.id)||void 0===R?void 0:R.join("-"))||"",this._handleAckMessage(C,p[0]||{},f),e.next=100;break;case 88:if(w=b(p,2),O=w[0],x=w[1],N=void 0===x?{}:x,"RXMediaMsg"!==O){e.next=100;break}P=N.type,D=N.data,FB.rtcSignaling(0,f,"on-".concat(P),"Recv","","",hB.DOWN),e.t19=P,e.next="RSCP"===e.t19?95:"RTT"===e.t19?97:99;break;case 95:try{M=JSON.parse(D),Array.isArray(M)&&this.emit(P,M)}catch(o){}return e.abrupt("break",100);case 97:try{(L=JSON.parse(D)).length&&this.emit(P,L[0])}catch(o){}return e.abrupt("break",100);case 99:return e.abrupt("break",100);case 100:case 101:return e.abrupt("break",102);case 102:case"end":return e.stop()}}),e,this,[[6,10]])}))),function(e){return t.apply(this,arguments)})},{key:"_handleHandler",value:function(){var e=this,t=function(t){wj.print("_handleHandler","dataChannel close",t),e.emit("close",t)},r=function(t){wj.print("_handleHandler","dataChannel error",t),e.emit("close",t)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n=this._singlingCache.get(e);n&&(this._singlingCache.delete(e),200===t.code?n.success(t):n.error(t),wj.print("Signal","<<<<<< [".concat(n.signalingType,"-ack] ").concat(e),t)),FB.rtcSignaling(0,r,null==n?void 0:n.signalingType,"Ack","","",hB.DOWN)}}]),a}(BL.exports.EventEmitter),Dj=function(){function e(){u(this,e),h(this,"xhr",void 0),h(this,"isSending",void 0),h(this,"timeout",void 0),this.isSending=!1}return l(e,[{key:"ajax",value:function(e){var t=this,r=e.method,n=e.url,i=e.body,o=void 0===i?{}:i,a=e.headers,s=void 0===a?{}:a,c=e.stringify,u=void 0===c||c;return new Promise((function(e,i){t.isSending=!0;var a=new XMLHttpRequest;a.open(r,n,!0);for(var c=0,d=Object.entries(s);c<d.length;c++){var l=b(d[c],2),h=l[0],f=l[1];a.setRequestHeader(h,f)}a.onreadystatechange=function(){if(4===a.readyState)if(t.isSending=!1,200===a.status)e(JSON.parse(a.responseText));else{var r=a.statusText,n=a.status;if(a.responseText)try{var o=JSON.parse(a.responseText);o.errMessage&&(r=o.errMessage),o.code&&(n=o.code)}catch(s){}i({message:r,code:n})}},a.onabort=function(){i({code:0,message:"Request abort"})},a.onerror=function(e){t.isSending=!1,i({code:-1,message:a.responseText||"unknown"})},t.timeout&&(a.timeout=t.timeout),u&&(o=JSON.stringify(o)),a.send(o),t.xhr=a}))}},{key:"get",value:function(e,t){return this.ajax({method:"GET",url:e,headers:t})}},{key:"post",value:function(e,t,r,n){return this.ajax({method:"POST",url:e,body:t,headers:r,stringify:n})}},{key:"abort",value:function(){var e;null===(e=this.xhr)||void 0===e||e.abort()}}]),e}(),Mj=new YL("ICE Request",3),Lj=function(){function e(){u(this,e),h(this,"_request",void 0),this._request=new Dj}var t,r,n;return l(e,[{key:"getAccessNode",value:(n=c(o().mark((function e(t,r,n,i,a,s,c,u){var d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(d=oj.getAccessNode(t))){e.next=9;break}if(this.getAccessNodeFromServer(t,r,n,i,a,s,c,u),QB("es.R.node.cache",d),!Array.isArray(d)){e.next=8;break}return e.abrupt("return",Promise.resolve(d));case 8:return e.abrupt("return",Promise.resolve([d]));case 9:return e.abrupt("return",this.getAccessNodeFromServer(t,r,n,i,a,s,c,u));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o,a,s,c){return n.apply(this,arguments)})},{key:"getAccessNodeFromServer",value:(r=c(o().mark((function e(t,r,n,i,a,s,c,u){var d,l,h,f,p=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h=oj.getAccessUrls(),f=!0,QB("es.R.req.cache.urls",h),(null===(d=h)||void 0===d?void 0:d.length)>0||(h=dj.ICE_CONFIG_REQUEST_URLS,f=!1,QB("es.R.req.external.urls",h)),(null===(l=h)||void 0===l?void 0:l.length)>0||(h=dj.ICE_CONFIG_REQUEST_URLS_INTERNAL,f=!1,QB("es.R.req.internal.urls",h)),e.abrupt("return",this.getICEConfigFromServer(h,t,r,n,i,a,s,c,u).then((function(e){var r=e.nodes;return oj.setAccessNode(t,r,e.ttl||11200),e.dispatchDomains&&oj.setAccessUrls(e.dispatchDomains),r})).catch((function(e){if(f)return QB("es.R.req.fallback",""),oj.clearAccessUrls(),p.getAccessNodeFromServer(t,r,n,i,a,s,c);throw e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o,a,s,c){return r.apply(this,arguments)})},{key:"getICEConfigFromServer",value:(t=c(o().mark((function e(t,r,n,i,a,s,u,d,l){var h,f,p,v,_=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h={appID:r,userID:i,deviceID:a,connectSessionID:hD(),os:"web",sdkVersion:dj.VERSION,isOversea:dj.OVERSEA,expectedAddr:hj("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:d,expectedIDC:l},s&&u&&(h.feedbackInfo=[{feedbackIP:null===(f=u.publicIPs[0])||void 0===f?void 0:f.ip,feedbackReason:{type:"NODE_CHANGED",reason:s}}],delete h.expectedAddr),p=Date.now(),FB.rtcGetAccess(0,JSON.stringify(h),0,uB.REQUEST,t.join(","),h.connectSessionID),v=t.map(function(){var e=c(o().mark((function e(t,r){var n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_._request.post(t,h);case 3:n=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new hP(dP.ICE_SERVER_WRONG,"get ICE config failed",e.t0);case 9:if(200===n.code){e.next=11;break}throw new hP(dP.ICE_SERVER_WRONG,"get ICE config failed",{server_code:n.code,message:JSON.stringify(n)});case 11:if(i=n.nodes[0]){e.next=14;break}throw new hP(dP.ICE_SERVER_WRONG,"ICE config server return empty nodes",{code:n.code,message:JSON.stringify(n)});case 14:return e.abrupt("return",{result:n,firstNode:i,index:r});case 15:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",MD(v).then((function(e){var r=e.result;e.firstNode;var n=e.index;return FB.rtcGetAccess(200,JSON.stringify(r),Date.now()-p,uB.RESPONSE,t[n],h.connectSessionID),r})).catch((function(e){var r,n,i=null===(r=e[0])||void 0===r?void 0:r.error;throw FB.rtcGetAccess(+((null==i?void 0:i.code)||(null==i?void 0:i.server_code)),null===(n=e[0])||void 0===n?void 0:n.message,Date.now()-p,uB.RESPONSE,t.join(","),h.connectSessionID,{error:JSON.stringify(i)}),i})));case 6:case"end":return e.stop()}}),e)}))),function(e,r,n,i,o,a,s,c,u){return t.apply(this,arguments)})},{key:"abort",value:function(){this._request.isSending&&(Mj.print("abort","HTTP Request of [getICEConfigFromServer] abort"),this._request.abort())}}]),e}(),Uj=function(){function e(){u(this,e),h(this,"_request",void 0),this._request=new Dj}return l(e,[{key:"getAudioProfile",value:function(){var e=this,t={keys:["engine_BAC"],labelSelector:"",sdkVersion:"4.49.14",deviceType:"web"},r=dj.CONFIG_REQUEST_DOMAINS.map((function(e){return"https://".concat(e,"/decision/v1/multi")}));FB.rtcGetConfig(0,JSON.stringify(t),0,r.join(","),iB.REQUEST,"",!1);var n=r.map(function(){var r=c(o().mark((function r(n,i){var a,s;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,e._request.post(n,t);case 3:s=r.sent,r.next=9;break;case 6:throw r.prev=6,r.t0=r.catch(0),new hP(dP.ICE_SERVER_WRONG,"get config failed");case 9:if(Array.isArray(null===(a=s)||void 0===a?void 0:a.engine_BAC)){r.next=11;break}throw new hP(dP.ICE_SERVER_WRONG,"get config failed");case 11:return r.abrupt("return",{result:s,index:i});case 12:case"end":return r.stop()}}),r,null,[[0,6]])})));return function(e,t){return r.apply(this,arguments)}}());return new Promise((function(e){MD(n).then((function(t){var n=t.result,i=t.index;oj.setAudioProfile(n.engine_BAC),FB.rtcGetConfig(200,JSON.stringify(n),0,r[i],iB.RESPONSE,"",!1),e(n.engine_BAC)})).catch((function(t){FB.rtcGetConfig(500,t.message,0,"",iB.RESPONSE,"",!1),e(oj.getAudioProfile()||[])}))}))}}]),e}();function Vj(e,t){var r=1,n=e;(e.width>t.width||e.height>t.height)&&(r=e.width/e.height>t.width/t.height?e.width/t.width:e.height/t.height,n={width:Math.floor(e.width/r),height:Math.floor(e.height/r)});return i(i({},n),{},{scaleResolutionDownBy:r})}var Fj=[{width:1920,height:1080,maxLayers:3,totalPixels:2073600},{width:1280,height:720,maxLayers:3,totalPixels:921600},{width:960,height:540,maxLayers:3,totalPixels:518400},{width:640,height:360,maxLayers:2,totalPixels:230400},{width:480,height:270,maxLayers:2,totalPixels:129600},{width:320,height:180,maxLayers:1,totalPixels:57600},{width:0,height:0,maxLayers:1,totalPixels:0}];var Bj={width:160,height:90,frameRate:15,maxkbps:100},jj={width:480,height:270,frameRate:15,maxkbps:400};yf("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Bf);var Gj=new Map,Hj=function(){var e=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){var n=hj("STATS_SCALLBACK_SUPPORT");if("chrome-stable"===mD()&&void 0===window.InstallTrigger&&yD&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!qj.includes(e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(i(i({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return r.filter((function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(TQ){r(TQ)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),zj=function(){var e=c(o().mark((function e(t){var r,n,i,a,s,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return i=e.sent,a={all:[]},s=new Map,i.forEach((function(e){var t=s.get(e.type)||new Map;t.set(e.id,e),s.set(e.type,t),a.all.push(e)})),c=function(e,t){e.forEach((function(e){var r,n,i,o,a,c,u=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=s.get(Wj.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=s.get(Wj.transport))||void 0===n||n.forEach((function(e){e.id===d&&(a=e,t.add(e))})),null===(i=s.get(Wj.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(o=s.get(Wj.mediaPlayout))||void 0===o||o.forEach((function(e){e.id===h&&t.add(e)})),a){var f,p,v=a,_=v.localCertificateId,m=v.remoteCertificateId,y=v.selectedCandidatePairId;null===(f=s.get(Wj.certificate))||void 0===f||f.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(p=s.get(Wj.candidatePair))||void 0===p||p.forEach((function(e){e.id===y&&(c=e,t.add(e))}))}if(c){var g,S,E=c,b=E.localCandidateId,k=E.remoteCandidateId;null===(g=s.get(Wj.localCandidate))||void 0===g||g.forEach((function(e){e.id===b&&t.add(e)})),null===(S=s.get(Wj.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},null===(r=s.get(Wj.mediaSource))||void 0===r||r.forEach((function(e){var t,r=new Set;r.add(e);var n=[];null===(t=s.get(Wj.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=s.get(Wj.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),c(n,r),a[e.trackIdentifier]=Array.from(r)})),null===(n=s.get(Wj.inboundRtp))||void 0===n||n.forEach((function(e){var t,r=new Set;r.add(e),null===(t=s.get(Wj.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),c([e],r);var n,i=e.trackIdentifier;i||(null===(n=s.get(Wj.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(i=t.trackIdentifier)})));a[i]=Array.from(r)})),e.abrupt("return",a);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Kj=function(){var e=c(o().mark((function e(t,r,n){var i,a,s,c,u,d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!gD&&!SD){e.next=10;break}return a=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){a.push(e)})),e.abrupt("return",a);case 10:return(!(s=Gj.get(t))||Date.now()-s.timestamp>150)&&(s={timestamp:Date.now(),statsPromise:zj(t),extraStatsPromise:Hj(t)},Gj.set(t,s)),e.next=14,s.statsPromise;case 14:if(c=e.sent,u=(i?c[i]:c.all)||[],n){e.next=21;break}return e.next=19,s.extraStatsPromise;case 19:d=e.sent,u=u.concat((i?d.getTrackStats(i):d.all)||[]);case 21:return e.abrupt("return",u);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();mD();var Xj,Wj=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(Wj||{}),qj=["codec","inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","media-source","csrc","peer-connection","data-channel","stream","track","transceiver","sender","receiver","transport","sctp-transport","candidate-pair","local-candidate","remote-candidate","certificate","ice-server"],Yj=new YL("isSupported",0),Jj=function(){var e=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!vD()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,Qj();case 5:return t=e.sent,e.abrupt("return",(null==t?void 0:t.includes("H264"))||(null==t?void 0:t.includes("vp8")));case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(){return e.apply(this,arguments)}}(),Qj=function(){var e=c(o().mark((function e(){var t,r,n,i,a,s,c,u,d,l,h,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Yj.print("internalGetSupportedCodecs()","Invoke, cachedSupportedCodecs: %o",Xj),!Xj){e.next=3;break}return e.abrupt("return",Xj);case 3:if(t=[],e.prev=4,!navigator.userAgent.includes("VivoBrowser")){e.next=8;break}return e.next=8,DD();case 8:return e.next=10,DD();case 10:if(r=e.sent){e.next=13;break}return e.abrupt("return",t);case 13:n=r.split("\n"),i=!1,a=A(n),e.prev=16,a.s();case 18:if((s=a.n()).done){e.next=25;break}if(!((c=s.value).includes("level-asymmetry-allowed=1")&&c.includes("packetization-mode=1")&&c.includes("profile-level-id=42e0"))){e.next=23;break}return i=!0,e.abrupt("break",25);case 23:e.next=18;break;case 25:e.next=30;break;case 27:e.prev=27,e.t0=e.catch(16),a.e(e.t0);case 30:return e.prev=30,a.f(),e.finish(30);case 33:if(i){for(u=navigator.userAgent.toLowerCase(),d=!1,l=0,h=["miuibrowser"];l<h.length;l++)f=h[l],u.includes(f)&&(d=!0);!d&&t.push("H264")}else Yj.print("internalGetSupportedCodecs()","sdp: %s",r);return null!=r&&r.includes("VP8")&&t.push("vp8"),Xj=t,e.abrupt("return",t);case 39:return e.prev=39,e.t1=e.catch(4),e.abrupt("return",t);case 42:case"end":return e.stop()}}),e,null,[[4,39],[16,27,30,33]])})));return function(){return e.apply(this,arguments)}}(),Zj=function(){var e=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Qj();case 2:return t=e.sent,e.abrupt("return",t.map((function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$j=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},eG={},tG=Wc,rG=ve,nG=Re,iG=Ac,oG=Fr,aG=Ue,sG=Ss,cG=Be,uG=em,dG=xu,lG=li,hG=As,fG=Rt,pG=Dl,vG=Dc,_G=mc,mG=de,yG=zs.UNSUPPORTED_Y,gG=4294967295,SG=Math.min,EG=[].push,bG=nG(/./.exec),kG=nG(EG),TG=nG("".slice),IG=!mG((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var r="ab".split(e);return 2!==r.length||"a"!==r[0]||"b"!==r[1]}));iG("split",(function(e,t,r){var n;return n="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,r){var n=hG(cG(this)),i=void 0===r?gG:r>>>0;if(0===i)return[];if(void 0===e)return[n];if(!sG(e))return rG(t,n,e,i);for(var o,a,s,c=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),d=0,l=new RegExp(e.source,u+"g");(o=rG(_G,l,n))&&!((a=l.lastIndex)>d&&(kG(c,TG(n,d,o.index)),o.length>1&&o.index<n.length&&tG(EG,c,pG(o,1)),s=o[0].length,d=a,c.length>=i));)l.lastIndex===o.index&&l.lastIndex++;return d===n.length?!s&&bG(l,"")||kG(c,""):kG(c,TG(n,d)),c.length>i?pG(c,0,i):c}:"0".split(void 0,0).length?function(e,r){return void 0===e&&0===r?[]:rG(t,this,e,r)}:t,[function(t,r){var i=cG(this),o=aG(t)?void 0:fG(t,e);return o?rG(o,t,i,r):rG(n,hG(i),t,r)},function(e,i){var o=oG(this),a=hG(e),s=r(n,o,a,i,n!==t);if(s.done)return s.value;var c=uG(o,RegExp),u=o.unicode,d=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(yG?"g":"y"),l=new c(yG?"^(?:"+o.source+")":o,d),h=void 0===i?gG:i>>>0;if(0===h)return[];if(0===a.length)return null===vG(l,a)?[a]:[];for(var f=0,p=0,v=[];p<a.length;){l.lastIndex=yG?0:p;var _,m=vG(l,yG?TG(a,p):a);if(null===m||(_=SG(lG(l.lastIndex+(yG?p:0)),a.length))===f)p=dG(a,p,u);else{if(kG(v,TG(a,f,p)),v.length===h)return v;for(var y=1;y<=m.length-1;y++)if(kG(v,m[y]),v.length===h)return v;p=f=_}}return kG(v,TG(a,f)),v}]}),!IG,yG);var AG={},RG={exports:{}},CG=RG.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(CG).forEach((function(e){CG[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=RG.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;s<(n[t]||[]).length;s+=1){var c=n[t][s];if(c.reg.test(i))return r(c,a,i)}})),t.media=o,t};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;i<n.length;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(AG);var wG=RG.exports,OG=/%[sdv%]/g,xG=function(e){var t=1,r=arguments,n=r.length;return e.replace(OG,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},NG=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?n.push(r[t.name][o]):n.push(r[t.names[i]])}else n.push(r[t.name]);return xG.apply(null,n)},PG=["v","o","s","i","u","e","p","c","b","t","r","z","a"],DG=["i","c","b","a"],MG=AG,LG=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||PG,n=t.innerOrder||DG,i=[];return r.forEach((function(t){wG[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(NG(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(NG(t,r,e))}))}))})),e.media.forEach((function(e){i.push(NG("m",wG.m[0],e)),n.forEach((function(t){wG[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(NG(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(NG(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};eG.write=LG,eG.parse=MG.parse,eG.parseParams=MG.parseParams,eG.parseFmtpConfig=MG.parseFmtpConfig,eG.parsePayloads=MG.parsePayloads,eG.parseRemoteCandidates=MG.parseRemoteCandidates,eG.parseImageAttributes=MG.parseImageAttributes,eG.parseSimulcastStreamList=MG.parseSimulcastStreamList;var UG=new YL("FirefoxHandler",3),VG=Math.pow(2,32),FG="kp34Za0H+aVf862l",BG="o/i14u9pJrxRKAsu";function jG(e){return e>VG-18?(UG.print("generateAllSsrc","reset start id",e),jG(e=e-VG+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var GG=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:BG;return[{id:r,attribute:"cname",value:n},{id:r,attribute:"msid",value:"".concat(e," ").concat(e,"-").concat(t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:"".concat(e,"-").concat(t)}]},HG=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=t.video,i=t.videoRtx,o=t.videoFec,a=[n,i],s=r.cname,c=r.flexfec;c&&a.push(o);var u=a.reduce((function(t,r){return t.concat(GG(e,"video",r,s))}),[]),d=[{semantics:"FID",ssrcs:"".concat(n," ").concat(i)}];return c&&d.push({semantics:"FEC-FR",ssrcs:"".concat(n," ").concat(o)}),{ssrcs:u,ssrcGroups:d}};function zG(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.bundleOnly,e}var KG=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=i(i({},e),{},{media:[]});return n&&(o.invalid=[{value:"realx-exts:rscp"}]),t&&o.media.push(t),r&&o.media.push(r),delete o.groups,delete o.msidSemantic,eG.write(o)};function XG(e){return WG.apply(this,arguments)}function WG(){return(WG=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,a=t.iceParams,s=t.iceConfig,r.fingerprint={type:"sha-256",hash:i},r.icePwd=a.serverIcePwd,e.next=6,JG(a.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=qG(n,s),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function qG(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,o=[];return e.forEach((function(e){var a={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){o.push(i(i({},a),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){o.push(i(i({},a),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),o}var YG,JG=function(){var e=c(o().mark((function e(t){var r,n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,_D.b64str2ab(t);case 5:return e.t1=e.sent,i=new e.t0(e.t1),a=new Uint8Array(4),crypto.getRandomValues(a),(s=new Uint8Array(2))[0]=0,s[1]=1,c=pD(Uint8Array,n,i,a,s),e.next=15,_D.ab2b64str(c.buffer);case 15:return u=e.sent,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),QG=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=A(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(o.config.includes("level-asymmetry-allowed=1")&&o.config.includes("packetization-mode=1")&&o.config.includes("profile-level-id=42e0")){r=o.payload;break}}}catch(u){i.e(u)}finally{i.f()}for(var a=0;a<e.rtp.length;a++){var s=e.rtp[a];if("H264"===t){if(s.payload===r){e.rtp.unshift(e.rtp.splice(a,1)[0]);break}}else if(s.codec===t){e.rtp.unshift(e.rtp.splice(a,1)[0]);break}}var c=[];e.rtp.forEach((function(e){return c.push(e.payload)})),e.payloads=c.join(" ")}},ZG=new YL("BasicHandler",3),$G={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!$j()||void 0};function eH(e){if(void 0===YG){var t=navigator.userAgent.toLowerCase();YG=t.includes("mobile")}return YG?Math.ceil(e):e}var tH=function(e){f(d,e);var t,r,n,a,s=g(d);function d(e,t){var r;return u(this,d),h(m(r=s.call(this)),"_peerConnection",void 0),h(m(r),"_dataChannel",void 0),h(m(r),"_context",void 0),h(m(r),"monitor",void 0),h(m(r),"_offerIce",{}),h(m(r),"_answerIce",{}),h(m(r),"_initSctpEvents",!1),h(m(r),"_nextSsrc",Math.floor(Math.random()*VG+1e4)),h(m(r),"_aSendonlyAnswerTpl",void 0),h(m(r),"_vSendonlyAnswerTpl",void 0),h(m(r),"_enableSubFlexfec",!1),h(m(r),"audioTrack4ff",void 0),h(m(r),"connection_id",""),h(m(r),"ms_addr",""),r.monitor=e,r._peerConnection=new RTCPeerConnection($G),r._dataChannel=r._peerConnection.createDataChannel("signaling",{negotiated:!0,id:100}),r._context=t,r._dataChannel.binaryType="arraybuffer",r._peerConnection.ontrack=function(e){var t,n,i=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;ZG.print("constructor","pc.ontrack ".concat(e.track.kind," ").concat(e.track.id," ").concat(i)),"ff-stream"===i&&(r.audioTrack4ff=e.track),r.emit("ontrack",e)},r._peerConnection.onconnectionstatechange=function(e){ZG.print("constructor","onconnectionstatechange ".concat(r._peerConnection.iceConnectionState," -> ").concat(r._peerConnection.connectionState)),"failed"!==r._peerConnection.iceConnectionState&&"closed"!==r._peerConnection.iceConnectionState&&"failed"!==r._peerConnection.connectionState||r.emit("disconnect")},r._peerConnection.oniceconnectionstatechange=function(){var t=r._peerConnection.iceConnectionState;e.rtcPreIceState(t,dB["".concat(t.toUpperCase())],r.connection_id,{ms_addr:r.ms_addr})},r}return l(d,[{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){ZG.print("destroy"),this.disconnect(),this._context=void 0}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"_simulcast",value:function(e,t,r,n,o){var a=[];1===e.videoEncodeConfig.length?(a=function(e,t){var r=[];if(t<=1)return r;var n=1,i=1;return e.width/e.height>16/9?(n=e.width/Bj.width,i=e.width/jj.width):(n=e.height/Bj.height,i=e.height/jj.height),r.push({maxkbps:Bj.maxkbps,scaleResolutionDownBy:n,frameRate:Bj.frameRate,width:Math.floor(e.width/n),height:Math.floor(e.height/n)}),t<=2||n>2&&r.unshift({maxkbps:jj.maxkbps,scaleResolutionDownBy:i,frameRate:jj.frameRate,width:Math.floor(e.width/i),height:Math.floor(e.height/i)}),r}(t,o),ZG.print("simulcast() ","simulcastLayers: %o",a)):(a=e.videoEncodeConfig.slice(1).slice(1-o).map((function(e){return i({frameRate:e.frameRate||15,maxkbps:e.maxKbps||600},Vj(t,e))})),ZG.print("simulcast() ","simulcastLayers2: %o",a)),a.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:eH(e.scaleResolutionDownBy),rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)})}))}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,o=e.enableSimulcast,a=e.pubAudio,s=e.pubVideo,c={direction:"sendonly",streams:[t]},u={direction:"sendonly",streams:[t]},d=[],l=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var h=null==r?void 0:r.getTrack(),f={width:640,height:360,frameRate:30};if(h){var p=null==h?void 0:h.getSettings();f={width:Math.floor(p.width),height:Math.floor(p.height),frameRate:Math.floor(p.frameRate)}}var v=null==e?void 0:e.videoEncodeConfig[0],_=Vj(f,v);e.prevScaleResolutionDownBy=_.scaleResolutionDownBy,e.prevBitrate=v.maxKbps,e.videoInputConfig=f;var m={maxBitrate:1e3*v.maxKbps,scaleResolutionDownBy:eH(_.scaleResolutionDownBy),rid:"0",maxFramerate:v.frameRate||15};if(u.sendEncodings=[m],d.push({width:_.width,height:_.height,framerate:v.frameRate,maxkbps:v.maxKbps,rid:"0"}),!gD&&o){var y,g,S=function(e){for(var t=0,r=e.width*e.height,n=0;n<Fj.length;n++)if(r>=Fj[n].totalPixels){t=n;break}if(0===t)return Fj[t].maxLayers;var i=Fj[t-1].totalPixels;return(i-r)/(i-Fj[t].totalPixels)<.1?Fj[t-1].maxLayers:Fj[t].maxLayers}(_);if(ZG.print("simulcast() ","maxLayers: %o",S),S>1)this._simulcast(e,f,u,d,S),null!==(y=this._context)&&void 0!==y&&null!==(g=y.serverConfig)&&void 0!==g&&g.simulcastOnDemand&&(l=d.map((function(e,t){return i(i({},e),{},{video_index:t,sub_index:t})}))),ZG.print("subVideoDesc","desc: %o ",l)}}ZG.print("publish videoTransceiverInit videoDescriptions","",u,d);var E=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==re.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(E=null==n?void 0:n.mixedAudioTrack),E=a&&E?E:"audio";var b=null==r?void 0:r.getTrack("preprocessing");b=s&&b?b:"video";try{this.monitor.rtcInvokeStatus(JSON.stringify({aTrack:jD(E),vTrack:jD(b),audioTransceiverInit:c,videoTransceiverInit:u}),0,"Handler.internalPublish","",0)}catch(TQ){}return{semantics:"unified-plan",videoDescriptions:d,subVideoDescriptions:l,audioTransceiverInit:{track:E,init:c},videoTransceiverInit:{track:b,init:u}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;ZG.print("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void ZG.print("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var u;c.encodings=null==c||null===(u=c.encodings)||void 0===u?void 0:u.map((function(t){var r,n=+t.rid||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this.monitor.rtcInvokeStatus(JSON.stringify(c.encodings),0,"Handler.updateScaleResolutionDownBy","",0)}catch(TQ){}}}else ZG.print("updateMaxBitrate()","no pub")}},{key:"updateScaleResolutionDownBy",value:(a=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(ZG.print("updateScaleResolutionDownBy()"),i=null===(r=t.videoTrack)||void 0===r?void 0:r.getTrack(),a=t.videoTransceiver,i&&t.pubVideo&&a){e.next=6;break}return ZG.print("updateScaleResolutionDownBy()","no pub"),e.abrupt("return");case 6:if(s=null==i?void 0:i.getSettings(),c={width:Math.floor(s.width),height:Math.floor(s.height),frameRate:Math.floor(s.frameRate)},(u=Vj(c,t.videoEncodeConfig[0])).scaleResolutionDownBy===t.prevScaleResolutionDownBy&&ZG.print("updateScaleResolutionDownBy()","no change %o",t.prevScaleResolutionDownBy),d=null===(n=a.sender)||void 0===n?void 0:n.getParameters()){h=u.scaleResolutionDownBy/t.prevScaleResolutionDownBy,d.encodings=null==d||null===(l=d.encodings)||void 0===l?void 0:l.map((function(e){var r;Math.max(e.scaleResolutionDownBy=(e.scaleResolutionDownBy||1)*h,1);var n=+e.rid||0;return e.maxFramerate=(null===(r=t.videoEncodeConfig[n])||void 0===r?void 0:r.frameRate)||e.maxFramerate,e})),t.prevScaleResolutionDownBy=u.scaleResolutionDownBy,t.videoInputConfig=c,null==a||a.sender.setParameters(d);try{this.monitor.rtcInvokeStatus(JSON.stringify(d.encodings),0,"Handler.updateScaleResolutionDownBy","",0)}catch(TQ){}}case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getStats",value:function(e,t){return Kj(this._peerConnection,e,t)}},{key:"setLocalDescription",value:(n=c(o().mark((function e(t,r){var n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fD(),e.prev=1,e.next=4,this._peerConnection.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:t}));case 4:this.monitor.rtcSetDescription(0,t,vB.W_1,"local"===(null==r?void 0:r.streamUserId)?_B.UP:_B.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",fD()-n,this.connection_id,{type:"offer",ms_addr:this.ms_addr}),this._initSctpEvents||(this._initSctpEvents=!0,(a=null===(i=this._peerConnection)||void 0===i?void 0:i.sctp)&&(a.onstatechange=function(){s.monitor.rtcInvokeStatus("sctp state change TO: ".concat(a.state),0,"sctp","",0,{ms_addr:s.ms_addr},s.connection_id)},a.transport&&(a.transport.onstatechange=function(){var e;s.monitor.rtcInvokeStatus("dtls state change TO: ".concat(null==a||null===(e=a.transport)||void 0===e?void 0:e.state),0,"dtls","",0,{ms_addr:s.ms_addr},s.connection_id)}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this.monitor.rtcSetDescription(-1,e.t0.message+t,vB.W_1,"local"===(null==r?void 0:r.streamUserId)?_B.UP:_B.DOWN,"","",fD()-n,this.connection_id,{type:"offer",ms_addr:this.ms_addr});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fD(),e.prev=1,e.next=4,this._peerConnection.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this.monitor.rtcSetDescription(0,t,vB.W_0,"local"===(null==r?void 0:r.streamUserId)?_B.UP:_B.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",fD()-n,this.connection_id,{type:"answer",ms_addr:this.ms_addr}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this.monitor.rtcSetDescription(-1,e.t0.message+t,vB.W_1,"local"===(null==r?void 0:r.streamUserId)?_B.UP:_B.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",fD()-n,this.connection_id,{type:"answer",ms_addr:this.ms_addr});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineAnswerTpl",value:function(e){var t=this;eG.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r=null==e?void 0:e.rtp.find((function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n=null==e?void 0:e.fmtp.find((function(e){return e.payload===r.payload}));n&&t._context&&(n.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&r.includes("flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n=r.codec,i=r.payload;if(["vp8","h264"].includes(n.toLocaleLowerCase())){var o=e.fmtp.find((function(e){return e.payload===i}));o?o.config=[].concat(k(o.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";"):e.fmtp.push({payload:i,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}}]),d}(BL.exports.EventEmitter),rH=Re,nH=Sf,iH=Rl.exports.getWeakData,oH=Xh,aH=Fr,sH=Ue,cH=Je,uH=Hh,dH=Kt,lH=Ln.set,hH=Ln.getterFor,fH=Ra.find,pH=Ra.findIndex,vH=rH([].splice),_H=0,mH=function(e){return e.frozen||(e.frozen=new yH)},yH=function(){this.entries=[]},gH=function(e,t){return fH(e.entries,(function(e){return e[0]===t}))};yH.prototype={get:function(e){var t=gH(this,e);if(t)return t[1]},has:function(e){return!!gH(this,e)},set:function(e,t){var r=gH(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=pH(this.entries,(function(t){return t[0]===e}));return~t&&vH(this.entries,t,1),!!~t}};var SH,EH={getConstructor:function(e,t,r,n){var i=e((function(e,i){oH(e,o),lH(e,{type:t,id:_H++,frozen:void 0}),sH(i)||uH(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=hH(t),s=function(e,t,r){var n=a(e),i=iH(aH(t),!0);return!0===i?mH(n).set(t,r):i[n.id]=r,e};return nH(o,{delete:function(e){var t=a(this);if(!cH(e))return!1;var r=iH(e);return!0===r?mH(t).delete(e):r&&dH(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!cH(e))return!1;var r=iH(e);return!0===r?mH(t).has(e):r&&dH(r,t.id)}}),nH(o,r?{get:function(e){var t=a(this);if(cH(e)){var r=iH(e);return!0===r?mH(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},bH=ce,kH=Re,TH=Sf,IH=Rl.exports,AH=yf,RH=EH,CH=Je,wH=Xl,OH=Ln.enforce,xH=mn,NH=!bH.ActiveXObject&&"ActiveXObject"in bH,PH=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},DH=AH("WeakMap",PH,RH);if(xH&&NH){SH=RH.getConstructor(PH,"WeakMap",!0),IH.enable();var MH=DH.prototype,LH=kH(MH.delete),UH=kH(MH.has),VH=kH(MH.get),FH=kH(MH.set);TH(MH,{delete:function(e){if(CH(e)&&!wH(e)){var t=OH(this);return t.frozen||(t.frozen=new SH),LH(this,e)||t.frozen.delete(e)}return LH(this,e)},has:function(e){if(CH(e)&&!wH(e)){var t=OH(this);return t.frozen||(t.frozen=new SH),UH(this,e)||t.frozen.has(e)}return UH(this,e)},get:function(e){if(CH(e)&&!wH(e)){var t=OH(this);return t.frozen||(t.frozen=new SH),UH(this,e)?VH(this,e):t.frozen.get(e)}return VH(this,e)},set:function(e,t){if(CH(e)&&!wH(e)){var r=OH(this);r.frozen||(r.frozen=new SH),UH(this,e)?FH(this,e,t):r.frozen.set(e,t)}else FH(this,e,t);return this}})}var BH=function(e){f(E,e);var t,r,n,i,a,s,d,p,v,_,y,S=g(E);function E(){var e,t,r;return u(this,E),h(m(r=S.call(this)),"inited",!1),h(m(r),"deviceMap",{audioinput:new Map,audiooutput:new Map,videoinput:new Map}),h(m(r),"checkDeviceChangeTimer",null),h(m(r),"isSupportedPermissionsQuery",!1),h(m(r),"isGrantedMicrophonePermission",!1),h(m(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!vD()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(m(r)),!vD()&&r.refreshDevices(),r}return l(E,[{key:"refreshDevices",value:(y=c(o().mark((function e(){var t,r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!gD){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return y.apply(this,arguments)})},{key:"initListener",value:(_=c(o().mark((function e(){var t,r,n,i,a=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){a._handleDeviceChange(),setTimeout((function(){a._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){a._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){a.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){a.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return _.apply(this,arguments)})},{key:"_handleDeviceChange",value:(v=c(o().mark((function e(){var t,r,n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,!gD){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:t=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:r=(r=e.sent).filter((function(e){return!!e.deviceId})),t&&t.getTracks().forEach((function(e){return e.stop()})),n=Array.from([].concat(k(this.deviceMap.audioinput.values()),k(this.deviceMap.videoinput.values()),k(this.deviceMap.audiooutput.values()))),r.forEach((function(e){var t=i.deviceMap[e.kind].get(e.deviceId);i.deviceMap[e.kind].set(e.deviceId,e),t||(e.kind.includes("video")?i.emit(oe.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):e.kind.includes("audio")&&i.emit(oe.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),n.forEach((function(e){r.find((function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(i.deviceMap[e.kind].delete(e.deviceId),e.kind.includes("video")?i.emit(oe.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):e.kind.includes("audio")&&i.emit(oe.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"getUserMedia",value:(p=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(d=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=r.filter((function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=r.filter((function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return d.apply(this,arguments)})},{key:"getPermissions",value:(s=c(o().mark((function e(){var t,r,n,i,a,s,c,u=this,d=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=d.length>0&&void 0!==d[0]?d[0]:{},n=r.audio,i=r.video,a=r.force,n||i||(n=!0,i=!0),s={audio:!1,video:!1},a){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return s.audio=!0,s.video=!0,e.abrupt("return",s);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return s.audio=this.isGrantedMicrophonePermission,s.video=this.isGrantedCameraPermission,e.abrupt("return",s);case 18:case 26:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(c=e.sent,!n||!i){e.next=28;break}if(!c.audio||!c.video){e.next=26;break}return e.abrupt("return",c);case 28:if(!(n&&c.audio||i&&c.video)){e.next=30;break}return e.abrupt("return",c);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=33;break}return e.next=33,navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),n&&(s.audio=!0,u.isGrantedMicrophonePermission=!0),i&&(s.video=!0,u.isGrantedCameraPermission=!0))})).catch((function(){}));case 33:return e.next=35,this.refreshDevices();case 35:return e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"enumerateDevices",value:(a=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Array.from([].concat(k(this.deviceMap.audioinput.values()),k(this.deviceMap.videoinput.values()),k(this.deviceMap.audiooutput.values()))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Array.from(this.deviceMap.audioinput.values()));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Array.from(this.deviceMap.videoinput.values()));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Array.from(this.deviceMap.audiooutput.values()));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",r.find((function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),E}(ZL),jH=new BH;!vD()&&(window.__rtc_dd__=jH);var GH=function(){function e(){u(this,e),h(this,"_audioContextInstance",void 0)}return l(e,[{key:"getAudioContextInstance",value:function(){if(!this._audioContextInstance){var e=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new e}return this._audioContextInstance}}]),e}(),HH=function(){function e(t){u(this,e),h(this,"_ctx",void 0),h(this,"_analyserNode",void 0),h(this,"_audioSource",void 0);var r=zH.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;return l(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;return t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))})),r/128*255}},{key:"resume",value:(t=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),zH=new GH,KH=function(e){return e[e.CAPTURE=0]="CAPTURE",e[e.PRE_PROCESSING=1]="PRE_PROCESSING",e[e.ENCODE=2]="ENCODE",e[e.TRANSFER=3]="TRANSFER",e[e.POST_PROCESSING=4]="POST_PROCESSING",e[e.DECODE=5]="DECODE",e[e.RENDERING=6]="RENDERING",e}(KH||{}),XH=function(){function e(){u(this,e),h(this,"_plugins",new Map),h(this,"_monitor",void 0)}var t;return l(e,[{key:"setMinotor",value:function(e){this._monitor=e}},{key:"register",value:function(e){e.monitor=this._monitor;var t=this._plugins.get(e.type)||[];if(t.findIndex((function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){return(this._plugins.get(e)||[]).find((function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=A(r),e.prev=3,i.s();case 5:if((a=i.n()).done){e.next=12;break}return s=a.value,e.next=9,s.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),WH=new YL("VERTC",0),qH=new WeakMap,YH=function(e){f(r,e);var t=g(r);function r(e,n){var i;return u(this,r),h(m(i=t.call(this)),"sourceType",1),h(m(i),"mediaType",void 0),h(m(i),"_trackId",void 0),i._trackId=e,i.mediaType=n,i}return l(r,[{key:"getId",value:function(){return this._trackId}}]),r}(ZL),JH=function(e){f(n,e);var t,r=g(n);function n(e,t,i){var o;return u(this,n),h(m(o=r.call(this,t,i)),"_mediaTrack",void 0),h(m(o),"_preProcessingTrack",void 0),h(m(o),"handleTrackEnded",(function(){FB.rtcError("track-ended mediaType: ".concat(o._mediaTrack.kind),-1001),o.emit("track-ended",m(o))})),o._mediaTrack=e,o._initListeners(),o}return l(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.getPreProcessingTrack(this);case 3:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(e){return t.apply(this,arguments)})},{key:"close",value:function(){var e,t,r;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._mediaTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._preProcessingTrack)||void 0===t||t.stop(),null===(r=this._mediaTrack)||void 0===r?void 0:r.stop()}},{key:"_initListeners",value:function(){this._mediaTrack instanceof MediaStreamTrack&&this._mediaTrack.addEventListener("ended",this.handleTrackEnded)}}]),n}(YH),QH=function(e){f(r,e);var t=g(r);function r(e,n,i){var o;return u(this,r),h(m(o=t.call(this,n,i)),"_mediaTrack",void 0),o._mediaTrack=e,o}return l(r,[{key:"getTrack",value:function(){return this._mediaTrack}}]),r}(YH),ZH=function(e){f(n,e);var t,r=g(n);function n(e,t){var i;return u(this,n),h(m(i=r.call(this,e,t,"video")),"resolution",void 0),h(m(i),"dummy",!1),i.resolution={width:0,height:0},i}return l(n,[{key:"updateVideoCaptureConfig",value:(t=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return WH.print("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=i({},t)).contentHint,e.next=7,this.getTrack().applyConstraints(r);case 7:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){this._mediaTrack&&"contentHint"in this._mediaTrack&&["text","motion","detail"].includes(e)&&(this._mediaTrack.contentHint=e)}}]),n}(JH),$H=function(e){f(n,e);var t,r=g(n);function n(e,t){var i;return u(this,n),h(m(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),h(m(i),"_audioLevelFetcher",void 0),h(m(i),"mixedAudioTrack",void 0),h(m(i),"mixType",re.PLAYOUT_AND_PUBLISH),i}return l(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new HH(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return WH.print("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(JH),ez=function(e){f(r,e);var t=g(r);function r(e,n){return u(this,r),t.call(this,e,n,"video")}return l(r)}(QH),tz=function(e){f(r,e);var t=g(r);function r(e,n){var i;return u(this,r),h(m(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return l(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new HH(this.getTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(QH),rz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_MAIN),e}return l(r)}($H),nz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_MAIN),e}return l(r)}(ZH),iz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_MAIN),h(m(e),"sourceType",0),e}return l(r)}(ZH),oz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_MAIN),h(m(e),"sourceType",0),e}return l(r)}($H),az=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_SCREEN),e}return l(r)}(ZH),sz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_SCREEN),e}return l(r)}($H),cz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_SCREEN),h(m(e),"sourceType",0),e}return l(r)}(ZH),uz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_SCREEN),h(m(e),"sourceType",0),e}return l(r)}($H);function dz(e,t){return lz.apply(this,arguments)}function lz(){return(lz=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new nz(t,hD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function hz(e,t){return fz.apply(this,arguments)}function fz(){return(fz=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new az(t,hD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function pz(e,t){return vz.apply(this,arguments)}function vz(){return(vz=c(o().mark((function e(t,r){var n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",e.prev=1,WH.print("createCameraVideoTrack","constraints:",t),FB.rtcVideoCaptureEvent({event_type:PB.START,media_device_id:a}),s=fD(),e.next=7,jH.getUserMedia({video:t});case 7:i=e.sent,FB.rtcVideoCaptureEvent({event_type:PB.START_CAPTURE_RESULT,media_device_id:a,reason:DB.SUCCESS,elapse:fD()-s}),e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(1),FB.rtcVideoCaptureEvent({event_type:PB.RUNNING_FAILED,media_device_id:a,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new hP(dP.GET_VIDEO_TRACK_FAILED,"throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ").concat(e.t0.message||"unknown message","."),e.t0);case 15:return c=i.getVideoTracks()[0],qH.set(c,i),u=new nz(c,hD()),e.next=20,u.generatePreProcessingTrack(r);case 20:return e.abrupt("return",u);case 21:case"end":return e.stop()}}),e,null,[[1,11]])})))).apply(this,arguments)}function _z(e,t,r){return mz.apply(this,arguments)}function mz(){return(mz=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v,_,m;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return WH.print("createMicrophoneAudioTrack","constraints:",t),s=(null==t||null===(i=t.deviceId)||void 0===i?void 0:i.exact)||"default",c=(null==n?void 0:n.config)||{},u=c.sampleRate,d=c.channel,l=c.agc,h=c.ans,f=c.aec,void 0===t.sampleRate&&(t.sampleRate=u),void 0===t.channelCount&&(t.channelCount=d),void 0===t.autoGainControl&&(t.autoGainControl=l),void 0===t.noiseSuppression&&(t.noiseSuppression=h),void 0===t.echoCancellation&&(t.echoCancellation=f),e.prev=8,FB.rtcVideoCaptureEvent({event_type:PB.START,media_device_id:s}),p=fD(),(v=r.getPluginByName(KH.PRE_PROCESSING,"RTCAIAnsExtension"))&&(v.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=15,jH.getUserMedia({audio:t});case 15:a=e.sent,FB.rtcVideoCaptureEvent({event_type:PB.START_CAPTURE_RESULT,media_device_id:s,reason:DB.SUCCESS,elapse:fD()-p}),e.next=23;break;case 19:throw e.prev=19,e.t0=e.catch(8),FB.rtcVideoCaptureEvent({event_type:PB.RUNNING_FAILED,media_device_id:s,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new hP(dP.GET_AUDIO_TRACK_FAILED,"throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ").concat(e.t0.message||"unknown message","."),e.t0);case 23:return _=a.getAudioTracks()[0],qH.set(_,a),m=new rz(_,hD()),e.next=28,m.generatePreProcessingTrack(r);case 28:return e.abrupt("return",m);case 29:case"end":return e.stop()}}),e,null,[[8,19]])})))).apply(this,arguments)}function yz(){return gz.apply(this,arguments)}function gz(){return gz=c(o().mark((function e(){var t,r,n,i,a,s,c,u,d,l=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]&&l[0],r=l.length>1?l[1]:void 0,n=l.length>2?l[2]:void 0,WH.print("createScreenTracks","withAudio: %o, constraints: %o",t,n),e.prev=4,FB.rtcVideoCaptureEvent({event_type:PB.START,media_device_id:"screen"}),a=fD(),e.next=9,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!SD||16!==kD))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 9:i=e.sent,FB.rtcVideoCaptureEvent({event_type:PB.START_CAPTURE_RESULT,media_device_id:"screen",reason:DB.SUCCESS,elapse:fD()-a}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(4),FB.rtcVideoCaptureEvent({event_type:PB.RUNNING_FAILED,media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new hP(dP.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 17:return s=i.getVideoTracks()[0],c=new az(s,hD()),e.next=21,c.generatePreProcessingTrack(r);case 21:if(!(u=i.getAudioTracks()[0])){e.next=27;break}return d=new sz(u,hD()),e.next=26,d.generatePreProcessingTrack(r);case 26:return e.abrupt("return",[c,d]);case 27:return e.abrupt("return",[c,void 0]);case 28:case"end":return e.stop()}}),e,null,[[4,13]])}))),gz.apply(this,arguments)}function Sz(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:hD();return new tz(e,t)}function Ez(e,t){return bz.apply(this,arguments)}function bz(){return(bz=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new iz(t,hD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function kz(e,t){return Tz.apply(this,arguments)}function Tz(){return(Tz=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new oz(t,hD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Iz(e,t){return Az.apply(this,arguments)}function Az(){return(Az=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new cz(t,hD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Rz(e,t){return Cz.apply(this,arguments)}function Cz(){return(Cz=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new uz(t,hD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var wz=$H,Oz=function(e){return e[e.NONE=0]="NONE",e}(Oz||{}),xz=function(){function e(){u(this,e)}return l(e,null,[{key:"getNalunits",value:function(t){if(t.length-t.position<4)return[];var r=t.position;return 1===t.getInt32(r)||0===t.getInt16(r)&&1===t.getInt8(r+2)?e.getAnnexbNals(t):e.getAvccNals(t)}},{key:"getAnnexbNals",value:function(t){for(var r=[],n=e.getHeaderPositionAnnexB(t),i=n.pos,o=i;i<t.length-4;){var a=new Uint8Array(t.buffer.slice(i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var s={header:a,body:new Uint8Array(t.buffer.slice(i+a.byteLength,o)),type:-1};e.analyseNal(s),s.type<=9&&0!==s.type&&r.push(s),t.skip(o-t.position),i=o}return r}},{key:"getAvccNals",value:function(t){for(var r=[];t.position<t.length-4;){var n=t.getInt32(t.position);if(!(t.length-t.position>=n))break;var i=new Uint8Array(t.buffer.slice(t.position,t.position+4));t.skip(4);var o=new Uint8Array(t.buffer.slice(t.position,t.position+n));t.skip(n);var a={header:i,body:o,type:-1};e.analyseNal(a),a.type<=9&&0!==a.type&&r.push(a)}return r}},{key:"analyseNal",value:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}}]),e}(),Nz=function(){function e(t){u(this,e),h(this,"_position",0),h(this,"_dataview",void 0),this._dataview=new DataView(t)}return l(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),Pz=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(Pz||{}),Dz=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),Mz=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),Lz=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)};function Uz(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function Vz(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0;255===e[t]&&t<e.byteLength;)t++,r+=255;return t<e.byteLength&&(r+=e[t++]),[r,t]}var Fz=function(){function e(){u(this,e)}return l(e,null,[{key:"generateSEI",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Uint8Array([0,0,0,1]),n=new Uint8Array([6]),i=new Uint8Array([5]),o=t?Dz:Mz,a=Uz(e.byteLength+o.byteLength),s=Lz(e);return new Uint8Array([].concat(k(r),k(n),k(i),k(a),k(o),k(s),[128]))}},{key:"decodeSeiBody",value:function(e){var t=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)}(e=e.slice(0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=b(Vz(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=Mz.byteLength&&i>=Mz.byteLength&&t.slice(r,r+Mz.byteLength).toString()===Mz.toString()?(r+=Mz.byteLength,o=1):t.byteLength>=Mz.byteLength&&i>=Mz.byteLength&&t.slice(r,r+Dz.byteLength).toString()===Dz.toString()&&(r+=Dz.byteLength,o=0),{type:o,payload:t.slice(r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new Map,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=b(Vz(e.payload,r),2),i=n[0];r=n[1];var o=b(Vz(e.payload,r),2),a=o[0];if(r=o[1],t.get(i)||!(a<=e.payload.byteLength-r))break;t.set(i,e.payload.slice(r,r+a)),r+=a}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=A(e);try{for(n.s();!(t=n.n()).done;){var i=b(t.value,2),o=i[0],a=i[1],s=Uz(o),c=Uz(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=r.reduce((function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return r.reduce((function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),Bz=function(){function e(t){u(this,e),h(this,"player",void 0),h(this,"_stream",void 0),h(this,"_timer",void 0),h(this,"client",void 0),h(this,"handler",void 0),h(this,"monitor",void 0),this._stream=t}return l(e,[{key:"setVar",value:function(e,t,r){this.client=e,this.handler=t,this.monitor=r}},{key:"delStatsEvtInterval",value:function(){var e;clearTimeout(this._timer),this._timer=void 0,null===(e=this.monitor)||void 0===e||e.rtcInvokeStatus("".concat((new Error).stack),0,"del_media_statistics_timer",this._stream.streamId||"",0)}},{key:"filterIllegal",value:function(e){var t={};return Object.keys(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){var e;null===(e=this.monitor)||void 0===e||e.rtcInvokeStatus("".concat((new Error).stack),0,"media_statistics_destroy","".concat(this._stream.streamId),0),this.delStatsEvtInterval()}}]),e}(),jz=function(e){f(i,e);var t,r,n=g(i);function i(e){var t;return u(this,i),(t=n.call(this,e))._stream=e,t}return l(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t,r){var n,i,a,s=this;if(!this._timer){this.setVar(e,t,r),e.once(Ej.ABNORMAL_DISCONNECTION,(function(){s.destroy()}));var u={audio:{},video:{}},d=this._stream,l=null===(n=d.audioTrack)||void 0===n?void 0:n.getTrack("preprocessing"),h=null===(i=d.videoTrack)||void 0===i?void 0:i.getTrack("preprocessing");this.getAudioStats(l,u,null===(a=d.audioTrack)||void 0===a?void 0:a.getAudioLevel()),this.getVideoStats(h,u),this.delStatsEvtInterval();var f=function(){var e=c(o().mark((function e(){var t,r,n,i,a,c,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=d.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),a=null===(r=d.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,s.getAudioStats(i,u,null===(n=d.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return c=e.sent,e.next=7,s.getVideoStats(a,u);case 7:return l=e.sent,e.abrupt("return",{audioStats:c,videoStats:l,isScreen:d.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),p=function(){var e=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f();case 2:r=e.sent,null===(t=s.client)||void 0===t||t.emit("onLocalStreamStats",r),s._timer&&clearTimeout(s._timer),s._timer=setTimeout(p,2e3);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();this._timer&&clearTimeout(this._timer),this._timer=setTimeout(p,2e3)}}},{key:"unpublish",value:function(){this.delStatsEvtInterval()}},{key:"getAudioStats",value:(r=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i={},a={timestamp:Date.now()},s=this._stream,c=s.streamId,u=s.audioMid,d=s.isScreen,l=s.pubAttributes,h=s.pubAudio,f={media_type:"audio",is_screen:!!d,direction:"up",stream_id:c,vid:u,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:l.localaudio?"capture_state_on":"capture_state_off",mute_state:h?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",i);case 6:return e.next=8,this.handler.getStats(t);case 8:if((p=e.sent).length){e.next=11;break}return e.abrupt("return",i);case 11:if(p.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,o=e.bytesSent,s=e.clockRate,c=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,_=e.nominated,m=e.id,y=e.currentRoundTripTime,g=e.state,S=e.writable,E=e.requestsReceived,b=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,A=e.jitter,R=e.candidateType,C=e.ip,w=e.address,O=e.networkType,x=e.port,N=e.protocol,P=e.nackCount,D=e.retransmittedBytesSent,M=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(a.packetsSent=r,a.bytesSent=o,f.bytes=o,f.packetsSent=r,f.nackCount=P,f.ssrc=U,f.retransmitted_bytes_sent=D,f.retransmitted_packets_sent=M,a.retransmittedBytesSent=D,a.retransmittedPacketsSent=M):"remote-inbound-rtp"===t?(a.packetsLost=n,f.packetsLost=n,f.net_jitter=1e3*A,i.rtt=1e3*c,f.rtt=i.rtt,i._fractionLost=j||0):"codec"===t?(i.recordSampleRate=s,i.numChannels=u,f.codecName=l):"media-source"===t&&void 0!==d?(f.audio_level=d?-10*Math.log10(Math.pow(d,2)):d,f.volume=255*d,f.total_audio_energy=V,f.totalInputDuration=F):"ssrc"===t&&"audio"===B?f.send_level=L:"candidate-pair"===t?(f.ice_available_incoming_bitrate=h,f.ice_available_outgoing_bitrate=p,f.ice_bytes_received=v,f.ice_bytes_sent=o,f.ice_nominated=+_,f.ice_pair_id=m,f.ice_pair_rtt=y,f.ice_pair_state=g,f.ice_pair_writable=S,f.recv_ping_requests=E,f.recv_ping_responses=b,f.sent_ping_requests_before_first_response=k,f.sent_ping_requests_total=k+(T||0),f.sent_ping_responses=I):"local-candidate"===t?(f.local_candidate_type=R,f.local_ip=C||w,f.local_network_type=O,f.local_port=x,f.protocol=N):"remote-candidate"===t&&(f.remote_candidate_type=R,f.remote_ip=C||w,f.remote_port=x);var G=hj("STATS_SCALLBACK_SUPPORT");yD&&G||"media-source"===t&&(f.send_level=d)})),void 0===f.volume&&void 0!==n&&(f.volume=n,f.audio_level=n?-10*Math.log10(Math.pow(n/255,2)):n),(v=r.audio).timestamp){e.next=17;break}return r.audio=a,e.abrupt("return",this.filterIllegal(i));case 17:return void 0!==a.packetsLost&&(i.audioLossRate=(a.packetsLost-v.packetsLost)/(a.packetsSent-v.packetsSent),i.audioLossRate=Number.isNaN(i.audioLossRate)?0:i.audioLossRate,f.fraction_lost=i.audioLossRate),i.statsInterval=a.timestamp-v.timestamp,f.stats_interval=i.statsInterval,i.sendKBitrate=(a.bytesSent-v.bytesSent||0)/i.statsInterval*8,f.mediaBitratebps=Math.round(1e3*i.sendKBitrate),f.bandwidth=Math.round(f.mediaBitratebps/1024),void 0!==a.retransmittedBytesSent&&(f.retransmitBitratebps=(a.retransmittedBytesSent-v.retransmittedBytesSent||0)/i.statsInterval),r.audio=a,this.monitor.rtcMediaStatistics(f,{}),i._retransmittedRate=(a.retransmittedPacketsSent-v.retransmittedPacketsSent)/(a.packetsSent-v.packetsSent),void 0===i.audioLossRate&&(i.audioLossRate=i._retransmittedRate,f.fraction_lost=i.audioLossRate),i._fractionLost=Math.max(i._fractionLost,i.audioLossRate),e.abrupt("return",this.filterIllegal(i));case 30:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i={},a={timestamp:Date.now(),simulcast:{}},s=this._stream,c=s.streamId,u=s.videoMid,d=s.isScreen,l=s.pubAttributes,h=s.enableSimulcast,f=s.pubVideo,p={media_type:"video",is_screen:!!d,direction:"up",stream_id:c,vid:u,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:l.localvideo?"capture_state_on":"capture_state_off",mute_state:f?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",i);case 6:return p.cap_frame_width=t.getSettings().width,p.cap_frame_height=t.getSettings().height,i.isScreen=d,e.next=11,this.handler.getStats(t);case 11:if((v=e.sent).length){e.next=14;break}return e.abrupt("return",i);case 14:if(null===(n=this.monitor)||void 0===n||n.rtcInvokeStatus("reports.length: ".concat(v.length,"; videoTrack: ").concat(t.id),0,"get_video_stats",c||"",0),_=0,v.forEach((function(e){var n=e.type,o=e.framesEncoded,s=e.packetsLost,c=e.bytesSent,u=e.framesSent,d=e.retransmittedBytesSent,l=e.totalPacketSendDelay,f=e.totalEncodeTime,v=e.firCount,m=e.targetBitrate,y=e.roundTripTime,g=e.mimeType,S=e.frameWidth,E=e.frameHeight,b=e.packetsSent,k=e.googActualEncBitrate,T=e.googAvailableReceiveBandwidth,I=e.googAvailableSendBandwidth,A=e.googAvgEncodeMs,R=e.googBucketDelay,C=e.googEncodeUsagePercent,w=e.googFrameRateInput,O=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,N=e.bytesReceived,P=e.nominated,D=e.id,M=e.currentRoundTripTime,L=e.state,U=e.writable,V=e.candidateType,F=e.ip,B=e.address,j=e.networkType,G=e.port,H=e.nackCount,z=e.pliCount,K=e.protocol,X=e.qpSum,W=e.requestsReceived,q=e.responsesReceived,Y=e.googRetransmitBitrate,J=e.requestsSent,Q=e.consentRequestsSent,Z=e.responsesSent,$=e.ssrc,ee=e.googTargetEncBitrate,te=e.googTransmitBitrate,re=e.retransmittedPacketsSent,ne=e.encoderImplementation,ie=e.jitter,oe=e.rid,ae=e.fractionLost,se=e.googAdaptationChanges,ce=e.qualityLimitationReason,ue=e.qualityLimitationDurations,de=e.googFirsReceived,le=e.googFrameRateSent,he=e.keyFramesEncoded;"outbound-rtp"===n?(h&&(oe?a.simulcast[oe]=e:a.simulcast[_]=e,_++),a.framesEncoded=o||a.framesEncoded||0,p.key_frames_encoded=he||0,a.bytesSent=c||a.bytesSent||0,a.framesSent=u||a.framesSent||0,p.bytes=c||p.bytes||0,a.packetsSent=b||a.packetsSent||0,p.packetsSent=b||p.packetsSent||0,p.nackCount=H||p.nackCount||0,p.pli_count=z||p.pli_count||0,p.qp_sum=X||p.qp_sum||0,p.ssrc=$||p.ssrc||0,p.retransmitted_packets_sent=re,a.retransmittedPacketsSent=re,a.retransmittedBytesSent=d,p.encoder_implementation=ne,p.qualityLimitationReason=ce,p.qualityLimitationDurations=ue,void 0!==S&&((!i.encodedFrameWidth||S>i.encodedFrameWidth)&&(i.encodedFrameWidth=S),(!i.encodedFrameHeight||E>i.encodedFrameHeight)&&(i.encodedFrameHeight=E),p.frame_size_height=E,p.frame_size_width=S)):"track"===n?(i.encodedFrameWidth=S,i.encodedFrameHeight=E,p.frame_size_height=E,p.frame_size_width=S):"remote-inbound-rtp"===n?(a.packetsLost=s,i.rtt=1e3*y,p.rtt=i.rtt,p.jitter=ie,p.packetsLost=s,i._fractionLost=ae||0):"codec"===n?(i.codecType=g,p.codecName=g):"candidate-pair"===n?(p.ice_available_incoming_bitrate=O,p.ice_available_outgoing_bitrate=x,p.ice_bytes_received=N,p.ice_bytes_sent=c,p.ice_nominated=+P,p.ice_pair_id=D,p.ice_pair_rtt=M,p.ice_pair_state=L,p.ice_pair_writable=U,p.recv_ping_requests=W,p.recv_ping_responses=q,p.sent_ping_requests_before_first_response=J,p.sent_ping_requests_total=J+Q,p.sent_ping_responses=Z):"local-candidate"===n?(p.local_candidate_type=V,p.local_ip=F||B,p.local_network_type=j,p.local_port=G,p.protocol=K):"remote-candidate"===n?(p.remote_candidate_type=V,p.remote_ip=F||B,p.remote_port=G):"VideoBwe"===n?(p.encBitratebps=k,p.available_receive_bandwidth=T,p.available_send_bandwidth=I,p.bucket_delay=R,p.retransmitBitratebps=Y,p.targetEncBitratebps=ee,p.transmit_bitrate=te,i._sendBandWidth=+I):"ssrc"===n&&(p.avg_encode_ms=A,p.encodeUsage=C,p.frame_rate_input=w,p.orignal_input_Framerate=+w,p.ddaptationChanges=se,p.firsReceived=de,p.frameRateSent=le);var fe=hj("STATS_SCALLBACK_SUPPORT");if(!yD||!fe){var pe=r.video,ve=a.timestamp-pe.timestamp;if("outbound-rtp"===n){var _e=c-pe.bytesSent,me=d-pe.retransmittedBytesSent;p.encBitratebps=Math.round(8e3*(_e-me)/ve),p.bucket_delay=l/b,p.retransmitBitratebps=Math.round(8e3*me/ve),p.targetEncBitratebps=m,p.transmit_bitrate=Math.round(1e3*(c-pe.bytesSent)*8/ve),p.avg_encode_ms=1e3*f/o,p.firsReceived=v+z,p.qualityLimitationReason="bandwidth"===ce,p.qualityLimitationDurations="cpu"===ce}else"candidate-pair"===n&&(p.available_send_bandwidth=x,i._sendBandWidth=x);if(t){var ye=null==t?void 0:t.getSettings().frameRate;p.orignal_input_Framerate=ye,p.frameRateSent=t.getSettings().frameRate}}})),(m=r.video).timestamp){e.next=21;break}return r.video=a,e.abrupt("return",this.filterIllegal(i));case 21:return i.statsInterval=a.timestamp-m.timestamp,p.stats_interval=i.statsInterval,y=Object.keys(a.simulcast),h?(p.sim_enc_width=[],p.sim_enc_height=[],p.sim_enc_bps=[],p.sim_enc_framerate=[],p.sim_enc_key_frames=[],p.sim_rids=[],p.sim_enc_bandwidth=[],p.sim_sent_framerate=[],p.sim_fraction_lost=[],p.sim_keyencoded=[],p.active_sim_streams=[],p.sim_retransmittedRate=[],g=!1,y.sort((function(e,t){return+e-+t})).forEach((function(e){var t=a.simulcast[e],r=t.frameWidth,n=t.frameHeight,o=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,h=t.qualityLimitationDurations,f=t.qualityLimitationResolutionChanges,v=t.retransmittedPacketsSent,_=t.pliCount,y=t.keyFramesEncoded;void 0!==l&&(p.sim_qualityLimitationReason||(p.sim_qualityLimitationReason=[],p.sim_qualityLimitationDurations=[],p.sim_qualityLimitationResolutionChanges=[]),p.sim_qualityLimitationReason.push(l),p.sim_qualityLimitationDurations.push(h),p.sim_qualityLimitationResolutionChanges.push(f));var S=m.simulcast[e];if(p.sim_enc_width.push(r||0),p.sim_enc_height.push(n||0),p.sim_enc_key_frames.push(y||0),S){var E=(o-S.bytesSent||0)/i.statsInterval;p.sim_enc_bps.push(Math.round(8e3*E)),p.sim_enc_bandwidth.push(Math.round(8e3*E/1024));var b=1e3*(s-S.framesEncoded)/i.statsInterval;p.sim_enc_framerate.push(Math.round(b)),p.sim_rids.push(e);var k=void 0!==c?c-S.framesSent:s-S.framesEncoded,T=1e3*k/i.statsInterval;p.sim_sent_framerate.push(Math.round(T));var I=(u-S.packetsLost)/(d-S.packetsSent);i._retransmittedRate=(v-S.retransmittedPacketsSent)/(d-S.packetsSent),I=Number.isNaN(I)?0:I,p.sim_fraction_lost.push(I),p.sim_keyencoded.push(_-S.pliCount>0),p.active_sim_streams.push(E>=0),p.sim_retransmittedRate.push(i._retransmittedRate),r>0&&!g&&(i.sentKBitrate=8*E,i.encoderOutputFrameRate=b,i.encodedFrameCount=k,i.sentFrameRate=T,i.videoLossRate=I,g=!0)}})),this.monitor.rtcMediaStatistics(p,{})):(i.encodedFrameCount=void 0!==a.framesSent?a.framesSent-m.framesSent:a.framesEncoded-m.framesEncoded,i.sentKBitrate=(a.bytesSent-m.bytesSent||0)/i.statsInterval*8,p.bitrate=Math.round(1e3*i.sentKBitrate),p.bandwidth=Math.round(p.bitrate/1024),i.encoderOutputFrameRate=1e3*(a.framesEncoded-m.framesEncoded)/i.statsInterval,p.frame_rate_encoded=Math.round(i.encoderOutputFrameRate),i.sentFrameRate=1e3*i.encodedFrameCount/i.statsInterval,p.frame_rate_sent=Math.round(i.sentFrameRate),i.videoLossRate=(a.packetsLost-m.packetsLost)/(a.packetsSent-m.packetsSent),i.videoLossRate=Number.isNaN(i.videoLossRate)?0:i.videoLossRate,p.fraction_lost=i.videoLossRate,i._retransmittedRate=(a.retransmittedPacketsSent-m.retransmittedPacketsSent)/(a.packetsSent-m.packetsSent),this.monitor.rtcMediaStatistics(p,{})),r.video=a,i._fractionLost=Math.max(i._fractionLost,i.videoLossRate),e.abrupt("return",this.filterIllegal(i));case 28:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(Bz),Gz=function(e){f(a,e);var t,r,n,i=g(a);function a(e){var t;return u(this,a),h(m(t=i.call(this,e)),"isPaused",void 0),h(m(t),"pauseStart",void 0),h(m(t),"pauseDuration",void 0),h(m(t),"_audioStallCount",void 0),h(m(t),"_setAudioStallCount",void 0),h(m(t),"_audioStallTimer",void 0),h(m(t),"_audioStallInterval",void 0),h(m(t),"_audioStallRatio",void 0),h(m(t),"_videoInWaiting",void 0),h(m(t),"_context",void 0),t._videoInWaiting=!1,t.pauseDuration=0,t}return l(a,[{key:"setRemoteStreamStatsEvtInterval",value:(n=c(o().mark((function e(t,r,n,i){var s,u,d,l,h,f,p,v,_,m,y,g,S,E,b=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return this.setVar(t,r,n),this._context=i,t.once(Ej.ABNORMAL_DISCONNECTION,(function(){b.destroy()})),this._audioStallInterval=a.audioStallInterval||100,this._audioStallRatio=a.audioStallRatio||.6,d={audio:{},video:{}},l=this._stream,h=null===(s=l.audioTrack)||void 0===s?void 0:s.getTrack(),f=null===(u=l.videoTrack)||void 0===u?void 0:u.getTrack(),this.getRemoteVideoStats(f,d),e.next=14,this.getRemoteAudioStats(h,d);case 14:this.delStatsEvtInterval(),p=0,v=0,m=[],y=0,g=fD(),this._setAudioStallCount=function(){if(dj.AUDIO_STALL&&b._audioStallInterval>0&&void 0!==d.audio.concealedSamples){var e=d.audio.concealedSamples,t=d.audio.totalSamplesReceived;g=fD();var r={isStall:!1,counted:!1,diff:0},n=.5*b._audioStallInterval;b._audioStallCount=c(o().mark((function i(){var a,s,c,u,d,h,f,_,S,E,k,T,I,A,R;return o().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(s=l.hasAudio,c=l.subAudio,s&&c){i.next=7;break}return r.isStall=!1,r.counted=!1,m.push({reason:"hasAudio: ".concat(s,", subAudio: ").concat(c)}),g=fD(),i.abrupt("return",{stall_count:p,stall_duration:v,stall_list:m,stats_count:y});case 7:return u=null===(a=l.audioTrack)||void 0===a?void 0:a.getTrack(),d=Date.now(),i.next=11,b.handler.getStats(u,!0);case 11:if(h=i.sent,f=Date.now(),_=fD(),!((S=_-g)<n)){i.next=18;break}return m.push({diff:S,start:g,end:_,get_stats_cost:f-d,get_stats_start:d,get_stats_end:f,reason:"diff(".concat(S,") < minInterval(").concat(n,")")}),i.abrupt("return",{stall_count:p,stall_duration:v,stall_list:m,stats_count:y});case 18:if(E=h.length,k=h.find((function(e){return"inbound-rtp"===e.type}))){i.next=23;break}return m.push({diff:S,start:g,end:_,get_stats_cost:f-d,get_stats_start:d,get_stats_end:f,reason:E?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:p,stall_duration:v,stall_list:m,stats_count:y});case 23:return T=k.concealedSamples,I=k.totalSamplesReceived,R=I-t,(A=T-e)>=0&&R>=0&&A>=b._audioStallRatio*R?(m.push({concealed:A,received:R,diff:S,start:g,end:_,get_stats_cost:f-d,get_stats_start:d,get_stats_end:f,is_stall:!0}),r.isStall?(r.counted?v+=S:(v=v+r.diff+S,p++),r.counted=!0):S>=200?(v+=S,p++,r.counted=!0):(r.counted=!1,r.diff=S),r.isStall=!0):(m.push({concealed:A,received:R,diff:S,start:g,end:_,get_stats_cost:f-d,get_stats_start:d,get_stats_end:f}),r.isStall=!1,r.counted=!1),e=T,t=I,g=_,y++,i.abrupt("return",{stall_count:p,stall_duration:v,stall_list:m,stats_count:y});case 32:case"end":return i.stop()}}),i)}))),_=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!b._audioStallCount&&b._setAudioStallCount&&b._setAudioStallCount(),!b._audioStallCount){e.next=6;break}return e.next=4,b._audioStallCount();case 4:b._audioStallTimer&&clearTimeout(b._audioStallTimer),b._audioStallTimer=setTimeout(_,b._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),b._audioStallTimer&&clearTimeout(b._audioStallTimer),b._audioStallTimer=setTimeout(_,b._audioStallInterval)}},this._setAudioStallCount(),S=function(){var e=c(o().mark((function e(){var t,r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null===(t=l.audioTrack)||void 0===t?void 0:t.getTrack(),i=null===(r=l.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,b.getRemoteAudioStats(n,d);case 4:return a=e.sent,p=0,v=0,m=[],y=0,e.next=11,b.getRemoteVideoStats(i,d);case 11:return s=e.sent,e.abrupt("return",{audioStats:a,videoStats:s,isScreen:l.isScreen,userId:l.userId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),E=function(){var e=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S();case 2:r=e.sent,null===(t=b.client)||void 0===t||t.emit("onRemoteStreamStats",r),_&&(g=fD(),b._audioStallTimer&&clearTimeout(b._audioStallTimer),b._audioStallTimer=setTimeout(_,b._audioStallInterval)),b._timer&&clearTimeout(b._timer),b._timer=setTimeout(E,2e3);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(E,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"delStatsEvtInterval",value:function(){E(p(a.prototype),"delStatsEvtInterval",this).call(this),clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){this.delStatsEvtInterval(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},i={},a=this._stream,s=a.streamId,c=a.userId,u=a.isScreen,d=a.audioMid,l=a.subMediaType,h=a._attributes,f=a.virtual,p={media_type:"audio",is_screen:!!u,direction:"down",stream_id:s,stream_user_id:c,vid:d,audio_mux:f,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:UD(l)?"mute_state_off":"mute_state_on",remote_user_capture_state:h.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:h.localaudio&&h.audiostream?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6:return e.next=8,this.handler.getStats(t);case 8:if((v=e.sent).length){e.next=11;break}return e.abrupt("return",n);case 11:if(v.forEach((function(e){var t=e.type,r=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,c=e.jitterBufferDelay,u=e.jitterBufferEmittedCount,d=e.clockRate,l=e.channels,h=e.totalSamplesReceived,f=e.concealedSamples,v=e.silentConcealedSamples,_=e.concealmentEvents,m=e.totalRoundTripTime,y=e.packetsDiscarded,g=e.state,S=e.currentRoundTripTime,E=e.audioLevel,b=e.totalAudioEnergy,T=e.totalSamplesDuration,I=e.mimeType,A=e.googDecodingNormal,R=e.googDecodingMuted,C=e.availableIncomingBitrate,w=e.availableOutgoingBitrate,O=e.bytesSent,x=e.nominated,N=e.id,P=e.writable,D=e.jitter,M=e.candidateType,L=e.ip,U=e.address,V=e.networkType,F=e.port,B=e.protocol,j=e.audioOutputLevel,G=e.requestsReceived,H=e.responsesReceived,z=e.requestsSent,K=e.consentRequestsSent,X=e.responsesSent,W=e.ssrc;e.kind;var q=e.nackCount,Y=e.lastPacketReceivedTimestamp,J=e.concealmentevents,Q=e.fecPacketsReceived;if("inbound-rtp"===t)i.packetsLost=r,i.packetsReceived=o,p.packetsReceived=o,p.packetsDiscarded=y,p.nackCount=q,p.lastPacketReceivedTimestamp=Y,p.concealmentevents=J,i.bytesReceived=a,void 0!==c&&(n.jitterBufferDelay=c/u*1e3,p.average_jitter_buffer_delay_ms=n.jitterBufferDelay),void 0!==h&&(i.totalSamplesReceived=h,n.concealedSamples=f,i.concealedSamples=f,i.silentConcealedSamples=v,p.concealedSamples=f,n.concealmentEvents=_,p.totalSamplesReceived=h),void 0!==Q&&(p.fec_packets_received=Q,i.fecPacketsReceived=Q),p.jitter=1e3*D,p.ssrc=W,void 0!==E&&(p.audio_level=E?-10*Math.log10(Math.pow(E,2)):E),void 0!==E&&(p.volume=255*E),void 0!==b&&(p.total_audio_energy=b),void 0!==T&&(p.totalAudioDuration=T);else if("codec"===t)n.recordSampleRate=d,l&&(n.numChannels=l),p.codecName=I;else if("candidate-pair"===t){var Z,$,ee;p.ice_available_incoming_bitrate=C,p.ice_available_outgoing_bitrate=w,p.ice_bytes_received=a,p.ice_bytes_sent=O,p.ice_nominated=+x,p.ice_pair_id=N,p.ice_pair_rtt=S,p.rtt=1e3*S,p.rtt&&null!==(Z=k._context)&&void 0!==Z&&null!==($=Z.streamRTT)&&void 0!==$&&null!==(ee=$[s])&&void 0!==ee&&ee.audio&&(p.total_rtt_ms=p.rtt+k._context.streamRTT[s].audio),p.ice_pair_state=g,p.ice_pair_writable=P,p.recv_ping_requests=G,p.recv_ping_responses=H,p.sent_ping_requests_before_first_response=z,p.sent_ping_requests_total=z+(K||0),p.sent_ping_responses=X,"succeeded"===g&&(n.rtt=1e3*S,n.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(p.audio_level=E?-10*Math.log10(Math.pow(E,2)):E,p.volume=255*E,p.total_audio_energy=b,p.totalAudioDuration=T):"ssrc"===t?(p.decodingNormal=A,p.recvAudioLevel=j,p.decodingMuted=R):"local-candidate"===t?(p.local_candidate_type=M,p.local_ip=L||U,p.local_network_type=V,p.local_port=F,p.protocol=B):"remote-candidate"===t&&(p.remote_candidate_type=M,p.remote_ip=L||U,p.remote_port=F)})),(_=r.audio).timestamp){e.next=17;break}return i.timestamp=Date.now(),r.audio=i,e.abrupt("return",this.filterIllegal(n));case 17:if(m={},void 0!==i.concealedSamples&&(p.interval_concealed_samples=i.concealedSamples-_.concealedSamples,p.interval_samples_received=i.totalSamplesReceived-_.totalSamplesReceived,p.interval_silent_concealed_samples=i.silentConcealedSamples-_.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==_.concealedSamples)){e.next=35;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=35;break}return e.next=25,this._audioStallCount();case 25:y=e.sent,g=y.stall_count,S=y.stall_duration,E=y.stall_list,b=y.stats_count,m.stall_list=E,m.stats_count=b,p.concealedSamples===p.interval_concealed_samples&&p.totalSamplesReceived===p.interval_samples_received?(p.stall_count=0,p.stall_duration=0):(p.stall_count=g,p.stall_duration=S),n.stallCount=p.stall_count,n.stallDuration=p.stall_duration;case 35:return i.timestamp=Date.now(),n.audioLossRate=(i.packetsLost-_.packetsLost)/(i.packetsReceived-_.packetsReceived+(i.packetsLost-_.packetsLost)),n.audioLossRate=Number.isNaN(n.audioLossRate)?0:n.audioLossRate,p.packetsLost=Math.round(i.packetsLost-_.packetsLost),p.fraction_lost=n.audioLossRate,n.statsInterval=i.timestamp-_.timestamp,p.stats_interval=n.statsInterval,n.receivedKBitrate=(i.bytesReceived-_.bytesReceived||0)/n.statsInterval*8,p.bandwidth=Math.round(1e3*n.receivedKBitrate/1024),void 0!==i.concealedSamples&&(n.receivedSampleRate=1e3*p.interval_samples_received/n.statsInterval),void 0!==i.fecPacketsReceived&&(p.fecBitratebps=(i.fecPacketsReceived-_.fecPacketsReceived||0)/n.statsInterval),r.audio=i,this.monitor.rtcMediaStatistics(p,{},m),e.abrupt("return",this.filterIllegal(n));case 49:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i={},a={timestamp:Date.now()},s=this._stream,c=s.streamId,u=s.userId,d=s.isScreen,l=s.subMediaType,h=s._attributes,f={media_type:"video",is_screen:!!d,direction:"down",stream_id:c,stream_user_id:u,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:VD(l)?"mute_state_off":"mute_state_on",remote_user_capture_state:h.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:h.localvideo&&h.videostream?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",i);case 6:return i.isScreen=d,e.next=9,this.handler.getStats(t);case 9:if(p=e.sent,null===(n=this.monitor)||void 0===n||n.rtcInvokeStatus("reports.length: ".concat(p.length,"; videoTrack: ").concat(t.id),0,"get_remote_video_stats",c,0),p.length){e.next=13;break}return e.abrupt("return",i);case 13:if(p.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,o=e.packetsLost,s=e.packetsReceived,u=e.bytesReceived,d=e.framesDecoded,l=e.jitterBufferDelay,h=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,_=e.availableIncomingBitrate,y=e.availableOutgoingBitrate,g=e.bytesSent,S=e.nominated,E=e.id,b=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,A=e.ip,R=e.address,C=e.networkType,w=e.port,O=e.nackCount,x=e.pliCount,N=e.protocol,P=e.requestsReceived,D=e.responsesReceived,M=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,G=e.decoderImplementation,H=e.lastPacketReceivedTimestamp;if("inbound-rtp"===t)a.packetsLost=o,f.packetsLost=o,a.packetsReceived=s,f.packetsReceived=s,a.bytesReceived=u,f.bytes=u,a.framesDecoded=d,void 0!==l&&(a.jitterBufferDelay=l/h*1e3,f.average_jitter_buffer_delay_ms=a.jitterBufferDelay),f.fir_count=v,f.nackCount=O,a.nackCount=O,f.pli_count=x,f.ssrc=V,f.jitter=F,f.framesReceived=B,a.framesReceived=B,f.framesDecoded=d,f.key_frames_decoded=j,f.decoder_name=G,f.last_packet_received_timestamp=H,void 0!==n&&(i.width=n,f.frame_size_width=n,i.height=r,f.frame_size_height=r);else if("track"===t&&void 0!==n)i.width=n,f.frame_size_width=n,i.height=r,f.frame_size_height=r,void 0!==B&&(f.framesReceived=B,a.framesReceived=B);else if("codec"===t)f.codecName=p;else if("candidate-pair"===t){var z,K,X;f.ice_available_incoming_bitrate=_,f.ice_available_outgoing_bitrate=y,f.ice_bytes_received=u,f.ice_bytes_sent=g,f.ice_nominated=+S,f.ice_pair_id=E,f.ice_pair_rtt=b,f.rtt=1e3*b,f.rtt&&null!==(z=m._context)&&void 0!==z&&null!==(K=z.streamRTT)&&void 0!==K&&null!==(X=K[c])&&void 0!==X&&X.video&&(f.total_rtt_ms=f.rtt+m._context.streamRTT[c].video),i.rtt=f.rtt,f.ice_pair_state=k,f.ice_pair_writable=T,f.recv_ping_requests=P,f.recv_ping_responses=D,f.sent_ping_requests_before_first_response=M,f.sent_ping_requests_total=M+(L||0),f.sent_ping_responses=U}else"local-candidate"===t?(f.local_candidate_type=I,f.local_ip=A||R,f.local_network_type=C,f.local_port=w,f.protocol=N):"remote-candidate"===t&&(f.remote_candidate_type=I,f.remote_ip=A||R,f.remote_port=w)})),(v=r.video).timestamp){e.next=18;break}return r.video=a,e.abrupt("return",this.filterIllegal(i));case 18:return i.videoLossRate=(a.packetsLost-v.packetsLost)/(a.packetsReceived-v.packetsReceived+(a.packetsLost-v.packetsLost)),i._retransmittedRate=(a.nackCount-v.nackCount)/(a.packetsReceived-v.packetsReceived+(a.packetsLost-v.packetsLost)),i.videoLossRate=Number.isNaN(i.videoLossRate)?0:i.videoLossRate,f.fraction_lost=i.videoLossRate,i.statsInterval=a.timestamp-v.timestamp,f.stats_interval=i.statsInterval,i.receivedKBitrate=(a.bytesReceived-v.bytesReceived||0)/i.statsInterval*8,f.bitrate=Math.round(1e3*i.receivedKBitrate),f.bandwidth=Math.round(f.bitrate/1024),i.decoderOutputFrameRate=1e3*(a.framesDecoded-v.framesDecoded)/i.statsInterval,i.receivedFrameRate=1e3*(a.framesReceived-v.framesReceived)/i.statsInterval,f.frame_rate_decoded=Math.round(i.decoderOutputFrameRate),f.frame_rate_received=Math.round(i.receivedFrameRate),r.video=a,this.processStall(this._stream,f,i,d),this.isPaused?(_=a.timestamp-(this.pauseStart||0),f.pause_duration=this.pauseDuration+(_>500?_:0),this.pauseStart=a.timestamp):f.pause_duration=this.pauseDuration,f.pause_duration=Math.min(f.stall_duration,f.pause_duration),this.pauseDuration=0,this.monitor.rtcMediaStatistics(f,{}),e.abrupt("return",this.filterIllegal(i));case 38:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=o,t.stall_duration=void 0):(t.stall_duration=o,t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){E(p(a.prototype),"destroy",this).call(this),this.delStatsEvtInterval(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){a.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,a.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),a}(Bz);h(Gz,"audioStallInterval",void 0),h(Gz,"audioStallRatio",void 0);var Hz,zz,Kz,Xz=new YL("Stream",0),Wz=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(Wz||{}),qz=function(){function e(){u(this,e),h(this,"isScreen",!1),h(this,"stream",void 0),h(this,"streamId",void 0),h(this,"audioMid",void 0),h(this,"videoMid",void 0),h(this,"seiList",[]),h(this,"videoTrack",void 0),h(this,"audioTrack",void 0),h(this,"videoTransceiver",void 0),h(this,"audioTransceiver",void 0),h(this,"videoInputConfig",void 0),h(this,"videoEncodeConfig",[vj]),h(this,"subVideoDescriptions",[]),h(this,"enableSimulcast",!1),h(this,"observer",void 0),h(this,"statsReport",void 0),h(this,"prevScaleResolutionDownBy",1),h(this,"prevBitrate",0),h(this,"pubAudio",!1),h(this,"pubVideo",!1),h(this,"pubAttributes",void 0),this.stream=new MediaStream,this.videoInputConfig={width:640,height:360,frameRate:30},this.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},this.statsReport=new jz(this)}return l(e,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return this.audioMid&&this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if($j()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i=Fz.generateSEI(n.content),o=new Uint8Array(i.byteLength+t.data.byteLength);0===n.repeatCount&&e.seiList.splice(0,1),n.repeatCount--,o.set(new Uint8Array(t.data)),o.set(i,t.data.byteLength),t.data=o.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else Xz.print("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else Xz.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){var e;FB.rtcInvokeStatus("".concat((new Error).stack),0,"localstream_clean",this.streamId||"",0),this.audioMid=void 0,this.videoMid=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,null===(e=this.observer)||void 0===e||e.reset(),this.statsReport.destroy(),this.prevScaleResolutionDownBy=1,this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),e}(),Yz=function(e){f(r,e);var t=g(r);function r(e,n,i,o){var a;return u(this,r),h(m(a=t.call(this)),"streamId",void 0),h(m(a),"userId",void 0),h(m(a),"isScreen",void 0),h(m(a),"hasVideo",void 0),h(m(a),"hasAudio",void 0),h(m(a),"_attributes",void 0),h(m(a),"streamState",void 0),h(m(a),"observer",void 0),h(m(a),"statsReport",void 0),h(m(a),"subVideo",void 0),h(m(a),"subAudio",void 0),h(m(a),"subMediaType",void 0),h(m(a),"subLayer",void 0),h(m(a),"audioMid",void 0),h(m(a),"videoMid",void 0),h(m(a),"_sequenceId",void 0),h(m(a),"stream",void 0),h(m(a),"videoTrack",void 0),h(m(a),"audioTrack",void 0),h(m(a),"videoTransceiver",void 0),h(m(a),"audioTransceiver",void 0),h(m(a),"recordedVideoFrames",void 0),h(m(a),"stillExist",void 0),h(m(a),"originalMediaType",void 0),h(m(a),"originalStreamIndex",0),h(m(a),"virtual",void 0),a.virtual=!1,a.userId=e,a.isScreen=i,a.streamId=n,a.hasAudio=o.audiostream&&o.localaudio,a.hasVideo=o.videostream&&o.localvideo,a._attributes=o,a.subVideo=!1,a.subAudio=!1,a._sequenceId=0,a.subMediaType=Oz.NONE,a.subLayer={spatialLayer:0,spatialSubLayer:-1},a.streamState=0,a.statsReport=new Gz(m(a)),a}return l(r,[{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){xz.getNalunits(new Nz(t.data)).forEach((function(t){if(t.sei){var r=Fz.decodeSeiBody(t.body);r&&r.type!==Pz.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else Xz.print("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else Xz.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{FB.rtcInvokeStatus(JSON.stringify({uid:this.userId,streamId:this.streamId,streams:e.streams.reduce((function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:JSON.stringify({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:JSON.stringify({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:JSON.stringify({track:jD(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:JSON.stringify({track:jD(o.track)}))})),track:jD(e.track)}),0,"Stream.ontrack","",0)}catch(TQ){}if(null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&n.includes(this.streamId)){var s,c=e.track;"video"===(null==c?void 0:c.kind)?this._setVideoTrack(c):"audio"===(null===(s=e.track)||void 0===s?void 0:s.kind)&&this._setAudioTrack(c),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e;Xz.print("clean","exec stream.clean ".concat(this.streamId," ").concat(this.userId)),FB.rtcInvokeStatus("".concat((new Error).stack),0,"remotestream_clean",this.streamId,0),this.subAudio=!1,this.subVideo=!1,this.audioMid=void 0,this.videoMid=void 0,this.sequenceId=0,this.videoTrack=void 0,this.audioTrack=void 0,this.stream=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,this.recordedVideoFrames=void 0,null===(e=this.observer)||void 0===e||e.reset(),this.statsReport.destroy()}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=Sz(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:hD();return new ez(e,t)}(e),this.emit("ontrack",this.videoTrack))}},{key:"_getSubLayerBySpatialLayer",value:function(e){var t=this._attributes,r=t.videoDescriptions,n=t.subVideoDescriptions,i=void 0===n?[]:n,o=r[e],a=o.width,s=o.height,c=i.find((function(e){return e.width===a&&e.height===s}));return{spatialLayer:e,spatialSubLayer:(null==c?void 0:c.sub_index)||-1}}}]),r}(ZL),Jz=new YL("queue",4),Qz=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(Qz||{}),Zz=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(Zz||{}),$z=(h(Hz={},"publish","unpublish"),h(Hz,"subscribe","unsubscribe"),h(Hz,"pushtrack","removetrack"),Hz),eK=(h(zz={},"publish",0),h(zz,"subscribe",0),h(zz,"pushtrack",0),h(zz,"unpublish",1),h(zz,"unsubscribe",1),h(zz,"removetrack",1),zz),tK=function(e){f(r,e);var t=g(r);function r(){var e;return u(this,r),h(m(e=t.call(this)),"_queue",void 0),e._queue=[],e}return l(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t=this._queue.length,r="";return this._queue=this._queue.filter((function(t){return t.streamId!==e.streamId||e.action!==$z[t.action]||(r=t.streamId,Jz.print("offsetStreamId",r),!1)})),this._queue.length===t&&this._queue.push(e),this.emit("start"),r}},{key:"dequeue",value:function(){if(!this._queue.length)return null;var e=this._queue.length;wD&&(e=Math.min(this._queue.length,5));for(var t=eK[this._queue[0].action],r=1;r<e;r++)if(eK[this._queue[r].action]!==t)return{sdpStrategy:t,items:this._queue.splice(0,r)};return{sdpStrategy:t,items:this._queue.splice(0,e)}}}]),r}(jL),rK=new YL("ChromeHandler",3),nK=$j(),iK=function(e){f(T,e);var r,n,a,s,d,v,_,y,S,k=g(T);function T(e,t){var r;return u(this,T),h(m(r=k.call(this,e,t)),"name","chrome"),h(m(r),"_queueBusy",!1),h(m(r),"_sdpQueue",void 0),h(m(r),"_aSendonlyOfferTpl",void 0),h(m(r),"_vSendonlyOfferTpl",void 0),h(m(r),"_aRecvonlyOfferTpl",void 0),h(m(r),"_vRecvonlyOfferTpl",void 0),h(m(r),"_mid",10),h(m(r),"_offerSession",void 0),h(m(r),"_answerSession",void 0),h(m(r),"_offerMlines",[]),h(m(r),"_answerMlines",[]),h(m(r),"_inactiveMlineIndex",[]),h(m(r),"_mlinesCache",{}),r._sdpQueue=new tK,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(rK.print("dequeue start"),r.dequeue())})),r}return l(T,[{key:"connect",value:(S=c(o().mark((function e(t){var r,n,a,s,c,u,d,l=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rK.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,XG(t);case 4:return this._answerIce=e.sent,this.connection_id=this._answerIce.iceUfrag||"",this.ms_addr=JSON.stringify((null==t||null===(a=t.publicIPs)||void 0===a?void 0:a.map((function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[]),e.next=9,this._peerConnection.createOffer();case 9:return s=e.sent,c=eG.parse(s.sdp),u=b(c.media,1),d=u[0],this._offerIce.fingerprint=c.fingerprint||d.fingerprint,delete c.media,this._offerSession=i({},c),this._answerSession=i({},c),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[i(i(i({},d),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[i(i(i({},d),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription(),e.next=23,new Promise((function(e,t){l._dataChannel.onopen=function(){rK.print("connect","dataChannel open"),QB("es.dc.open","",0,!1,l.connection_id,{ms_addr:l.ms_addr}),e("")},l._dataChannel.onerror=function(e){FB.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,lB.INVALID_DATA),QB("es.dc.error","",0,!1,l.connection_id,{ms_addr:l.ms_addr}),t(e)},l._dataChannel.onclose=function(e){QB("es.dc.close","",0,!1,l.connection_id,{ms_addr:l.ms_addr}),t(e)},l._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==l._peerConnection.iceConnectionState&&"closed"!==l._peerConnection.iceConnectionState&&"failed"!==l._peerConnection.connectionState||t(e)}))}));case 23:return rK.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 25:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){E(p(T.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(y=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h,f,v,_,m,y,g,S,k,I,A,R,C,w,O,x,N,P,D,M,L,U;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=t.stream,u=t.enableSimulcast,d=E(p(T.prototype),"internalPublish",this).call(this,t),l=d.videoDescriptions,h=d.subVideoDescriptions,f=d.audioTransceiverInit,v=d.videoTransceiverInit,_=jG(this._nextSsrc),this._nextSsrc=_.next,m="".concat(this._mid++),y="".concat(this._mid++),g=i(i(i({},this._aSendonlyOfferTpl),this._offerIce),{},{mid:m,msid:"".concat(c.id," ").concat(c.id,"-audio"),ssrcs:GG(c.id,"audio",_.audio,FG)}),S=i(i(i({},this._vSendonlyOfferTpl),this._offerIce),{},{mid:y,msid:"".concat(c.id," ").concat(c.id,"-video")}),u?(rK.print("subVideoDesc","desc: %o ",h),delete S.ssrcGroups,delete S.ssrcs,k=[],S.rids=l.map((function(e){var t=e.rid;return k.unshift(t),{id:t,direction:"send"}})),S.simulcast={dir1:"send",list1:k.join(";")}):(I=HG(c.id,_,{cname:FG}),A=I.ssrcs,R=I.ssrcGroups,S.ssrcs=A,S.ssrcGroups=R),null!==(r=this._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.audioRed&&Array.isArray(g.rtp)&&(-1!==(C=g.rtp.findIndex((function(e){return"red"===e.codec})))&&(w=g.rtp.splice(C,1),O=b(w,1),x=O[0],g.rtp.unshift(x)),N=[],g.rtp.forEach((function(e){return N.push(e.payload)})),g.payloads=N.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&QG(S,null===(P=this._context)||void 0===P||null===(D=P.serverConfig)||void 0===D?void 0:D.videoCodec),(SD||TD)&&Array.isArray(S.ext)&&(S.ext=S.ext.filter((function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&t.includes("video-orientation"))}))),(M=null==g?void 0:g.rtp.find((function(e){return"opus"===e.codec})))&&g.fmtp&&(U=g.fmtp.find((function(e){return e.payload===M.payload})))&&null!==(L=this._context)&&void 0!==L&&L.audioProfileManager&&(U.config+=this._context.audioProfileManager.getOpusConfigStr()),u||SD||this.addBitrateLimit(S,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[g,S],e.abrupt("return",{partialSdp:KG(this._offerSession,g,S),audioMid:m,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:l,subVideoDescriptions:h,audioTransceiverInit:f,videoTransceiverInit:v});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"subscribe",value:(_=c(o().mark((function e(t,r){var n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A,R,C,w=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rK.print("subscribe"),s="incroffer",c="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return u=e.sent,e.next=9,this.createAVMlineOfferTpl(u);case 9:if(d="",l="",h=!1,f=!1,p=void 0,v=void 0,this._mlinesCache[t.streamId]=[p,v],t.virtual?(d="".concat(this._mid++),h=!0):r.multiChatMode?(d="".concat(this._mid++),l="".concat(this._mid++),f=!0):(h=!0,f=!0,d="".concat(this._mid++),l="".concat(this._mid++)),d&&(p=i(i({},this._aRecvonlyOfferTpl),{},{mid:d})),h&&(this._mlinesCache[t.streamId][0]=p,_={track:"audio",init:{direction:"recvonly"}}),l&&(v=i(i({},this._vRecvonlyOfferTpl),{},{mid:l})),f&&(this._mlinesCache[t.streamId][1]=v,m={track:"video",init:{direction:"recvonly"}}),y=KG(this._offerSession,p,v),g=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=32;break}return g=jG(this._nextSsrc),this._nextSsrc=g.next,k=i(i(i({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:d,msid:"".concat(t.streamId).concat(null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ").concat(t.streamId,"-audio"),ssrcs:GG(t.streamId,"audio",g.audio)}),T=i(i(i({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:l,msid:"".concat(t.streamId).concat(null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-video"," ").concat(t.streamId,"-video")},HG(t.streamId,g,{flexfec:this._enableSubFlexfec})),I=new Promise((function(e){w._sdpQueue.enqueue({action:Zz.subscribe,streamId:t.streamId,audioMid:d,videoMid:l,audioTransceiverInit:_,videoTransceiverInit:m,signalingAck:{sdp:eG.write(i(i({},w._answerSession),{},{media:[k,T]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:y,onSuccess:function(){rK.print("subscribe()","sub success"),e(0)}})})),e.next=31,I;case 31:null===(b=g)||void 0===b||delete b.next;case 32:return(A=null===(n=p)||void 0===n?void 0:n.rtp.find((function(e){return"opus"===e.codec})))&&null!==(a=p)&&void 0!==a&&a.fmtp&&(C=null===(R=p)||void 0===R?void 0:R.fmtp.find((function(e){return e.payload===A.payload})))&&this._context&&(C.config+=";stereo=1;sprop-stereo=1"),e.abrupt("return",{partialSdp:y,audioMid:d,videoMid:l,type:s,semantics:c,audioTransceiverInit:_,videoTransceiverInit:m,allSsrc:g});case 35:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"handleAck",value:(v=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rK.print("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return rK.print("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"dequeue",value:(d=c(o().mark((function e(){var r,n,a,s,c,u,d,l,h,f,p,v,_=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,r=this._sdpQueue.dequeue(),rK.print("dequeue()","ret: %o",r),r){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,n=r.items,a=r.sdpStrategy,s=[],c=[],u=[],a!==Qz.ADD){e.next=15;break}return e.delegateYield(o().mark((function e(){var r,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(r=i({},_._answerIce)).candidates,d=!1,l=!1,e.prev=4,f=t(n);case 6:return e.next=8,f.next();case 8:if(!(d=!(p=e.sent).done)){e.next=16;break}if(a=p.value,"break"!==function(){var e=a.audioMid,t=a.videoMid,n=a.action,o=a.audioTransceiverInit,d=a.videoTransceiverInit,l=a.signalingAck,h=a.stream,f=h instanceof Yz;if(a.onSuccess&&u.push(a.onSuccess),f&&(null==l?void 0:l.sequenceId)<h.sequenceId)return"break";var p={},v={},m=eG.parse(l.sdp);Array.isArray(m.media)&&m.media.sort((function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(n){"audio"===(n=i(i({},n),r)).type?(p=n).mid=e:(v=n).mid=t}));var y,g=h.streamId;if(n===Zz.publish&&(g=null===(y=h.stream)||void 0===y?void 0:y.id),!_._mlinesCache[g])return"break";var S=b(_._mlinesCache[g],2),E=S[0],k=S[1];if(o&&E){h.audioTransceiver=_._peerConnection.addTransceiver(o.track,o.init),_.monitor.rtcInvokeStatus(JSON.stringify({audioStreamTrack:jD(o.track)}),0,"chromeHandler.addTrack","",0);var T=_._inactiveMlineIndex.shift();T||(T=_._offerMlines.length),_._offerMlines[T]=i({},E),_._answerMlines[T]=p,nK&&h.initAudioEncodedTransform()}if(d&&k){var I;n===Zz.publish&&CD&&(null==d||null===(I=d.init)||void 0===I||delete I.sendEncodings),h.videoTransceiver=_._peerConnection.addTransceiver(d.track,d.init),_.monitor.rtcInvokeStatus(JSON.stringify({videoStreamTrack:jD(d.track)}),0,"chromeHandler.addTrack","",0);var A=_._inactiveMlineIndex.shift();A||(A=_._offerMlines.length),_._offerMlines[A]=i({},k),_._answerMlines[A]=v,nK&&h.initVideoEncodedTransform()}s.push(h.streamId||""),c.push(f?h.userId:"local"),f&&(h.sequenceId=null==l?void 0:l.sequenceId),delete _._mlinesCache[g]}()){e.next=13;break}return e.abrupt("break",16);case 13:d=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),l=!0,h=e.t0;case 22:if(e.prev=22,e.prev=23,!d||null==f.return){e.next=27;break}return e.next=27,f.return();case 27:if(e.prev=27,!l){e.next=30;break}throw h;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:v={},n.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;v[t]=t,n!==Zz.removetrack&&(v[r]=r),v[t]=t})),this._offerMlines=this._offerMlines.map((function(e,t){return v[e.mid]&&(e=zG(e),_._inactiveMlineIndex.push(t)),e})),this._inactiveMlineIndex.sort((function(e,t){return e-t})),this._answerMlines=this._answerMlines.map((function(e){return v[e.mid]&&(e=zG(e)),e}));case 20:return e.next=22,this.setDescription(s.length?{streamId:s.join(","),streamUserId:c.join(",")}:void 0);case 22:try{u.forEach((function(e){return e()}))}catch(TQ){}rK.print("dequeue","loop"),e.next=29;break;case 26:e.prev=26,e.t1=e.catch(6),rK.print("dequeue","unknown error: %o",e.t1);case 29:return e.prev=29,this.dequeue(),e.finish(29);case 32:case"end":return e.stop()}}),e,this,[[6,26,29,32]])}))),function(){return d.apply(this,arguments)})},{key:"setDescription",value:(s=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rK.print("setDescription"),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=fD(),t&&FB.rtcBeginCreateOffer("local"===t.streamUserId?fB.UP:fB.DOWN,t.streamId,t.streamUserId),e.next=10,this._peerConnection.createOffer();case 10:return t&&FB.rtcCreateOffer(0,"local"===t.streamUserId?pB.UP:pB.DOWN,t.streamId,t.streamUserId,fD()-n),e.next=13,this.setLocalDescription(eG.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(eG.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getDefaultSdp",value:(a=c(o().mark((function e(){var t,r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return t=e.sent,this.createAVMlineOfferTpl(t),r=eG.parse(t),n=[],r.media=r.media.filter((function(e){return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=e.ext.filter((function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),n.push(e.mid+""),!0)})),r.groups=[{mids:n.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:eG.write(r),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(n=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;eG.parse(e).media.forEach((function(e){"audio"===e.type?"sendonly"===e.direction?t._aSendonlyOfferTpl=e:(Array.isArray(e.ext)&&(e.ext=e.ext.filter((function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),t._aRecvonlyOfferTpl=e):"video"===e.type&&("sendonly"===e.direction?t._vSendonlyOfferTpl=e:(Array.isArray(e.ext)&&(e.ext=e.ext.filter((function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),t._vRecvonlyOfferTpl=e))}))}},{key:"_genOfferSdp",value:(r=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,DD(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new hP(dP.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return r.apply(this,arguments)})}]),T}(tH),oK=new YL("FirefoxHandler",3),aK=function(e){f(k,e);var t,r,n,a,s,d,v,_,y,S=g(k);function k(){var e;u(this,k);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return h(m(e=S.call.apply(S,[this].concat(r))),"name","firefox"),h(m(e),"_aRecvonlyOfferTpl",void 0),e}return l(k,[{key:"connect",value:(y=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oK.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,XG(t);case 4:return this._answerIce=e.sent,this.connection_id=this._answerIce.iceUfrag||"",this.ms_addr=JSON.stringify((null==t||null===(a=t.publicIPs)||void 0===a?void 0:a.map((function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[]),this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=11,this._peerConnection.createOffer();case 11:return s=e.sent,c=eG.parse(s.sdp),u=b(c.media,1),d=u[0],this._offerIce.fingerprint=c.fingerprint||d.fingerprint,c.media=c.media.map((function(e){return i(i({},e),h._offerIce)})),c.media.map((function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return-1===e.uri.indexOf("abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:r.filter((function(e){return"goog-remb"!==e.type})))})),(l=i({},c)).fingerprint=this._answerIce.fingerprint,l.media=l.media.map((function(e){return delete(e=i(i({},e),h._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),e.next=22,this.setLocalDescription(eG.write(c));case 22:return e.next=24,this.setRemoteDescription(eG.write(l));case 24:return e.next=26,new Promise((function(e,t){h._dataChannel.onopen=function(){oK.print("connect","dataChannel open"),QB("es.dc.open","",0,!1,h.connection_id,{ms_addr:h.ms_addr}),e("")},h._dataChannel.onerror=function(e){FB.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,lB.INVALID_DATA),QB("es.dc.error","",0,!1,h.connection_id,{ms_addr:h.ms_addr}),t(e)},h._dataChannel.onclose=function(e){QB("es.dc.close","",0,!1,h.connection_id,{ms_addr:h.ms_addr}),t(e)},h._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==h._peerConnection.iceConnectionState&&"closed"!==h._peerConnection.iceConnectionState&&"failed"!==h._peerConnection.connectionState||t(e)}))}));case 26:return oK.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 28:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"publish",value:(_=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h,f,v,_,m,y,g=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=E(p(k.prototype),"internalPublish",this).call(this,t),s=a.videoDescriptions,c=a.subVideoDescriptions,u=a.audioTransceiverInit,d=a.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(u.track,u.init),t.videoTransceiver=this._peerConnection.addTransceiver(d.track,d.init),l=fD(),FB.rtcBeginCreateOffer(fB.UP,"",""),e.next=7,this._peerConnection.createOffer();case 7:return h=e.sent,FB.rtcCreateOffer(0,pB.UP,"","",fD()-l),(f=eG.parse(h.sdp)).media=null===(r=f.media)||void 0===r?void 0:r.map((function(e){return i(i({},e),g._offerIce)})),e.next=13,this.setLocalDescription(eG.write(f));case 13:return v=t.audioTransceiver.mid,_=t.videoTransceiver.mid,m=null,y=null,f.media=null===(n=f.media)||void 0===n?void 0:n.map((function(e){if("".concat(e.mid)===v){var t,r=null===(t=m=e)||void 0===t?void 0:t.rtp.find((function(e){return"opus"===e.codec}));if(r&&m.fmtp){var n,i=m.fmtp.find((function(e){return e.payload===r.payload}));i&&null!==(n=g._context)&&void 0!==n&&n.audioProfileManager&&(i.config+=g._context.audioProfileManager.getOpusConfigStr())}}else if("".concat(e.mid)===_){var o,a,s,c;null!==(o=g._context)&&void 0!==o&&null!==(a=o.serverConfig)&&void 0!==a&&a.videoCodec&&QG(e,null===(s=g._context)||void 0===s||null===(c=s.serverConfig)||void 0===c?void 0:c.videoCodec),y=e}return e})),this.addBitrateLimit(y,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(eG.write(f));case 21:return e.abrupt("return",{partialSdp:KG(f,m,y,!1),audioMid:v,videoMid:_,type:"incroffer",semantics:"unified-plan",videoDescriptions:s,subVideoDescriptions:c,audioTransceiverInit:u,videoTransceiverInit:d});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"subscribe",value:(v=c(o().mark((function e(t,r){var n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oK.print("subscribe()"),u="",d="",l=!1,h=!1,f=void 0,p=void 0,t.virtual?l=!0:(r.multiChatMode||(l=!0),h=!0),l&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),h&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=fD(),FB.rtcBeginCreateOffer(fB.UP,t.streamId,t.userId),e.next=14,this._peerConnection.createOffer();case 14:return _=e.sent,FB.rtcCreateOffer(0,pB.UP,t.streamId,t.userId,fD()-v),(m=eG.parse(_.sdp)).media=null===(n=m.media)||void 0===n?void 0:n.map((function(e){return i(i({},e),T._offerIce)})),m.media.map((function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return-1===e.uri.indexOf("abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:r.filter((function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(eG.write(m),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(u=null===(a=t.audioTransceiver)||void 0===a?void 0:a.mid,d=null===(s=t.videoTransceiver)||void 0===s?void 0:s.mid,null===(c=m.media)||void 0===c||c.forEach((function(e){"".concat(e.mid)===u?f=e:"".concat(e.mid)===d&&(p=e)})),u&&f||(u="audio_".concat(d),f=i(i({},this._aRecvonlyOfferTpl),{},{mid:u})),t.audioMid=u,t.videoMid=d,y=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return y=jG(this._nextSsrc),this._nextSsrc=y.next,b=i(i(i({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:u,msid:"".concat(t.streamId).concat(null!==(g=this._context)&&void 0!==g&&g.avSync?"":"-audio"," ").concat(t.streamId,"-audio"),ssrcs:GG(t.streamId,"audio",y.audio)}),k=i(i(i({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:d,msid:"".concat(t.streamId).concat(null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-video"," ").concat(t.streamId,"-video")},HG(t.streamId,y,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([b,k],t);case 35:null===(E=y)||void 0===E||delete E.next;case 36:return e.abrupt("return",{partialSdp:KG(m,f,p,!1),audioMid:u,videoMid:d,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:y});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"handleAck",value:(d=c(o().mark((function e(t){var r,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==Zz.unpublish&&i!==Zz.unsubscribe&&i!==Zz.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return oK.print("already set remote"),e.abrupt("return","");case 8:return a=eG.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(a.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(s=c(o().mark((function e(t,r){var n,a,s,c,u,d,l=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=eG.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=i(i({},e),l._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=eG.parse(null===(a=this._peerConnection.localDescription)||void 0===a?void 0:a.sdp),d=u.media.map((function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,c.media.map((function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return-1===e.uri.indexOf("abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:r.filter((function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(eG.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"getDefaultSdp",value:(a=c(o().mark((function e(){var t,r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=eG.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),i=[],n.media=n.media.filter((function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,i.push(e.mid+""),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:eG.write(n),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(n=c(o().mark((function e(t,r,n){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oK.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=c(o().mark((function e(t,r){var n,a,s,c,u,d,l,h=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oK.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=eG.parse(null==c?void 0:c.sdp)).media=u.media.map((function(e){return a[e.mid]&&(e=zG(e)),"inactive"!==e.direction&&s.push(e.mid),i(i({},e),h._offerIce)})),d=eG.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=u.media.map((function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(eG.write(u));case 17:return e.next=19,this.setRemoteDescription(eG.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;eG.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),k}(tH),sK=function(e,t){return gD?new aK(e,t):new iK(e,t)},cK=new YL("Locker",2),uK=1,dK=function(){function e(t){u(this,e),h(this,"lockingPromise",Promise.resolve()),h(this,"locks",0),h(this,"name",""),h(this,"lockId",void 0),this.lockId=uK++,t&&(this.name=t),cK.print("[lock-".concat(this.name,"-").concat(this.lockId,"] is created."))}return l(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1,cK.print("[lock-".concat(this.name,"-").concat(this.lockId,"] locked, current queue ").concat(this.locks,"."));var r=new Promise((function(r){e=function(){t.locks-=1,cK.print("[lock-".concat(t.name,"-").concat(t.lockId,"] unlocked, current queue ").concat(t.locks,".")),r()}})),n=this.lockingPromise.then((function(){return e}));return this.lockingPromise=this.lockingPromise.then((function(){return r})),n}}]),e}(),lK=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e}(lK||{}),hK=function(e){return e[e.START=1]="START",e[e.START_SUCCESS=2]="START_SUCCESS",e[e.START_FAILED=3]="START_FAILED",e[e.UPDATE=4]="UPDATE",e[e.UPDATE_SUCCESS=5]="UPDATE_SUCCESS",e[e.UPDATE_FAILED=6]="UPDATE_FAILED",e[e.STOP=7]="STOP",e[e.STOP_SUCCESS=8]="STOP_SUCCESS",e[e.STOP_FAILED=9]="STOP_FAILED",e}(hK||{}),fK=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(fK||{}),pK=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(pK||{}),vK=(h(Kz={},Y.communication,[0]),h(Kz,Y.chat,[0]),h(Kz,Y.chatRoom,[1,"IES_chatroom"]),h(Kz,Y.coHost,[1,"IES_PK"]),h(Kz,Y.meeting,[16]),h(Kz,Y.classRoom,[0]),Kz),_K=Object.defineProperty,mK=Object.getOwnPropertyDescriptor,yK=function(e,t,r,n){for(var i,o=n>1?void 0:n?mK(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&_K(t,r,o),o},gK=new YL("MediaServerClient",2),SK=6e4,EK=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(EK||{}),bK=function(e,t){gK.print(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},kK=function(e){f(N,e);var t,r,n,a,s,d,p,v,_,y,S,E,k,T,I,A,R,C,w,O,x=g(N);function N(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:FB;return u(this,N),h(m(t=x.call(this)),"_token",void 0),h(m(t),"_appId",void 0),h(m(t),"_roomId",void 0),h(m(t),"_roomAttributes",void 0),h(m(t),"_clientId",void 0),h(m(t),"_businessId",void 0),h(m(t),"_userInfo",void 0),h(m(t),"_useCloudProxy",void 0),h(m(t),"_expectedIDC",void 0),h(m(t),"_authorization",void 0),h(m(t),"_sessionId",void 0),h(m(t),"_iceConfigRequestManager",void 0),h(m(t),"_ontrackCallbackMap",new Map),h(m(t),"_subResolves",{}),h(m(t),"supportConcurrent",!1),h(m(t),"_handler",void 0),h(m(t),"_pubSubLock",void 0),h(m(t),"_joinLeaveLock",void 0),h(m(t),"_state",void 0),h(m(t),"_dataChannelSignal",void 0),h(m(t),"_subConfig",{}),h(m(t),"monitor",void 0),h(m(t),"_roomProfile",Y.communication),h(m(t),"_context",void 0),h(m(t),"_subStreamQueue",{}),t.monitor=r,t._pubSubLock=new dK("pubSubLock"),t._joinLeaveLock=new dK("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t}return l(N,[{key:"_addHandlerEvents",value:function(){var e,t=this;null===(e=this._handler)||void 0===e||e.once("disconnect",(function(){gK.print("emit ABNORMAL_DISCONNECTION ice"),t.safeEmit(Ej.ABNORMAL_DISCONNECTION)}))}},{key:"_addSignalEventHandler",value:function(){var e,t=this;[gj.ON_ADD_STREAM,gj.ON_ADD_STREAM_LIST,gj.ON_REMOVE_STREAM,gj.ON_REMOVE_STREAM_LIST,gj.USER_CONNECTION,gj.USER_CONNECTION_LIST,gj.USER_DISCONNECTION,gj.USER_DISCONNECTION_LIST,gj.ON_UPDATE_STREAM_ATTRIBUTES,gj.ON_UPDATE_ROOM_ATTRIBUTES,gj.ON_PUSH_TRACK,gj.NODE_CHANGE,gj.ON_CUSTOM_MESSAGE,gj.USER_MESSAGE_RECEIVED,gj.USER_BINARY_MESSAGE_RECEIVED,gj.POST_PROCESSING_MESSAGE,gj.ON_USER_TOKEN_WILL_EXPIRE,gj.STREAM_CONTROL_MESSAGE,gj.ON_SCENE_CONFIG,gj.ON_UPDATE_USER_ATTRIBUTES,gj.ON_SPEAKER_CHANGE,Sj.RSCP,Sj.RTT,gj.ON_STREAM_FAILED].forEach((function(e){var r;null===(r=t._dataChannelSignal)||void 0===r||r.on(e,(function(r){t.safeEmit(e,r)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.once("close",(function(){gK.print("emit ABNORMAL_DISCONNECTION datachannel"),t.safeEmit(Ej.ABNORMAL_DISCONNECTION)}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(Ej.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"connect",value:(O=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l=this,h=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=h.length>1&&void 0!==h[1]?h[1]:"",n=h.length>2&&void 0!==h[2]?h[2]:"",i=h.length>3&&void 0!==h[3]?h[3]:{},this.connectionState="connecting",this._appId=t,this._handler&&(this._removeSignalEventHandler(),this._handler.destroy()),!i.node){e.next=11;break}a=[i.node],QB("es.join.nodeChange",i),e.next=20;break;case 11:return Promise.resolve().then((function(){return l.emit("onGetIceConfigHook")})),this._iceConfigRequestManager=new Lj,e.next=15,null===(s=this._iceConfigRequestManager)||void 0===s?void 0:s.getAccessNode(t,r,n,oj.getDeviceId(),null==i?void 0:i.reason,null==i?void 0:i.feedbackNode,this._useCloudProxy,this._expectedIDC);case 15:if(a=e.sent){e.next=19;break}throw QB("es.join.getNodeFailed",""),new hP(dP.ICE_SERVER_WRONG,"get ICE config failed");case 19:QB("es.join.getNodeSuccess",a);case 20:return Promise.resolve().then((function(){return l.emit("onEstablishConnectionHook")})),e.prev=21,u=!1,d=a.map((function(e){var t=sK(l.monitor,l._context);return t.connect(e).then((function(r){var n;l.emit("onConnectSuccessHook",null===(n=a)||void 0===n?void 0:n.length),u?t.destroy():(u=!0,c=r,l.safeEmit("prevIceNode",e),l._handler=t,GB.setStats({connection_id:t.connection_id}),l.supportConcurrent="chrome"===t.name,l._addHandlerEvents())})).catch((function(e){throw t.destroy(),e}))})),e.next=26,MD(d);case 26:gK.print("join","establish peerConnection success"),e.next=33;break;case 29:throw e.prev=29,e.t0=e.catch(21),this.connectionState="disconnected",new hP(dP.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t0);case 33:if(!c){e.next=39;break}this._dataChannelSignal=new Pj(c),this._addSignalEventHandler(),this._dataChannelSignal.sendPingSignaling(),e.next=41;break;case 39:throw this.connectionState="disconnected",new hP(dP.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed");case 41:case"end":return e.stop()}}),e,this,[[21,29]])}))),function(e){return O.apply(this,arguments)})},{key:"join",value:(w=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I=this,A=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=A.length>1&&void 0!==A[1]?A[1]:{},i=A.length>2&&void 0!==A[2]&&A[2],a=A.length>3?A[3]:void 0,gK.print("join()","info: %o, params: %o, reconnect: %o, controlMessage: %o",t,n,i,a),this._appId=t.appId,this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._useCloudProxy=t.useCloudProxy,this._expectedIDC=t.expectedIDC,this._roomProfile=t.roomProfile,this._sessionId=n.sessionId,e.next=16,this.connect(this._appId,this._roomId,this._clientId,n);case 16:return e.t0=_D.token2auth(this._appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId||"",e.t2=Date.now(),e.t3=a,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=23,null===(r=this._handler)||void 0===r?void 0:r.getDefaultSdp();case 23:return e.t5=e.sent,e.next=26,Qj();case 26:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=dj.VERSION,e.t9=oj.getDeviceId(),e.t10=this._appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._useCloudProxy,e.t15=vK[this._roomProfile]?vK[this._roomProfile][0]+"":"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0},s={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17},Promise.resolve().then((function(){return I.emit("onSendingJoinMessageHook")})),e.prev=40,_=i?"reconnected":"joinRoom",e.next=44,this._dataChannelSignal.sendSignaling(_,s);case 44:return m=e.sent,gK.print("join","send join message success"),this._authorization=s.Authorization,this.connectionState="connected",this._context&&(k=null===(y=m.config)||void 0===y?void 0:y.engine_WEB,this._context.serverConfig={videoCodec:(null==k?void 0:k.video_codec)||"H264",audioRed:!(null==k||!k.pub_audio_red),muteReplaceUnsub:!(null===(g=m.config)||void 0===g||!g.mute_replace_unsub),simulcastOnDemand:!(gD||!1===(null===(S=m.config)||void 0===S||null===(E=S.engine_VPM)||void 0===E||null===(b=E.ondemand)||void 0===b?void 0:b.enable))},"boolean"==typeof(null==k?void 0:k.av_sync)&&(this._context.avSync=k.av_sync)),Gz.audioStallConfig=null===(c=m.config)||void 0===c?void 0:c.engine_WEB,null===(u=this._context)||void 0===u||null===(d=u.audioProfileManager)||void 0===d||d.updateEngineBAC(null===(l=m.config)||void 0===l?void 0:l.engine_BAC),null===(h=this._context)||void 0===h||null===(f=h.audioProfileManager)||void 0===f||f.updateEngineANM(null===(p=m.config)||void 0===p?void 0:p.engine_ANM),null!=m&&null!==(v=m.relayMessage)&&void 0!==v&&v.sdp&&(null===(T=this._handler)||void 0===T||T.createAVMlineAnswerTpl(m.relayMessage.sdp)),e.abrupt("return",m);case 56:if(e.prev=56,e.t18=e.catch(40),this.connectionState="disconnected",!((null===e.t18||void 0===e.t18?void 0:e.t18.code)>=700&&(null===e.t18||void 0===e.t18?void 0:e.t18.code)<800)){e.next=61;break}throw new hP(dP.INVALID_TOKEN,(null===e.t18||void 0===e.t18?void 0:e.t18.message)||"Invalid token");case 61:if(200===(null===e.t18||void 0===e.t18?void 0:e.t18.code)){e.next=63;break}throw new hP(dP.JOIN_ROOM_FAILED,(null===e.t18||void 0===e.t18?void 0:e.t18.message)||"Join room failed");case 63:case"end":return e.stop()}}),e,this,[[40,56]])}))),function(e){return w.apply(this,arguments)})},{key:"publish",value:(C=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gK.print("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,a=fD(),s="",c="",e.prev=6,e.next=9,null===(u=this._handler)||void 0===u?void 0:u.publish(t);case 9:if(_=e.sent){e.next=12;break}throw new hP(dP.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 12:return s=_.audioMid,c=_.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof iz),extaudio:!!(n instanceof oz)},m={attributes:i({videoDescriptions:_.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:s,videoMid:c,sdpInfo:{msid:t.stream.id,type:_.type,sdp:_.partialSdp,semantics:_.semantics}},t.enableSimulcast&&null!==(d=this._context)&&void 0!==d&&null!==(l=d.serverConfig)&&void 0!==l&&l.simulcastOnDemand&&null!==(h=_.subVideoDescriptions)&&void 0!==h&&h.length&&(m.attributes.subVideoDescriptions=_.subVideoDescriptions),e.next=19,null===(f=this._dataChannelSignal)||void 0===f?void 0:f.sendSignaling("publish",m);case 19:if(200===(null==(y=e.sent)?void 0:y.code)){e.next=22;break}throw new hP(dP.PUBLISH_FAILED,(null==y?void 0:y.message)||"publish failed");case 22:if(FB.rtcRecvAnswer(0,mB.INCRANSWER,(null==y||null===(p=y.relayMessage)||void 0===p?void 0:p.sequenceId)||0,null==y||null===(v=y.relayMessage)||void 0===v?void 0:v.sdp,yB.UP,"",""),g=new Promise((function(e,r){var n,i,o;null===(n=E._handler)||void 0===n||n.handleAck({action:Zz.publish,streamId:y.streamId,audioMid:s,videoMid:c,audioTransceiverInit:null==_?void 0:_.audioTransceiverInit,videoTransceiverInit:null==_?void 0:_.videoTransceiverInit,signalingAck:{sdp:null==y||null===(i=y.relayMessage)||void 0===i?void 0:i.sdp,sequenceId:null==y||null===(o=y.relayMessage)||void 0===o?void 0:o.sequenceId},sdp:_.sdp,stream:t,onSuccess:function(){gK.print("publish()","publish success"),e(0)}})})),e.t0=!gD,!e.t0){e.next=28;break}return e.next=28,g;case 28:return t.streamId=y.streamId,t.videoMid=c,t.audioMid=s,t.subVideoDescriptions=_.subVideoDescriptions,this.monitor.rtcPublishStat(gB.SUCCESS,SB.W_0,a,EB.UNKNOWN),t.statsReport.setLocalStreamStatsEvtInterval(this,this._handler,this.monitor),e.abrupt("return");case 37:return e.prev=37,e.t1=e.catch(6),e.t1 instanceof Error&&this.monitor.rtcPublishStat(gB.FAIL,SB.W_0,a,e.t1.message),e.next=42,null===(S=this._handler)||void 0===S?void 0:S.rollback(t.stream.id,t);case 42:throw e.t1;case 43:case"end":return e.stop()}}),e,this,[[6,37]])}))),function(e){return C.apply(this,arguments)})},{key:"updatePubTrack",value:(R=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,k,T,I,A,R,C,w,O,x,N,P,D,M;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:gK.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,a=t.audioTrack,s=t.pubAudio,c=t.pubVideo,u=null==a?void 0:a.getTrack("preprocessing"),d=null==i?void 0:i.getTrack("preprocessing"),c&&d?null===(l=t.videoTransceiver)||void 0===l||l.sender.replaceTrack(d):null===(h=t.videoTransceiver)||void 0===h||h.sender.replaceTrack(null),CD||null===(f=this._handler)||void 0===f||f.updateScaleResolutionDownBy(t),null===(r=this._handler)||void 0===r||r.updateMaxBitrate(t),s&&u?(v=a.mixType,(_=a.mixedAudioTrack)&&v!==re.PLAYOUT&&!0===u.enabled&&(u=_),null===(p=t.audioTransceiver)||void 0===p||p.sender.replaceTrack(u)):(null===(m=t.audioTransceiver)||void 0===m||m.sender.replaceTrack(null),this.monitor.rtcInvokeStatus("null",0,"MediaClient.updatePubTrack(audio)","",0));try{this.monitor.rtcInvokeStatus(JSON.stringify({audioStreamTrack:jD(u),videoStreamTrack:jD(d)}),0,"MediaClient.updatePubTrack","",0)}catch(TQ){}for(y={localaudio:!!a,localvideo:!!i,videostream:c,audiostream:s,extvideo:!!(i instanceof iz),extaudio:!!(a instanceof oz)},g={},S=0,E=Object.entries(y);S<E.length;S++)k=b(E[S],2),T=k[0],(I=k[1])!==Reflect.get(t.pubAttributes,T)&&Reflect.set(g,T,I);if(Object.keys(g).length){e.next=14;break}return e.abrupt("return");case 14:return t.observer&&(A=t.observer,R=g.audiostream,C=g.videostream,w=g.localaudio,O=g.localvideo,x=g.extaudio,N=g.extvideo,void 0!==O?void 0!==N?A.setPushVideo(N):A.setEnableVideo(O):void 0!==C&&A.setUnmuteVideo(C),void 0!==w?void 0!==x?A.setPushAudio(x):A.setEnableAudio(w):void 0!==R&&A.setUnmuteAudio(R)),t.pubAttributes=y,P={roomId:this._roomId,streamId:t.streamId,attributes:g},e.next=19,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateStreamAttributes",P);case 19:if(200===(null==(D=e.sent)?void 0:D.code)){e.next=22;break}throw new hP(dP.UPDATE_TRACK_FAILED,(null==D?void 0:D.message)||"update track failed");case 22:if(!gD){e.next=25;break}return e.next=25,null===(M=this._handler)||void 0===M?void 0:M.setCurrentDescription();case 25:case"end":return e.stop()}}),e,this)}))),function(e){return R.apply(this,arguments)})},{key:"updateToken",value:(A=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gK.print("updateToken()","newToken: %o",t),this._token=t,this._appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(a=this._dataChannelSignal)||void 0===a?void 0:a.sendSignaling("updateToken",i);case 8:if(200===(null==(s=e.sent)?void 0:s.code)){e.next=11;break}throw new hP(dP.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new hP(dP.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return A.apply(this,arguments)})},{key:"unpublish",value:(I=c(o().mark((function e(t){var r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gK.print("unpublish()","localStream: %o",t),i={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",i),e.next=5,null===(n=this._handler)||void 0===n?void 0:n.handleAck({action:Zz.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 5:t.statsReport.unpublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"subscribe",value:(T=c(o().mark((function e(t,r,n){var i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=c(o().mark((function e(a,s){var c,u,d,l,f,p,v,_,m,y,g,S,E,b,k,T,I,A,R,C,w,O,x,N,P,D,M,L,U,V;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==Wz.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,pK.SUB).then(a,s));case 2:if(t.streamState!==Wz.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),gK.print("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:a,reject:s}),e.abrupt("return");case 7:if(gK.print("subscribe()","mediaType: %o",r),bK("subscribe()",t),t.streamState=Wz.SUB_ING,u=!1,d=!1,UD(r)&&(d=!0),VD(r)&&(u=!0),u||!i.multiChatMode()){e.next=17;break}return t.streamState=Wz.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",a(null));case 17:return l=fD(),f=t.subVideo,p=[],v=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),p.push(new Promise((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new hP(dP.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),SK);t.on("ontrack",(function r(i){"video"===i.mediaType&&(gK.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v&&p.push(new Promise((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new hP(dP.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),SK);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(gK.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_=function(e){t.ontrack(e)},null===(c=i._handler)||void 0===c||c.on("ontrack",_),i._ontrackCallbackMap.set(t,_),e.prev=27,e.next=30,null===(m=i._handler)||void 0===m?void 0:m.subscribe(t,{multiChatMode:i.multiChatMode()});case 30:if(I=e.sent){e.next=33;break}throw new hP(dP.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 33:return A=I.audioMid,R=I.videoMid,t.subVideo=u,C={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},w={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:R,audioMid:A,sdpInfo:{sdp:null==I?void 0:I.partialSdp,semantics:null==I?void 0:I.semantics,type:null==I?void 0:I.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||d,video:u},qualityLayer:C},extra:{enableSendRTT:!0}},O=i._context||{},x=O.subscribeFallbackOption,N=O.userPriority,"number"==typeof x&&(w.config.fallbackOption=x),null!=N&&N.has(t.userId)&&(w.config.priority=N.get(t.userId)),null!=I&&I.allSsrc&&(w.extra.subscribeSSRC=I.allSsrc),e.next=44,null===(y=i._dataChannelSignal)||void 0===y?void 0:y.sendSignaling("subscribe",w);case 44:if(200===(null==(P=e.sent)?void 0:P.code)){e.next=47;break}throw new hP(dP.SUBSCRIBE_FAILED,(null==P?void 0:P.message)||"subscribe failed");case 47:return D=null==P?void 0:P.relayMessage,M=D.audioMid,L=D.videoMid,h(g={},A,M),h(g,R,L),U=g,gK.print("sub midmap",t.userId,U),t.videoMid=R,t.audioMid=A,t.subMediaType=r,t.streamState=Wz.SUB_ED,t.subLayer=C,FB.rtcRecvAnswer(0,mB.INCRANSWER,(null==P||null===(S=P.relayMessage)||void 0===S?void 0:S.sequenceId)||0,null==P||null===(E=P.relayMessage)||void 0===E?void 0:E.sdp,yB.DOWN,t.streamId,t.userId),e.next=58,null===(b=i._handler)||void 0===b?void 0:b.handleAck({action:Zz.subscribe,streamId:t.streamId,audioMid:A,videoMid:R,audioTransceiverInit:null==I?void 0:I.audioTransceiverInit,videoTransceiverInit:null==I?void 0:I.videoTransceiverInit,signalingAck:{sdp:null==P||null===(k=P.relayMessage)||void 0===k?void 0:k.sdp,sequenceId:null==P||null===(T=P.relayMessage)||void 0===T?void 0:T.sequenceId},stream:t,sdp:I.sdp,generatorSsrc:!!I.allSsrc});case 58:return e.next=60,Promise.all(p);case 60:i.multiChatMode()||(t.subAudio=d),i.monitor.rtcSubscribeStat(bB.SUCCESS,l,kB.UNKNOWN,t.userId),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval(i,i._handler,i.monitor,i._context),a(null),i.emit("SUB_END",t.streamId),e.next=76;break;case 67:return e.prev=67,e.t0=e.catch(27),e.t0 instanceof Error&&i.monitor.rtcSubscribeStat(bB.FAIL,l,e.t0.message,t.userId),t.subVideo=f,t.streamState=Wz.INIT,e.next=74,null===(V=i._handler)||void 0===V?void 0:V.rollback(t.streamId,t);case 74:s(e.t0),i.emit("SUB_END",t.streamId);case 76:case"end":return e.stop()}}),e,null,[[27,67]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return T.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){gK.print("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else gK.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(k=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gK.print("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"updateUserAttributes",value:(E=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gK.print("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"updateSubTrack",value:(S=c(o().mark((function e(t,r,n){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return S.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(y=c(o().mark((function e(t,r){var n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gK.print("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return gK.print("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=10;break}throw new hP(dP.UPDATE_TRACK_FAILED,(null==a?void 0:a.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return y.apply(this,arguments)})},{key:"_updateSubTrack",value:(_=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gK.print("updateSubTrack()","mediaType: %o",r),bK("updateSubTrack()",t),!this.multiChatMode()||r!==U.AUDIO){e.next=5;break}return gK.print("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return s=0,s=n===pK.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),gK.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,s),t.subMediaType===s&&gK.print("updateSubTrack","mediaType no change"),c=!1,u=!1,UD(s)&&(u=!0),VD(s)&&(c=!0),d={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:c,audio:!!this.multiChatMode()||u}}},l=this._context||{},h=l.subscribeFallbackOption,f=l.userPriority,"number"==typeof h&&(d.config.fallbackOption=h),null!=f&&f.has(t.userId)&&(d.config.priority=f.get(t.userId)),e.next=18,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",d);case 18:if(200===(null==(p=e.sent)?void 0:p.code)){e.next=21;break}throw new hP(dP.UPDATE_TRACK_FAILED,(null==p?void 0:p.message)||"update track failed");case 21:return this.multiChatMode()||(null===(v=t.observer)||void 0===v||v.setUnmuteAudio(u),t.subAudio=u),null===(a=t.observer)||void 0===a||a.setUnmuteVideo(c),t.subVideo=c,t.subMediaType=s,e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(v=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gK.print("subscribe4pushTrack()","streamInfo: %o",r),bK("subscribe4pushTrack()",t),t.subAudio=!0,null===(n=t.observer)||void 0===n||n.setPushTrack(!0),e.next=6,null===(i=this._handler)||void 0===i?void 0:i.subscribe(t,{multiChatMode:this.multiChatMode()});case 6:if(c=e.sent){e.next=9;break}throw new hP(dP.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 9:return u=c.audioMid,d=c.videoMid,(l=[]).push(new Promise((function(e,r){var n=setTimeout((function(){return r(new hP(dP.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),SK);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(gK.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),h=function(e){t.ontrack(e)},null===(a=this._handler)||void 0===a||a.on("ontrack",h),this._ontrackCallbackMap.set(t,h),e.next=18,null===(s=this._handler)||void 0===s?void 0:s.handleAck({action:Zz.pushtrack,streamId:t.streamId,audioMid:u,videoMid:d,stream:t,audioTransceiverInit:null==c?void 0:c.audioTransceiverInit,videoTransceiverInit:null==c?void 0:c.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:c.sdp});case 18:return e.next=20,Promise.all(l);case 20:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval(this,this._handler,this.monitor,this._context);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(p=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:bK("unsubscribe4removeTrack()",t),gK.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return p.apply(this,arguments)})},{key:"unsubscribe",value:(d=c(o().mark((function e(t,r){var n,i,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=a.length>2&&void 0!==a[2]&&a[2],bK("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!VD(r)){e.next=6;break}return e.abrupt("return",this._unsubscribe(t,r));case 6:if(i=t.subMediaType-(t.subMediaType&r),this.multiChatMode()||i!==Oz.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,pK.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"_unsubscribe",value:(s=c(o().mark((function e(t,r){var n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.hasSubscribed){e.next=2;break}return e.abrupt("return");case 2:if(!this._subConfig.muteReplaceUnsub){e.next=4;break}return e.abrupt("return",this._updateSubTrack(t,r,pK.UNSUB));case 4:return c={roomId:this._roomId,streamId:t.streamId,userId:t.userId},null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",c).catch((function(){})),t.streamState=Wz.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(a=t.observer)||void 0===a||a.setSubscribeAudio(!1)),e.next=13,null===(s=this._handler)||void 0===s?void 0:s.handleAck({action:Zz.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 13:u=e.sent,this._subResolves[u]&&this._subResolves[u].forEach((function(e){return e(0)})),gK.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t,r=this._ontrackCallbackMap.get(e);r&&(null===(t=this._handler)||void 0===t||t.off("ontrack",r),this._ontrackCallbackMap.delete(e))}},{key:"handleRemoveStream",value:(a=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(bK("handleRemoveStream()",t),t.subVideo=!1,t.hasSubscribed){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,U.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"leave",value:(n=c(o().mark((function e(){var t,r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gK.print("leave()"),"connected"!==this.connectionState){e.next=22;break}return this.connectionState="disconnecting",t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=6,this._joinLeaveLock.lock();case 6:return r=e.sent,e.prev=7,e.next=10,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 10:this.connectionState="disconnected",e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),this.connectionState="connected",e.t0;case 17:return e.prev=17,r(),e.finish(17);case 20:e.next=23;break;case 22:return e.abrupt("return",Promise.reject(new hP(dP.NOT_CONNECTED_YET,"server not connected")));case 23:case"end":return e.stop()}}),e,this,[[7,13,17,20]])}))),function(){return n.apply(this,arguments)})},{key:"subscribePublicStream",value:(r=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new hP(dP.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=fD(),u=s.audioMid,d=s.videoMid,e.t0=this._appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,Qj();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=dj.VERSION,e.t8=oj.getDeviceId(),e.t9=this._appId,e.t10=this._businessId,e.t11=this._useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,f=[],this._subResolves[t.streamId]=[],f.push(new Promise((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new hP(dP.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),SK);t.on("ontrack",(function r(i){"video"===i.mediaType&&(gK.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),f.push(new Promise((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new hP(dP.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),SK);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(gK.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",p),this._ontrackCallbackMap.set(t,p),v=null==h?void 0:h.relayMessage,_=v.sequenceId,m=v.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=_,t.streamState=Wz.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:Zz.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:_},stream:t});case 44:return e.next=46,Promise.all(f);case 46:this.monitor.rtcSubscribeStat(bB.SUCCESS,c,kB.UNKNOWN,t.userId),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval(this,this._handler,this.monitor,this._context);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(t=c(o().mark((function e(t){var r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return bK("unsubscribePublicStream()",t),n={appId:this._appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=Wz.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:Zz.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;gK.print("destroy()"),this._token=void 0,this._appId=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId=void 0,this._context=void 0,null===(e=this._handler)||void 0===e||e.destroy(),null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),null===(r=this._iceConfigRequestManager)||void 0===r||r.abort(),this._handler=void 0,this._dataChannelSignal=void 0,this._iceConfigRequestManager=void 0,this._removeSignalEventHandler(),this.connectionState="disconnected",this.emit("INTERRUPT")}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}}]),N}(ZL);function TK(e,t,r){var n=r.value;return r.value=c(o().mark((function e(){var r,i,a,s=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=s.length,i=new Array(r),a=0;a<r;a++)i[a]=s[a];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new hP(dP.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function IK(e,t,r){var n=r.value;return r.value=c(o().mark((function e(){var t,r,i,a,s=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=s.length,i=new Array(r),a=0;a<r;a++)i[a]=s[a];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}yK([function(e,t,r){var n=r.value;return r.value=c(o().mark((function e(){var t,r,i,a,s=this,u=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=u.length,r=new Array(t),i=0;i<t;i++)r[i]=u[i];return a=!1,e.abrupt("return",new Promise(function(){var e=c(o().mark((function e(t,i){var c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s.on("INTERRUPT",(function(){a=!0,i(new hP(dP.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(s,r);case 4:c=e.sent,t(c),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),a||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],kK.prototype,"join",1),yK([IK,TK],kK.prototype,"publish",1),yK([IK,TK],kK.prototype,"updatePubTrack",1),yK([IK,TK],kK.prototype,"unpublish",1),yK([IK,TK],kK.prototype,"subscribe",1),yK([TK],kK.prototype,"controlMessage",1),yK([TK],kK.prototype,"updateUserAttributes",1),yK([TK],kK.prototype,"updateSubTrack",1),yK([TK],kK.prototype,"updateSubTrackLayer",1),yK([IK,TK],kK.prototype,"subscribe4pushTrack",1),yK([IK,TK],kK.prototype,"unsubscribe4removeTrack",1),yK([IK,TK],kK.prototype,"unsubscribe",1),yK([TK],kK.prototype,"handleRemoveStream",1),yK([IK],kK.prototype,"subscribePublicStream",1),yK([IK],kK.prototype,"unsubscribePublicStream",1);var AK,RK=function(){function e(t,r){u(this,e),h(this,"_audioEventSessionId",xD()),h(this,"_videoEventSessionId",xD()),h(this,"_handler",void 0),h(this,"_stream",void 0),h(this,"_firstAudioFrameTimer",void 0),h(this,"_firstVideoFrameTimer",void 0),h(this,"_transportDelayInterval",void 0),h(this,"_transportDelay",void 0),h(this,"_firstVideoFrameInterval",void 0),h(this,"_firstAudioFrameInterval",void 0),h(this,"_isScreen",!1),h(this,"_audioFirstFrameState",0),h(this,"_videoFirstFrameState",0),h(this,"_timeout",1e4),h(this,"_currentAudioRecv",{startTime:0,eventSessionId:0,type:RB.LOGIN}),h(this,"_currentVideoRecv",{startTime:0,eventSessionId:0,type:RB.LOGIN}),h(this,"_login",!1),h(this,"_unMuteAudio",!1),h(this,"_enableAudio",!1),h(this,"_unMuteVideo",!1),h(this,"_enableVideo",!1),h(this,"_remoteUnmuteAudio",!1),h(this,"_remoteUnmuteVideo",!1),h(this,"_audioExternal",!1),h(this,"_pushAudio",!1),h(this,"_videoExternal",!1),h(this,"_pushVideo",!1),h(this,"_autoSubscribeVideo",!1),h(this,"_autoSubscribeAudio",!1),h(this,"_autoSubscribe",!1),h(this,"_publishVideo",!1),h(this,"_publishAudio",!1),h(this,"_subscribeAudio",!1),h(this,"_subscribeVideo",!1),h(this,"_subscribe",!1),h(this,"_pushTrack",!1),h(this,"_multiChatMode",!1),this._stream=t,this._handler=r,this.getTransportDelay()}var t,r,n,i;return l(e,[{key:"beginRecvFrame",value:(i=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:n=this._transportDelay,i=!0,a=RB.LOGIN,s=RB.UNMUTE,c=RB.SUBSCRIBE,u=RB.PUSH_TRACK,[a,s,c,u].indexOf(r)>=0&&(n=0,i=!1),t===AB.AUDIO?(i||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},h={media_type:t,event_type:IB.BEGIN_RECV,type:r,start:null===(d=this._currentAudioRecv)||void 0===d?void 0:d.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(l=this._stream)||void 0===l?void 0:l.userId,transport_delay:n},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){m.stopRecvFrame(AB.AUDIO,CB.TIMEOUT),m._firstAudioFrameInterval&&window.clearInterval(m._firstAudioFrameInterval)}),this._timeout),FB.rtcFirstFrame(h),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):t===AB.VIDEO&&(i||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},_={media_type:null!==(f=this._stream)&&void 0!==f&&f.isScreen?AB.SCREEN_VIDEO:t,event_type:IB.BEGIN_RECV,type:r,start:null===(p=this._currentVideoRecv)||void 0===p?void 0:p.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(v=this._stream)||void 0===v?void 0:v.userId,transport_delay:n},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){m.stopRecvFrame(AB.VIDEO,CB.TIMEOUT),m._firstVideoFrameInterval&&window.clearInterval(m._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),FB.rtcFirstFrame(_),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if(e===AB.AUDIO){var r,n,i;if(1!==this._audioFirstFrameState)return;var o={event_type:IB.RECV_END,media_type:e,start:null===(r=this._currentAudioRecv)||void 0===r?void 0:r.startTime,reason:t,result:!1,stream_user_id:null===(n=this._stream)||void 0===n?void 0:n.userId,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioRecv)||void 0===i?void 0:i.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,FB.rtcFirstFrame(o),this._audioFirstFrameState=2}else if(e===AB.VIDEO){var a,s,c,u;if(1!==this._videoFirstFrameState)return;var d={event_type:IB.RECV_END,media_type:null!==(a=this._stream)&&void 0!==a&&a.isScreen?AB.SCREEN_VIDEO:e,start:null===(s=this._currentVideoRecv)||void 0===s?void 0:s.startTime,reason:t,result:!1,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,event_session_id:this._videoEventSessionId,type:null===(u=this._currentVideoRecv)||void 0===u?void 0:u.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,FB.rtcFirstFrame(d),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,n=RB.LOGIN,i=RB.UNMUTE,a=RB.SUBSCRIBE,s=RB.PUSH_TRACK,t!==AB.AUDIO){e.next=18;break}if(1===this._audioFirstFrameState){e.next=7;break}return e.abrupt("return");case 7:if(this._currentAudioRecv){e.next=9;break}return e.abrupt("return");case 9:u=this._currentAudioRecv,d=u.type,l=u.startTime,[n,i,a,s].indexOf(d)>=0&&(r=0),h={event_type:IB.RECV_END,media_type:t,start:l,result:!0,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,event_session_id:this._audioEventSessionId,type:d,transport_delay:r},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),FB.rtcFirstFrame(h),this._audioFirstFrameState=3,e.next=30;break;case 18:if(t!==AB.VIDEO){e.next=30;break}if(1===this._videoFirstFrameState){e.next=21;break}return e.abrupt("return");case 21:if(this._currentVideoRecv){e.next=23;break}return e.abrupt("return");case 23:v=this._currentVideoRecv,_=v.type,m=v.startTime,[n,i,a,s].indexOf(_)>=0&&(r=0),y={event_type:IB.RECV_END,media_type:null!==(f=this._stream)&&void 0!==f&&f.isScreen?AB.SCREEN_VIDEO:t,start:m,result:!0,stream_user_id:null===(p=this._stream)||void 0===p?void 0:p.userId,event_session_id:this._videoEventSessionId,type:_,transport_delay:r},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),FB.rtcFirstFrame(y),this._videoFirstFrameState=3;case 30:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame(AB.AUDIO,RB.LOGIN),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame(AB.VIDEO,RB.LOGIN),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame(AB.AUDIO,CB.LEAVE_ROOM),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame(AB.VIDEO,CB.LEAVE_ROOM))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&null!==(r=this._stream)&&void 0!==r&&r.audioHasPublish&&(this._unMuteAudio?this.beginRecvFrame(AB.AUDIO,RB.UNMUTE):null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame(AB.AUDIO,CB.MUTE)))}},{key:"setRemoteUnmuteAudio",value:function(e){var t;this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame(AB.AUDIO,RB.REMOTE_UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(AB.AUDIO,CB.REMOTE_MUTE))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame(AB.AUDIO,RB.ENABLE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(AB.AUDIO,CB.DISABLE))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&null!==(r=this._stream)&&void 0!==r&&r.videoHasPublish&&(this._unMuteVideo?this.beginRecvFrame(AB.VIDEO,RB.UNMUTE):null!==(n=this._stream)&&void 0!==n&&n.hasVideo&&this.stopRecvFrame(AB.VIDEO,CB.MUTE)))}},{key:"setRemoteUnmuteVideo",value:function(e){var t;this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame(AB.VIDEO,RB.REMOTE_UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(AB.VIDEO,CB.REMOTE_MUTE))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame(AB.VIDEO,RB.ENABLE):this.stopRecvFrame(AB.VIDEO,CB.DISABLE))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame(AB.AUDIO,RB.PUSH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame(AB.AUDIO,RB.PUSH)}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame(AB.VIDEO,RB.PUSH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame(AB.VIDEO,RB.PUSH)}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame(AB.VIDEO,RB.PUBLISH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(AB.VIDEO,CB.UNPUBLISH)}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame(AB.AUDIO,RB.PUBLISH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(AB.AUDIO,CB.UNPUBLISH)}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame(AB.AUDIO,RB.SUBSCRIBE));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(AB.AUDIO,CB.UNSUBSCRIBE)}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame(AB.VIDEO,RB.SUBSCRIBE));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(AB.VIDEO,CB.UNSUBSCRIBE)}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame(AB.AUDIO,RB.PUSH_TRACK),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(AB.AUDIO,CB.REMOVE_TRACK))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(c(o().mark((function n(){var i,a,s,c,u,d,l,h;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(a=e._stream)||void 0===a||null===(s=a.videoTrack)||void 0===s||!s.getTrack()){n.next=12;break}return n.next=3,Kj(null===(c=e._handler)||void 0===c?void 0:c.pc,null===(u=e._stream)||void 0===u||null===(d=u.videoTrack)||void 0===d?void 0:d.getTrack());case 3:if(l=n.sent,!(h=l.find((function(e){return"inbound-rtp"===e.type})))||!(h.framesReceived>t||h.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=h.framesReceived,r=h.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish(AB.VIDEO),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(c(o().mark((function n(){var i,a,s,c,u,d,l,h;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(a=e._stream)||void 0===a||null===(s=a.audioTrack)||void 0===s||!s.getTrack()){n.next=12;break}return n.next=3,Kj(null===(c=e._handler)||void 0===c?void 0:c.pc,null===(u=e._stream)||void 0===u||null===(d=u.audioTrack)||void 0===d?void 0:d.getTrack());case 3:if(l=n.sent,!(h=l.find((function(e){return"inbound-rtp"===e.type})))||!(h.totalSamplesReceived>t||h.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=h.totalSamplesReceived,r=h.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish(AB.AUDIO),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=c(o().mark((function e(){var t=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=c(o().mark((function e(){var t,r,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,Kj(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=n.find((function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(a=n.find((function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*a.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:RB.LOGIN},this._currentVideoRecv={startTime:0,eventSessionId:0,type:RB.LOGIN},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}}]),e}(),CK=function(){function e(t,r){u(this,e),h(this,"_audioEventSessionId",xD()),h(this,"_videoEventSessionId",xD()),h(this,"_pcSessionId",void 0),h(this,"_handler",void 0),h(this,"_firstAudioFrameTimer",void 0),h(this,"_firstVideoFrameTimer",void 0),h(this,"_stream",void 0),h(this,"_firstVideoFrameInterval",void 0),h(this,"_firstAudioFrameInterval",void 0),h(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:RB.LOGIN}),h(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:RB.LOGIN}),h(this,"_login",!1),h(this,"_publisher",!1),h(this,"_unMuteAudio",!1),h(this,"_enableAudio",!1),h(this,"_unMuteVideo",!1),h(this,"_enableVideo",!1),h(this,"_audioExternal",!1),h(this,"_pushAudio",!1),h(this,"_videoExternal",!1),h(this,"_pushVideo",!1),h(this,"_autoPublish",!1),h(this,"_publish",!1),h(this,"_timeout",1e4),h(this,"_audioFirstFrameState",0),h(this,"_videoFirstFrameState",0),this._stream=t,this._handler=r}var t,r;return l(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if(e===AB.AUDIO){var n;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var i={media_type:e,event_type:IB.BEGIN_SEND,type:t,start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,event_session_id:this._audioEventSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){r.stopSendFrame(AB.AUDIO,CB.TIMEOUT),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),FB.rtcFirstFrame(i),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if(e===AB.VIDEO){var o,a;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var s={media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?AB.SCREEN_VIDEO:e,event_type:IB.BEGIN_SEND,type:t,start:null===(a=this._currentVideoSend)||void 0===a?void 0:a.startTime,event_session_id:this._videoEventSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){r.stopSendFrame(AB.VIDEO,CB.TIMEOUT),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),FB.rtcFirstFrame(s),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if(e===AB.AUDIO){var r,n;if(1!==this._audioFirstFrameState)return;var i={event_type:IB.SENT_END,media_type:e,start:null===(r=this._currentAudioSend)||void 0===r?void 0:r.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(n=this._currentAudioSend)||void 0===n?void 0:n.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,FB.rtcFirstFrame(i),this._audioFirstFrameState=2}else if(e===AB.VIDEO){var o,a,s;if(1!==this._videoFirstFrameState)return;var c={event_type:IB.SENT_END,media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?AB.SCREEN_VIDEO:e,start:null===(a=this._currentVideoSend)||void 0===a?void 0:a.startTime,reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(s=this._currentVideoSend)||void 0===s?void 0:s.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,FB.rtcFirstFrame(c),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if(e===AB.AUDIO){if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var t=this._currentAudioSend,r=t.type,n=t.startTime,i={event_type:IB.SENT_END,media_type:e,start:n,result:!0,event_session_id:this._audioEventSessionId,type:r};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),FB.rtcFirstFrame(i),this._audioFirstFrameState=3}else if(e===AB.VIDEO){var o;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var a=this._currentVideoSend,s=a.type,c=a.startTime,u={event_type:IB.SENT_END,media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?AB.SCREEN_VIDEO:e,start:c,result:!0,event_session_id:this._videoEventSessionId,type:s};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),FB.rtcFirstFrame(u),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame(AB.VIDEO,RB.LOGIN),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame(AB.AUDIO,RB.LOGIN);!e&&this._audioSending&&this.stopSendFrame(AB.AUDIO,CB.LEAVE_ROOM),!e&&this._videoSending&&this.stopSendFrame(AB.VIDEO,CB.LEAVE_ROOM)}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r,n,i;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&(null===(r=this._stream)||void 0===r?void 0:r.pubVideo)&&this.beginSendFrame(AB.VIDEO,RB.PUBLISH),(null===(n=this._stream)||void 0===n?void 0:n.audioTrack)&&(null===(i=this._stream)||void 0===i?void 0:i.pubAudio)&&this.beginSendFrame(AB.AUDIO,RB.PUBLISH);!e&&this._audioSending&&this.stopSendFrame(AB.AUDIO,CB.UNPUBLISH),!e&&this._videoSending&&this.stopSendFrame(AB.VIDEO,CB.UNPUBLISH)}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame(AB.AUDIO,RB.UNMUTE),!e&&this._audioSending&&this.stopSendFrame(AB.AUDIO,CB.MUTE)))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame(AB.AUDIO,RB.ENABLE),!e&&this._audioSending&&this.stopSendFrame(AB.AUDIO,CB.DISABLE))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame(AB.VIDEO,RB.UNMUTE),!e&&this._videoSending&&this.stopSendFrame(AB.VIDEO,CB.MUTE)))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame(AB.VIDEO,RB.ENABLE),!e&&this._videoSending&&this.stopSendFrame(AB.VIDEO,CB.DISABLE))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame(AB.AUDIO,CB.DISABLE),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame(AB.AUDIO,CB.STOP_PUSH),this._pushAudio=!1))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame(AB.AUDIO,RB.PUSH),!e&&this._audioSending&&this.stopSendFrame(AB.AUDIO,CB.STOP_PUSH))}},{key:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame(AB.VIDEO,CB.DISABLE),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame(AB.VIDEO,CB.STOP_PUSH),this._pushVideo=!1))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame(AB.VIDEO,RB.PUSH),!e&&this._videoSending&&this.stopSendFrame(AB.VIDEO,CB.STOP_PUSH))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame(AB.AUDIO,CB.AUDIENCE),!e&&this._videoSending&&this.stopSendFrame(AB.VIDEO,CB.AUDIENCE))}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=c(o().mark((function e(){var t,r,n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,Kj(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(a=this._stream)||void 0===a||null===(s=a.videoTrack)||void 0===s?void 0:s.getTrack("preprocessing"));case 3:return c=e.sent,u=c.find((function(e){return"outbound-rtp"===e.type})),e.abrupt("return",u);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=c(o().mark((function e(){var t,r,n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,Kj(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(a=this._stream)||void 0===a||null===(s=a.audioTrack)||void 0===s?void 0:s.getTrack("preprocessing"));case 3:return c=e.sent,u=c.find((function(e){return"outbound-rtp"===e.type})),e.abrupt("return",u);case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(c(o().mark((function n(){var i;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(!(i=n.sent)||!(i.framesSent>t||i.packetsSent>r)){n.next=10;break}if(-1!==t||-1!==r){n.next=8;break}return t=i.framesSent,r=i.packetsSent,n.abrupt("return");case 8:e.sendFrameFinish(AB.VIDEO),window.clearInterval(e._firstVideoFrameInterval);case 10:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(c(o().mark((function r(){var n;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish(AB.AUDIO),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:RB.LOGIN},this._currentVideoSend={startTime:0,eventSessionId:0,type:RB.LOGIN},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),wK=(h(AK={},"audio",{delay:1200,stallRadio:.3}),h(AK,"video",{delay:1200,stallRadio:.6}),h(AK,"screen_audio",{delay:1600,stallRadio:.8}),h(AK,"screen_video",{delay:1600,stallRadio:.8}),AK),OK=function(){function e(){u(this,e),h(this,"_preUplinkStats",new Map),h(this,"_preDownlinkStats",new Map),h(this,"_timer",void 0),h(this,"_delayTimer",void 0),h(this,"_connectionState",EK.CONNECTED),h(this,"reportor",void 0)}return l(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i=n?"screen_audio":"audio",o=t.rtt,a=t._fractionLost,s=t._retransmittedRate,c=this._getQosLevel(o,a||0,s||0),u=this._preUplinkStats.get(i)||[c];this._preUplinkStats.set(i,[].concat(k(u),[c]).slice(-2))}if(r.sentKBitrate>0&&r.rtt){var d=n?"screen_video":"video",l=r._fractionLost,h=r.rtt,f=r._sendBandWidth,p=r._retransmittedRate;0===f&&(l=Math.max(.65,l));var v=this._getQosLevel(h,l||0,p||0),_=this._preUplinkStats.get(d)||[v];this._preUplinkStats.set(d,[].concat(k(_),[v]).slice(-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=W.VBAD;else{var l=s.rtt,h=s.audioLossRate,f=s.stallDuration,p=s.statsInterval,v=s.e2eDelay,_=f/p,m=u?"screen_audio":"audio",y=this._getQosLevel(l,h||0,c._retransmittedRate||0),g=this._getDownlinkQoE(m,_,v);r=this._getNetworkQuality(y,g)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=W.VBAD;else{var S=c.rtt,E=c.videoLossRate,b=c.stallDuration,T=c.statsInterval,I=c.e2eDelay,A=c._retransmittedRate,R=b/T,C=u?"screen_video":"video",w=this._getQosLevel(S,E||0,A||0),O=this._getDownlinkQoE(C,R,I);n=this._getNetworkQuality(w,O)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var N="".concat(d).concat(u?"_screen":""),P=this._preDownlinkStats.get(N)||[x];this._preDownlinkStats.set(N,[].concat(k(P),[x]).slice(-2)),this._startNetworkQualityReport()}}}},{key:"setConnectionState",value:function(e){this._connectionState=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r=this;if(this._connectionState!==EK.CONNECTED)e=t=W.VBAD;else{var n=this._getBetterQualityAndRemoveOldest("audio","up"),i=this._getBetterQualityAndRemoveOldest("video","up");e=n&&i?Math.ceil((n+i)/2):n||i||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||W.EXCELLENT;var o=Array.from(this._preDownlinkStats.keys()).map((function(e){return r._getBetterQualityAndRemoveOldest(e,"down")})).filter((function(e){return e}));t=Math.ceil(o.reduce((function(e,t){return t+e}),0)/o.length)||W.UNKNOWN}"function"==typeof this.reportor&&this.reportor(e,t)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=wK[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=W.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=i.filter((function(e){return e}));o.length>0&&(r=Math.min.apply(Math,k(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&UD(t)&&r.localaudio&&r.audiostream,videoActive:n&&VD(t)&&r.localvideo&&r.videostream}}}]),e}(),xK=function(){function e(t){u(this,e),h(this,"_timer",void 0),h(this,"_remoteVideoSizeCache",{}),h(this,"_remoteScreenSizeCache",{}),h(this,"onchange",void 0),this._room=t,this._start()}return l(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,f=a.getSettings(),p=f.width,v=void 0===p?0:p,_=f.height,m=void 0===_?0:_;h===m&&d===v||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,v,m),delete s[i],(n.isScreen?r:t)[i]={width:v,height:m}}}))})),Object.keys(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),Object.keys(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),NK=new YL("Room",1),PK={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1},DK=function(e){f(M,e);var t,r,n,a,s,d,p,v,_,y,S,E,k,T,I,R,C,O,x,N,D=g(M);function M(e,t){var r;return u(this,M),h(m(r=D.call(this)),"_mediaServerClient",void 0),h(m(r),"_localStream",void 0),h(m(r),"_localScreenStream",void 0),h(m(r),"_remoteUsers",new Map),h(m(r),"_remoteStreams",new Map),h(m(r),"_remoteStreamStreamIdUserIdMap",{}),h(m(r),"_virtualStreams",[]),h(m(r),"_joinResolveCallback",void 0),h(m(r),"_joinRejectCallback",void 0),h(m(r),"_getAccessNode",void 0),h(m(r),"_getAccessFeedback",void 0),h(m(r),"_getAccessFeedbackIceNode",void 0),h(m(r),"_reconnectTimer",void 0),h(m(r),"_isReconnecting",void 0),h(m(r),"_context",void 0),h(m(r),"_sessionId",void 0),h(m(r),"_reconnectRecord",void 0),h(m(r),"_connectionLostTimer",void 0),h(m(r),"_liveControlMessage",void 0),h(m(r),"_serverConfig",void 0),h(m(r),"_liveTranscodingOnceSucc",!1),h(m(r),"_roomConfig",void 0),h(m(r),"_roomInfo",void 0),h(m(r),"_waitForNewToken",!1),h(m(r),"_userDuplicateLoginTimerMap",new Map),h(m(r),"_networkQualityManager",void 0),h(m(r),"_videoSizeObserver",void 0),h(m(r),"_hasPublished",!1),h(m(r),"_csrcUserIdMap",void 0),h(m(r),"_publishOnDemandItem",void 0),h(m(r),"_publishOnDemandBusy",!1),r._roomConfig=e,r._mediaServerClient=new kK(t),r._reconnectRecord=new MK,r._addHandlerEventHandler(),r._isReconnecting=!1,r._networkQualityManager=new OK,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(m(r)),r._videoSizeObserver=new xK(m(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(m(r)),r._context=t,r._csrcUserIdMap={},r}return l(M,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A,R,C,w,O,x=this;null===(e=this._mediaServerClient)||void 0===e||e.on(gj.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(gj.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return x._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(gj.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(gj.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return x._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(gj.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(gj.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return x._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(gj.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(gj.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return x._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(gj.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(gj.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(gj.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(gj.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(gj.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(gj.NODE_CHANGE,this._nodeChange.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(gj.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(gj.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(gj.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(gj.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(gj.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(gj.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(gj.ON_SCENE_CONFIG,this._onSceneConfig.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(gj.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(b=this._mediaServerClient)||void 0===b||b.on(Sj.RSCP,(function(e){!!e.find((function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:t.includes(null===(r=x._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(x._publishOnDemandItem=e,x._onPublishOnDemand())})),null===(k=this._mediaServerClient)||void 0===k||k.on(Sj.RTT,this._onRTT.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(Ej.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(I=this._mediaServerClient)||void 0===I||I.on(Ej.ABNORMAL_DISCONNECTION,this._handleAbnormalDisconnection.bind(this)),null===(A=this._mediaServerClient)||void 0===A||A.on(gj.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){x._networkQualityManager.updateDownlinkStats(e,x._findRemoteStreamByScreen(e.userId,e.isScreen)),x.emit(lK.ON_REMOTE_STREAM_STATS,FD(e))})),null===(C=this._mediaServerClient)||void 0===C||C.on("onLocalStreamStats",(function(e){x._networkQualityManager.updateUplinkStats(e),x.emit(lK.ON_LOCAL_STREAM_STATS,FD(e))})),null===(w=this._mediaServerClient)||void 0===w||w.on("prevIceNode",(function(e){x._getAccessFeedbackIceNode=e})),null===(O=this._mediaServerClient)||void 0===O||O.on("prevIceNode",(function(e){x._getAccessFeedbackIceNode=e}))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"join",value:(N=c(o().mark((function e(t,r,n,i,a,s,c){var u=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GB.setStats({rtc_app_id:t,room_id:r,user_id:i.userId}),NK.print("join()"),e.abrupt("return",new Promise((function(e,o){var d,l,h=fD();u._joinResolveCallback=function(t){var r;FB.joinRoom(OB.END,h,!0,"",{enable_cloud_proxy:null===(r=u._roomInfo)||void 0===r?void 0:r.useCloudProxy}),e(t)},u._joinRejectCallback=function(e){var t;FB.joinRoom(OB.END,h,!1,e.message,{enable_cloud_proxy:null===(t=u._roomInfo)||void 0===t?void 0:t.useCloudProxy}),o(e)},u._liveControlMessage=a,u._roomInfo={appId:t,roomId:r,token:n,userInfo:i,useCloudProxy:s,roomProfile:u._roomConfig.roomProfileType,expectedIDC:c},u.setSessionId(),FB.joinRoom(OB.BEGIN,h,!1,"",{enable_cloud_proxy:null===(d=u._roomInfo)||void 0===d?void 0:d.useCloudProxy,expectedIDC:null===(l=u._roomInfo)||void 0===l?void 0:l.expectedIDC}),u._join(u._joinResolveCallback,u._joinRejectCallback,!1)})));case 3:case"end":return e.stop()}}),e)}))),function(e,t,r,n,i,o,a){return N.apply(this,arguments)})},{key:"_join",value:(x=c(o().mark((function e(t,r){var n,i,a,s,c=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>2&&void 0!==c[2]&&c[2],i=fD(),NK.print("_join()"),e.prev=3,e.next=6,this._mediaServerClient.join(this._roomInfo,{node:this._getAccessNode,reason:this._getAccessFeedback,sessionId:this._sessionId,feedbackNode:this._getAccessFeedbackIceNode},n,this._liveControlMessage);case 6:s=e.sent,this._mediaServerClient.roomAttributes=s.roomAttributes,null!==(a=s.roomAttributes)&&void 0!==a&&a.multiChatMode&&this._handleFFAudioTrack(),this._reconnectRecord.clear(),this._joinResolveCallback=void 0,this._joinRejectCallback=void 0,this._getAccessFeedback=void 0,this._getAccessNode=void 0,"function"==typeof t&&t({users:s.clients,streams:s.streams}),this._isReconnecting=!1,FB.rtcJoinRoom(0,"web","web",fD()-i),this._onJoinSucc(s,n),e.next=24;break;case 20:if(e.prev=20,e.t0=e.catch(3),e.t0.code===dP.OPERATION_CANCEL||"function"!=typeof r){e.next=24;break}return e.abrupt("return",r(e.t0));case 24:case"end":return e.stop()}}),e,this,[[3,20]])}))),function(e,t){return x.apply(this,arguments)})},{key:"publishScreen",value:(O=c(o().mark((function e(t,r,n,i,a){var s,c,u,d,l,h,f,p,v,_;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(NK.print("publishScreen()"),this._localScreenStream||(this._localScreenStream=new qz,this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new CK(this._localScreenStream,this._mediaServerClient.handler))),s=!1,c=!1,u=!1,d=!1,!this._localScreenStream.videoTrack&&r?(r instanceof iz&&(c=!0),s=!0):this._localScreenStream.videoTrack&&!r&&(s=!1),!this._localScreenStream.audioTrack&&n?(n instanceof oz&&(d=!0),u=!0):this._localScreenStream.audioTrack&&!n&&(u=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(UD(i)&&(this._localScreenStream.pubAudio=a===fK.PUB),VD(i)&&(this._localScreenStream.pubVideo=a===fK.PUB),NK.print("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(l=this._localScreenStream)||void 0===l||!l.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(h=this._localScreenStream.observer)||void 0===h||h.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return c?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushVideo(s):null===(p=this._localScreenStream.observer)||void 0===p||p.setEnableVideo(s),d?null===(v=this._localScreenStream.observer)||void 0===v||v.setPushAudio(u):null===(_=this._localScreenStream.observer)||void 0===_||_.setEnableAudio(u),e.next=28,this.updatePubScreenTrack();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return O.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(C=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(NK.print("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return C.apply(this,arguments)})},{key:"unpublishScreen",value:(R=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(NK.print("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=7;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.clean(),this._localScreenStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"liveControlMessage",value:(I=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return NK.print("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),this._liveControlMessage=t,e.next=5,this._mediaServerClient.controlMessage(t);case 5:"stopped"===t.action&&(delete this._liveControlMessage,this._liveTranscodingOnceSucc=!1),this._liveTranscodingOnceSucc=!0;case 7:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(T=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"updateUserAttributes",value:(k=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return NK.print("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"publish",value:(E=c(o().mark((function e(t,r,n,i,a,s){var c,u,d,l,h,f,p,v,_,m,y,g,S=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=S.length>6&&void 0!==S[6]&&S[6],NK.print("publish","Invoke publish"),u=!1,this._localStream||(this._localStream=new qz,this._mediaServerClient.handler&&(this._localStream.observer=new CK(this._localStream,this._mediaServerClient.handler)),u=!0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,a&&(UD(a)&&(this._localStream.pubAudio=s===fK.PUB),VD(a)&&(this._localStream.pubVideo=s===fK.PUB),NK.print("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,c?null===(d=this._localStream.observer)||void 0===d||d.setLogin(!0):u&&(l=!!this._localStream.videoTrack,h=!!this._localStream.audioTrack,f=this._localStream.videoTrack instanceof iz,p=this._localStream.audioTrack instanceof oz,this._roomConfig.isAutoPublish&&!this._hasPublished?(l&&(f?null===(v=this._localStream.observer)||void 0===v||v.setPushVideo(!0):null===(_=this._localStream.observer)||void 0===_||_.setEnableVideo(!0)),h&&(p?null===(m=this._localStream.observer)||void 0===m||m.setPushAudio(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableAudio(!0))):null===(g=this._localStream.observer)||void 0===g||g.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(lK.ON_PUBLISH_RESULT,{isScreen:!1,state:P.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(lK.ON_PUBLISH_RESULT,{isScreen:!1,state:P.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return E.apply(this,arguments)})},{key:"updatePubTrack",value:(S=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(NK.print("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return S.apply(this,arguments)})},{key:"unpublish",value:(y=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(NK.print("unpublish","Invoke unpublish"),!this._localStream){e.next=6;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.clean(),this._localStream=void 0;case 6:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"subscribe",value:(_=c(o().mark((function e(t,r,n){var i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return NK.print("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"updateSubTrack",value:(v=c(o().mark((function e(t,r,n,i){var a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(NK.print("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(s=this._mediaServerClient)||void 0===s?void 0:s.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return v.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(p=c(o().mark((function e(t,r){var n,i,a,s,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((s=this._findRemoteStreamByScreen(t,!1))&&s.hasSubscribed&&!((null==s||null===(n=s.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return c=this._getSubLayer(r,s),s.originalStreamIndex=c.spatialLayer,e.abrupt("return",null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(s,c));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,f=0;f<(null==d?void 0:d.length);f++){var p,v;if(h>=(null===(p=d[f])||void 0===p?void 0:p.width)*(null===(v=d[f])||void 0===v?void 0:v.height)){l=f;break}}var _=d[0];if(-1===l)_=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,y=(m-h)/(m-d[l].width*d[l].height);_=y<.1?d[l-1]:d[l],l=y<.1?l-1:l}return a=null!==(r=null===(n=_)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=_)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(d=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return NK.print("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"leave",value:(s=c(o().mark((function e(){var t,r,n,i,a,s,c=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=c.length>0&&void 0!==c[0]&&c[0],NK.print("leave","Invoke leave"),r=fD(),e.prev=3,this._mediaServerClient.connectionState!==EK.CONNECTED&&this._joinRejectCallback&&this._joinRejectCallback(new Error(xB.LEAVE_ROOM)),clearTimeout(this._reconnectTimer),n=A(this._remoteStreams.values());try{for(n.s();!(i=n.n()).done;)a=i.value,Array.isArray(a)&&a.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(o){n.e(o)}finally{n.f()}return this._localStream&&(null===(s=this._localStream.observer)||void 0===s||s.setLogin(!1)),e.next=11,this._mediaServerClient.leave();case 11:this.destroy(),FB.rtcLeaveRoom(0,"",fD()-r),GB.setStats({room_id:void 0,user_id:void 0,rtc_session_id:void 0}),e.next=24;break;case 16:if(e.prev=16,e.t0=e.catch(3),!t){e.next=22;break}throw e.t0;case 22:this.destroy();case 23:e.t0 instanceof Error&&FB.rtcLeaveRoom(-1,e.t0.message,fD()-r);case 24:case"end":return e.stop()}}),e,this,[[3,16]])}))),function(){return s.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(e){e.streamState!==Wz.INIT&&r._mediaServerClient.subscribe(e,e.subMediaType)}))}},{key:"destroy",value:function(){NK.print("destroy","Invoke destroy"),FB.rtcInvokeStatus("".concat((new Error).stack),0,"room_destroy","",0),this._destroyAndInitMediaServerClient(),this._roomInfo=void 0,this._remoteUsers=new Map;var e,t,r,n=A(this._remoteStreams);try{for(n.s();!(e=n.n()).done;){var i=b(e.value,2)[1];Array.isArray(i)&&i.forEach((function(e){e&&e.clean()}))}}catch(o){n.e(o)}finally{n.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new Map,this._localStream)&&(null===(t=this._localStream)||void 0===t||t.clean(),this._localStream=void 0);this._localScreenStream&&(null===(r=this._localScreenStream)||void 0===r||r.clean(),this._localScreenStream=void 0);this._context=void 0,this._reconnectRecord=new MK,this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={}}},{key:"updateToken",value:(a=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return NK.print("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.next=4,this._mediaServerClient.updateToken(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){this._sessionId=uD(),GB.setStats({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(n=c(o().mark((function e(t){var r,n,i,a,s,c=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=c.length>1&&void 0!==c[1]&&c[1],s={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:a,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!a){e.next=8;break}return e.next=5,_D.ab2b64str(t);case 5:s.message=e.sent,e.next=9;break;case 8:s.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(s));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_destroyAndInitMediaServerClient",value:function(){NK.print("_destroyAndInitMediaServerClient()"),this._mediaServerClient&&(this._mediaServerClient.destroy(),this._removeHandlerEventHandler()),this._mediaServerClient=new kK(this._context),this._addHandlerEventHandler()}},{key:"_onJoinSucc",value:function(e,t){var r,n=this;NK.print("JoinSuccess()"),this._serverConfig=e.config;var i=[],o=[],a=[],s=[],c=[];null===(r=e.clientsDetail)||void 0===r||r.forEach((function(t){if(t.attributes&&(t.attributes.serverMuteVideo&&n.safeEmit(lK.ON_VIDEO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteVideo}),t.attributes.serverMuteAudio&&n.safeEmit(lK.ON_AUDIO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteAudio})),t.clientId!==e.clientId){var r=n._remoteUsers.get(t.clientId);r?r._stillExist=!0:i.push(t)}}));var u,d=A(this._remoteUsers.values());try{for(d.s();!(u=d.n()).done;){var l=u.value;l._stillExist||o.push({clientId:l.userId}),delete l._stillExist}}catch(v){d.e(v)}finally{d.f()}e.streams.forEach((function(e){var t=n._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,c.push(e)):s.push(e)}));var h,f=A(this._remoteStreams.values());try{for(f.s();!(h=f.n()).done;){var p=h.value;Array.isArray(p)&&p.forEach((function(e){e.stillExist?delete e.stillExist:a.push({clientId:e.userId,streamId:e.streamId,message:mj.clientDisconnected})}))}}catch(v){f.e(v)}finally{f.f()}o.forEach((function(e){return n._onUserDisconnection(e)})),i.forEach((function(e){return n._onUserConnection(e)})),a.forEach((function(e){return n._onRemoveStream(e)})),s.forEach((function(e){return n._onAddStream(e,{fromSignal:!1})})),c.forEach((function(e){return n._onUpdateStreamAttributes(e)})),t&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e=this;this._localStream&&(this._localStream.clean(),this._mediaServerClient.publish(this._localStream).catch((function(e){}))),this._localScreenStream&&(this._localScreenStream.clean(),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var t,r=A(this._remoteStreams.values());try{for(r.s();!(t=r.n()).done;){var n=t.value;Array.isArray(n)&&n.forEach(function(){var t=c(o().mark((function t(r){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.hasSubscribed){t.next=15;break}return r.resetHasSubscribed(),t.prev=2,NK.print("start resubscribe ".concat(r.userId," with ").concat(r.subMediaType)),t.next=6,e._mediaServerClient.subscribe(r,r.subMediaType);case 6:NK.print("success resubscribe ".concat(r.userId," with ").concat(r.subMediaType)),e.safeEmit(lK.RESUBSCRIBE,{stream:r}),t.next=15;break;case 10:t.prev=10,t.t0=t.catch(2),NK.print("failed resubscribe ".concat(r.userId," with ").concat(r.subMediaType,", error:").concat(t.t0)),r.clean(),null==r||r.resetHasSubscribed();case 15:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e){return t.apply(this,arguments)}}())}}catch(i){r.e(i)}finally{r.f()}}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=o.find((function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new Yz("ff-stream","ff-stream",!1,PK);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=Sz(i),this._virtualStreams.push(s),this.safeEmit(lK.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?r.find((function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?r.find((function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var f,p=null===(f=this._remoteStreams.get(e.clientId))||void 0===f?void 0:f.filter((function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,p||[])}var v=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,v)v.attributes=e.attributes;else if((v=new Yz(e.clientId,e.streamId,e.screen,e.attributes)).virtual=c,this._initStreamListeners(v),!c){var _=this._remoteStreams.get(e.clientId);_?_.push(v):this._remoteStreams.set(e.clientId,[v])}if(this._mediaServerClient.handler&&(v.observer=new RK(v,this._mediaServerClient.handler)),!v.isScreen&&l){var m,y,g,S,E,b,k,T;if(a&&v.hasVideo)if(v.attributes.extvideo)null===(m=v.observer)||void 0===m||m.setExternalVideoSource(!0),null===(y=v.observer)||void 0===y||y.setPushVideo(!0);else null===(g=v.observer)||void 0===g||g.setExternalVideoSource(!1),null===(S=v.observer)||void 0===S||S.setPublishVideo(!0);if(a&&v.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(v.attributes.extaudio)null===(E=v.observer)||void 0===E||E.setExternalAudioSource(!0),null===(b=v.observer)||void 0===b||b.setPushAudio(!0);else null===(k=v.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=v.observer)||void 0===T||T.setPublishAudio(!0);if(!0===i&&!1===a){var I,A=this._roomConfig,R=A.isAutoSubscribeAudio,C=A.isAutoSubscribeVideo;null===(I=v.observer)||void 0===I||I.setLogin(!0,{audio:!!R,video:!!C})}}return i&&this.safeEmit(gj.ON_ADD_STREAM,{stream:v}),v}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,i({},n)),this.safeEmit(gj.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(lK.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(lK.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===bj.kickedByAdmin?a=dP.KICKED_OUT:i===bj.onUserTokenDidExpire?a=dP.TOKEN_EXPIRED:i===bj.userDuplicateLogin&&(a=dP.DUPLICATE_LOGIN),o===kj.roomDismissByAdmin&&(a=dP.ROOM_DISMISS),a&&this.safeEmit(lK.ON_ROOM_ERROR,{errorCode:a})}else{var s=w.DROPPED;i===bj.userLeave?s=w.QUIT:i===bj.kickedByAdmin?s=w.KICKED_BY_ADMIN:i===bj.roleChanged&&(s=w.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){e.clean(),r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:mj.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(lK.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===bj.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=n.find((function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=t.filter((function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(gj.ON_REMOVE_STREAM,{stream:i,reason:e.message})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(lK.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(lK.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=i(i({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,o=e.clientId,a=e.streamId,s=e.attributes,c=this._findRemoteStream(o,a);if(c){var u,d,l=c.attributes,h=i(i({},l),s),f=!1,p=h.localaudio!==l.localaudio,v=!1,_=!1,m=h.localvideo!==l.localvideo,y=!1,g=Oz.NONE,S=Oz.NONE;if(h.audiostream!==l.audiostream&&(f=h.localaudio,v=!!h.audiostream,h.audiostream?g|=U.AUDIO:S|=U.AUDIO),h.videostream!==l.videostream&&(_=h.localvideo,y=!!h.videostream,h.videostream?g|=U.VIDEO:S|=U.VIDEO),g&&this.safeEmit(lK.ON_USER_PUBLISH_STATE_CHANGE,{userId:o,mediaType:g,isScreen:c.isScreen,pubState:fK.PUB,remoteStream:c}),S&&this.safeEmit(lK.ON_USER_PUBLISH_STATE_CHANGE,{userId:o,mediaType:S,isScreen:c.isScreen,pubState:fK.UNPUB,remoteStream:c}),c.attributes=h,h.localaudio!==l.localaudio)if(h.localaudio){var E,b,k,T;if(r)if(h.extaudio)null===(E=c.observer)||void 0===E||E.setExternalAudioSource(!0),null===(b=c.observer)||void 0===b||b.setPushAudio(!0);else null===(k=c.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=c.observer)||void 0===T||T.setEnableAudio(!0);this.safeEmit(lK.ON_USER_START_AUDIO_CAPTURE,{userId:o},c)}else{var I,A,R,C;if(h.extaudio)null===(I=c.observer)||void 0===I||I.setExternalAudioSource(!0),null===(A=c.observer)||void 0===A||A.setPushAudio(!1);else null===(R=c.observer)||void 0===R||R.setExternalAudioSource(!1),null===(C=c.observer)||void 0===C||C.setEnableAudio(!1);!c.isScreen&&this.safeEmit(lK.ON_USER_STOP_AUDIO_CAPTURE,{userId:o})}if(h.localvideo!==l.localvideo)if(h.localvideo){var w,O,x,N;if(n)if(h.extvideo)null===(w=c.observer)||void 0===w||w.setExternalVideoSource(!0),null===(O=c.observer)||void 0===O||O.setPushVideo(!0);else null===(x=c.observer)||void 0===x||x.setExternalVideoSource(!1),null===(N=c.observer)||void 0===N||N.setEnableVideo(!0);this.safeEmit(lK.ON_USER_START_VIDEO_CAPTURE,{userId:o})}else{var P,D,M,L;if(h.extvideo)null===(P=c.observer)||void 0===P||P.setExternalVideoSource(!0),null===(D=c.observer)||void 0===D||D.setPushVideo(!1);else null===(M=c.observer)||void 0===M||M.setExternalVideoSource(!1),null===(L=c.observer)||void 0===L||L.setEnableVideo(!1);!c.isScreen&&this.safeEmit(lK.ON_USER_STOP_VIDEO_CAPTURE,{userId:o})}if(f&&!p)null===(u=c.observer)||void 0===u||u.setRemoteUnmuteAudio(v);if(_&&!m)null===(d=c.observer)||void 0===d||d.setRemoteUnmuteVideo(y)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&t.startsWith("audio_mux")){var n=this._onAddStream(i(i({},e),{},{attributes:PK}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(lK.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){NK.print("subscribe","push track failed %o",e)}))}else FB.rtcError("onPushTrack, userId: ".concat(e.clientId,", ").concat(e.streamId),-1001)}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message;NK.print("_onRemoveTrack","remove track: %o",r);var o=this._findRemoteStream(r,n);o&&(null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(o,i))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=b(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&t.sort((function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_nodeChange",value:function(e){var t,r=e.nodes,n=e.reason;oj.clearAccessNode(null===(t=this._roomInfo)||void 0===t?void 0:t.appId),this._destroyAndInitMediaServerClient(),Array.isArray(r)&&r.length?this._getAccessNode=r[0]:this._getAccessFeedback=n,FB.rtcNodeChange(0,JSON.stringify(e),JSON.stringify(n)),this._joinResolveCallback&&this._joinRejectCallback?this._join(this._joinResolveCallback,this._joinRejectCallback):this._reconnect()}},{key:"_reconnect",value:function(){var e=this;this._isReconnecting=!0;var t,r=A(this._remoteStreams.values());try{for(r.s();!(t=r.n()).done;){var n=t.value;Array.isArray(n)&&n.forEach((function(e){return e.clean()}))}}catch(i){r.e(i)}finally{r.f()}FB.rtcReconnect(1002,oB.PEERCONNECTION_RECONNECTING,this._roomInfo.userInfo.userId,aB.PEERCONNECTION),this._liveTranscodingOnceSucc||delete this._liveControlMessage,this._join((function(){FB.rtcReconnected(sB.PEERCONNECTION_RECONNECTED,cB.PEERCONNECTION)}),(function(t){e._reconnectRecord.record(t),e._reconnectRecord.shouldReconnect?(NK.print("Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=window.setTimeout(e._reconnect.bind(e),3e3)):(e.safeEmit(lK.RECONNECT_FAILED),e.destroy())}),!0)}},{key:"_handleAbnormalDisconnection",value:function(){NK.print("on ABNORMAL_DISCONNECTION"),this._destroyAndInitMediaServerClient(),navigator.onLine?this._reconnect():this._reconnectTimer=window.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===EK.DISCONNECTED)t=F.CONNECTION_STATE_DISCONNECTED;else if(e.next===EK.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._isReconnecting?F.CONNECTION_STATE_RECONNECTED:F.CONNECTION_STATE_CONNECTED;else{if(e.next!==EK.CONNECTING)return;t=this._isReconnecting?F.CONNECTION_STATE_RECONNECTING:F.CONNECTION_STATE_CONNECTING}e.prev===EK.CONNECTED&&e.next===EK.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(Ej.ON_CONNECTION_STATE_CHANGE,{state:F.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setConnectionState(e.next),this.safeEmit(Ej.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(lK.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(gj.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(gj.USER_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onUserBinaryMessageReceived",value:function(e){this.safeEmit(gj.USER_BINARY_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onPostProcessingMessage",value:function(e){if(e.body){var t=e.body,r=t.error||0,n=hK.START,i=["success","parameter error","subscription timeout","ffmpeg error","cdn error","publish error"];if("2.0"===t.protocol){switch(t.eventType){case"TranscodeStarted":0!==t.error&&(n=hK.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?hK.START_FAILED:hK.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?hK.STOP_FAILED:hK.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?hK.UPDATE_FAILED:hK.UPDATE_SUCCESS}this.safeEmit(gj.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(gj.POST_PROCESSING_MESSAGE,{code:r,message:i[r],type:e.type})}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(gj.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onSceneConfig",value:function(e){try{var t=e.multiSceneConfig,r=vK[this._roomConfig.roomProfileType][1];if(t){var n,i,o,a,s=t[r];if(null!=s&&s.engine_BAC)null===(n=this._context)||void 0===n||null===(i=n.audioProfileManager)||void 0===i||i.updateEngineBAC(s.engine_BAC);if(null!=s&&s.engine_ANM)null===(o=this._context)||void 0===o||null===(a=o.audioProfileManager)||void 0===a||a.updateEngineANM(s.engine_ANM)}}catch(c){}}},{key:"_onStreamFailed",value:(r=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(c=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?c=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(c=this.localScreenStream),c){e.next=5;break}return e.abrupt("return");case 5:return null===(i=c)||void 0===i||i.clean(),e.next=8,null===(a=this._mediaServerClient)||void 0===a?void 0:a.unpublish(c).catch((function(){}));case 8:null===(s=this._mediaServerClient)||void 0===s||s.publish(c).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(u=this._remoteStreamStreamIdUserIdMap[t.streamId],!(d=this._findRemoteStream(u,t.streamId))){e.next=20;break}return e.next=17,null===(l=this._mediaServerClient)||void 0===l?void 0:l.unsubscribe(d,U.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(h=this._mediaServerClient)||void 0===h?void 0:h.subscribe(d,d.subMediaType,d.subLayer);case 19:this.safeEmit(lK.RESUBSCRIBE,{stream:d});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===yj.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(t=c(o().mark((function e(){var t,r,n,i,a,s,c,u,d,l,h,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(s=this._publishOnDemandItem,this._publishOnDemandItem=void 0,s){e.next=6;break}return e.abrupt("return");case 6:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(a=this._localStream)||void 0===a||!a.videoTransceiver){e.next=15;break}return this._publishOnDemandBusy=!0,d=null===(c=this._localStream)||void 0===c?void 0:c.stream.id,l=null===(u=this._localStream)||void 0===u?void 0:u.videoTransceiver.sender,h=l.getParameters(),Array.isArray(h.encodings)&&Array.isArray(s)&&(f={},NK.print("_onPublishOnDemand exec","usedDescriptions: %o",s),s.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&t.includes(d)){var r=null==e?void 0:e.Metadata.VideoIndex;f[r]=!0}})),h.encodings=h.encodings.map((function(e){return e.rid&&(f[e.rid]?e.active=!0:e.active=!1),e}))),e.next=14,l.setParameters(h);case 14:this._publishOnDemandBusy=!1;case 15:this._onPublishOnDemand();case 16:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(lK.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(lK.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}}]),M}(ZL),MK=function(){function e(){u(this,e),h(this,"_all_201_count",void 0),h(this,"_has_4xx",void 0),this._all_201_count=0,this._has_4xx=!1}return l(e,[{key:"shouldReconnect",get:function(){return!(this._all_201_count>=3||this._has_4xx)}},{key:"record",value:function(e){var t=!1,r=!1;if(Array.isArray(e)){var n=0;e.map((function(e){var t,i,o;400<=(null===(t=e.error)||void 0===t?void 0:t.code)&&(null===(i=e.error)||void 0===i?void 0:i.code)<500&&(r=!0),201===(null===(o=e.error)||void 0===o?void 0:o.code)&&n++})),n===e.length&&(t=!0),t&&this._all_201_count++,r&&(this._has_4xx=!0)}}},{key:"clear",value:function(){this._all_201_count=0,this._has_4xx=!1}}]),e}(),LK=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&Object.assign(r.style,t.style),t.attributes&&Object.entries(t.attributes).forEach((function(e){var t=b(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},UK=new YL("Player",0),VK=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],FK={playsinline:"","webkit-playsinline":""},BK={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},jK=function(e){f(n,e);var t,r=g(n);function n(e){var t;u(this,n),h(m(t=r.call(this)),"_containerDom",void 0),h(m(t),"_videoDom",void 0),h(m(t),"__cumulativeTime",void 0),h(m(t),"userId",void 0),h(m(t),"renderMode",void 0),h(m(t),"mirrorType",B.MIRROR_TYPE_NONE),h(m(t),"isScreen",void 0),h(m(t),"isLocal",void 0),h(m(t),"played",!1),h(m(t),"_emitPlayFailed",!1),h(m(t),"_videoContainer",void 0),h(m(t),"emitVideoEvent",(function(e){var r,n,i={type:"video",rawEvent:e,readyState:(null===(r=t._videoDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:e.type,currentTime:(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime)||0,isScreen:t.isScreen};switch(t.emit("playback_event",i),e.type){case"canplay":case"loadeddata":t._internalPlay();break;case"playing":UK.print("VideoPlayerPlaying","[userId-".concat(t.userId,"] video element playing"))}})),h(m(t),"_internalPlay",(function(){var e;if(null!==(e=t._videoDom)&&void 0!==e&&e.paused){var r=t._videoDom.play();null!=r&&r.then&&r.catch((function(e){var r,n;t._emitPlayFailed||("AbortError"!==e.name?(t._emitPlayFailed=!0,FB.rtcError("video autoplay failed, userId: ".concat(t.userId,", ").concat(e.name),-1e3),t.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(r=t._videoDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:"autoplay-error",currentTime:(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime)||0,isScreen:t.isScreen})):FB.rtcError("video autoplay failed, userId: ".concat(t.userId,", ").concat(e.name),-1e3))}))}}));var i=e.renderDom,o=e.userId;t.renderMode=void 0!==e.renderMode?e.renderMode:M.RENDER_MODE_FIT;var a="string"==typeof i?document.getElementById(i):i;if(!a)throw new hP(dP.CANT_FIND_DOM,"can't find dom");return t._videoContainer=document.createElement("div"),t._videoContainer.style.width="100%",t._videoContainer.style.height="100%",t._videoContainer.style.position="relative",t._videoContainer.style.overflow="hidden",t._containerDom=a,t.userId=o,t.isLocal=!!e.isLocal,t.isScreen=!!e.isScreen,t._initVideo(),t}return l(n,[{key:"_initVideo",value:function(){this._videoDom||(this._videoDom=LK("video",{style:{width:"100%",height:"100%"},attributes:BK}),this._videoDom.id="".concat(this.userId,"_").concat(hD()),this.renderMode===M.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this._videoDom.style.objectFit="cover",this.mirror(this.mirrorType===B.MIRROR_TYPE_RENDER)),this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&VK.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.addEventListener(t,e.emitVideoEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._videoDom&&VK.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.5;if(SD&&dj.VIDEO_STALL){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(!dj.VIDEO_STALL)return;if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=fD();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=fD()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"playVideo",value:(t=c(o().mark((function e(t,r){var n,i,a,s,c=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=this._videoDom,UK.print("playVideo","play video track: ".concat(this.userId)),!(a&&a.srcObject instanceof MediaStream&&a.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{FB.rtcInvokeStatus("play video repeatedly",0,"playVideo",this.userId,0)}catch(TQ){}return e.abrupt("return");case 5:a||(this._initVideo(),a=this._videoDom),UK.print("playVideo","play video by dom: ".concat(null===(i=a)||void 0===i?void 0:i.id)),(s=new MediaStream).addTrack(t.getTrack("preprocessing")),a.srcObject=s,a&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),a&&!this._videoContainer.contains(a)&&this._videoContainer.appendChild(a),setTimeout((function(){return c._internalPlay()})),r&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"manuallyPlay",value:function(){if(UK.print("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new hP(dP.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||AD?this._videoDom.play():Promise.resolve()}},{key:"mirror",value:function(e){UK.print("mirror","".concat(this.userId," set mirror: ").concat(e)),this.mirrorType=e?B.MIRROR_TYPE_RENDER:B.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t=this._containerDom;(UK.print("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(this._videoDom.srcObject=null,null!=t&&t.contains(this._videoContainer)&&t.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){UK.print("destroy","video player: ".concat(this.userId)),this.stop(),E(p(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._videoDom&&(this._videoDom.srcObject=null,delete this._videoDom)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(BL.exports.EventEmitter),GK=function(e){f(i,e);var t,r,n=g(i);function i(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{divId:void 0,muted:!1,isScreen:!1},o=r.divId,a=r.muted,s=r.isScreen;if(u(this,i),h(m(t=n.call(this)),"_containerDom",void 0),h(m(t),"_audioDom",void 0),h(m(t),"_fakeAudioDom",void 0),h(m(t),"userId",void 0),h(m(t),"muted",!1),h(m(t),"_emitPlayFailed",!1),h(m(t),"played",!1),h(m(t),"isScreen",void 0),h(m(t),"_wechatTimer",void 0),h(m(t),"emitAudioEvent",(function(e){var r,n,i={type:"audio",rawEvent:e,readyState:(null===(r=t._audioDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:e.type,currentTime:(null===(n=t._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&UK.print("AudioPlayerPlaying","[userId-".concat(t.userId,"] audio element playing")),"pause"===e.type&&UK.print("AudioPlayerPause","[userId-".concat(t.userId,"] audio element pause")),RD&&AD&&("canplay"===e.type?(clearTimeout(t._wechatTimer),t._wechatTimer=window.setTimeout((function(){t._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(t._wechatTimer)),t.emit("playback_event",i)})),h(m(t),"_internalPlay",(function(){var e,r;if(QB("_internalPlay",{paused:null===(e=t._audioDom)||void 0===e?void 0:e.paused}),null!==(r=t._audioDom)&&void 0!==r&&r.paused)try{var n=t._audioDom.play();null!=n&&n.then&&n.catch((function(e){t._autoPlayError(e),FB.rtcError("audio autoplay failed, userId: ".concat(t.userId,": ").concat(e.message," ").concat(e.name),-1e3)})).then((function(){QB("_internalPlay successfully",{userId:t.userId})}))}catch(i){t._autoPlayError(i),FB.rtcError("audio autoplay failed, userId: ".concat(t.userId,": ").concat(i.message," ").concat(i.name),-1e3)}})),o){var c=document.getElementById(o);if(!c)throw new hP(dP.CANT_FIND_DOM,"can't find dom");t._containerDom=c}else t._containerDom=document.body;return t.userId=e,t.muted=a,t.isScreen=s,t._initAudio(),t}return l(i,[{key:"_initAudio",value:function(){this._audioDom||(this._audioDom=LK("audio",{style:{display:"none"},attributes:FK}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id="".concat(this.userId,"_").concat(hD()),this._containerDom.appendChild(this._audioDom)),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&VK.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.addEventListener(t,e.emitAudioEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._audioDom&&(VK.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=c(o().mark((function e(t){var r,n,i,a,s,c=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UK.print("playAudio","play audio track: ".concat(this.userId)),!((a=this._audioDom)&&a.srcObject instanceof MediaStream&&a.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:a||(this._initAudio(),a=this._audioDom),(s=new MediaStream).addTrack(t.getTrack("preprocessing")),a.srcObject=s,null===(n=a)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=a)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return c._internalPlay()})),this.played=!0;case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"pause",value:function(){if(!this._audioDom)throw new hP(dP.INVALID_PARAMS,"Player not found");this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e;if(UK.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new hP(dP.INVALID_PARAMS,"Player not found");if(!this.played)return Promise.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var t=this._audioDom.play();return null!=t&&t.then?t:Promise.resolve(t)}},{key:"setPlaybackDevice",value:(t=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UK.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,jH.enumerateAudioPlaybackDevices();case 3:if(e.sent.map((function(e){return e.deviceId})).includes(t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;UK.print("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){UK.print("destroy","audio player: ".concat(this.userId)),this.stop(),E(p(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom)}}]),i}(BL.exports.EventEmitter);function HK(e,t,r,n){var i=function(){var e=c(o().mark((function e(t,i){var a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null==n?void 0:n.get(i),Array.isArray(a)&&(a=null===(s=a)||void 0===s?void 0:s.find((function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:a&&(t instanceof jK&&a.videoTrack&&t.playVideo(a.videoTrack,a),t instanceof GK&&a.audioTrack&&t.playAudio(a.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var a=[];return e.forEach((function(e,t){return a.push(i(e,t))})),Promise.all(a)}var zK=function(){function e(){u(this,e),h(this,"_timer",void 0),h(this,"userMessage",void 0),h(this,"roomMessage",void 0),this.userMessage={},this.roomMessage={},this._setTimer()}return l(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(Object.keys(this.userMessage).length||Object.keys(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e=this;FB.rtcMessageStatistics(Object.keys(this.userMessage).map((function(t){return e.userMessage[t]})),Object.keys(this.roomMessage).map((function(t){return e.roomMessage[t]})),"")}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){this.userMessage["".concat(t,"-").concat(e)]||(this.userMessage["".concat(t,"-").concat(e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:1/0,dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){this._checkInitUserMessage(e,t),this.userMessage["".concat(t,"-").concat(e)].dc_send_total++,r&&this.userMessage["".concat(t,"-").concat(e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){this._checkInitUserMessage(e,t),this.userMessage["".concat(t,"-").concat(e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n=this.userMessage["".concat(t,"-").concat(e)];n&&(n.dc_send_fail++,this._handleUserFail(n,r))}},{key:"_handleUserFail",value:function(e,t){t&&(t.code||t.err)&&(t.code===dP.TIME_OUT?e.dc_fail_timeout++:t.err===Aj.NO_RECEIVER?e.dc_fail_no_receiver++:t.err===Aj.NO_RELAYPATH?e.dc_fail_no_relay_path++:t.err===Aj.TIMEOUT&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o=this.userMessage["".concat(t,"-").concat(e)];o&&(o.dc_send_ack++,o.dc_cost_time+=r,o.dc_cost_s2s+=n||0,o.dc_cost_peer_s2e+=i,o.dc_cost_e2s+=r-(n||0)-i,r<=100?(o.dc_send_ack_100++,o.dc_send_ack_200++,o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=200?(o.dc_send_ack_200++,o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=400?(o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=1e3&&o.dc_send_ack_1s++,r<o.dc_least_time&&(o.dc_least_time=r),r>o.dc_most_time&&(o.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:1/0,dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,NB.P2P,t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,NB.P2P)}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,NB.P2P,t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,NB.P2P,t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,NB.P2P_OUTSIDE_ROOM,t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,NB.P2P_OUTSIDE_ROOM)}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,NB.P2P_OUTSIDE_ROOM,t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,NB.P2P_OUTSIDE_ROOM,t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("",NB.P2SERVER,e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("",NB.P2SERVER,e)}},{key:"sendP2serveAck",value:function(e){this._sendUserAck("",NB.P2SERVER,e,0,0)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?this.sendP2serveAck(Date.now()-r):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),KK="object"==typeof global&&global&&global.Object===Object&&global,XK="object"==typeof self&&self&&self.Object===Object&&self,WK=KK||XK||Function("return this")(),qK=WK.Symbol,YK=Object.prototype,JK=YK.hasOwnProperty,QK=YK.toString,ZK=qK?qK.toStringTag:void 0;var $K=Object.prototype.toString;var eX=qK?qK.toStringTag:void 0;function tX(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":eX&&eX in Object(e)?function(e){var t=JK.call(e,ZK),r=e[ZK];try{e[ZK]=void 0;var n=!0}catch(o){}var i=QK.call(e);return n&&(t?e[ZK]=r:delete e[ZK]),i}(e):function(e){return $K.call(e)}(e)}function rX(e){return null!=e&&"object"==typeof e}var nX=Array.isArray;function iX(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function oX(e){return e}function aX(e){if(!iX(e))return!1;var t=tX(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var sX,cX=WK["__core-js_shared__"],uX=(sX=/[^.]+$/.exec(cX&&cX.keys&&cX.keys.IE_PROTO||""))?"Symbol(src)_1."+sX:"";var dX=Function.prototype.toString;var lX=/^\[object .+?Constructor\]$/,hX=Function.prototype,fX=Object.prototype,pX=hX.toString,vX=fX.hasOwnProperty,_X=RegExp("^"+pX.call(vX).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function mX(e){return!(!iX(e)||(t=e,uX&&uX in t))&&(aX(e)?_X:lX).test(function(e){if(null!=e){try{return dX.call(e)}catch(t){}try{return e+""}catch(t){}}return""}(e));var t}function yX(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var gX=Date.now;var SX,EX,bX,kX=function(){try{var e=mX(t=function(e,t){return null==e?void 0:e[t]}(Object,"defineProperty"))?t:void 0;return e({},"",{}),e}catch(r){}var t}(),TX=kX,IX=TX?function(e,t){return TX(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:oX,AX=(SX=IX,EX=0,bX=0,function(){var e=gX(),t=16-(e-bX);if(bX=e,t>0){if(++EX>=800)return arguments[0]}else EX=0;return SX.apply(void 0,arguments)}),RX=AX,CX=/^(?:0|[1-9]\d*)$/;function wX(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&CX.test(e))&&e>-1&&e%1==0&&e<t}function OX(e,t,r){"__proto__"==t&&TX?TX(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function xX(e,t){return e===t||e!=e&&t!=t}var NX=Object.prototype.hasOwnProperty;function PX(e,t,r){var n=e[t];NX.call(e,t)&&xX(n,r)&&(void 0!==r||t in e)||OX(e,t,r)}var DX=Math.max;function MX(e,t){return RX(function(e,t,r){return t=DX(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=DX(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),yX(e,this,s)}}(e,t,oX),e+"")}function LX(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function UX(e){return null!=e&&LX(e.length)&&!aX(e)}var VX=Object.prototype;function FX(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||VX)}function BX(e){return rX(e)&&"[object Arguments]"==tX(e)}var jX=Object.prototype,GX=jX.hasOwnProperty,HX=jX.propertyIsEnumerable,zX=BX(function(){return arguments}())?BX:function(e){return rX(e)&&GX.call(e,"callee")&&!HX.call(e,"callee")},KX=zX;var XX="object"==typeof exports&&exports&&!exports.nodeType&&exports,WX=XX&&"object"==typeof module&&module&&!module.nodeType&&module,qX=WX&&WX.exports===XX?WK.Buffer:void 0,YX=(qX?qX.isBuffer:void 0)||function(){return!1},JX={};JX["[object Float32Array]"]=JX["[object Float64Array]"]=JX["[object Int8Array]"]=JX["[object Int16Array]"]=JX["[object Int32Array]"]=JX["[object Uint8Array]"]=JX["[object Uint8ClampedArray]"]=JX["[object Uint16Array]"]=JX["[object Uint32Array]"]=!0,JX["[object Arguments]"]=JX["[object Array]"]=JX["[object ArrayBuffer]"]=JX["[object Boolean]"]=JX["[object DataView]"]=JX["[object Date]"]=JX["[object Error]"]=JX["[object Function]"]=JX["[object Map]"]=JX["[object Number]"]=JX["[object Object]"]=JX["[object RegExp]"]=JX["[object Set]"]=JX["[object String]"]=JX["[object WeakMap]"]=!1;var QX="object"==typeof exports&&exports&&!exports.nodeType&&exports,ZX=QX&&"object"==typeof module&&module&&!module.nodeType&&module,$X=ZX&&ZX.exports===QX&&KK.process,eW=function(){try{var e=ZX&&ZX.require&&ZX.require("util").types;return e||$X&&$X.binding&&$X.binding("util")}catch(t){}}(),tW=eW&&eW.isTypedArray,rW=tW?function(e){return function(t){return e(t)}}(tW):function(e){return rX(e)&&LX(e.length)&&!!JX[tX(e)]},nW=rW,iW=Object.prototype.hasOwnProperty;function oW(e,t){var r=nX(e),n=!r&&KX(e),i=!r&&!n&&YX(e),o=!r&&!n&&!i&&nW(e),a=r||n||i||o,s=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!iW.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||wX(u,c))||s.push(u);return s}var aW=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),sW=aW,cW=Object.prototype.hasOwnProperty;function uW(e){return UX(e)?oW(e):function(e){if(!FX(e))return sW(e);var t=[];for(var r in Object(e))cW.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var dW=Object.prototype.hasOwnProperty;function lW(e){if(!iX(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=FX(e),r=[];for(var n in e)("constructor"!=n||!t&&dW.call(e,n))&&r.push(n);return r}var hW,fW=(hW=function(e,t){!function(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?OX(r,s,c):PX(r,s,c)}}(t,function(e){return UX(e)?oW(e,!0):lW(e)}(t),e)},MX((function(e,t){var r=-1,n=t.length,i=n>1?t[n-1]:void 0,o=n>2?t[2]:void 0;for(i=hW.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!iX(r))return!1;var n=typeof t;return!!("number"==n?UX(r)&&wX(t,r.length):"string"==n&&t in r)&&xX(r[t],e)}(t[0],t[1],o)&&(i=n<3?void 0:i,n=1),e=Object(e);++r<n;){var a=t[r];a&&hW(e,a,r,i)}return e})));function pW(e,t){return function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}(t,(function(t){return e[t]}))}function vW(e){return null==e?[]:pW(e,uW(e))}var _W=de,mW=sr("iterator"),yW=!_W((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[mW]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),gW=Re,SW=2147483647,EW=/[^\0-\u007E]/,bW=/[.\u3002\uFF0E\uFF61]/g,kW="Overflow: input needs wider integers to process",TW=RangeError,IW=gW(bW.exec),AW=Math.floor,RW=String.fromCharCode,CW=gW("".charCodeAt),wW=gW([].join),OW=gW([].push),xW=gW("".replace),NW=gW("".split),PW=gW("".toLowerCase),DW=function(e){return e+22+75*(e<26)},MW=function(e,t,r){var n=0;for(e=r?AW(e/700):e>>1,e+=AW(e/t);e>455;)e=AW(e/35),n+=36;return AW(n+36*e/(e+38))},LW=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=CW(e,r++);if(i>=55296&&i<=56319&&r<n){var o=CW(e,r++);56320==(64512&o)?OW(t,((1023&i)<<10)+(1023&o)+65536):(OW(t,i),r--)}else OW(t,i)}return t}(e);var r,n,i=e.length,o=128,a=0,s=72;for(r=0;r<e.length;r++)(n=e[r])<128&&OW(t,RW(n));var c=t.length,u=c;for(c&&OW(t,"-");u<i;){var d=SW;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>AW((SW-a)/l))throw TW(kW);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>SW)throw TW(kW);if(n==o){for(var h=a,f=36;;){var p=f<=s?1:f>=s+26?26:f-s;if(h<p)break;var v=h-p,_=36-p;OW(t,RW(DW(p+v%_))),h=AW(v/_),f+=36}OW(t,RW(DW(h))),s=MW(a,l,u==c),a=0,u++}}a++,o++}return wW(t,"")},UW=ro,VW=ce,FW=ve,BW=Re,jW=le,GW=yW,HW=$n,zW=Sf,KW=Nd,XW=Fd,WW=Ln,qW=Xh,YW=We,JW=Kt,QW=ga,ZW=So,$W=Fr,eq=Je,tq=As,rq=cs,nq=be,iq=Ih,oq=yh,aq=rm,sq=DI,cq=sr("iterator"),uq="URLSearchParams",dq="URLSearchParamsIterator",lq=WW.set,hq=WW.getterFor(uq),fq=WW.getterFor(dq),pq=Object.getOwnPropertyDescriptor,vq=function(e){if(!jW)return VW[e];var t=pq(VW,e);return t&&t.value},_q=vq("fetch"),mq=vq("Request"),yq=vq("Headers"),gq=mq&&mq.prototype,Sq=yq&&yq.prototype,Eq=VW.RegExp,bq=VW.TypeError,kq=VW.decodeURIComponent,Tq=VW.encodeURIComponent,Iq=BW("".charAt),Aq=BW([].join),Rq=BW([].push),Cq=BW("".replace),wq=BW([].shift),Oq=BW([].splice),xq=BW("".split),Nq=BW("".slice),Pq=/\+/g,Dq=Array(4),Mq=function(e){return Dq[e-1]||(Dq[e-1]=Eq("((?:%[\\da-f]{2}){"+e+"})","gi"))},Lq=function(e){try{return kq(e)}catch(TQ){return e}},Uq=function(e){var t=Cq(e,Pq," "),r=4;try{return kq(t)}catch(TQ){for(;r;)t=Cq(t,Mq(r--),Lq);return t}},Vq=/[!'()~]|%20/g,Fq={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Bq=function(e){return Fq[e]},jq=function(e){return Cq(Tq(e),Vq,Bq)},Gq=XW((function(e,t){lq(this,{type:dq,iterator:iq(hq(e).entries),kind:t})}),"Iterator",(function(){var e=fq(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),Hq=function(e){this.entries=[],this.url=null,void 0!==e&&(eq(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===Iq(e,0)?Nq(e,1):e:tq(e)))};Hq.prototype={type:uq,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=oq(e);if(c)for(r=(t=iq(e,c)).next;!(n=FW(r,t)).done;){if(o=(i=iq($W(n.value))).next,(a=FW(o,i)).done||(s=FW(o,i)).done||!FW(o,i).done)throw bq("Expected sequence with length 2");Rq(this.entries,{key:tq(a.value),value:tq(s.value)})}else for(var u in e)JW(e,u)&&Rq(this.entries,{key:u,value:tq(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=xq(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=xq(t,"="),Rq(this.entries,{key:Uq(wq(r)),value:Uq(Aq(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],Rq(r,jq(e.key)+"="+jq(e.value));return Aq(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var zq=function(){qW(this,Kq);var e=arguments.length>0?arguments[0]:void 0;lq(this,new Hq(e))},Kq=zq.prototype;if(zW(Kq,{append:function(e,t){aq(arguments.length,2);var r=hq(this);Rq(r.entries,{key:tq(e),value:tq(t)}),r.updateURL()},delete:function(e){aq(arguments.length,1);for(var t=hq(this),r=t.entries,n=tq(e),i=0;i<r.length;)r[i].key===n?Oq(r,i,1):i++;t.updateURL()},get:function(e){aq(arguments.length,1);for(var t=hq(this).entries,r=tq(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){aq(arguments.length,1);for(var t=hq(this).entries,r=tq(e),n=[],i=0;i<t.length;i++)t[i].key===r&&Rq(n,t[i].value);return n},has:function(e){aq(arguments.length,1);for(var t=hq(this).entries,r=tq(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){aq(arguments.length,1);for(var r,n=hq(this),i=n.entries,o=!1,a=tq(e),s=tq(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?Oq(i,c--,1):(o=!0,r.value=s));o||Rq(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=hq(this);sq(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=hq(this).entries,n=QW(e,arguments.length>1?arguments[1]:void 0),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new Gq(this,"keys")},values:function(){return new Gq(this,"values")},entries:function(){return new Gq(this,"entries")}},{enumerable:!0}),HW(Kq,cq,Kq.entries,{name:"entries"}),HW(Kq,"toString",(function(){return hq(this).serialize()}),{enumerable:!0}),KW(zq,uq),UW({global:!0,constructor:!0,forced:!GW},{URLSearchParams:zq}),!GW&&YW(yq)){var Xq=BW(Sq.has),Wq=BW(Sq.set),qq=function(e){if(eq(e)){var t,r=e.body;if(ZW(r)===uq)return t=e.headers?new yq(e.headers):new yq,Xq(t,"content-type")||Wq(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),rq(e,{body:nq(0,tq(r)),headers:nq(0,t)})}return e};if(YW(_q)&&UW({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return _q(e,arguments.length>1?qq(arguments[1]):{})}}),YW(mq)){var Yq=function(e){return qW(this,gq),new mq(e,arguments.length>1?qq(arguments[1]):{})};gq.constructor=Yq,Yq.prototype=gq,UW({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Yq})}}var Jq,Qq=ro,Zq=le,$q=yW,eY=ce,tY=ga,rY=Re,nY=$n,iY=tS,oY=Xh,aY=Kt,sY=vv,cY=QP,uY=Dl,dY=wu.codeAt,lY=function(e){var t,r,n=[],i=NW(xW(PW(e),bW,"."),".");for(t=0;t<i.length;t++)r=i[t],OW(n,IW(EW,r)?"xn--"+LW(r):r);return wW(n,".")},hY=As,fY=Nd,pY=rm,vY={URLSearchParams:zq,getState:hq},_Y=Ln,mY=_Y.set,yY=_Y.getterFor("URL"),gY=vY.URLSearchParams,SY=vY.getState,EY=eY.URL,bY=eY.TypeError,kY=eY.parseInt,TY=Math.floor,IY=Math.pow,AY=rY("".charAt),RY=rY(/./.exec),CY=rY([].join),wY=rY(1..toString),OY=rY([].pop),xY=rY([].push),NY=rY("".replace),PY=rY([].shift),DY=rY("".split),MY=rY("".slice),LY=rY("".toLowerCase),UY=rY([].unshift),VY="Invalid scheme",FY="Invalid host",BY="Invalid port",jY=/[a-z]/i,GY=/[\d+-.a-z]/i,HY=/\d/,zY=/^0x/i,KY=/^[0-7]+$/,XY=/^\d+$/,WY=/^[\da-f]+$/i,qY=/[\0\t\n\r #%/:<>?@[\\\]^|]/,YY=/[\0\t\n\r #/:<>?@[\\\]^|]/,JY=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,QY=/[\t\n\r]/g,ZY=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)UY(t,e%256),e=TY(e/256);return CY(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t}(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=wY(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},$Y={},eJ=sY({},$Y,{" ":1,'"':1,"<":1,">":1,"`":1}),tJ=sY({},eJ,{"#":1,"?":1,"{":1,"}":1}),rJ=sY({},tJ,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),nJ=function(e,t){var r=dY(e,0);return r>32&&r<127&&!aY(t,e)?e:encodeURIComponent(e)},iJ={ftp:21,file:null,http:80,https:443,ws:80,wss:443},oJ=function(e,t){var r;return 2==e.length&&RY(jY,AY(e,0))&&(":"==(r=AY(e,1))||!t&&"|"==r)},aJ=function(e){var t;return e.length>1&&oJ(MY(e,0,2))&&(2==e.length||"/"===(t=AY(e,2))||"\\"===t||"?"===t||"#"===t)},sJ=function(e){return"."===e||"%2e"===LY(e)},cJ={},uJ={},dJ={},lJ={},hJ={},fJ={},pJ={},vJ={},_J={},mJ={},yJ={},gJ={},SJ={},EJ={},bJ={},kJ={},TJ={},IJ={},AJ={},RJ={},CJ={},wJ=function(e,t,r){var n,i,o,a=hY(e);if(t){if(i=this.parse(a))throw bY(i);this.searchParams=null}else{if(void 0!==r&&(n=new wJ(r,!0)),i=this.parse(a,null,n))throw bY(i);(o=SY(new gY)).bindURL(this),this.searchParams=o}};wJ.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||cJ,d=0,l="",h=!1,f=!1,p=!1;for(e=hY(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=NY(e,JY,"")),e=NY(e,QY,""),n=cY(e);d<=n.length;){switch(i=n[d],u){case cJ:if(!i||!RY(jY,i)){if(t)return VY;u=dJ;continue}l+=LY(i),u=uJ;break;case uJ:if(i&&(RY(GY,i)||"+"==i||"-"==i||"."==i))l+=LY(i);else{if(":"!=i){if(t)return VY;l="",u=dJ,d=0;continue}if(t&&(c.isSpecial()!=aY(iJ,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&iJ[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=EJ:c.isSpecial()&&r&&r.scheme==c.scheme?u=lJ:c.isSpecial()?u=vJ:"/"==n[d+1]?(u=hJ,d++):(c.cannotBeABaseURL=!0,xY(c.path,""),u=AJ)}break;case dJ:if(!r||r.cannotBeABaseURL&&"#"!=i)return VY;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=uY(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=CJ;break}u="file"==r.scheme?EJ:fJ;continue;case lJ:if("/"!=i||"/"!=n[d+1]){u=fJ;continue}u=_J,d++;break;case hJ:if("/"==i){u=mJ;break}u=IJ;continue;case fJ:if(c.scheme=r.scheme,i==Jq)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=uY(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=pJ;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=uY(r.path),c.query="",u=RJ;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=uY(r.path),c.path.length--,u=IJ;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=uY(r.path),c.query=r.query,c.fragment="",u=CJ}break;case pJ:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=IJ;continue}u=mJ}else u=_J;break;case vJ:if(u=_J,"/"!=i||"/"!=AY(l,d+1))continue;d++;break;case _J:if("/"!=i&&"\\"!=i){u=mJ;continue}break;case mJ:if("@"==i){h&&(l="%40"+l),h=!0,o=cY(l);for(var v=0;v<o.length;v++){var _=o[v];if(":"!=_||p){var m=nJ(_,rJ);p?c.password+=m:c.username+=m}else p=!0}l=""}else if(i==Jq||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=cY(l).length+1,l="",u=yJ}else l+=i;break;case yJ:case gJ:if(t&&"file"==c.scheme){u=kJ;continue}if(":"!=i||f){if(i==Jq||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return FY;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=TJ,t)return;continue}"["==i?f=!0:"]"==i&&(f=!1),l+=i}else{if(""==l)return FY;if(a=c.parseHost(l))return a;if(l="",u=SJ,t==gJ)return}break;case SJ:if(!RY(HY,i)){if(i==Jq||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var y=kY(l,10);if(y>65535)return BY;c.port=c.isSpecial()&&y===iJ[c.scheme]?null:y,l=""}if(t)return;u=TJ;continue}return BY}l+=i;break;case EJ:if(c.scheme="file","/"==i||"\\"==i)u=bJ;else{if(!r||"file"!=r.scheme){u=IJ;continue}if(i==Jq)c.host=r.host,c.path=uY(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=uY(r.path),c.query="",u=RJ;else{if("#"!=i){aJ(CY(uY(n,d),""))||(c.host=r.host,c.path=uY(r.path),c.shortenPath()),u=IJ;continue}c.host=r.host,c.path=uY(r.path),c.query=r.query,c.fragment="",u=CJ}}break;case bJ:if("/"==i||"\\"==i){u=kJ;break}r&&"file"==r.scheme&&!aJ(CY(uY(n,d),""))&&(oJ(r.path[0],!0)?xY(c.path,r.path[0]):c.host=r.host),u=IJ;continue;case kJ:if(i==Jq||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&oJ(l))u=IJ;else if(""==l){if(c.host="",t)return;u=TJ}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=TJ}continue}l+=i;break;case TJ:if(c.isSpecial()){if(u=IJ,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=Jq&&(u=IJ,"/"!=i))continue}else c.fragment="",u=CJ;else c.query="",u=RJ;break;case IJ:if(i==Jq||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=LY(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||xY(c.path,"")):sJ(l)?"/"==i||"\\"==i&&c.isSpecial()||xY(c.path,""):("file"==c.scheme&&!c.path.length&&oJ(l)&&(c.host&&(c.host=""),l=AY(l,0)+":"),xY(c.path,l)),l="","file"==c.scheme&&(i==Jq||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)PY(c.path);"?"==i?(c.query="",u=RJ):"#"==i&&(c.fragment="",u=CJ)}else l+=nJ(i,tJ);break;case AJ:"?"==i?(c.query="",u=RJ):"#"==i?(c.fragment="",u=CJ):i!=Jq&&(c.path[0]+=nJ(i,$Y));break;case RJ:t||"#"!=i?i!=Jq&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":nJ(i,$Y)):(c.fragment="",u=CJ);break;case CJ:i!=Jq&&(c.fragment+=nJ(i,eJ))}d++}},parseHost:function(e){var t,r,n;if("["==AY(e,0)){if("]"!=AY(e,e.length-1))return FY;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,d=null,l=0,h=function(){return AY(e,l)};if(":"==h()){if(":"!=AY(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&RY(WY,h());)t=16*t+kY(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!RY(HY,h()))return;for(;RY(HY,h());){if(o=kY(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;c[u++]=t}else{if(null!==d)return;l++,d=++u}}if(null!==d)for(a=u-d,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[d+a-1],c[d+--a]=s;else if(8!=u)return;return c}(MY(e,1,-1)),!t)return FY;this.host=t}else if(this.isSpecial()){if(e=lY(e),RY(qY,e))return FY;if(t=function(e){var t,r,n,i,o,a,s,c=DY(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==AY(i,0)&&(o=RY(zY,i)?16:8,i=MY(i,8==o?1:2)),""===i)a=0;else{if(!RY(10==o?XY:8==o?KY:WY,i))return e;a=kY(i,o)}xY(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=IY(256,5-t))return null}else if(a>255)return null;for(s=OY(r),n=0;n<r.length;n++)s+=r[n]*IY(256,3-n);return s}(e),null===t)return FY;this.host=t}else{if(RY(YY,e))return FY;for(t="",r=cY(e),n=0;n<r.length;n++)t+=nJ(r[n],$Y);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return aY(iJ,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&oJ(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=ZY(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+CY(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw bY(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new OJ(e.path[0]).origin}catch(TQ){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+ZY(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(hY(e)+":",cJ)},getUsername:function(){return this.username},setUsername:function(e){var t=cY(hY(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=nJ(t[r],rJ)}},getPassword:function(){return this.password},setPassword:function(e){var t=cY(hY(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=nJ(t[r],rJ)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?ZY(e):ZY(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,yJ)},getHostname:function(){var e=this.host;return null===e?"":ZY(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,gJ)},getPort:function(){var e=this.port;return null===e?"":hY(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=hY(e))?this.port=null:this.parse(e,SJ))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+CY(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,TJ))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=hY(e))?this.query=null:("?"==AY(e,0)&&(e=MY(e,1)),this.query="",this.parse(e,RJ)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=hY(e))?("#"==AY(e,0)&&(e=MY(e,1)),this.fragment="",this.parse(e,CJ)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var OJ=function(e){var t=oY(this,xJ),r=pY(arguments.length,1)>1?arguments[1]:void 0,n=mY(t,new wJ(e,!1,r));Zq||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},xJ=OJ.prototype,NJ=function(e,t){return{get:function(){return yY(this)[e]()},set:t&&function(e){return yY(this)[t](e)},configurable:!0,enumerable:!0}};if(Zq&&(iY(xJ,"href",NJ("serialize","setHref")),iY(xJ,"origin",NJ("getOrigin")),iY(xJ,"protocol",NJ("getProtocol","setProtocol")),iY(xJ,"username",NJ("getUsername","setUsername")),iY(xJ,"password",NJ("getPassword","setPassword")),iY(xJ,"host",NJ("getHost","setHost")),iY(xJ,"hostname",NJ("getHostname","setHostname")),iY(xJ,"port",NJ("getPort","setPort")),iY(xJ,"pathname",NJ("getPathname","setPathname")),iY(xJ,"search",NJ("getSearch","setSearch")),iY(xJ,"searchParams",NJ("getSearchParams")),iY(xJ,"hash",NJ("getHash","setHash"))),nY(xJ,"toJSON",(function(){return yY(this).serialize()}),{enumerable:!0}),nY(xJ,"toString",(function(){return yY(this).serialize()}),{enumerable:!0}),EY){var PJ=EY.createObjectURL,DJ=EY.revokeObjectURL;PJ&&nY(OJ,"createObjectURL",tY(PJ,EY)),DJ&&nY(OJ,"revokeObjectURL",tY(DJ,EY))}fY(OJ,"URL"),Qq({global:!0,constructor:!0,forced:!$q,sham:!Zq},{URL:OJ});var MJ=function(){var e=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(URL.createObjectURL(new Blob([t],r))),e.prev=1,n.muted=!0,e.next=5,n.play();case 5:return n.pause(),e.abrupt("return",!0);case 9:return e.prev=9,e.t0=e.catch(1),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r){return e.apply(this,arguments)}}(),LJ=Object.defineProperty,UJ=Object.getOwnPropertyDescriptor,VJ=function(e,t,r,n){for(var i,o=n>1?void 0:n?UJ(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&LJ(t,r,o),o},FJ=function(){function e(t){u(this,e),h(this,"_sharedAudioContext",new AudioContext),h(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),h(this,"_localGainNode",this._sharedAudioContext.createGain()),h(this,"_bufferGainNode",this._sharedAudioContext.createGain()),h(this,"_audioBufferSource",void 0),h(this,"_localSource",void 0),h(this,"_context",void 0),h(this,"_failedAudioList",[]),h(this,"_startingIds",new Map),h(this,"mixingMap",new Map),h(this,"resourcesCache",new Map),h(this,"volumeConfig",new Map),h(this,"cachedBuffer",[]),h(this,"id","AudioMixingManager"),this._context=t,this._localGainNode.gain.value=1}var t,r,n;return l(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v,_,m,y=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),console.log(this._startingIds),i=n.playCount,KD(a=n.type,"mixingType",vW(re)),s=this._context.getLocalAudioTrack()){e.next=10;break}return e.abrupt("return");case 10:if((c=s.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([c])),null!=(u=this.mixingMap.get(t))&&u.audioNode){u.audioNode.pause(),this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_STOPPED,error:lP.AUDIO_MIXING_ERROR_OK});try{u.gainNode.disconnect(this._audioDestination),u.audioSource.disconnect(u.gainNode)}catch(o){}}if(!(l=this.resourcesCache.get(t))||l.filePath!==r){e.next=19;break}d=l.getAudioNode(),e.next=32;break;case 19:return e.next=21,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw y._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FAILED,error:lP.AUDIO_MIXING_ERROR_START_FAILED}),new hP(dP.LOAD_RESOURCES_FAILED,e.statusText)}));case 21:return h=e.sent,r.endsWith("mp3")?f={type:"audio/mpeg"}:r.endsWith("aac")&&(f={type:"audio/aac"}),e.next=25,MJ(h,f);case 25:if(e.sent){e.next=29;break}throw this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FAILED,error:lP.AUDIO_MIXING_ERROR_START_FAILED}),new hP(dP.LOAD_RESOURCES_FAILED,"invalid audio resource");case 29:(d=new Audio).crossOrigin="anonymous",d.src=URL.createObjectURL(new Blob([h],f));case 32:return i<=0?d.loop=!0:i>0&&(p=i,d.onended=function(){--p>0?d.play():(y.mixingMap.delete(t),y._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FINISHED,error:lP.AUDIO_MIXING_ERROR_OK}))}),e.prev=33,e.next=36,d.play();case 36:e.next=43;break;case 38:e.prev=38,e.t0=e.catch(33),console.error(e.t0),this._failedAudioList.push(d),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:L.STREAM_INDEX_MAIN,mediaType:U.AUDIO});case 43:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(d),_=this._sharedAudioContext.createGain(),m=this.volumeConfig.get(t),_.gain.value=m?m/100:1,v.connect(_).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:d,gainNode:_,type:"file"}),a===re.PUBLISH)try{_.disconnect(this._sharedAudioContext.destination)}catch(o){}else _.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_PLAYING,error:lP.AUDIO_MIXING_ERROR_OK});case 53:case"end":return e.stop()}}),e,this,[[33,38]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:ne.AUDIO_MIXING_STATE_STOPPED,error:lP.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:ne.AUDIO_MIXING_STATE_PAUSED,error:lP.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:ne.AUDIO_MIXING_STATE_PLAYING,error:lP.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=c(o().mark((function e(t,r){var n,i,a=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw new hP(dP.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(a._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FAILED,error:lP.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof hP)throw e;throw new hP(dP.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,r.endsWith("mp3")?i={type:"audio/mpeg"}:r.endsWith("aac")&&(i={type:"audio/aac"}),e.next=7,MJ(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FAILED,error:lP.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new hP(dP.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_PRELOADED,error:lP.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){return new Audio(URL.createObjectURL(new Blob([n],i)))},filePath:r});case 13:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unloadAudioMixing",value:function(e){this.resourcesCache.has(e)&&this.resourcesCache.delete(e)}},{key:"getAudioMixingVolume",value:function(e){var t=this.mixingMap.get(e);return t?100*t.gainNode.gain.value:0}},{key:"setAudioMixingVolume",value:function(e,t){t<0?t=0:t>400&&(t=400),this.volumeConfig.set(e,t);var r=this.mixingMap.get(e);r&&(r.gainNode.gain.value=Number(t)/100)}},{key:"getAudioMixingDuration",value:function(e){var t=this.mixingMap.get(e),r=this.mixingMap.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.audioNode.duration:0:0}},{key:"getAudioMixingCurrentPosition",value:function(e){var t=this.mixingMap.get(e);return t?1e3*t.audioNode.currentTime:0}},{key:"setAudioMixingPosition",value:function(e,t){var r=this.mixingMap.get(e);r&&(r.audioNode.currentTime=t/1e3,r.audioNode.play())}},{key:"enableAudioMixingBuffer",value:function(e){KD(e,"type",vW(re));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===re.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(n){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:ne.AUDIO_MIXING_STATE_PCM_ENABLED,error:lP.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:ne.AUDIO_MIXING_STATE_PCM_DISABLED,error:lP.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(r){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(t){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=c(o().mark((function e(){var t,r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=A(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:L.STREAM_INDEX_MAIN,mediaType:U.AUDIO}),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new Map}}]),e}();VJ([YB("default","id","filePath","options")],FJ.prototype,"startAudioMixing",1),VJ([YB("default","id")],FJ.prototype,"stopAudioMixing",1),VJ([YB("default","id")],FJ.prototype,"pauseAudioMixing",1),VJ([YB("default","id")],FJ.prototype,"resumeAudioMixing",1),VJ([YB("default","id")],FJ.prototype,"preloadAudioMixing",1),VJ([YB("default","id")],FJ.prototype,"unloadAudioMixing",1),VJ([YB("default","id")],FJ.prototype,"getAudioMixingVolume",1),VJ([YB("default","id","volume")],FJ.prototype,"setAudioMixingVolume",1),VJ([YB("default","id")],FJ.prototype,"getAudioMixingDuration",1),VJ([YB("default","id")],FJ.prototype,"getAudioMixingCurrentPosition",1),VJ([YB("default","id","position")],FJ.prototype,"setAudioMixingPosition",1),VJ([YB("default","type")],FJ.prototype,"enableAudioMixingBuffer",1),VJ([YB()],FJ.prototype,"disableAudioMixingBuffer",1),VJ([YB("default","buffer")],FJ.prototype,"pushAudioMixingBuffer",1);var BJ=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(BJ||{}),jJ=new YL("RTMClient",1),GJ=function(e){f(_,e);var t,r,n,i,a,s,d,v=g(_);function _(e){var t;return u(this,_),h(m(t=v.call(this)),"_dataChannelSignal",null),h(m(t),"_handler",null),h(m(t),"_dataChannelSignalState",EK.DISCONNECTED),h(m(t),"_loginSessionId",null),h(m(t),"_userId",null),h(m(t),"_token",null),h(m(t),"_isReconnecting",!1),h(m(t),"_reconnectTimer",null),h(m(t),"_loginResolveCallback",null),h(m(t),"_loginRejectCallback",null),h(m(t),"_iceConfigNode",null),h(m(t),"_wait_login_token",!1),h(m(t),"_serverParamsCache",void 0),t._appId=e,t}return l(_,[{key:"login",value:function(e,t){var r=this;return new Promise((function(n,i){if(jJ.print("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new hP(dP.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new hP(dP.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,HB.setStats({rtc_app_id:r._appId,user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():(jJ.print("login","init dataChannelSingling"),r._dataChannelSignalState=EK.CONNECTING,r._createDataChannelSignaling(t).then((function(e){r._dataChannelSignal=e,r._login()})).catch((function(){r._onDisconnect()})))}))}},{key:"logout",value:(d=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new hP(dP.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId},{functionType:xj.C2RTM}).catch((function(){}));case 4:this._closeDataChannelSignaling(),this._clearState();case 6:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"updateLoginToken",value:(s=c(o().mark((function e(t){var r=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Promise((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(a=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new hP(dP.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,peerUserId:t},{functionType:xj.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(i=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new hP(dP.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setServerParams",value:(n=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,zD(t,"signature"),zD(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new hP(dP.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,signature:t,url:r},{functionType:xj.C2RTM}).catch((function(e){throw new hP(dP.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return n.apply(this,arguments)})},{key:"sendServerMessage",value:(r=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new hP(dP.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:"",room:"",type:Ij.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){this._clearState(),this._closeDataChannelSignaling(),E(p(_.prototype),"removeAllListeners",this).call(this),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=hD();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:_D.token2auth(this._appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:dj.VERSION,deviceId:oj.getDeviceId(),appId:this._appId,userId:this._userId}},{functionType:xj.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=dP.INVALID_PARAMS,n="Invalid userId"):(r=dP.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=dP.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new hP(r,a||n))})).finally((function(){e._loginResolveCallback=null,e._loginRejectCallback=null}))}}},{key:"_createDataChannelSignaling",value:(t=c(o().mark((function e(t){var r,n,i,a,s,c,u,d=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new Lj,i=this._iceConfigNode){e.next=16;break}return e.prev=3,e.next=6,null==n?void 0:n.getAccessNode(this._appId,"",t,oj.getDeviceId(),"");case 6:if(a=e.sent,i=a[0]){e.next=10;break}throw new Error;case 10:e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(3),QB("rtm.login.getNodeFailed","",0,!0),new hP(dP.ICE_SERVER_WRONG,"get ICE config failed");case 16:return QB("rtm.login.getNodeSuccess",i,0,!0),jJ.print("_createDataChannelSignaling()","get node success",i),this._handler=sK(BB),null===(r=this._handler)||void 0===r||r.once("disconnect",(function(){jJ.print("_createDataChannelSignaling()","recv BasicHandler event: disconnect"),d._onDisconnect()})),e.prev=20,e.next=23,null===(c=this._handler)||void 0===c?void 0:c.connect(i);case 23:s=e.sent,jJ.print("_createDataChannelSignaling()","establish peerConnection success"),this._dataChannelSignalState=EK.CONNECTED,e.next=33;break;case 28:throw e.prev=28,e.t1=e.catch(20),this._iceConfigNode=null,this._dataChannelSignalState=EK.DISCONNECTED,new hP(dP.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t1);case 33:return u=new Pj(s),jJ.print("_createDataChannelSignaling()","send ping"),u.sendPingSignaling(),u.once("close",(function(){jJ.print("_createDataChannelSignaling()","recv DataChannelSignaling event: close"),d._onDisconnect()})),u.on(gj.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){d.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),u.on(gj.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){d.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),u.on(gj.USER_DISCONNECTION,(function(){d.emit("onUserDisconnection"),d._clearState()})),u.on(gj.NODE_CHANGE,(function(e){QB("rtm.nodeChange",JSON.stringify(e),0,!0),Array.isArray(e.nodes)&&e.nodes.length&&(d._iceConfigNode=e.nodes[0]),d._loginResolveCallback&&d._loginRejectCallback?d._login():d._reconnect()})),e.abrupt("return",u);case 42:case"end":return e.stop()}}),e,this,[[3,12],[20,28]])}))),function(e){return t.apply(this,arguments)})},{key:"_closeDataChannelSignaling",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),this._dataChannelSignal=null,null===(t=this._handler)||void 0===t||t.destroy(),this._handler=null}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==EK.CONNECTED)throw new hP(dP.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_onDisconnect",value:function(){this._dataChannelSignalState=EK.DISCONNECTED,this._closeDataChannelSignaling(),navigator.onLine?this._reconnect():this._reconnectTimer=self.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_reconnect",value:function(){var e=this;!this._isReconnecting&&this._userId&&(jJ.print("_reconnect()","start reconnect..."),this._isReconnecting=!0,this._createDataChannelSignaling(this._userId).then((function(t){jJ.print("_reconnect()","reconnect success!"),e._dataChannelSignal=t,e._login(),e._reconnectTimer=null})).catch((function(t){jJ.print("_reconnect()","Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=self.setTimeout(e._reconnect.bind(e),3e3)})).finally((function(){e._isReconnecting=!1})))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,null!==this._reconnectTimer&&(self.clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}}]),_}(BL.exports.EventEmitter),HJ=function(e){f(a,e);var t,r,n,i=g(a);function a(e){var t;return u(this,a),h(m(t=i.call(this)),"_mediaServerClient",void 0),h(m(t),"_appId",void 0),h(m(t),"_reconnectTimer",void 0),h(m(t),"remoteStreams",void 0),t._appId=e,t.remoteStreams=new Map,t}return l(a,[{key:"connect",value:(n=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new kK({avSync:!0}),this._bindEvents(),e.next=4,this._mediaServerClient.connect(this._appId);case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new hP(dP.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new Yz(t,t,!1,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=BD(e),i=0;i<t.seiCount;i++)n.emit(lK.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){this.remoteStreams=new Map,this._mediaServerClient&&this._mediaServerClient.destroy()}},{key:"_handleReconnected",value:(t=c(o().mark((function e(){var t,r,n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:clearTimeout(this._reconnectTimer),t=A(this.remoteStreams);try{for(n=function(){var e=b(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(lK.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_reconnect",value:function(){var e=this;this._mediaServerClient.removeAllListeners(),this._mediaServerClient.destroy(),navigator.onLine?this.connect().then(this._handleReconnected.bind(this)):this._reconnectTimer=window.setTimeout((function(){return e.connect().then(e._handleReconnected.bind(e))}),3e3)}},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on(Ej.ABNORMAL_DISCONNECTION,this._reconnect.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),a}(ZL),zJ=new YL("AudioDeviceManager",1),KJ=function(e){f(a,e);var t,r,n,i=g(a);function a(e){var t;return u(this,a),h(m(t=i.call(this)),"_audioLevelFetcher",void 0),h(m(t),"_playbackDeviceTestTimer",void 0),h(m(t),"_audioElement",void 0),h(m(t),"_audioTrack",void 0),h(m(t),"_mediaRecorder",void 0),h(m(t),"_recoderTimer",void 0),h(m(t),"_isAudioPlaybackDeviceTesting",!1),h(m(t),"_isAudioDeviceRecordTesting",!1),h(m(t),"_audioCaptureAndRecoderResolve",void 0),h(m(t),"_onAutoplayFailed",void 0),t._extensionManager=e,t}return l(a,[{key:"startAudioPlaybackDeviceTest",value:(n=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new hP(dP.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,zJ.print("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),zJ.print("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return n.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(zJ.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(r=c(o().mark((function e(t,r){var n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(window.MediaRecorder){e.next=2;break}throw new hP(dP.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 2:if(!this._isAudioDeviceRecordTesting){e.next=4;break}throw new hP(dP.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 4:return this._isAudioDeviceRecordTesting=!0,zJ.print("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){zJ.print("startAudioDeviceRecordTest()","".concat(3e4,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),n._stopAudioCaptureAndRecoder()}),3e4),e.prev=7,this._onAutoplayFailed=r,e.next=11,this._startAudioCaptureAndRecoder(t);case 11:e.next=18;break;case 13:throw e.prev=13,e.t0=e.catch(7),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 18:delete this._audioCaptureAndRecoderResolve;case 19:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e,t){return r.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){zJ.print("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(zJ.print("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"destroy",value:function(){zJ.print("destroy()","Invoke"),E(p(a.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:function(e,t){var r=this;return zJ.print("_playAudioFile()","Invoke url=".concat(e,"; loop=").concat(t.loop)),new Promise((function(n,i){var a,s,u=LK("audio",{attributes:{src:e,crossOrigin:"anonymous"}});r._audioElement=u,u.loop=t.loop,r._audioLevelFetcher=new HH(u),u.onplaying=function(){u.onplaying=null,zJ.print("_playAudioFile()","onplaying"),n()},u.onerror=function(){var e=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:zJ.print("_playAudioFile()","onerror",t),n=t.message||(null==u||null===(r=u.error)||void 0===r?void 0:r.message),i(new hP(dP.LOAD_RESOURCES_FAILED,"Failed to play recorded audio"+(n?", reason: ".concat(n):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),null===(a=u.play())||void 0===a||null===(s=a.catch)||void 0===s||s.call(a,(function(e){zJ.print("_playAudioFile()","autoplay error",e);var t="Failed to play recorded audio, ".concat(e.name,": ").concat(e.message);"NotAllowedError"===e.name&&r._onAutoplayFailed?r._onAutoplayFailed((function(){var e;return Promise.all([null===(e=r._audioLevelFetcher)||void 0===e?void 0:e.resume(),u.play()])})):i(new hP(dP.LOAD_RESOURCES_FAILED,t))}))}))}},{key:"_destroyAudioElement",value:function(){this._audioElement&&(zJ.print("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(zJ.print("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(zJ.print("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(t=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_z({},this._extensionManager);case 2:return this._audioTrack=e.sent,i=this._audioTrack.getTrack("preprocessing"),r=qH.get(i),zJ.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Promise((function(e,i){var a;"function"==typeof MediaRecorder.isTypeSupported&&(a=["audio/webm","audio/mp4"].find((function(e){return MediaRecorder.isTypeSupported(e)})),zJ.print("startAudioDeviceRecordTest()","use mimeType: ".concat(a))),n._mediaRecorder=new MediaRecorder(r,a?{mimeType:a}:void 0);var s=n._mediaRecorder.mimeType;n._mediaRecorder.ondataavailable=function(){var r=c(o().mark((function r(a){var c,u;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!n._isAudioDeviceRecordTesting){r.next=16;break}return zJ.print("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),u=new Blob([a.data],{type:s}),r.prev=3,r.next=6,n._playAudioFile(URL.createObjectURL(u),{loop:!1});case 6:r.next=11;break;case 8:return r.prev=8,r.t0=r.catch(3),r.abrupt("return",i(r.t0));case 11:n._startEmitAudioPlaybackDeviceTestVolume(t),null===(c=n._audioElement)||void 0===c||c.addEventListener("ended",(function(){n.stopAudioDevicePlayTest(),e()})),n._audioCaptureAndRecoderResolve=e,r.next=17;break;case 16:e();case 17:case"end":return r.stop()}}),r,null,[[3,8]])})));return function(e){return r.apply(this,arguments)}}(),n._mediaRecorder.onerror=function(e){i(new hP(dP.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},n._mediaRecorder.start()})));case 6:case"end":return e.stop()}var i}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}}]),a}(BL.exports.EventEmitter),XJ=function(){function e(){u(this,e),h(this,"engineBAC",{adm:{},agc:{},ans:{}}),h(this,"engineANM",{}),h(this,"bitrate",void 0),h(this,"sampleRate",void 0),h(this,"channel",void 0),h(this,"aec",void 0),h(this,"agc",void 0),h(this,"ans",void 0),this._init()}var t;return l(e,[{key:"_init",value:(t=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new Uj,e.next=3,t.getAudioProfile();case 3:this.engineBAC=e.sent;case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateEngineBAC",value:function(e){e&&(this.engineBAC={codec:i(i({},this.engineBAC.codec),e.codec),adm:i(i({},this.engineBAC.adm),e.adm)},this.setAEC(!!e.aec),this.setAGC(!!e.agc),this.setANS(!!e.ans))}},{key:"updateEngineANM",value:function(e){e&&(this.engineANM=e)}},{key:"setAudioProfile",value:function(e){var t,r,n;switch(e){case J.fluent:r=16e3,t=24e3;break;case J.standard:r=48e3,t=48e3;break;case J.hd:r=48e3,t=128e3,n=2;break;case J.standardStereo:r=48e3,t=8e4,n=2;break;case J.hdMono:r=48e3,t=128e3}t&&(this.bitrate=t),n&&(this.channel=n),r&&(this.sampleRate=r)}},{key:"setBitrate",value:function(e){e>128e3&&(e=128e3),this.bitrate=e}},{key:"setAEC",value:function(e){this.aec=e}},{key:"setAGC",value:function(e){this.agc=e}},{key:"setANS",value:function(e){this.ans=e}},{key:"getOpusConfigStr",value:function(){var e=";",t=this.config;return console.log("config",t),t.bitrate&&(e+="maxaveragebitrate=".concat(t.bitrate,";")),t.encSampleRate&&(e+="sprop-maxcapturerate=".concat(t.encSampleRate,";")),t.playbackRate&&(e+="maxplaybackrate=".concat(t.playbackRate,";")),t.encChannel&&t.encChannel>1&&(e+="sprop-stereo=1;"),t.channel&&t.channel>1&&(e+="stereo=1;"),console.log("configStr",e),e.slice(0,-1)}},{key:"config",get:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,f,p,v,_;return{bitrate:this.bitrate||(null===(e=this.engineANM.enc_param)||void 0===e?void 0:e.bitrate)||0,playChannel:(null===(t=this.engineBAC.adm)||void 0===t||null===(r=t.play)||void 0===r?void 0:r.chn)||1,encChannel:this.channel||(null===(n=this.engineANM)||void 0===n||null===(i=n.enc_param)||void 0===i?void 0:i.chn)||(null===(o=this.engineBAC.adm)||void 0===o||null===(a=o.record)||void 0===a?void 0:a.chn),channel:this.channel||(null===(s=this.engineBAC.adm)||void 0===s||null===(c=s.record)||void 0===c?void 0:c.chn),aec:this.aec,agc:this.agc,ans:this.ans,encSampleRate:this.sampleRate||(null===(u=this.engineBAC.codec)||void 0===u?void 0:u.enc_fs)||(null===(d=this.engineANM.enc_param)||void 0===d?void 0:d.sr)||(null===(l=this.engineBAC.adm)||void 0===l||null===(h=l.record)||void 0===h?void 0:h.sr),sampleRate:this.sampleRate||(null===(f=this.engineBAC.adm)||void 0===f||null===(p=f.record)||void 0===p?void 0:p.sr),playbackRate:null===(v=this.engineBAC.adm)||void 0===v||null===(_=v.play)||void 0===_?void 0:_.sr}}}]),e}(),WJ=new YL("VideoSnapshot",1),qJ=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},YJ=function(){var e=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),a=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(s=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?a.setTransform(-1,0,0,1,t,0):a.setTransform(1,0,0,1,0,0),a.drawImage(e,0,0,t,n),a.getImageData(0,0,t,n)},c=Date.now(),!(u=qJ(n))){e.next=16;break}return WJ.print("takeSnapshot","VideoPlayer already set."),e.next=11,s(u,u.videoWidth,u.videoHeight);case 11:return d=e.sent,WJ.print("takeSnapshot","success, cost ".concat(Date.now()-c,"ms")),e.abrupt("return",d);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(l=new window.ImageCapture(t)).track.readyState||!l.track.enabled||l.track.muted){e.next=29;break}return WJ.print("takeSnapshot","use ImageCapture"),e.t0=s,e.next=23,l.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return h=e.sent,WJ.print("takeSnapshot","success, cost ".concat(Date.now()-c,"ms")),e.abrupt("return",h);case 29:return WJ.print("takeSnapshot","use temp video"),e.abrupt("return",new Promise((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=s(i,i.videoWidth,i.videoHeight);WJ.print("takeSnapshot","success, cost ".concat(Date.now()-c,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),JJ=function(){return{url:"",video:{codec:$.H264,width:640,height:360,fps:15,gop:2,kBitRate:QJ(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Z.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function QJ(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function ZJ(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new hP(dP.INVALID_PARAMS,"Invalid rtmp address")}function $J(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new hP(dP.INVALID_PARAMS,"regions should not be empty.");var t,r=A(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new hP(dP.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new hP(dP.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function eQ(e,t){var r,n,i,o=function(e,r){var n=e.reduce((function(e,t){return null==e?void 0:e[t]}),t),i=e.reduce((function(e,t){return null==e?void 0:e[t]}),JJ());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),u=o(["video","fps"],(function(e){return e>=1&&e<=60})),d=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,l=o(["audio","sampleRate"],(function(e){return!![32e3,44100,48e3].find((function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:l<100?1e3*l:l,channels:o(["audio","channels"],(function(e){return[1,2].includes(e)})),profile:o(["audio","AACProfile"],(function(e){return[Z.LC,Z.HEv1,Z.HEv2].includes(e)}))},video:{codec:o(["video","codec"],(function(e){return["H264","H265"].includes(e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(d>=16&&d<=1e4?d:QJ(s,c,u)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:i.map((function(e){return{alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,uid:e.userId,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,renderMode:e.renderMode&&[1,2,3].includes(e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&[0,1,2].includes(e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}var tQ,rQ={getDefaultValue:JJ,checkStartParams:function(e){var t;ZJ(e.url),$J(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&ZJ(e.url),$J(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return eQ("started",e)},getUpdateParams:function(e){return eQ("layoutChanged",e)}},nQ=Object.defineProperty,iQ=Object.getOwnPropertyDescriptor,oQ=function(e,t,r,n){for(var i,o=n>1?void 0:n?iQ(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&nQ(t,r,o),o},aQ=new YL("Engine",0),sQ=function(e){f(Ge,e);var t,r,n,a,s,d,v,_,y,S,k,T,I,w,O,x,D,M,j,G,H,z,W,q,J,Z,$,ee,te,ne,ie,ae,se,ce,ue,de,le,he,fe,pe,ve,_e,me,ye,ge,Se,Ee,be,ke,Te,Ie,Ae,Re,Ce,we,Oe,xe,Ne,Pe,De,Me,Le,Ue,Ve,Fe,Be,je=g(Ge);function Ge(e,t){var r;return u(this,Ge),h(m(r=je.call(this)),"_room",void 0),h(m(r),"_outsideRoom",void 0),h(m(r),"_appId",void 0),h(m(r),"_businessId",void 0),h(m(r),"_visibility",!0),h(m(r),"_localVideoTrack",void 0),h(m(r),"_localAudioTrack",void 0),h(m(r),"_localImgVideoTrack",void 0),h(m(r),"_localImgScreenTrack",void 0),h(m(r),"_localScreenVideoTrack",void 0),h(m(r),"_localScreenAudioTrack",void 0),h(m(r),"_tempMixingAudioTrack",void 0),h(m(r),"_audioPlaybackDeviceId",void 0),h(m(r),"_videoPlayer",void 0),h(m(r),"_screenPlayer",void 0),h(m(r),"_remoteVideoPlayer",new Map),h(m(r),"_remoteScreenPlayer",new Map),h(m(r),"_remoteAudioPlayer",new Map),h(m(r),"_remoteScreenAudioPlayer",new Map),h(m(r),"_publicStreamAudioPlayer",new Map),h(m(r),"_publicStreamVideoPlayer",new Map),h(m(r),"_publicStreamIds",new Map),h(m(r),"_roomConfig",void 0),h(m(r),"_videoStreamConstraints",{width:640,height:360,frameRate:15}),h(m(r),"_audioStreamConstraints",{}),h(m(r),"_enableSimulcast",!1),h(m(r),"_videoStreamEncodeConfig",[vj]),h(m(r),"_screenStreamEncodeConfig",[_j]),h(m(r),"_dummyMainImage",void 0),h(m(r),"_dummyScreenImage",void 0),h(m(r),"_trackSourceType",void 0),h(m(r),"_liveTranscodeConfig",void 0),h(m(r),"_useCloudProxy",void 0),h(m(r),"_startCloudProxyTimestamp",void 0),h(m(r),"_localVideoDeviceId",void 0),h(m(r),"_localAudioDeviceId",void 0),h(m(r),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),h(m(r),"_audioVolumeIndicationTimer",void 0),h(m(r),"_dummyMainTimer",void 0),h(m(r),"_dummyScreenTimer",void 0),h(m(r),"_audioPropertiesReportTimer",null),h(m(r),"_mirrorType",B.MIRROR_TYPE_RENDER),h(m(r),"_audioMixingManager",void 0),h(m(r),"_pubLock",void 0),h(m(r),"_rtmClient",void 0),h(m(r),"_messageStatisticsObserver",void 0),h(m(r),"_tempRoomInfo",void 0),h(m(r),"_originIceConfigRequestUrls",void 0),h(m(r),"_originConfigServerUrls",void 0),h(m(r),"_originLogServerUrl",void 0),h(m(r),"_extensionManager",new XH),h(m(r),"_audioDeviceManager",new KJ(r._extensionManager)),h(m(r),"_audioProfileManager",new XJ),h(m(r),"_remoteVideoConfig",new Map),h(m(r),"_userPriorityMap",new Map),h(m(r),"_subscribeFallbackOption",void 0),h(m(r),"_cameraCapturing",!1),h(m(r),"_interruptCameraCapture",!1),h(m(r),"_micCapturing",!1),h(m(r),"_interruptMicCapture",!1),h(m(r),"_avSync",!0),h(m(r),"_config",void 0),h(m(r),"_needClosePreTrack",!1),h(m(r),"_updateMixAudioTrack",function(){var e=c(o().mark((function e(t){var n,i,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>1&&void 0!==a[1]?a[1]:re.PLAYOUT_AND_PUBLISH,aQ.print("_updateMixAudioTrack()"),r._localAudioTrack){e.next=5;break}return t&&(r._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(r._localAudioTrack.mixType=i,r._localAudioTrack.mixedAudioTrack=t):(delete r._localAudioTrack.mixType,delete r._localAudioTrack.mixedAudioTrack),null===(n=r._room)||void 0===n||!n.hasPublished){e.next=9;break}return e.next=9,r._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),h(m(r),"_onAudioMixingMessage",(function(e){r.safeEmit(oe.onAudioMixingStateChanged,e)})),h(m(r),"_onAudioMixingAutoplayFailed",(function(e){r.safeEmit(oe.onAutoplayFailed,e)})),r._appId=e,r._pubLock=new dK("pubLock"),r._addDeviceEventHandler(),r._audioMixingManager=new FJ({getLocalAudioTrack:function(){return r._localAudioTrack},updateLocalAudioTrack:r._updateMixAudioTrack,emitMessage:r._onAudioMixingMessage,onAutoPlayFailed:r._onAudioMixingAutoplayFailed}),window.__rtc_engine__=m(r),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=m(r),r._trackSourceType={video:R.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:R.VIDEO_SOURCE_TYPE_INTERNAL,audio:C.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:C.AUDIO_SOURCE_TYPE_INTERNAL},r._config=t,r._rtmClient=new GJ(e),r._handleRTMClient(r._rtmClient),r._useCloudProxy=!1,r._handleAudioDeviceManager(),r._messageStatisticsObserver=new zK,r._extensionManager.setMinotor(FB),r}return l(Ge,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(Be=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("updateToken()","token: %s",t),zD(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,a=n.userInfo,s=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,s,a,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new hP(dP.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return Be.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Fe=c(o().mark((function e(t){var r,n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("setVideoCaptureDevice()","deviceId: %s",t),zD(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=fW({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),aQ.print("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=11,pz(r,this._extensionManager).catch((function(e){if(i._localVideoTrack&&!i._localVideoTrack.dummy)return aQ.print("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),i._removeLocalTrackEvents(i._localVideoTrack),i._localVideoTrack.close(),delete i._localVideoTrack,pz(r,i._extensionManager).then((function(e){return i._needClosePreTrack=!0,e})).catch(c(o().mark((function t(){var r;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return aQ.print("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,pz(i._videoStreamConstraints,i._extensionManager);case 3:throw r=t.sent,i._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 11:return n=e.sent,aQ.print("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=17,this._switchTrack(n);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return Fe.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(Ve=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("setAudioCaptureDevice()","deviceId: %s",t),zD(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return(r=this._audioStreamConstraints).deviceId={exact:t},this._audioStreamConstraints=r,this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.next=12,_z(r,this._extensionManager,this._audioProfileManager);case 12:if(n=e.sent,this._initLocalTrackEvents(n),this._localAudioTrack=n,this._room){e.next=17;break}return e.abrupt("return");case 17:if(!this._room.hasPublished){e.next=20;break}return e.next=20,this._updatePublish();case 20:case"end":return e.stop()}}),e,this)}))),function(e){return Ve.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){jH.on(oe.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),jH.on(oe.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A,R,C,w=this;null===(e=this._room)||void 0===e||e.on(gj.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(gj.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(gj.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(lK.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(lK.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(lK.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(gj.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(gj.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(gj.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(gj.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(gj.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?w._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?w._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&w._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(Ej.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(lK.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(f=this._room)||void 0===f||f.on(lK.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(p=this._room)||void 0===p||p.on(lK.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(v=this._room)||void 0===v||v.on(lK.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=w._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&w.safeEmit(oe.onAutoPublishResult,e)})),null===(_=this._room)||void 0===_||_.on(lK.ON_REMOTE_STREAM_STATS,(function(e){w.safeEmit(oe.onRemoteStreamStats,e)})),null===(m=this._room)||void 0===m||m.on(lK.ON_LOCAL_STREAM_STATS,(function(e){w.safeEmit(oe.onLocalStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(lK.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(g=this._room)||void 0===g||g.on(lK.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;w._updateAudioPlayerState(t),w.safeEmit(oe.onUserStartAudioCapture,{userId:r})})),null===(S=this._room)||void 0===S||S.on(lK.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;w.safeEmit(oe.onUserStopAudioCapture,{userId:t})})),null===(E=this._room)||void 0===E||E.on(lK.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;w.safeEmit(oe.onUserStartVideoCapture,{userId:t})})),null===(b=this._room)||void 0===b||b.on(lK.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;w.safeEmit(oe.onUserStopVideoCapture,{userId:t})})),null===(k=this._room)||void 0===k||k.on(lK.ON_SEI_MESSAGED_RECEIVED,(function(e){w.safeEmit(oe.onSEIMessageReceived,e)})),null===(T=this._room)||void 0===T||T.on(lK.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){w.safeEmit(oe.onRemoteVideoSizeChanged,e,t)})),null===(I=this._room)||void 0===I||I.on(lK.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return w.safeEmit(oe.onSimulcastSubscribeFallback,e)})),null===(A=this._room)||void 0===A||A.on(lK.RECONNECT_FAILED,(function(){w.safeEmit(oe.onError,{errorCode:dP.RECONNECT_FAILED})})),null===(R=this._room)||void 0===R||R.on(lK.ON_VIDEO_STREAM_BANNED,(function(e){w.safeEmit(oe.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(C=this._room)||void 0===C||C.on(lK.ON_AUDIO_STREAM_BANNED,(function(e){w.safeEmit(oe.onAudioStreamBanned,{uid:e.uid,banned:e.banned})}))}},{key:"safeEmit",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return oM(e)&&JB(e,PD(n)),(t=E(p(Ge.prototype),"safeEmit",this)).call.apply(t,[this,e].concat(n))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"joinRoom",value:(Ue=c(o().mark((function e(t,r,n){var a,s,c,u,d,l,h,f=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=f.length>3&&void 0!==f[3]?f[3]:{},aQ.print("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,a),QD(t)||zD(t,"token"),ZD(r),tM(n),rM(a=fW({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Y.communication},a)),!this._room||this._room.connectionState===EK.DISCONNECTED){e.next=11;break}throw new hP(dP.REPEAT_JOIN,"Already joined");case 11:return this._room=new DK(a,{audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync}),this._addHandlerEventHandler(),s=this._liveTranscodeConfig&&rQ.getStartParams(this._liveTranscodeConfig),c=i(i({},n),{},{businessId:this._businessId,role:this._visibility?BJ.NORMAL_USER:BJ.SILENT_USER}),e.prev=15,this._useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),e.next=19,this._room.join(this._appId,r,t,c,s,this._useCloudProxy,null===(u=this._config)||void 0===u?void 0:u.expectedIDC);case 19:return l=e.sent,this._roomConfig=a,this._tempRoomInfo&&delete this._tempRoomInfo,null!==(d=a)&&void 0!==d&&d.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:U.AUDIO_AND_VIDEO}):this.safeEmit(oe.onAutoPublishResult,{isScreen:!1,state:P.PUBLISH_FAIL})),e.abrupt("return",l);case 26:throw e.prev=26,e.t0=e.catch(15),e.t0.code===dP.INVALID_TOKEN&&(this._tempRoomInfo={config:a,roomId:r,userInfo:c}),null===(h=this._room)||void 0===h||h.destroy(),e.t0;case 31:case"end":return e.stop()}}),e,this,[[15,26]])}))),function(e,t,r){return Ue.apply(this,arguments)})},{key:"leaveRoom",value:(Le=c(o().mark((function e(){var t,r,n,i=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],aQ.print("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new Map,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new Map,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new Map,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new Map,this._roomConfig=void 0,this._publicStreamIds=new Map;case 21:case"end":return e.stop()}}),e,this)}))),function(){return Le.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;aQ.print("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._audioStreamConstraints={},this._videoStreamEncodeConfig=[vj],this._screenStreamEncodeConfig=[_j],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new Map,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new Map,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new Map,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new Map,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new Map,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new Map,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._outsideRoom)||void 0===r||r.destroy(),this._publicStreamIds=new Map,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new Map,this._userPriorityMap.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._avSync=!0}},{key:"publishStream",value:(Me=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!VD(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,dz(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Me.apply(this,arguments)})},{key:"unpublishStream",value:(De=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:fK.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return De.apply(this,arguments)})},{key:"publishScreen",value:(Pe=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!VD(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,hz(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:fK.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof hP)){e.next=18;break}throw e.t0;case 18:throw new hP(dP.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return Pe.apply(this,arguments)})},{key:"unpublishScreen",value:(Ne=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:fK.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return Ne.apply(this,arguments)})},{key:"subscribeStream",value:(xe=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return xe.apply(this,arguments)})},{key:"_subscribe",value:(Oe=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==U.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return aQ.print("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(d=this._room.remoteStreams.get(r),l=null==d?void 0:d.find((function(e){return e.isScreen===t}))){e.next=9;break}throw new hP(dP.STREAM_NOT_EXIST,"stream not exist");case 9:return h=this._pauseAllSubscribeState.audio,f=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&U.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&U.VIDEO),aQ.print("subscribeStream()","due to pauseAll mediaType: %o",n),p=l.hasSubscribed,v=this._remoteVideoConfig.get(r)||(null===(a=this._roomConfig)||void 0===a?void 0:a.remoteVideoConfig),l.originalMediaType=n,e.next=19,this._room.subscribe(l,n,v);case 19:UD(n)&&this._updateAudioPlayerState(l),VD(n)&&this._updateVideoPlayerState(l),_=0,m=0,h!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?_|=U.AUDIO:m|=U.AUDIO),f!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?_|=U.VIDEO:m|=U.VIDEO),_&&this.pauseAllSubscribedStream(_),m&&this.resumeAllSubscribedStream(m),this._pauseAllSubscribeState.resumeStreamIds[l.streamId]=l.streamId,!t&&(null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeAudio||null!==(c=this._roomConfig)&&void 0!==c&&c.isAutoSubscribeVideo)&&(l.audioTrack||l.videoTrack)&&(y={userId:r,isScreen:!1,state:N.SUBSCRIBE_SUCC},this.safeEmit(oe.onAutoSubscribeResult,y)),null!==(u=this._room)&&void 0!==u&&u.multiChatMode||p||!UD(n)||!l.hasAudio||null===(g=l.observer)||void 0===g||g.setSubscribeAudio(!0),!p&&VD(n)&&l.hasVideo&&(null===(S=l.observer)||void 0===S||S.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return Oe.apply(this,arguments)})},{key:"unsubscribeStream",value:(we=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:aQ.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return we.apply(this,arguments)})},{key:"subscribeScreen",value:(Ce=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return Ce.apply(this,arguments)})},{key:"unsubscribeScreen",value:(Re=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:aQ.print("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return Re.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==U.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a=this._room.remoteStreams.get(t),s=null==a?void 0:a.find((function(t){return t.isScreen===e}));if(null==s||!s.hasSubscribed)throw new hP(dP.STREAM_NOT_EXIST,"stream not exist");return this._room.unsubscribe(s,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[s.streamId]}))}aQ.print("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(Ae=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),$D(t),aM(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return Ae.apply(this,arguments)})},{key:"startVideoCapture",value:(Ie=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("startVideoCapture()","deviceId: %s",t),QD(t)||zD(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new hP(dP.REPEAT_CAPTURE,"Has already capture");case 8:return i=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?i.facingMode=t:i.deviceId={exact:t},this._videoStreamConstraints=i),a={},e.prev=11,this._cameraCapturing=!0,e.next=15,pz(i,this._extensionManager);case 15:if(c=e.sent,!this._interruptCameraCapture){e.next=21;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(c),c.close(),new hP(dP.INTERRUPT,"interrupt by stopVideoCapture");case 21:if(this._initLocalTrackEvents(c),this._localVideoTrack=c,null===(s=this._videoPlayer)||void 0===s||s.playVideo(c),(u=null==c?void 0:c.getTrack())&&(a=u.getSettings(),d={width:a.width,height:a.height},this._localVideoTrack.resolution=d,setTimeout((function(){return h.safeEmit(oe.onLocalVideoSizeChanged,{streamIndex:L.STREAM_INDEX_MAIN,info:d})}))),this._room){e.next=28;break}return e.abrupt("return",a);case 28:return e.prev=28,this._cameraCapturing=!1,e.finish(28);case 31:return l=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||l)&&(this._visibility?this._updatePublish():this.safeEmit(oe.onAutoPublishResult,{isScreen:!1,state:P.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableVideo(!0),e.abrupt("return",a);case 35:case"end":return e.stop()}}),e,this,[[11,,28,31]])}))),function(e){return Ie.apply(this,arguments)})},{key:"stopVideoCapture",value:(Te=c(o().mark((function e(){var t,r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,aQ.print("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(s=this._localVideoTrack)||void 0===s||s.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||!r.hasPublished){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||null===(a=i.observer)||void 0===a||a.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return Te.apply(this,arguments)})},{key:"startAudioCapture",value:(ke=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("startAudioCapture()","deviceId: $o",t),QD(t)||zD(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new hP(dP.REPEAT_CAPTURE,"Has already capture");case 8:return i=this._audioStreamConstraints,t&&(i.deviceId={exact:t},this._audioStreamConstraints=i),e.prev=10,this._micCapturing=!0,e.next=14,_z(i,this._extensionManager,this._audioProfileManager);case 14:if(a=e.sent,!this._interruptMicCapture){e.next=20;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(a),a.close(),new hP(dP.INTERRUPT,"interrupt by stopAudioCapture");case 20:if(this._initLocalTrackEvents(a),this._localAudioTrack=a,this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),this._room){e.next=25;break}return e.abrupt("return");case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:s=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||s)&&(this._visibility?this._updatePublish():this.safeEmit(oe.onAutoPublishResult,{isScreen:!1,state:P.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!0);case 31:case"end":return e.stop()}}),e,this,[[10,,25,28]])}))),function(e){return ke.apply(this,arguments)})},{key:"stopAudioCapture",value:(be=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,aQ.print("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=12;break}return e.abrupt("return");case 12:if(!this._room.hasPublished){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(t=this._room.localStream)||void 0===t||null===(r=t.observer)||void 0===r||r.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return be.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return aQ.print("getAudioMixingManager()"),this._audioMixingManager}},{key:"startScreenCapture",value:(Ee=c(o().mark((function e(){var t,r,n,i,a,s,c,u,d,l,h,f,p,v=this,_=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=_.length>0&&void 0!==_[0]?_[0]:{},aQ.print("startScreenCapture()","config: %o",a),s=a.enableAudio,c=void 0!==s&&s,this._trackSourceType.screenVideo!==R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,yz(c,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(u=e.sent,d=b(u,2),l=d[0],h=d[1],this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=l,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&l.setContentHint(null===(f=this._screenStreamEncodeConfig[0])||void 0===f?void 0:f.contentHint),(p=null==l?void 0:l.getTrack())&&setTimeout((function(){var e=p.getSettings(),t={width:e.width,height:e.height};l.resolution=t,v.safeEmit(oe.onLocalVideoSizeChanged,{streamIndex:L.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),h&&(this._localScreenAudioTrack=h,this._initLocalTrackEvents(h)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(i=this._room)||void 0===i||!i.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(){return Ee.apply(this,arguments)})},{key:"stopScreenCapture",value:(Se=c(o().mark((function e(){var t,r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(n=this._localScreenVideoTrack)||void 0===n||n.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,null===(r=this._room)||void 0===r||!r.hasScreenPublished){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return Se.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(aQ.print("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),KD(e,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,o=i(i({userId:this._getUserId()},t),{},{isLocal:!0});if(nM(o),e===L.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new jK(o),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==Q.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),this._videoPlayer.domElement;if(e===L.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new jK(i(i({},o),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Q.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),this._screenPlayer.domElement}else{var a,s;e===L.STREAM_INDEX_MAIN?(null===(a=this._videoPlayer)||void 0===a||a.destroy(),delete this._videoPlayer):(null===(s=this._screenPlayer)||void 0===s||s.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(ge=c(o().mark((function e(t){var r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("startLiveTranscoding()","transcode: %o",t),rQ.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new hP(dP.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(oe.onStreamMixingEvent,{event:hK.START,error:0,message:""}),!this._room||this._room.connectionState!==EK.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(rQ.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof hP)){e.next=19;break}throw e.t0;case 19:throw new hP(dP.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return ge.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(ye=c(o().mark((function e(t){var r,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=fW({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,rQ.checckUpdateParams(i),this._liveTranscodeConfig=fW(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(oe.onStreamMixingEvent,{event:hK.UPDATE,error:0,message:""}),e.next=13,null===(a=this._room)||void 0===a?void 0:a.liveControlMessage(rQ.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof hP)){e.next=21;break}throw e.t0;case 21:throw new hP(dP.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return ye.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(me=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(oe.onStreamMixingEvent,{event:hK.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof hP)){e.next=16;break}throw e.t0;case 16:throw new hP(dP.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return me.apply(this,arguments)})},{key:"setBusinessId",value:function(e){return aQ.print("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(GB.setStats({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(_e=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?BJ.NORMAL_USER:BJ.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:U.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return _e.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:L.STREAM_INDEX_MAIN,i=n===L.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o=e.userId.replace("_screen","");r?t.safeEmit(oe.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:o}):(t.safeEmit(oe.onAudioFirstFrameDecoded,{userId:o,isScreen:i}),t.safeEmit(oe.onRemoteAudioFirstFrame,{userId:o,isScreen:i})),FB.firstRemoteAudioRender("",o||"",{isScreen:i})}else{var a,s,c={userId:e.userId,height:(null===(a=e.domElement)||void 0===a?void 0:a.videoHeight)||0,width:(null===(s=e.domElement)||void 0===s?void 0:s.videoWidth)||0,isScreen:i};r?(c.publicStreamId=c.userId,delete c.userId,delete c.isScreen,t.safeEmit(oe.onFirstPublicStreamVideoFrameRendered,c),t.safeEmit(oe.onFirstPublicStreamVideoFrameDecoded,c)):e.isLocal||(t.safeEmit(oe.onVideoFirstFrameRendered,c),t.safeEmit(oe.onVideoFirstFrameDecoded,c),t.safeEmit(oe.onRemoteVideoFirstFrame,c)),FB.firstRemoteVideoRender("",n.userId||"",{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),FB.rtcInvokeStatus(e instanceof jK?"video":"audio",0,"autoplay-error",n.userId||"",0),void t.safeEmit(oe.onAutoplayFailed,{userId:n.userId,kind:e instanceof jK?"video":"audio",mediaType:e instanceof jK?U.VIDEO:U.AUDIO,streamIndex:e.isScreen?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN})}t.safeEmit(oe.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.on("track-ended",(function(e){var r=!1;e!==t._localScreenAudioTrack&&e!==t._localScreenVideoTrack||(r=!0),t.safeEmit(oe.onTrackEnded,{kind:e.getTrack().kind,isScreen:r})})),e.on("resolution-change",(function(e){t.safeEmit(oe.onLocalVideoSizeChanged,{streamIndex:r?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){aQ.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),KD(e,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),nM(t);var r,n,o,a=t.userId;if(e===L.STREAM_INDEX_MAIN){var s,c,u;if(null===(s=this._remoteVideoPlayer.get(a))||void 0===s||s.destroy(),!t.renderDom)return;var d=new jK(t);this._initPlayerEvents(d,!1,e),this._remoteVideoPlayer.set(a,d);var l=null===(c=this._room)||void 0===c||null===(u=c.remoteStreams.get(a))||void 0===u?void 0:u.find((function(e){return!e.isScreen}));return l&&this._updateVideoPlayerState(l),d.domElement}if(null===(r=this._remoteScreenPlayer.get(a))||void 0===r||r.destroy(),t.renderDom){var h=new jK(i(i({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(a,h),this._initPlayerEvents(h,!1,e);var f=null===(n=this._room)||void 0===n||null===(o=n.remoteStreams.get(a))||void 0===o?void 0:o.find((function(e){return e.isScreen}));return f&&this._updateVideoPlayerState(f),h.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){aQ.print("setLocalVideoMirrorType()","mirrorType: %o",e),KD(e,"mirrorType",[B.MIRROR_TYPE_NONE,B.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(ve=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("setAudioPlaybackDevice()","deviceId: %s",t),zD(t,"deviceId"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=5;break}return aQ.print("setAudioPlaybackDevice failed","setSinkId not supported by current browser"),e.abrupt("return");case 5:return e.next=7,jH.getDeviceById(t);case 7:if(r=e.sent){e.next=10;break}throw new hP(dP.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 10:this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._audioPlaybackDeviceId=t,r&&this.safeEmit(oe.onAudioPlaybackDeviceChanged,r),FB.rtcAudioDevice(TB.PLAYOUT_DEVICE_SWITCH,t,0);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return ve.apply(this,arguments)})},{key:"play",value:(pe=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=g.length>1&&void 0!==g[1]?g[1]:U.AUDIO_AND_VIDEO,s=g.length>2?g[2]:void 0,aQ.print("play()","userId: %s, mediaType: %s, streamIndex: %s",t,a,s),c=!t||t===this._getUserId()||"local_user",u=void 0===s||s===L.STREAM_INDEX_MAIN,d=void 0===s||s===L.STREAM_INDEX_SCREEN,l=a!==U.VIDEO,h=a!==U.AUDIO,f=[],c&&h&&(u&&this._localVideoTrack&&(null===(p=this._videoPlayer)||void 0===p||p.mirror(!!this._mirrorType),f.push(null===(v=this._videoPlayer)||void 0===v?void 0:v.playVideo(this._localVideoTrack))),d&&this._localScreenVideoTrack&&f.push(null===(_=this._screenPlayer)||void 0===_?void 0:_.playVideo(this._localScreenVideoTrack))),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&f.push(this._audioMixingManager.resumeLocalPlay()),m=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,h&&u&&f.push(HK(this._remoteVideoPlayer,t,!1,m)),h&&d&&f.push(HK(this._remoteScreenPlayer,t,!0,m)),l&&u&&f.push(HK(this._remoteAudioPlayer,t,!1,m)),h&&d&&f.push(HK(this._remoteScreenAudioPlayer,t,!0,m)),y=null===(i=this._outsideRoom)||void 0===i?void 0:i.remoteStreams,l&&f.push(HK(this._publicStreamVideoPlayer,t,!1,y)),h&&f.push(HK(this._publicStreamAudioPlayer,t,!1,y)),e.abrupt("return",Promise.all(f).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return pe.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(fe=c(o().mark((function e(t){var r,n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),UD(t)&&(s._pauseAllSubscribeState.audio=!0),VD(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Promise.resolve());case 6:r=[],n=A(this._room.remoteStreams.values());try{for(n.s();!(i=n.n()).done;)a=i.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var n=s._unsubscribe(e.isScreen,e.userId,t,!0);n&&r.push(n)}}))}catch(o){n.e(o)}finally{n.f()}return e.abrupt("return",Promise.all(r).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return fe.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(he=c(o().mark((function e(t){var r,n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),UD(t)&&(s._pauseAllSubscribeState.audio=!1),VD(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Promise.resolve());case 6:r=[],n=A(this._room.remoteStreams.values());try{for(n.s();!(i=n.n()).done;)a=i.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var n=s._subscribe(e.isScreen,e.userId,t);n&&r.push(n)}}))}catch(o){n.e(o)}finally{n.f()}return e.abrupt("return",Promise.all(r).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"sendUserMessage",value:(le=c(o().mark((function e(t,r){var n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $D(t),iM(r),this._assertNotInRoom(),a=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return s._messageStatisticsObserver.countP2PMessage(!0,t,!1,a,e),e.id})).catch((function(e){throw s._messageStatisticsObserver.countP2PMessage(!1,t,!1,a,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return le.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(de=c(o().mark((function e(t,r){var n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $D(t),qD(r,"message"),iM(r),this._assertNotInRoom(),a=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return s._messageStatisticsObserver.countP2PMessage(!0,t,!0,a,e),e.id})).catch((function(e){throw s._messageStatisticsObserver.countP2PMessage(!1,t,!0,a,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return de.apply(this,arguments)})},{key:"sendRoomMessage",value:(ue=c(o().mark((function e(t){var r,n,i,a=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iM(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return a._messageStatisticsObserver.countRoomMessage(!0,null===(t=a._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw a._messageStatisticsObserver.countRoomMessage(!1,null===(t=a._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ue.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(ce=c(o().mark((function e(t){var r,n,i,a=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iM(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return a._messageStatisticsObserver.countRoomMessage(!0,null===(t=a._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw a._messageStatisticsObserver.countRoomMessage(!1,null===(t=a._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ce.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(se=c(o().mark((function e(){var t,r,n,i=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},aQ.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,YD(t),r=this._audioStreamConstraints.deviceId,this._audioStreamConstraints=t,r&&(this._audioStreamConstraints.deviceId=r),!this._localAudioTrack){e.next=11;break}return this._localAudioTrack.audioCaptureConfig=this._audioStreamConstraints,e.next=11,null===(n=this._localAudioTrack)||void 0===n?void 0:n.updateAudioCaptureConfig();case 11:case"end":return e.stop()}}),e,this)}))),function(){return se.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(ae=c(o().mark((function e(){var t,r,n,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.length>0&&void 0!==a[0]?a[0]:{},aQ.print("setVideoCaptureConfig()","config: %o",r),delete r.deviceId,YD(r),n=i(i({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=9;break}return e.next=8,this._localVideoTrack.updateVideoCaptureConfig(n);case 8:this._updatePublish();case 9:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 11:case"end":return e.stop()}}),e,this)}))),function(){return ae.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){return aQ.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,!0}},{key:"setVideoEncoderConfig",value:(ie=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:aQ.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),t.length>3&&(t=t.slice(0,3)),t.sort((function(e,t){return t.maxKbps-e.maxKbps})),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(L.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 7:case"end":return e.stop()}}),e,this)}))),function(e){return ie.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(ne=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:aQ.print("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(L.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return ne.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(aQ.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!$j())throw new hP(dP.NOT_SUPPORTED,"Browser does not support sending SEI");KD(e,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),HD(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(_D.str2ab(t)):t;if(t.length){var i;if(e===L.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,d;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)aQ.print("sei size must not bigger than 4KB");else{var l=hD();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){if(i){var e=i.seiList.findIndex((function(e){return e.uuid===l}));e&&i.seiList.splice(e,1)}}),2e3)}}else aQ.print("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;aQ.print("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=e.find((function(e){return!1===e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(oe.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=t.reduce((function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(oe.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};aQ.print("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:L.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:LD(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:L.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:LD(o)}})}if(e.safeEmit(oe.onLocalAudioPropertiesReport,t),e._room){var a,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:L.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:LD(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.push({streamKey:{userId:r,streamIndex:t.isScreen?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:LD(o)}})}}))}));e.safeEmit(oe.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,s.filter((function(e){return e.streamKey.streamIndex!==L.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(te=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),KD(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),KD(r,"VideoSourceType",[R.VIDEO_SOURCE_TYPE_EXTERNAL,R.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===L.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,aQ.print("setVideoSourceType","set ".concat(n," source type to ").concat(r)),!this._localVideoTrack||t!==L.STREAM_INDEX_MAIN){e.next=17;break}if(c=!1,r===R.VIDEO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(i=this._videoPlayer)||void 0===i||i.stop(),this._localVideoTrack=void 0,u=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableVideo(!1):null===(f=this._room)||void 0===f||null===(p=f.localStream)||void 0===p||null===(v=p.observer)||void 0===v||v.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&s.hasPublished||u)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==L.STREAM_INDEX_SCREEN){e.next=26;break}if(y=!1,r===R.VIDEO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(_=this._screenPlayer)||void 0===_||_.stop(),this._localScreenVideoTrack=void 0,y?null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||null===(E=S.observer)||void 0===E||E.setEnableVideo(!1):null===(b=this._room)||void 0===b||null===(k=b.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushVideo(!1),null===(m=this._room)||void 0===m||!m.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return te.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(ee=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("setExternalVideoTrack()","index: %o, track: %o",t,r),KD(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),XD(r),t!==L.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,Ez(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||s)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==L.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,Iz(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(c=this._screenPlayer)||void 0===c||c.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||!h.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return ee.apply(this,arguments)})},{key:"setAudioSourceType",value:($=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),KD(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),KD(r,"audioSourceType",[C.AUDIO_SOURCE_TYPE_EXTERNAL,C.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===L.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,aQ.print("setVideoSourceType","set ".concat(n," source type to ").concat(r)),!this._localAudioTrack||t!==L.STREAM_INDEX_MAIN){e.next=16;break}if(s=!1,this._trackSourceType.audio===C.AUDIO_SOURCE_TYPE_EXTERNAL&&(s=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,c=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,s?null===(u=this._room)||void 0===u||null===(d=u.localStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setEnableAudio(!1):null===(h=this._room)||void 0===h||null===(f=h.localStream)||void 0===f||null===(p=f.observer)||void 0===p||p.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||c)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==L.STREAM_INDEX_SCREEN){e.next=24;break}if(_=!1,this._trackSourceType.audio===C.AUDIO_SOURCE_TYPE_EXTERNAL&&(_=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,_?null===(m=this._room)||void 0===m||null===(y=m.localScreenStream)||void 0===y||null===(g=y.observer)||void 0===g||g.setEnableAudio(!1):null===(S=this._room)||void 0===S||null===(E=S.localScreenStream)||void 0===E||null===(b=E.observer)||void 0===b||b.setPushAudio(!1),null===(v=this._room)||void 0===v||!v.hasScreenPublished){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return $.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(Z=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("setExternalAudioTrack()","index: %o, track: %o",t,r),KD(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),XD(r),t!==L.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.audio===C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,kz(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(a=i.localStream)||void 0===a||null===(s=a.observer)||void 0===s||s.setPushAudio(!0),!(null!==(c=this._room)&&void 0!==c&&c.hasPublished||u)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==L.STREAM_INDEX_SCREEN){e.next=26;break}if(this._trackSourceType.screenAudio===C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new hP(dP.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 18:return e.next=20,Rz(r,this._extensionManager);case 20:if(this._localScreenAudioTrack=e.sent,this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(f=this._room)||void 0===f||!f.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return Z.apply(this,arguments)})},{key:"login",value:(J=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("login()","token: %o, userInfo: %o",t,r),QD(t)||zD(t,"token"),$D(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return J.apply(this,arguments)})},{key:"logout",value:(q=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return q.apply(this,arguments)})},{key:"updateLoginToken",value:(W=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("updateLoginToken()","token: %o",t),QD(t)||zD(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(z=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("getPeerOnlineStatus()","userId: %o",t),$D(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return z.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(H=c(o().mark((function e(t,r){var n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $D(t),iM(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return H.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(G=c(o().mark((function e(t,r){var n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $D(t),qD(r,"message"),iM(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return G.apply(this,arguments)})},{key:"setServerParams",value:(j=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return j.apply(this,arguments)})},{key:"sendServerMessage",value:(M=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zD(t,"message"),iM(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(){n._messageStatisticsObserver.countServerMessage(!0,!1,r)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(D=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qD(t,"message"),iM(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(){n._messageStatisticsObserver.countServerMessage(!0,!0,r)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return D.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new hP(dP.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");aQ.print("startCloudProxy()",e),zD(e.logProxy,"logProxy"),zD(e.accessProxy,"accessProxy"),zD(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=hj("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=hj("LOG_SERVER_URL"),this._originConfigServerUrls=hj("CONFIG_REQUEST_DOMAINS"),lj("ICE_CONFIG_REQUEST_URLS",e.accessProxy),lj("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),lj("CONFIG_REQUEST_DOMAINS",[e.configProxy]),this._useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){if(this._room)throw new hP(dP.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");aQ.print("stopCloudProxy()"),lj("ICE_CONFIG_REQUEST_URLS",[]),lj("LOG_SERVER_URL",this._originLogServerUrl),lj("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),this._useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(x=c(o().mark((function e(t,r){var n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),eM(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new hP(dP.REPEAT_PUSH,"repeat push public media stream");case 5:return a=fj(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(a))||void 0===i?void 0:i.then((function(){s._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return x.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(O=c(o().mark((function e(t,r){var n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),eM(t),this._assertNotInRoom(),i=fj(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"stopPushPublicStream",value:(w=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("startPushPublicStream()","publicStreamId: %o",t),eM(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"startPlayPublicStream",value:(I=c(o().mark((function e(t){var r,n,i,a,s,c,u=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(eM(t),this._outsideRoom){e.next=8;break}return this._outsideRoom=new HJ(this._appId),this._outsideRoom.on(lK.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=u._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=u._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._outsideRoom)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,u.safeEmit(oe.onPublicStreamStats,e)})),null===(n=this._outsideRoom)||void 0===n||n.on(lK.ON_SEI_MESSAGED_RECEIVED,(function(e){u.safeEmit(oe.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._outsideRoom.connect();case 8:return e.next=10,this._outsideRoom.startPlayPublicStream(t);case 10:i=e.sent,(a=this._publicStreamVideoPlayer.get(t))&&null!=i&&i.videoTrack&&a.playVideo(i.videoTrack,i),!(s=this._publicStreamAudioPlayer.get(t))&&null!=i&&i.audioTrack&&(s=new GK(t,{muted:(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)===Q.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(s,!0),s.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,s));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(T=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._outsideRoom){e.next=2;break}return e.abrupt("return");case 2:this._outsideRoom.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"setAudioProfile",value:(k=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._audioProfileManager.setAudioProfile(t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,o,a;aQ.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var s=this._publicStreamVideoPlayer.get(e);if(null===(r=s)||void 0===r||r.destroy(),null!=t&&t.renderDom){s=new jK(i(i({},t),{},{userId:e})),this._initPlayerEvents(s,!0),this._publicStreamVideoPlayer.set(e,s);var c=null===(n=this._outsideRoom)||void 0===n||null===(o=n.remoteStreams)||void 0===o?void 0:o.get(e);null!=c&&c.videoTrack&&(null===(a=this._config)||void 0===a?void 0:a.autoPlayPolicy)!==Q.PLAY_MANUALLY&&s.playVideo(c.videoTrack,c)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(S=c(o().mark((function e(t,r){var n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,i){zD(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===L.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new hP(dP.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new hP(dP.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return S.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===L.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d");if(!a)throw new hP(dP.UNEXPECTED_ERROR,"Not support canvas");!r||t.width<=r.width&&t.height<=r.height?(n=t.width,i=t.height):(n=Math.min(r.width,t.width*r.height/t.height),i=Math.min(r.height,t.height*r.width/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var s=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===L.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=s):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=s);var c,u,d,l,h=o.captureStream(5).getVideoTracks()[0];if(e===L.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=h,null!==(c=this._localVideoTrack)&&void 0!==c&&c.dummy)null===(u=this._localVideoTrack)||void 0===u||u.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=h,null!==(d=this._localScreenVideoTrack)&&void 0!==d&&d.dummy)null===(l=this._localScreenVideoTrack)||void 0===l||l.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))}))}},{key:"registerExtension",value:(y=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor=FB,t.isSupported()){e.next=3;break}throw new Error("This extension is not supported.");case 3:return e.next=5,t.init();case 5:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(JSON.stringify(rQ.getDefaultValue()))}},{key:"_updatePublish",value:(_=c(o().mark((function e(){var t,r,n,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.length>0&&void 0!==a[0]?a[0]:{},aQ.print("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:fK.PUB},t=i(i({},r),t),this._visibility){e.next=6;break}throw new hP(dP.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===EK.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:e.next=24;break;case 17:if(e.prev=17,e.t0=e.catch(12),!(e.t0 instanceof hP)){e.next=23;break}throw e.t0;case 23:throw new hP(dP.UNEXPECTED_ERROR,"unexpected error",e.t0);case 24:return e.prev=24,n(),e.finish(24);case 27:case"end":return e.stop()}}),e,this,[[12,17,24,27]])}))),function(){return _.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(v=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),zD(t,"filePath"),HD(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){aQ.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(d=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aQ.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),HD(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){aQ.print("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){aQ.print("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;aQ.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{$D(e),KD(t,"priority",[X.HIGH,X.MEDIUM,X.LOW])}catch(n){return console.warn(n),!1}return this._userPriorityMap.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(s=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("takeLocalSnapshot()","streamIndex: %o",t),KD(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),r=t===L.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new hP(dP.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===L.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",YJ(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===B.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(a=c(o().mark((function e(t,r){var n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aQ.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),zD(t,"id"),KD(r,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),u=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(a=i.find((function(e){return e.isScreen===(r===L.STREAM_INDEX_SCREEN)})))||void 0===a?void 0:a.videoTrack)||(null===(s=this._outsideRoom)||void 0===s||null===(c=s.remoteStreams.get(t))||void 0===c?void 0:c.videoTrack)){e.next=6;break}throw new hP(dP.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",YJ(u.getTrack(),!1,r===L.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){aQ.print("setSubscribeFallbackOption()","option: %o",e);try{KD(e,"option",[K.DISABLE,K.VIDEO_STREAM_LOW,K.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===L.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof wz&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===L.STREAM_INDEX_MAIN)a=o.find((function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=o.find((function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._outsideRoom&&this._outsideRoom.remoteStreams){var r=this._outsideRoom.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._avSync=!!e,!0)}},{key:"_reportMsTrackEvent",value:function(e,t){if(!e.hookStop){e.hookStop=!0;var r=e.stop;e.stop=function(){FB.rtcInvokeStatus(t,0,"stop",t||"",0),r.call(e)}}}},{key:"_updateScreenPublish",value:(n=c(o().mark((function e(){var t,r,n,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:{},aQ.print("_updateScreenPublish()"),r={mediaType:void 0,pubState:fK.PUB},t=i(i({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===EK.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(10),!(e.t0 instanceof hP)){e.next=21;break}throw e.t0;case 21:throw new hP(dP.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:return e.prev=22,n(),e.finish(22);case 25:case"end":return e.stop()}}),e,this,[[10,15,22,25]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){aQ.print("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&(e.attributes.audiostream&&e.subAudio||this.multiChatMode)){var a,s;if(!o)o=new GK(r,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===Q.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN),i.set(r,o),this._audioPlaybackDeviceId&&o.setPlaybackDevice(this._audioPlaybackDeviceId);(null===(a=this._config)||void 0===a?void 0:a.autoPlayPolicy)!==Q.PLAY_MANUALLY&&o.playAudio(e.audioTrack),SD&&ID&&(t=this._remoteAudioPlayer,tQ&&clearTimeout(tQ),tQ=setTimeout((function(){var e,r=A(t);try{for(r.s();!(e=r.n()).done;){var n=b(e.value,2),i=n[0],o=n[1];null!=i&&i.startsWith("mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=A(t);try{for(s.s();!(a=s.n()).done;){var c=b(a.value,2),u=c[0],d=c[1];null!=u&&u.startsWith("mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var c;null===(c=o)||void 0===c||c.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;aQ.print("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Q.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=c(o().mark((function e(t){var r,n,i,a,s,c,u,d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.stream,n=null==r?void 0:r.attributes,i=n.localaudio,a=n.audiostream,s=n.localvideo,c=n.videostream,u=Oz.NONE,a&&(u|=U.AUDIO),c&&(u|=U.VIDEO),!u){e.next=11;break}return e.next=8,new Promise((function(e){return setTimeout(e)}));case 8:null!=r&&r.isScreen?this.safeEmit(oe.onUserPublishScreen,{userId:r.userId,mediaType:u}):(this.safeEmit(oe.onUserPublishStream,{userId:r.userId,mediaType:u,videoStreamDescriptions:null==r||null===(d=r.attributes)||void 0===d?void 0:d.videoDescriptions}),this._handleAutoSubscribe(r,!0)),this.safeEmit("onAddStream",{userId:r.userId,mediaType:u,isScreen:!(null==r||!r.isScreen)}),null!=r&&r.isScreen||(i&&this.safeEmit(oe.onUserStartAudioCapture,{userId:r.userId}),s&&this.safeEmit(oe.onUserStartVideoCapture,{userId:r.userId}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=Oz.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=U.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=U.VIDEO),i){var o,a;if(t&&UD(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&VD(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=cQ[e.reason])&&void 0!==t?t:V.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?oe.onUserUnpublishScreen:oe.onUserUnpublishStream,a=Oz.NONE;n.attributes.audiostream&&(a|=U.AUDIO),n.attributes.videostream&&(a|=U.VIDEO),a!==Oz.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){var t=n.isScreen?"".concat(n.userId,"_screen"):n.userId;r._remoteAudioPlayer.delete(t),n.isScreen?r._remoteScreenPlayer.delete(n.userId):r._remoteVideoPlayer.delete(n.userId),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(oe.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){this.safeEmit(oe.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(oe.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.safeEmit.apply(this,[oe.onNetworkQuality].concat(t))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._useCloudProxy&&e.state===F.CONNECTION_STATE_CONNECTED&&this.safeEmit(oe.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(oe.onConnectionStateChanged,e),e.state===F.CONNECTION_STATE_RECONNECTING){var t,r=A(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=b(t.value,2),i=n[0],o=n[1];null!=i&&i.startsWith("mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){return[(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e)]}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(oe.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(oe.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=this,n=e.userId,o=e.isScreen,a=e.mediaType,s=e.pubState,c=e.remoteStream,u={userId:n,mediaType:a};(a&U.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(c)})),o)?s===fK.PUB?this.safeEmit(oe.onUserPublishScreen,u):this.safeEmit(oe.onUserUnpublishScreen,i(i({},u),{},{reason:V.STREAM_REMOVE_REASON_UNPUBLISH})):s===fK.PUB?(u.videoStreamDescriptions=null==c||null===(t=c.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(oe.onUserPublishStream,u),this._handleAutoSubscribe(c,!0)):this.safeEmit(oe.onUserUnpublishStream,i(i({},u),{},{reason:V.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(oe.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(oe.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(oe.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(oe.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(oe.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(oe.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(oe.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(oe.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(oe.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(oe.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(oe.onError,{errorCode:dP.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(oe.onError,{errorCode:dP.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(oe.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&(null===(t=this._room)||void 0===t||t.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){r.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})));return r}},{key:"iceState",get:function(){var e,t,r,n;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||null===(r=t.handler)||void 0===r||null===(n=r._peerConnection)||void 0===n?void 0:n.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&(null===(t=this._room)||void 0===t||t.remoteUsers.forEach((function(e){r.push({userId:e.userId})})));return r}},{key:"multiChatMode",get:function(){var e,t;return!(null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||!t.roomAttributes.multiChatMode)}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(oe.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==EK.CONNECTED)throw new hP(dP.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){KD(e,"mediaType",[U.AUDIO,U.VIDEO,U.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||!n.hasPublished){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),Ge}(ZL);oQ([YB()],sQ.prototype,"updateToken",1),oQ([YB()],sQ.prototype,"setVideoCaptureDevice",1),oQ([YB()],sQ.prototype,"setAudioCaptureDevice",1),oQ([YB()],sQ.prototype,"joinRoom",1),oQ([YB()],sQ.prototype,"leaveRoom",1),oQ([YB()],sQ.prototype,"destroy",1),oQ([YB()],sQ.prototype,"publishStream",1),oQ([YB()],sQ.prototype,"unpublishStream",1),oQ([YB()],sQ.prototype,"publishScreen",1),oQ([YB()],sQ.prototype,"unpublishScreen",1),oQ([YB()],sQ.prototype,"subscribeStream",1),oQ([YB()],sQ.prototype,"unsubscribeStream",1),oQ([YB()],sQ.prototype,"subscribeScreen",1),oQ([YB()],sQ.prototype,"unsubscribeScreen",1),oQ([YB()],sQ.prototype,"setRemoteVideoConfig",1),oQ([YB()],sQ.prototype,"startVideoCapture",1),oQ([YB()],sQ.prototype,"stopVideoCapture",1),oQ([YB()],sQ.prototype,"startAudioCapture",1),oQ([YB()],sQ.prototype,"stopAudioCapture",1),oQ([YB()],sQ.prototype,"getAudioMixingManager",1),oQ([YB()],sQ.prototype,"startScreenCapture",1),oQ([YB()],sQ.prototype,"stopScreenCapture",1),oQ([YB()],sQ.prototype,"setLocalVideoPlayer",1),oQ([YB()],sQ.prototype,"startLiveTranscoding",1),oQ([YB()],sQ.prototype,"updateLiveTranscoding",1),oQ([YB()],sQ.prototype,"stopLiveTranscoding",1),oQ([YB()],sQ.prototype,"setBusinessId",1),oQ([YB()],sQ.prototype,"setUserVisibility",1),oQ([YB()],sQ.prototype,"setRemoteVideoPlayer",1),oQ([YB()],sQ.prototype,"setLocalVideoMirrorType",1),oQ([YB()],sQ.prototype,"setAudioPlaybackDevice",1),oQ([YB()],sQ.prototype,"play",1),oQ([YB()],sQ.prototype,"pauseAllSubscribedStream",1),oQ([YB()],sQ.prototype,"resumeAllSubscribedStream",1),oQ([YB()],sQ.prototype,"sendUserMessage",1),oQ([YB()],sQ.prototype,"sendUserBinaryMessage",1),oQ([YB()],sQ.prototype,"sendRoomMessage",1),oQ([YB()],sQ.prototype,"sendRoomBinaryMessage",1),oQ([YB()],sQ.prototype,"setAudioCaptureConfig",1),oQ([YB()],sQ.prototype,"setVideoCaptureConfig",1),oQ([YB()],sQ.prototype,"enableSimulcastMode",1),oQ([YB()],sQ.prototype,"setVideoEncoderConfig",1),oQ([YB()],sQ.prototype,"setScreenEncoderConfig",1),oQ([YB()],sQ.prototype,"sendSEIMessage",1),oQ([YB()],sQ.prototype,"setAudioVolumeIndicationInterval",1),oQ([YB()],sQ.prototype,"enableAudioPropertiesReport",1),oQ([YB()],sQ.prototype,"setVideoSourceType",1),oQ([YB()],sQ.prototype,"setExternalVideoTrack",1),oQ([YB()],sQ.prototype,"setAudioSourceType",1),oQ([YB()],sQ.prototype,"setExternalAudioTrack",1),oQ([YB("rtm")],sQ.prototype,"login",1),oQ([YB("rtm")],sQ.prototype,"logout",1),oQ([YB("rtm")],sQ.prototype,"updateLoginToken",1),oQ([YB("rtm")],sQ.prototype,"getPeerOnlineStatus",1),oQ([YB("rtm")],sQ.prototype,"sendUserMessageOutsideRoom",1),oQ([YB("rtm")],sQ.prototype,"sendUserBinaryMessageOutsideRoom",1),oQ([YB("rtm")],sQ.prototype,"setServerParams",1),oQ([YB("rtm")],sQ.prototype,"sendServerMessage",1),oQ([YB("rtm")],sQ.prototype,"sendServerBinaryMessage",1),oQ([YB()],sQ.prototype,"startCloudProxy",1),oQ([YB()],sQ.prototype,"stopCloudProxy",1),oQ([YB()],sQ.prototype,"startPushPublicStream",1),oQ([YB()],sQ.prototype,"updatePublicStreamParam",1),oQ([YB()],sQ.prototype,"stopPushPublicStream",1),oQ([YB("outsideRoom","streamId")],sQ.prototype,"startPlayPublicStream",1),oQ([YB("outsideRoom","streamId")],sQ.prototype,"stopPlayPublicStream",1),oQ([YB()],sQ.prototype,"setAudioProfile",1),oQ([YB("outsideRoom")],sQ.prototype,"setPublicStreamVideoPlayer",1),oQ([YB()],sQ.prototype,"setDummyCaptureImagePath",1),oQ([YB()],sQ.prototype,"registerExtension",1),oQ([YB()],sQ.prototype,"startAudioPlaybackDeviceTest",1),oQ([YB()],sQ.prototype,"stopAudioPlaybackDeviceTest",1),oQ([YB()],sQ.prototype,"startAudioDeviceRecordTest",1),oQ([YB()],sQ.prototype,"stopAudioDeviceRecordAndPlayTest",1),oQ([YB()],sQ.prototype,"stopAudioDevicePlayTest",1),oQ([YB()],sQ.prototype,"setRemoteUserPriority",1),oQ([YB()],sQ.prototype,"takeLocalSnapshot",1),oQ([YB()],sQ.prototype,"takeRemoteSnapshot",1),oQ([YB()],sQ.prototype,"setSubscribeFallbackOption",1),oQ([YB()],sQ.prototype,"getLocalStreamTrack",1),oQ([YB()],sQ.prototype,"getRemoteStreamTrack",1),oQ([YB()],sQ.prototype,"getPublicStreamTrack",1),oQ([YB()],sQ.prototype,"setRemoteStreamRenderSync",1);var cQ={"client unpublished":V.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":V.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":V.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":V.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":V.STREAM_REMOVE_REASON_REPUBLISH},uQ=new YL("VERTC",0);KL.storeKey="".concat(Date.now(),"-").concat(oj.getDeviceId()),[GB,HB,zB].forEach((function(e){var t;return e.setStats({rtc_sdk_version:dj.VERSION,product_line:tB.RTC,report_version:rB.W_5,os:nB.WEB,device_id:oj.getDeviceId(),log_cache_key:KL.storeKey,user_agent:vD()?"":null===(t=navigator)||void 0===t?void 0:t.userAgent})}));var dQ=function(e,t){return uQ.print("createEngine","Invoke VERTC.createEngine"),zD(e,"appId"),[GB,HB,zB].forEach((function(r){return r.setStats({rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy})})),FB.sdkInitEngine(Date.now(),wB.BEGIN),new sQ(e,t)},lQ=function(e){if(uQ.print("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof sQ))throw new hP(dP.INVALID_ENGINE,"Invalid engine object");e.destroy(),FB.sdkInitEngine(Date.now(),wB.END)},hQ=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",jH.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),fQ=function(){var e=c(o().mark((function e(){var t,r,n,i,a,s,c=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=13;break}return e.prev=4,e.next=7,jH.getPermissions({video:!0,force:!0});case 7:a=e.sent,i.video=a.video,e.next=13;break;case 11:e.prev=11,e.t0=e.catch(4);case 13:if(!n){e.next=23;break}return e.prev=14,e.next=17,jH.getPermissions({audio:!0,force:!0});case 17:s=e.sent,i.audio=s.audio,e.next=23;break;case 21:e.prev=21,e.t1=e.catch(14);case 23:return e.abrupt("return",i);case 24:case"end":return e.stop()}}),e,null,[[4,11],[14,21]])})));return function(){return e.apply(this,arguments)}}(),pQ=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",jH.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),vQ=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",jH.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_Q=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",jH.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),mQ=function(){return dj.VERSION},yQ=function(){return FB.rtcSdkApiCall("isSupported",0,""),Jj()},gQ=function(){return FB.rtcSdkApiCall("getSupportedCodecs",0,""),Zj()},SQ=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(KL.logLevel=t),r&&(KL.LogfileSize=r)},EQ=function(e){KL.download(e)};function bQ(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return JSON.stringify(t.map((function(e){return e instanceof sQ?"[ENGINE]":e})))}function kQ(e,t){return function(){WB(t,0,bQ.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return qB(t,0,bQ(e)),e})).catch((function(e){throw qB(t,e.code,e.message),e})):(qB(t,0,bQ(r)),r)}}return!vD()&&location.search.includes("_rtc_autotest_"),i(i(i(i({},new(l((function e(){u(this,e),h(this,"getSdkVersion",kQ(mQ,"getSdkVersion")),h(this,"createEngine",kQ(dQ,"createEngine")),h(this,"destroyEngine",kQ(lQ,"destroyEngine")),h(this,"enumerateDevices",kQ(hQ,"enumerateDevices")),h(this,"enableDevices",kQ(fQ,"enableDevices")),h(this,"enumerateAudioCaptureDevices",kQ(pQ,"enumerateAudioCaptureDevices")),h(this,"enumerateVideoCaptureDevices",kQ(vQ,"enumerateVideoCaptureDevices")),h(this,"enumerateAudioPlaybackDevices",kQ(_Q,"enumerateAudioPlaybackDevices")),h(this,"getParameter",hj),h(this,"setParameter",lj),h(this,"isSupported",kQ(yQ,"isSupported")),h(this,"getSupportedCodecs",kQ(gQ,"getSupportedCodecs")),h(this,"events",oe),h(this,"ErrorCode",dP),h(this,"platform","".concat({}.PRODUCT_PLATFORM)),h(this,"_monitor",FB),h(this,"downloadLog",kQ(EQ,"downloadLog")),h(this,"setLogConfig",kQ(SQ,"setLogConfig"))})))),ee),ie),{},{events:oe})}));
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).BytePlusRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function t(e){var t,n,i,o=2;for("undefined"!=typeof Symbol&&(n=Symbol.asyncIterator,i=Symbol.iterator);o--;){if(n&&null!=(t=e[n]))return t.call(e);if(i&&null!=(t=e[i]))return new r(t.call(e));n="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}function r(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(r=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new r(e)}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(){o=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(w){u=function(e,t,r){return e[t]=r}}function d(e,t,r,i){var o=t&&t.prototype instanceof f?t:f,a=Object.create(o.prototype),s=new A(i||[]);return n(a,"_invoke",{value:b(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(w){return{type:"throw",arg:w}}}e.wrap=d;var h={};function f(){}function p(){}function v(){}var _={};u(_,a,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(R([])));y&&y!==t&&r.call(y,a)&&(_=y);var g=v.prototype=f.prototype=Object.create(_);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function i(n,o,a,s){var c=l(e[n],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function b(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=k(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function k(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method))return h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function R(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return p.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=u(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},S(E.prototype),u(E.prototype,s,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new E(d(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(g),u(g,c,"Generator"),u(g,a,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=R,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:R(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function a(e){return(a="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})(e)}function s(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void r(u)}s.done?t(c):Promise.resolve(c).then(n,i)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){s(o,n,i,a,c,"next",e)}function c(e){s(o,n,i,a,c,"throw",e)}a(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(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&&v(e,t)}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function _(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(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 m(e)}function g(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=p(e);if(t){var i=p(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return y(this,r)}}function S(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}function E(){return E="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=S(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},E.apply(this,arguments)}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(c){s=!0,i=c}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||T(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 k(e){return function(e){if(Array.isArray(e))return I(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||T(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 T(e,t){if(e){if("string"==typeof e)return I(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function A(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=T(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},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 o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}var R=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}(R||{}),C=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(C||{}),w=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(w||{}),O=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(O||{}),x=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(x||{}),P=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(P||{}),D=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(D||{}),N=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(N||{}),M=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e}(M||{}),L=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(L||{}),U=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(U||{}),V=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(V||{}),F=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(F||{}),B=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(B||{}),j=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(j||{}),G=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(G||{}),H=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(H||{}),z=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(z||{}),K=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(K||{}),X=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(X||{}),W=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e}(W||{}),q=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(q||{}),Y=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(Y||{}),J=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(J||{}),Q=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(Q||{}),Z=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Z||{}),$=function(e){return e.H264="H264",e.H265="H265",e}($||{}),ee=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:R,AudioSourceType:C,UserOfflineReason:w,ChannelProfile:O,SubscribeMode:x,SubscribeState:P,PublishState:D,MirrorMode:N,VideoRenderMode:M,StreamIndex:L,MediaType:U,StreamRemoveReason:V,ConnectionState:F,MirrorType:B,LogChannel:j,USER_ONLINE_STATUS:G,PublicStreamType:H,PublicInterpolationMode:z,SubscribeFallbackOption:K,RemoteUserPriority:X,NetworkQuality:W,FallbackOrRecoverReason:q,RoomProfileType:Y,AudioProfileType:J,RTCAutoPlayPolicy:Q,AAC_PROFILE:Z,TRANSCODING_VIDEO_CODEC:$},Symbol.toStringTag,{value:"Module"})),te=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(te||{}),re=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(re||{}),ne=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(ne||{}),ie=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:te,AudioMixingType:re,AudioMixingState:ne},Symbol.toStringTag,{value:"Module"})),oe=function(e){return e.onTrackEnded="onTrackEnded",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onServerParamsSetResult="onServerParamsSetResult",e}(oe||{}),ae="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var se=function(e){return e&&e.Math==Math&&e},ce=se("object"==typeof globalThis&&globalThis)||se("object"==typeof window&&window)||se("object"==typeof self&&self)||se("object"==typeof ae&&ae)||function(){return this}()||Function("return this")(),ue={},de=function(e){try{return!!e()}catch(t){return!0}},le=!de((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),he=!de((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),fe=he,pe=Function.prototype.call,ve=fe?pe.bind(pe):function(){return pe.apply(pe,arguments)},_e={},me={}.propertyIsEnumerable,ye=Object.getOwnPropertyDescriptor,ge=ye&&!me.call({1:2},1);_e.f=ge?function(e){var t=ye(this,e);return!!t&&t.enumerable}:me;var Se,Ee,be=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},ke=he,Te=Function.prototype,Ie=Te.call,Ae=ke&&Te.bind.bind(Ie,Ie),Re=ke?Ae:function(e){return function(){return Ie.apply(e,arguments)}},Ce=Re,we=Ce({}.toString),Oe=Ce("".slice),xe=function(e){return Oe(we(e),8,-1)},Pe=de,De=xe,Ne=Object,Me=Re("".split),Le=Pe((function(){return!Ne("z").propertyIsEnumerable(0)}))?function(e){return"String"==De(e)?Me(e,""):Ne(e)}:Ne,Ue=function(e){return null==e},Ve=Ue,Fe=TypeError,Be=function(e){if(Ve(e))throw Fe("Can't call method on "+e);return e},je=Le,Ge=Be,He=function(e){return je(Ge(e))},ze="object"==typeof document&&document.all,Ke={all:ze,IS_HTMLDDA:void 0===ze&&void 0!==ze},Xe=Ke.all,We=Ke.IS_HTMLDDA?function(e){return"function"==typeof e||e===Xe}:function(e){return"function"==typeof e},qe=We,Ye=Ke.all,Je=Ke.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:qe(e)||e===Ye}:function(e){return"object"==typeof e?null!==e:qe(e)},Qe=ce,Ze=We,$e=function(e){return Ze(e)?e:void 0},et=function(e,t){return arguments.length<2?$e(Qe[e]):Qe[e]&&Qe[e][t]},tt=Re({}.isPrototypeOf),rt=et("navigator","userAgent")||"",nt=ce,it=rt,ot=nt.process,at=nt.Deno,st=ot&&ot.versions||at&&at.version,ct=st&&st.v8;ct&&(Ee=(Se=ct.split("."))[0]>0&&Se[0]<4?1:+(Se[0]+Se[1])),!Ee&&it&&(!(Se=it.match(/Edge\/(\d+)/))||Se[1]>=74)&&(Se=it.match(/Chrome\/(\d+)/))&&(Ee=+Se[1]);var ut=Ee,dt=ut,lt=de,ht=!!Object.getOwnPropertySymbols&&!lt((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&dt&&dt<41})),ft=ht&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,pt=et,vt=We,_t=tt,mt=Object,yt=ft?function(e){return"symbol"==typeof e}:function(e){var t=pt("Symbol");return vt(t)&&_t(t.prototype,mt(e))},gt=String,St=function(e){try{return gt(e)}catch(t){return"Object"}},Et=We,bt=St,kt=TypeError,Tt=function(e){if(Et(e))return e;throw kt(bt(e)+" is not a function")},It=Tt,At=Ue,Rt=function(e,t){var r=e[t];return At(r)?void 0:It(r)},Ct=ve,wt=We,Ot=Je,xt=TypeError,Pt={exports:{}},Dt=ce,Nt=Object.defineProperty,Mt=function(e,t){try{Nt(Dt,e,{value:t,configurable:!0,writable:!0})}catch(r){Dt[e]=t}return t},Lt=Mt,Ut="__core-js_shared__",Vt=ce[Ut]||Lt(Ut,{}),Ft=Vt;(Pt.exports=function(e,t){return Ft[e]||(Ft[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Bt=Be,jt=Object,Gt=function(e){return jt(Bt(e))},Ht=Gt,zt=Re({}.hasOwnProperty),Kt=Object.hasOwn||function(e,t){return zt(Ht(e),t)},Xt=Re,Wt=0,qt=Math.random(),Yt=Xt(1..toString),Jt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Yt(++Wt+qt,36)},Qt=ce,Zt=Pt.exports,$t=Kt,er=Jt,tr=ht,rr=ft,nr=Zt("wks"),ir=Qt.Symbol,or=ir&&ir.for,ar=rr?ir:ir&&ir.withoutSetter||er,sr=function(e){if(!$t(nr,e)||!tr&&"string"!=typeof nr[e]){var t="Symbol."+e;tr&&$t(ir,e)?nr[e]=ir[e]:nr[e]=rr&&or?or(t):ar(t)}return nr[e]},cr=ve,ur=Je,dr=yt,lr=Rt,hr=function(e,t){var r,n;if("string"===t&&wt(r=e.toString)&&!Ot(n=Ct(r,e)))return n;if(wt(r=e.valueOf)&&!Ot(n=Ct(r,e)))return n;if("string"!==t&&wt(r=e.toString)&&!Ot(n=Ct(r,e)))return n;throw xt("Can't convert object to primitive value")},fr=TypeError,pr=sr("toPrimitive"),vr=function(e,t){if(!ur(e)||dr(e))return e;var r,n=lr(e,pr);if(n){if(void 0===t&&(t="default"),r=cr(n,e,t),!ur(r)||dr(r))return r;throw fr("Can't convert object to primitive value")}return void 0===t&&(t="number"),hr(e,t)},_r=vr,mr=yt,yr=function(e){var t=_r(e,"string");return mr(t)?t:t+""},gr=Je,Sr=ce.document,Er=gr(Sr)&&gr(Sr.createElement),br=function(e){return Er?Sr.createElement(e):{}},kr=br,Tr=!le&&!de((function(){return 7!=Object.defineProperty(kr("div"),"a",{get:function(){return 7}}).a})),Ir=le,Ar=ve,Rr=_e,Cr=be,wr=He,Or=yr,xr=Kt,Pr=Tr,Dr=Object.getOwnPropertyDescriptor;ue.f=Ir?Dr:function(e,t){if(e=wr(e),t=Or(t),Pr)try{return Dr(e,t)}catch(r){}if(xr(e,t))return Cr(!Ar(Rr.f,e,t),e[t])};var Nr={},Mr=le&&de((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Lr=Je,Ur=String,Vr=TypeError,Fr=function(e){if(Lr(e))return e;throw Vr(Ur(e)+" is not an object")},Br=le,jr=Tr,Gr=Mr,Hr=Fr,zr=yr,Kr=TypeError,Xr=Object.defineProperty,Wr=Object.getOwnPropertyDescriptor,qr="enumerable",Yr="configurable",Jr="writable";Nr.f=Br?Gr?function(e,t,r){if(Hr(e),t=zr(t),Hr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&Jr in r&&!r.writable){var n=Wr(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:Yr in r?r.configurable:n.configurable,enumerable:qr in r?r.enumerable:n.enumerable,writable:!1})}return Xr(e,t,r)}:Xr:function(e,t,r){if(Hr(e),t=zr(t),Hr(r),jr)try{return Xr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw Kr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var Qr=Nr,Zr=be,$r=le?function(e,t,r){return Qr.f(e,t,Zr(1,r))}:function(e,t,r){return e[t]=r,e},en={exports:{}},tn=le,rn=Kt,nn=Function.prototype,on=tn&&Object.getOwnPropertyDescriptor,an=rn(nn,"name"),sn={EXISTS:an,PROPER:an&&"something"===function(){}.name,CONFIGURABLE:an&&(!tn||tn&&on(nn,"name").configurable)},cn=We,un=Vt,dn=Re(Function.toString);cn(un.inspectSource)||(un.inspectSource=function(e){return dn(e)});var ln,hn,fn,pn=un.inspectSource,vn=We,_n=ce.WeakMap,mn=vn(_n)&&/native code/.test(String(_n)),yn=Pt.exports,gn=Jt,Sn=yn("keys"),En=function(e){return Sn[e]||(Sn[e]=gn(e))},bn={},kn=mn,Tn=ce,In=Je,An=$r,Rn=Kt,Cn=Vt,wn=En,On=bn,xn="Object already initialized",Pn=Tn.TypeError,Dn=Tn.WeakMap;if(kn||Cn.state){var Nn=Cn.state||(Cn.state=new Dn);Nn.get=Nn.get,Nn.has=Nn.has,Nn.set=Nn.set,ln=function(e,t){if(Nn.has(e))throw Pn(xn);return t.facade=e,Nn.set(e,t),t},hn=function(e){return Nn.get(e)||{}},fn=function(e){return Nn.has(e)}}else{var Mn=wn("state");On[Mn]=!0,ln=function(e,t){if(Rn(e,Mn))throw Pn(xn);return t.facade=e,An(e,Mn,t),t},hn=function(e){return Rn(e,Mn)?e[Mn]:{}},fn=function(e){return Rn(e,Mn)}}var Ln={set:ln,get:hn,has:fn,enforce:function(e){return fn(e)?hn(e):ln(e,{})},getterFor:function(e){return function(t){var r;if(!In(t)||(r=hn(t)).type!==e)throw Pn("Incompatible receiver, "+e+" required");return r}}},Un=de,Vn=We,Fn=Kt,Bn=le,jn=sn.CONFIGURABLE,Gn=pn,Hn=Ln.enforce,zn=Ln.get,Kn=Object.defineProperty,Xn=Bn&&!Un((function(){return 8!==Kn((function(){}),"length",{value:8}).length})),Wn=String(String).split("String"),qn=en.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Fn(e,"name")||jn&&e.name!==t)&&(Bn?Kn(e,"name",{value:t,configurable:!0}):e.name=t),Xn&&r&&Fn(r,"arity")&&e.length!==r.arity&&Kn(e,"length",{value:r.arity});try{r&&Fn(r,"constructor")&&r.constructor?Bn&&Kn(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(i){}var n=Hn(e);return Fn(n,"source")||(n.source=Wn.join("string"==typeof t?t:"")),e};Function.prototype.toString=qn((function(){return Vn(this)&&zn(this).source||Gn(this)}),"toString");var Yn=We,Jn=Nr,Qn=en.exports,Zn=Mt,$n=function(e,t,r,n){n||(n={});var i=n.enumerable,o=void 0!==n.name?n.name:t;if(Yn(r)&&Qn(r,o,n),n.global)i?e[t]=r:Zn(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch(a){}i?e[t]=r:Jn.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},ei={},ti=Math.ceil,ri=Math.floor,ni=Math.trunc||function(e){var t=+e;return(t>0?ri:ti)(t)},ii=function(e){var t=+e;return t!=t||0===t?0:ni(t)},oi=ii,ai=Math.max,si=Math.min,ci=function(e,t){var r=oi(e);return r<0?ai(r+t,0):si(r,t)},ui=ii,di=Math.min,li=function(e){return e>0?di(ui(e),9007199254740991):0},hi=li,fi=function(e){return hi(e.length)},pi=He,vi=ci,_i=fi,mi=function(e){return function(t,r,n){var i,o=pi(t),a=_i(o),s=vi(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},yi={includes:mi(!0),indexOf:mi(!1)},gi=Kt,Si=He,Ei=yi.indexOf,bi=bn,ki=Re([].push),Ti=function(e,t){var r,n=Si(e),i=0,o=[];for(r in n)!gi(bi,r)&&gi(n,r)&&ki(o,r);for(;t.length>i;)gi(n,r=t[i++])&&(~Ei(o,r)||ki(o,r));return o},Ii=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ai=Ti,Ri=Ii.concat("length","prototype");ei.f=Object.getOwnPropertyNames||function(e){return Ai(e,Ri)};var Ci={};Ci.f=Object.getOwnPropertySymbols;var wi=et,Oi=ei,xi=Ci,Pi=Fr,Di=Re([].concat),Ni=wi("Reflect","ownKeys")||function(e){var t=Oi.f(Pi(e)),r=xi.f;return r?Di(t,r(e)):t},Mi=Kt,Li=Ni,Ui=ue,Vi=Nr,Fi=function(e,t,r){for(var n=Li(t),i=Vi.f,o=Ui.f,a=0;a<n.length;a++){var s=n[a];Mi(e,s)||r&&Mi(r,s)||i(e,s,o(t,s))}},Bi=de,ji=We,Gi=/#|\.prototype\./,Hi=function(e,t){var r=Ki[zi(e)];return r==Wi||r!=Xi&&(ji(t)?Bi(t):!!t)},zi=Hi.normalize=function(e){return String(e).replace(Gi,".").toLowerCase()},Ki=Hi.data={},Xi=Hi.NATIVE="N",Wi=Hi.POLYFILL="P",qi=Hi,Yi=ce,Ji=ue.f,Qi=$r,Zi=$n,$i=Mt,eo=Fi,to=qi,ro=function(e,t){var r,n,i,o,a,s=e.target,c=e.global,u=e.stat;if(r=c?Yi:u?Yi[s]||$i(s,{}):(Yi[s]||{}).prototype)for(n in t){if(o=t[n],i=e.dontCallGetSet?(a=Ji(r,n))&&a.value:r[n],!to(c?n:s+(u?".":"#")+n,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;eo(o,i)}(e.sham||i&&i.sham)&&Qi(o,"sham",!0),Zi(r,n,o,e)}},no=xe,io=Array.isArray||function(e){return"Array"==no(e)},oo=TypeError,ao=function(e){if(e>9007199254740991)throw oo("Maximum allowed index exceeded");return e},so=yr,co=Nr,uo=be,lo=function(e,t,r){var n=so(t);n in e?co.f(e,n,uo(0,r)):e[n]=r},ho={};ho[sr("toStringTag")]="z";var fo="[object z]"===String(ho),po=fo,vo=We,_o=xe,mo=sr("toStringTag"),yo=Object,go="Arguments"==_o(function(){return arguments}()),So=po?_o:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=yo(e),mo))?r:go?_o(t):"Object"==(n=_o(t))&&vo(t.callee)?"Arguments":n},Eo=Re,bo=de,ko=We,To=So,Io=pn,Ao=function(){},Ro=[],Co=et("Reflect","construct"),wo=/^\s*(?:class|function)\b/,Oo=Eo(wo.exec),xo=!wo.exec(Ao),Po=function(e){if(!ko(e))return!1;try{return Co(Ao,Ro,e),!0}catch(t){return!1}},Do=function(e){if(!ko(e))return!1;switch(To(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return xo||!!Oo(wo,Io(e))}catch(t){return!0}};Do.sham=!0;var No=!Co||bo((function(){var e;return Po(Po.call)||!Po(Object)||!Po((function(){e=!0}))||e}))?Do:Po,Mo=io,Lo=No,Uo=Je,Vo=sr("species"),Fo=Array,Bo=function(e){var t;return Mo(e)&&(t=e.constructor,(Lo(t)&&(t===Fo||Mo(t.prototype))||Uo(t)&&null===(t=t[Vo]))&&(t=void 0)),void 0===t?Fo:t},jo=function(e,t){return new(Bo(e))(0===t?0:t)},Go=de,Ho=ut,zo=sr("species"),Ko=function(e){return Ho>=51||!Go((function(){var t=[];return(t.constructor={})[zo]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Xo=ro,Wo=de,qo=io,Yo=Je,Jo=Gt,Qo=fi,Zo=ao,$o=lo,ea=jo,ta=Ko,ra=ut,na=sr("isConcatSpreadable"),ia=ra>=51||!Wo((function(){var e=[];return e[na]=!1,e.concat()[0]!==e})),oa=ta("concat"),aa=function(e){if(!Yo(e))return!1;var t=e[na];return void 0!==t?!!t:qo(e)};Xo({target:"Array",proto:!0,arity:1,forced:!ia||!oa},{concat:function(e){var t,r,n,i,o,a=Jo(this),s=ea(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(aa(o=-1===t?a:arguments[t]))for(i=Qo(o),Zo(c+i),r=0;r<i;r++,c++)r in o&&$o(s,c,o[r]);else Zo(c+1),$o(s,c++,o);return s.length=c,s}});var sa=So,ca=fo?{}.toString:function(){return"[object "+sa(this)+"]"};fo||$n(Object.prototype,"toString",ca,{unsafe:!0});var ua={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},da=br("span").classList,la=da&&da.constructor&&da.constructor.prototype,ha=la===Object.prototype?void 0:la,fa=xe,pa=Re,va=function(e){if("Function"===fa(e))return pa(e)},_a=Tt,ma=he,ya=va(va.bind),ga=function(e,t){return _a(e),void 0===t?e:ma?ya(e,t):function(){return e.apply(t,arguments)}},Sa=ga,Ea=Le,ba=Gt,ka=fi,Ta=jo,Ia=Re([].push),Aa=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,f,p=ba(c),v=Ea(p),_=Sa(u,d),m=ka(v),y=0,g=l||Ta,S=t?g(c,m):r||a?g(c,0):void 0;m>y;y++)if((s||y in v)&&(f=_(h=v[y],y,p),e))if(t)S[y]=f;else if(f)switch(e){case 3:return!0;case 5:return h;case 6:return y;case 2:Ia(S,h)}else switch(e){case 4:return!1;case 7:Ia(S,h)}return o?-1:n||i?i:S}},Ra={forEach:Aa(0),map:Aa(1),filter:Aa(2),some:Aa(3),every:Aa(4),find:Aa(5),findIndex:Aa(6),filterReject:Aa(7)},Ca=de,wa=function(e,t){var r=[][e];return!!r&&Ca((function(){r.call(null,t||function(){return 1},1)}))},Oa=Ra.forEach,xa=wa("forEach")?[].forEach:function(e){return Oa(this,e,arguments.length>1?arguments[1]:void 0)},Pa=ce,Da=ua,Na=ha,Ma=xa,La=$r,Ua=function(e){if(e&&e.forEach!==Ma)try{La(e,"forEach",Ma)}catch(t){e.forEach=Ma}};for(var Va in Da)Da[Va]&&Ua(Pa[Va]&&Pa[Va].prototype);Ua(Na);var Fa={},Ba=Ti,ja=Ii,Ga=Object.keys||function(e){return Ba(e,ja)},Ha=le,za=Mr,Ka=Nr,Xa=Fr,Wa=He,qa=Ga;Fa.f=Ha&&!za?Object.defineProperties:function(e,t){Xa(e);for(var r,n=Wa(t),i=qa(t),o=i.length,a=0;o>a;)Ka.f(e,r=i[a++],n[r]);return e};var Ya,Ja=et("document","documentElement"),Qa=Fr,Za=Fa,$a=Ii,es=bn,ts=Ja,rs=br,ns=En("IE_PROTO"),is=function(){},os=function(e){return"<script>"+e+"</"+"script>"},as=function(e){e.write(os("")),e.close();var t=e.parentWindow.Object;return e=null,t},ss=function(){try{Ya=new ActiveXObject("htmlfile")}catch(n){}var e,t;ss="undefined"!=typeof document?document.domain&&Ya?as(Ya):((t=rs("iframe")).style.display="none",ts.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(os("document.F=Object")),e.close(),e.F):as(Ya);for(var r=$a.length;r--;)delete ss.prototype[$a[r]];return ss()};es[ns]=!0;var cs=Object.create||function(e,t){var r;return null!==e?(is.prototype=Qa(e),r=new is,is.prototype=null,r[ns]=e):r=ss(),void 0===t?r:Za.f(r,t)},us=sr,ds=cs,ls=Nr.f,hs=us("unscopables"),fs=Array.prototype;null==fs[hs]&&ls(fs,hs,{configurable:!0,value:ds(null)});var ps=function(e){fs[hs][e]=!0},vs=yi.includes,_s=ps;ro({target:"Array",proto:!0,forced:de((function(){return!Array(1).includes()}))},{includes:function(e){return vs(this,e,arguments.length>1?arguments[1]:void 0)}}),_s("includes");var ms=Je,ys=xe,gs=sr("match"),Ss=function(e){var t;return ms(e)&&(void 0!==(t=e[gs])?!!t:"RegExp"==ys(e))},Es=Ss,bs=TypeError,ks=function(e){if(Es(e))throw bs("The method doesn't accept regular expressions");return e},Ts=So,Is=String,As=function(e){if("Symbol"===Ts(e))throw TypeError("Cannot convert a Symbol value to a string");return Is(e)},Rs=sr("match"),Cs=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Rs]=!1,"/./"[e](t)}catch(n){}}return!1},ws=ro,Os=ks,xs=Be,Ps=As,Ds=Cs,Ns=Re("".indexOf);ws({target:"String",proto:!0,forced:!Ds("includes")},{includes:function(e){return!!~Ns(Ps(xs(this)),Ps(Os(e)),arguments.length>1?arguments[1]:void 0)}});var Ms,Ls,Us=Fr,Vs=function(){var e=Us(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Fs=de,Bs=ce.RegExp,js=Fs((function(){var e=Bs("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),Gs=js||Fs((function(){return!Bs("a","y").sticky})),Hs=js||Fs((function(){var e=Bs("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),zs={BROKEN_CARET:Hs,MISSED_STICKY:Gs,UNSUPPORTED_Y:js},Ks=de,Xs=ce.RegExp,Ws=Ks((function(){var e=Xs(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),qs=de,Ys=ce.RegExp,Js=qs((function(){var e=Ys("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),Qs=ve,Zs=Re,$s=As,ec=Vs,tc=zs,rc=Pt.exports,nc=cs,ic=Ln.get,oc=Ws,ac=Js,sc=rc("native-string-replace",String.prototype.replace),cc=RegExp.prototype.exec,uc=cc,dc=Zs("".charAt),lc=Zs("".indexOf),hc=Zs("".replace),fc=Zs("".slice),pc=(Ls=/b*/g,Qs(cc,Ms=/a/,"a"),Qs(cc,Ls,"a"),0!==Ms.lastIndex||0!==Ls.lastIndex),vc=tc.BROKEN_CARET,_c=void 0!==/()??/.exec("")[1];(pc||_c||vc||oc||ac)&&(uc=function(e){var t,r,n,i,o,a,s,c=this,u=ic(c),d=$s(e),l=u.raw;if(l)return l.lastIndex=c.lastIndex,t=Qs(uc,l,d),c.lastIndex=l.lastIndex,t;var h=u.groups,f=vc&&c.sticky,p=Qs(ec,c),v=c.source,_=0,m=d;if(f&&(p=hc(p,"y",""),-1===lc(p,"g")&&(p+="g"),m=fc(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==dc(d,c.lastIndex-1))&&(v="(?: "+v+")",m=" "+m,_++),r=new RegExp("^(?:"+v+")",p)),_c&&(r=new RegExp("^"+v+"$(?!\\s)",p)),pc&&(n=c.lastIndex),i=Qs(cc,f?r:c,m),f?i?(i.input=fc(i.input,_),i[0]=fc(i[0],_),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:pc&&i&&(c.lastIndex=c.global?i.index+i[0].length:n),_c&&i&&i.length>1&&Qs(sc,i[0],r,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(i[o]=void 0)})),i&&h)for(i.groups=a=nc(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=i[s[1]];return i});var mc=uc;ro({target:"RegExp",proto:!0,forced:/./.exec!==mc},{exec:mc});var yc=va,gc=$n,Sc=mc,Ec=de,bc=sr,kc=$r,Tc=bc("species"),Ic=RegExp.prototype,Ac=function(e,t,r,n){var i=bc(e),o=!Ec((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),a=o&&!Ec((function(){var t=!1,r=/a/;return"split"===e&&((r={}).constructor={},r.constructor[Tc]=function(){return r},r.flags="",r[i]=/./[i]),r.exec=function(){return t=!0,null},r[i](""),!t}));if(!o||!a||r){var s=yc(/./[i]),c=t(i,""[e],(function(e,t,r,n,i){var a=yc(e),c=t.exec;return c===Sc||c===Ic.exec?o&&!i?{done:!0,value:s(t,r,n)}:{done:!0,value:a(r,t,n)}:{done:!1}}));gc(String.prototype,e,c[0]),gc(Ic,i,c[1])}n&&kc(Ic[i],"sham",!0)},Rc=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},Cc=ve,wc=Fr,Oc=We,xc=xe,Pc=mc,Dc=TypeError,Nc=function(e,t){var r=e.exec;if(Oc(r)){var n=Cc(r,e,t);return null!==n&&wc(n),n}if("RegExp"===xc(e))return Cc(Pc,e,t);throw Dc("RegExp#exec called on incompatible receiver")},Mc=ve,Lc=Fr,Uc=Ue,Vc=Be,Fc=Rc,Bc=As,jc=Rt,Gc=Nc;Ac("search",(function(e,t,r){return[function(t){var r=Vc(this),n=Uc(t)?void 0:jc(t,e);return n?Mc(n,t,r):new RegExp(t)[e](Bc(r))},function(e){var n=Lc(this),i=Bc(e),o=r(t,n,i);if(o.done)return o.value;var a=n.lastIndex;Fc(a,0)||(n.lastIndex=0);var s=Gc(n,i);return Fc(n.lastIndex,a)||(n.lastIndex=a),null===s?-1:s.index}]}));var Hc=he,zc=Function.prototype,Kc=zc.apply,Xc=zc.call,Wc="object"==typeof Reflect&&Reflect.apply||(Hc?Xc.bind(Kc):function(){return Xc.apply(Kc,arguments)}),qc=Re([].slice),Yc=ro,Jc=et,Qc=Wc,Zc=ve,$c=Re,eu=de,tu=io,ru=We,nu=Je,iu=yt,ou=qc,au=ht,su=Jc("JSON","stringify"),cu=$c(/./.exec),uu=$c("".charAt),du=$c("".charCodeAt),lu=$c("".replace),hu=$c(1..toString),fu=/[\uD800-\uDFFF]/g,pu=/^[\uD800-\uDBFF]$/,vu=/^[\uDC00-\uDFFF]$/,_u=!au||eu((function(){var e=Jc("Symbol")();return"[null]"!=su([e])||"{}"!=su({a:e})||"{}"!=su(Object(e))})),mu=eu((function(){return'"\\udf06\\ud834"'!==su("\udf06\ud834")||'"\\udead"'!==su("\udead")})),yu=function(e,t){var r=ou(arguments),n=t;if((nu(t)||void 0!==e)&&!iu(e))return tu(t)||(t=function(e,t){if(ru(n)&&(t=Zc(n,this,e,t)),!iu(t))return t}),r[1]=t,Qc(su,null,r)},gu=function(e,t,r){var n=uu(r,t-1),i=uu(r,t+1);return cu(pu,e)&&!cu(vu,i)||cu(vu,e)&&!cu(pu,n)?"\\u"+hu(du(e,0),16):e};su&&Yc({target:"JSON",stat:!0,arity:3,forced:_u||mu},{stringify:function(e,t,r){var n=ou(arguments),i=Qc(_u?yu:su,null,n);return mu&&"string"==typeof i?lu(i,fu,gu):i}});var Su=Ra.map;ro({target:"Array",proto:!0,forced:!Ko("map")},{map:function(e){return Su(this,e,arguments.length>1?arguments[1]:void 0)}});var Eu=Re,bu=ii,ku=As,Tu=Be,Iu=Eu("".charAt),Au=Eu("".charCodeAt),Ru=Eu("".slice),Cu=function(e){return function(t,r){var n,i,o=ku(Tu(t)),a=bu(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Au(o,a))<55296||n>56319||a+1===s||(i=Au(o,a+1))<56320||i>57343?e?Iu(o,a):n:e?Ru(o,a,a+2):i-56320+(n-55296<<10)+65536}},wu={codeAt:Cu(!1),charAt:Cu(!0)},Ou=wu.charAt,xu=function(e,t,r){return t+(r?Ou(e,t).length:1)},Pu=ve,Du=Fr,Nu=Ue,Mu=li,Lu=As,Uu=Be,Vu=Rt,Fu=xu,Bu=Nc;Ac("match",(function(e,t,r){return[function(t){var r=Uu(this),n=Nu(t)?void 0:Vu(t,e);return n?Pu(n,t,r):new RegExp(t)[e](Lu(r))},function(e){var n=Du(this),i=Lu(e),o=r(t,n,i);if(o.done)return o.value;if(!n.global)return Bu(n,i);var a=n.unicode;n.lastIndex=0;for(var s,c=[],u=0;null!==(s=Bu(n,i));){var d=Lu(s[0]);c[u]=d,""===d&&(n.lastIndex=Fu(i,Mu(n.lastIndex),a)),u++}return 0===u?null:c}]}));var ju="\t\n\v\f\r                 \u2028\u2029\ufeff",Gu=Be,Hu=As,zu=Re("".replace),Ku="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Xu=RegExp("^"+Ku+Ku+"*"),Wu=RegExp(Ku+Ku+"*$"),qu=function(e){return function(t){var r=Hu(Gu(t));return 1&e&&(r=zu(r,Xu,"")),2&e&&(r=zu(r,Wu,"")),r}},Yu={start:qu(1),end:qu(2),trim:qu(3)},Ju=ce,Qu=de,Zu=Re,$u=As,ed=Yu.trim,td=ju,rd=Ju.parseInt,nd=Ju.Symbol,id=nd&&nd.iterator,od=/^[+-]?0x/i,ad=Zu(od.exec),sd=8!==rd(td+"08")||22!==rd(td+"0x16")||id&&!Qu((function(){rd(Object(id))}))?function(e,t){var r=ed($u(e));return rd(r,t>>>0||(ad(od,r)?16:10))}:rd;ro({global:!0,forced:parseInt!=sd},{parseInt:sd});var cd,ud,dd,ld={},hd=!de((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),fd=Kt,pd=We,vd=Gt,_d=hd,md=En("IE_PROTO"),yd=Object,gd=yd.prototype,Sd=_d?yd.getPrototypeOf:function(e){var t=vd(e);if(fd(t,md))return t[md];var r=t.constructor;return pd(r)&&t instanceof r?r.prototype:t instanceof yd?gd:null},Ed=de,bd=We,kd=Je,Td=Sd,Id=$n,Ad=sr("iterator"),Rd=!1;[].keys&&("next"in(dd=[].keys())?(ud=Td(Td(dd)))!==Object.prototype&&(cd=ud):Rd=!0),(!kd(cd)||Ed((function(){var e={};return cd[Ad].call(e)!==e})))&&(cd={}),bd(cd[Ad])||Id(cd,Ad,(function(){return this}));var Cd={IteratorPrototype:cd,BUGGY_SAFARI_ITERATORS:Rd},wd=Nr.f,Od=Kt,xd=sr("toStringTag"),Pd=function(e,t,r){e&&!r&&(e=e.prototype),e&&!Od(e,xd)&&wd(e,xd,{configurable:!0,value:t})},Dd=Cd.IteratorPrototype,Nd=cs,Md=be,Ld=Pd,Ud=ld,Vd=function(){return this},Fd=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Nd(Dd,{next:Md(+!n,r)}),Ld(e,i,!1),Ud[i]=Vd,e},Bd=We,jd=String,Gd=TypeError,Hd=Re,zd=Fr,Kd=function(e){if("object"==typeof e||Bd(e))return e;throw Gd("Can't set "+jd(e)+" as a prototype")},Xd=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Hd(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return zd(r),Kd(n),t?e(r,n):r.__proto__=n,r}}():void 0),Wd=ro,qd=ve,Yd=We,Jd=Fd,Qd=Sd,Zd=Xd,$d=Pd,el=$r,tl=$n,rl=ld,nl=sn.PROPER,il=sn.CONFIGURABLE,ol=Cd.IteratorPrototype,al=Cd.BUGGY_SAFARI_ITERATORS,sl=sr("iterator"),cl="keys",ul="values",dl="entries",ll=function(){return this},hl=function(e,t,r,n,i,o,a){Jd(r,t,n);var s,c,u,d=function(e){if(e===i&&v)return v;if(!al&&e in f)return f[e];switch(e){case cl:case ul:case dl:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,f=e.prototype,p=f[sl]||f["@@iterator"]||i&&f[i],v=!al&&p||d(i),_="Array"==t&&f.entries||p;if(_&&(s=Qd(_.call(new e)))!==Object.prototype&&s.next&&(Qd(s)!==ol&&(Zd?Zd(s,ol):Yd(s[sl])||tl(s,sl,ll)),$d(s,l,!0)),nl&&i==ul&&p&&p.name!==ul&&(il?el(f,"name",ul):(h=!0,v=function(){return qd(p,this)})),i)if(c={values:d(ul),keys:o?v:d(cl),entries:d(dl)},a)for(u in c)(al||h||!(u in f))&&tl(f,u,c[u]);else Wd({target:t,proto:!0,forced:al||h},c);return f[sl]!==v&&tl(f,sl,v,{name:i}),rl[t]=v,c},fl=function(e,t){return{value:e,done:t}},pl=He,vl=ps,_l=ld,ml=Ln,yl=Nr.f,gl=hl,Sl=fl,El=le,bl="Array Iterator",kl=ml.set,Tl=ml.getterFor(bl),Il=gl(Array,"Array",(function(e,t){kl(this,{type:bl,target:pl(e),index:0,kind:t})}),(function(){var e=Tl(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,Sl(void 0,!0)):Sl("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values"),Al=_l.Arguments=_l.Array;if(vl("keys"),vl("values"),vl("entries"),El&&"values"!==Al.name)try{yl(Al,"name",{value:"values"})}catch(EZ){}var Rl={exports:{}},Cl={},wl=ci,Ol=fi,xl=lo,Pl=Array,Dl=Math.max,Nl=function(e,t,r){for(var n=Ol(e),i=wl(t,n),o=wl(void 0===r?n:r,n),a=Pl(Dl(o-i,0)),s=0;i<o;i++,s++)xl(a,s,e[i]);return a.length=s,a},Ml=xe,Ll=He,Ul=ei.f,Vl=Nl,Fl="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Cl.f=function(e){return Fl&&"Window"==Ml(e)?function(e){try{return Ul(e)}catch(EZ){return Vl(Fl)}}(e):Ul(Ll(e))};var Bl=de((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),jl=de,Gl=Je,Hl=xe,zl=Bl,Kl=Object.isExtensible,Xl=jl((function(){Kl(1)}))||zl?function(e){return!!Gl(e)&&((!zl||"ArrayBuffer"!=Hl(e))&&(!Kl||Kl(e)))}:Kl,Wl=!de((function(){return Object.isExtensible(Object.preventExtensions({}))})),ql=ro,Yl=Re,Jl=bn,Ql=Je,Zl=Kt,$l=Nr.f,eh=ei,th=Cl,rh=Xl,nh=Wl,ih=!1,oh=Jt("meta"),ah=0,sh=function(e){$l(e,oh,{value:{objectID:"O"+ah++,weakData:{}}})},ch=Rl.exports={enable:function(){ch.enable=function(){},ih=!0;var e=eh.f,t=Yl([].splice),r={};r[oh]=1,e(r).length&&(eh.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===oh){t(n,i,1);break}return n},ql({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:th.f}))},fastKey:function(e,t){if(!Ql(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Zl(e,oh)){if(!rh(e))return"F";if(!t)return"E";sh(e)}return e[oh].objectID},getWeakData:function(e,t){if(!Zl(e,oh)){if(!rh(e))return!0;if(!t)return!1;sh(e)}return e[oh].weakData},onFreeze:function(e){return nh&&ih&&rh(e)&&!Zl(e,oh)&&sh(e),e}};Jl[oh]=!0;var uh=ld,dh=sr("iterator"),lh=Array.prototype,hh=function(e){return void 0!==e&&(uh.Array===e||lh[dh]===e)},fh=So,ph=Rt,vh=Ue,_h=ld,mh=sr("iterator"),yh=function(e){if(!vh(e))return ph(e,mh)||ph(e,"@@iterator")||_h[fh(e)]},gh=ve,Sh=Tt,Eh=Fr,bh=St,kh=yh,Th=TypeError,Ih=function(e,t){var r=arguments.length<2?kh(e):t;if(Sh(r))return Eh(gh(r,e));throw Th(bh(e)+" is not iterable")},Ah=ve,Rh=Fr,Ch=Rt,wh=function(e,t,r){var n,i;Rh(e);try{if(!(n=Ch(e,"return"))){if("throw"===t)throw r;return r}n=Ah(n,e)}catch(EZ){i=!0,n=EZ}if("throw"===t)throw r;if(i)throw n;return Rh(n),r},Oh=ga,xh=ve,Ph=Fr,Dh=St,Nh=hh,Mh=fi,Lh=tt,Uh=Ih,Vh=yh,Fh=wh,Bh=TypeError,jh=function(e,t){this.stopped=e,this.result=t},Gh=jh.prototype,Hh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),f=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),v=Oh(t,d),_=function(e){return n&&Fh(n,"normal",e),new jh(!0,e)},m=function(e){return l?(Ph(e),p?v(e[0],e[1],_):v(e[0],e[1])):p?v(e,_):v(e)};if(h)n=e.iterator;else if(f)n=e;else{if(!(i=Vh(e)))throw Bh(Dh(e)+" is not iterable");if(Nh(i)){for(o=0,a=Mh(e);a>o;o++)if((s=m(e[o]))&&Lh(Gh,s))return s;return new jh(!1)}n=Uh(e,i)}for(c=h?e.next:n.next;!(u=xh(c,n)).done;){try{s=m(u.value)}catch(EZ){Fh(n,"throw",EZ)}if("object"==typeof s&&s&&Lh(Gh,s))return s}return new jh(!1)},zh=tt,Kh=TypeError,Xh=function(e,t){if(zh(t,e))return e;throw Kh("Incorrect invocation")},Wh=sr("iterator"),qh=!1;try{var Yh=0,Jh={next:function(){return{done:!!Yh++}},return:function(){qh=!0}};Jh[Wh]=function(){return this},Array.from(Jh,(function(){throw 2}))}catch(EZ){}var Qh=function(e,t){if(!t&&!qh)return!1;var r=!1;try{var n={};n[Wh]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(EZ){}return r},Zh=We,$h=Je,ef=Xd,tf=function(e,t,r){var n,i;return ef&&Zh(n=t.constructor)&&n!==r&&$h(i=n.prototype)&&i!==r.prototype&&ef(e,i),e},rf=ro,nf=ce,of=Re,af=qi,sf=$n,cf=Rl.exports,uf=Hh,df=Xh,lf=We,hf=Ue,ff=Je,pf=de,vf=Qh,_f=Pd,mf=tf,yf=function(e,t,r){var n=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),o=n?"set":"add",a=nf[e],s=a&&a.prototype,c=a,u={},d=function(e){var t=of(s[e]);sf(s,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!ff(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return i&&!ff(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!ff(e))&&t(this,0===e?0:e)}:function(e,r){return t(this,0===e?0:e,r),this})};if(af(e,!lf(a)||!(i||s.forEach&&!pf((function(){(new a).entries().next()})))))c=r.getConstructor(t,e,n,o),cf.enable();else if(af(e,!0)){var l=new c,h=l[o](i?{}:-0,1)!=l,f=pf((function(){l.has(1)})),p=vf((function(e){new a(e)})),v=!i&&pf((function(){for(var e=new a,t=5;t--;)e[o](t,t);return!e.has(-0)}));p||((c=t((function(e,t){df(e,s);var r=mf(new a,e,c);return hf(t)||uf(t,r[o],{that:r,AS_ENTRIES:n}),r}))).prototype=s,s.constructor=c),(f||v)&&(d("delete"),d("has"),n&&d("get")),(v||h)&&d(o),i&&s.clear&&delete s.clear}return u[e]=c,rf({global:!0,constructor:!0,forced:c!=a},u),_f(c,e),i||r.setStrong(c,e,n),c},gf=$n,Sf=function(e,t,r){for(var n in t)gf(e,n,t[n],r);return e},Ef=et,bf=Nr,kf=le,Tf=sr("species"),If=function(e){var t=Ef(e),r=bf.f;kf&&t&&!t[Tf]&&r(t,Tf,{configurable:!0,get:function(){return this}})},Af=Nr.f,Rf=cs,Cf=Sf,wf=ga,Of=Xh,xf=Ue,Pf=Hh,Df=hl,Nf=fl,Mf=If,Lf=le,Uf=Rl.exports.fastKey,Vf=Ln.set,Ff=Ln.getterFor,Bf={getConstructor:function(e,t,r,n){var i=e((function(e,i){Of(e,o),Vf(e,{type:t,index:Rf(null),first:void 0,last:void 0,size:0}),Lf||(e.size=0),xf(i)||Pf(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=Ff(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=Uf(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),Lf?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=Uf(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return Cf(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,Lf?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),Lf?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=wf(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),Cf(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),Lf&&Af(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=Ff(t),o=Ff(n);Df(e,t,(function(e,t){Vf(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?Nf("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,Nf(void 0,!0))}),r?"entries":"values",!r,!0),Mf(t)}};yf("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Bf);var jf=wu.charAt,Gf=As,Hf=Ln,zf=hl,Kf=fl,Xf="String Iterator",Wf=Hf.set,qf=Hf.getterFor(Xf);zf(String,"String",(function(e){Wf(this,{type:Xf,string:Gf(e),index:0})}),(function(){var e,t=qf(this),r=t.string,n=t.index;return n>=r.length?Kf(void 0,!0):(e=jf(r,n),t.index+=e.length,Kf(e,!1))}));var Yf=ce,Jf=ua,Qf=ha,Zf=Il,$f=$r,ep=sr,tp=ep("iterator"),rp=ep("toStringTag"),np=Zf.values,ip=function(e,t){if(e){if(e[tp]!==np)try{$f(e,tp,np)}catch(EZ){e[tp]=np}if(e[rp]||$f(e,rp,t),Jf[t])for(var r in Zf)if(e[r]!==Zf[r])try{$f(e,r,Zf[r])}catch(EZ){e[r]=Zf[r]}}};for(var op in Jf)ip(Yf[op]&&Yf[op].prototype,op);ip(Qf,"DOMTokenList");var ap=Gt,sp=Ga;ro({target:"Object",stat:!0,forced:de((function(){sp(1)}))},{keys:function(e){return sp(ap(e))}});var cp=ro,up=le,dp=Nr.f;cp({target:"Object",stat:!0,forced:Object.defineProperty!==dp,sham:!up},{defineProperty:dp});var lp=Nr.f,hp=function(e,t,r){r in e||lp(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},fp=As,pp=function(e,t){return void 0===e?arguments.length<2?"":t:fp(e)},vp=Je,_p=$r,mp=Error,yp=Re("".replace),gp=String(mp("zxcasd").stack),Sp=/\n\s*at [^:]*:[^\n]*/,Ep=Sp.test(gp),bp=function(e,t){if(Ep&&"string"==typeof e&&!mp.prepareStackTrace)for(;t--;)e=yp(e,Sp,"");return e},kp=be,Tp=!de((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",kp(1,7)),7!==e.stack)})),Ip=et,Ap=Kt,Rp=$r,Cp=tt,wp=Xd,Op=Fi,xp=hp,Pp=tf,Dp=pp,Np=function(e,t){vp(t)&&"cause"in t&&_p(e,"cause",t.cause)},Mp=bp,Lp=Tp,Up=le,Vp=ro,Fp=Wc,Bp=function(e,t,r,n){var i="stackTraceLimit",o=n?2:1,a=e.split("."),s=a[a.length-1],c=Ip.apply(null,a);if(c){var u=c.prototype;if(Ap(u,"cause")&&delete u.cause,!r)return c;var d=Ip("Error"),l=t((function(e,t){var r=Dp(n?t:e,void 0),i=n?new c(e):new c;return void 0!==r&&Rp(i,"message",r),Lp&&Rp(i,"stack",Mp(i.stack,2)),this&&Cp(u,this)&&Pp(i,this,l),arguments.length>o&&Np(i,arguments[o]),i}));l.prototype=u,"Error"!==s?wp?wp(l,d):Op(l,d,{name:!0}):Up&&i in c&&(xp(l,c,i),xp(l,c,"prepareStackTrace")),Op(l,c);try{u.name!==s&&Rp(u,"name",s),u.constructor=l}catch(EZ){}return l}},jp="WebAssembly",Gp=ce.WebAssembly,Hp=7!==Error("e",{cause:7}).cause,zp=function(e,t){var r={};r[e]=Bp(e,t,Hp),Vp({global:!0,constructor:!0,arity:1,forced:Hp},r)},Kp=function(e,t){if(Gp&&Gp[e]){var r={};r[e]=Bp("WebAssembly."+e,t,Hp),Vp({target:jp,stat:!0,constructor:!0,arity:1,forced:Hp},r)}};zp("Error",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("EvalError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("RangeError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("ReferenceError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("SyntaxError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("TypeError",(function(e){return function(t){return Fp(e,this,arguments)}})),zp("URIError",(function(e){return function(t){return Fp(e,this,arguments)}})),Kp("CompileError",(function(e){return function(t){return Fp(e,this,arguments)}})),Kp("LinkError",(function(e){return function(t){return Fp(e,this,arguments)}})),Kp("RuntimeError",(function(e){return function(t){return Fp(e,this,arguments)}}));var Xp=Tt,Wp=Gt,qp=Le,Yp=fi,Jp=TypeError,Qp=function(e){return function(t,r,n,i){Xp(r);var o=Wp(t),a=qp(o),s=Yp(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw Jp("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},Zp={left:Qp(!1),right:Qp(!0)},$p="process"==xe(ce.process),ev=Zp.left,tv=ut,rv=$p;ro({target:"Array",proto:!0,forced:!wa("reduce")||!rv&&tv>79&&tv<83},{reduce:function(e){var t=arguments.length;return ev(this,e,t,t>1?arguments[1]:void 0)}});var nv=le,iv=Re,ov=ve,av=de,sv=Ga,cv=Ci,uv=_e,dv=Gt,lv=Le,hv=Object.assign,fv=Object.defineProperty,pv=iv([].concat),vv=!hv||av((function(){if(nv&&1!==hv({b:1},hv(fv({},"a",{enumerable:!0,get:function(){fv(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=hv({},e)[r]||sv(hv({},t)).join("")!=n}))?function(e,t){for(var r=dv(e),n=arguments.length,i=1,o=cv.f,a=uv.f;n>i;)for(var s,c=lv(arguments[i++]),u=o?pv(sv(c),o(c)):sv(c),d=u.length,l=0;d>l;)s=u[l++],nv&&!ov(a,c,s)||(r[s]=c[s]);return r}:hv,_v=vv;ro({target:"Object",stat:!0,arity:2,forced:Object.assign!==_v},{assign:_v});var mv,yv=ro,gv=va,Sv=ue.f,Ev=li,bv=As,kv=ks,Tv=Be,Iv=Cs,Av=gv("".endsWith),Rv=gv("".slice),Cv=Math.min,wv=Iv("endsWith");yv({target:"String",proto:!0,forced:!!(wv||(mv=Sv(String.prototype,"endsWith"),!mv||mv.writable))&&!wv},{endsWith:function(e){var t=bv(Tv(this));kv(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Cv(Ev(r),n),o=bv(e);return Av?Av(t,o,i):Rv(t,i-o.length,i)===o}});var Ov=le,xv=io,Pv=TypeError,Dv=Object.getOwnPropertyDescriptor,Nv=Ov&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(EZ){return EZ instanceof TypeError}}()?function(e,t){if(xv(e)&&!Dv(e,"length").writable)throw Pv("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},Mv=ro,Lv=Gt,Uv=fi,Vv=Nv,Fv=ao,Bv=de((function(){return 4294967297!==[].push.call({length:4294967296},1)})),jv=!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(EZ){return EZ instanceof TypeError}}();Mv({target:"Array",proto:!0,arity:1,forced:Bv||jv},{push:function(e){var t=Lv(this),r=Uv(t),n=arguments.length;Fv(r+n);for(var i=0;i<n;i++)t[r]=arguments[i],r++;return Vv(t,r),r}});var Gv=!0,Hv=!0;function zv(e,t,r){var n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function Kv(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get:function(){return this["_on"+t]},set:function(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 Xv(e){return"boolean"!=typeof e?new Error("Argument type: "+a(e)+". Please use a boolean."):(Gv=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Wv(e){return"boolean"!=typeof e?new Error("Argument type: "+a(e)+". Please use a boolean."):(Hv=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function qv(){if("object"===("undefined"==typeof window?"undefined":a(window))){if(Gv)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Yv(e,t){Hv&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Jv(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=zv(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=zv(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=zv(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function Qv(e){return"[object Object]"===Object.prototype.toString.call(e)}function Zv(e){return Qv(e)?Object.keys(e).reduce((function(t,r){var n=Qv(e[r]),i=n?Zv(e[r]):e[r],o=n&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,h({},r,i))}),{}):e}function $v(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((function(n){n.endsWith("Id")?$v(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach((function(t){$v(e,e.get(t),r)}))})))}function e_(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&$v(e,r,i)}))})),i}var t_=ro,r_=Ra.find,n_=ps,i_="find",o_=!0;i_ in[]&&Array(1).find((function(){o_=!1})),t_({target:"Array",proto:!0,forced:o_},{find:function(e){return r_(this,e,arguments.length>1?arguments[1]:void 0)}}),n_(i_);var a_=ro,s_=io,c_=No,u_=Je,d_=ci,l_=fi,h_=He,f_=lo,p_=sr,v_=qc,__=Ko("slice"),m_=p_("species"),y_=Array,g_=Math.max;a_({target:"Array",proto:!0,forced:!__},{slice:function(e,t){var r,n,i,o=h_(this),a=l_(o),s=d_(e,a),c=d_(void 0===t?a:t,a);if(s_(o)&&(r=o.constructor,(c_(r)&&(r===y_||s_(r.prototype))||u_(r)&&null===(r=r[m_]))&&(r=void 0),r===y_||void 0===r))return v_(o,s,c);for(n=new(void 0===r?y_:r)(g_(c-s,0)),i=0;s<c;s++,i++)s in o&&f_(n,i,o[s]);return n.length=i,n}});var S_=ro,E_=yi.indexOf,b_=wa,k_=va([].indexOf),T_=!!k_&&1/k_([1],1,-0)<0,I_=b_("indexOf");S_({target:"Array",proto:!0,forced:T_||!I_},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return T_?k_(this,e,t)||0:E_(this,e,t)}});var A_=St,R_=TypeError,C_=function(e,t){if(!delete e[t])throw R_("Cannot delete property "+A_(t)+" of "+A_(e))},w_=ro,O_=Gt,x_=ci,P_=ii,D_=fi,N_=Nv,M_=ao,L_=jo,U_=lo,V_=C_,F_=Ko("splice"),B_=Math.max,j_=Math.min;w_({target:"Array",proto:!0,forced:!F_},{splice:function(e,t){var r,n,i,o,a,s,c=O_(this),u=D_(c),d=x_(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=j_(B_(P_(t),0),u-d)),M_(u+r-n),i=L_(c,n),o=0;o<n;o++)(a=d+o)in c&&U_(i,o,c[a]);if(i.length=n,r<n){for(o=d;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:V_(c,s);for(o=u;o>u-n+r;o--)V_(c,o-1)}else if(r>n)for(o=u-n;o>d;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:V_(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return N_(c,u-n+r),i}});var G_,H_,z_,K_,X_=No,W_=St,q_=TypeError,Y_=function(e){if(X_(e))return e;throw q_(W_(e)+" is not a constructor")},J_=Fr,Q_=Y_,Z_=Ue,$_=sr("species"),em=function(e,t){var r,n=J_(e).constructor;return void 0===n||Z_(r=J_(n)[$_])?t:Q_(r)},tm=TypeError,rm=function(e,t){if(e<t)throw tm("Not enough arguments");return e},nm=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),im=ce,om=Wc,am=ga,sm=We,cm=Kt,um=de,dm=Ja,lm=qc,hm=br,fm=rm,pm=nm,vm=$p,_m=im.setImmediate,mm=im.clearImmediate,ym=im.process,gm=im.Dispatch,Sm=im.Function,Em=im.MessageChannel,bm=im.String,km=0,Tm={},Im="onreadystatechange";try{G_=im.location}catch(EZ){}var Am=function(e){if(cm(Tm,e)){var t=Tm[e];delete Tm[e],t()}},Rm=function(e){return function(){Am(e)}},Cm=function(e){Am(e.data)},wm=function(e){im.postMessage(bm(e),G_.protocol+"//"+G_.host)};_m&&mm||(_m=function(e){fm(arguments.length,1);var t=sm(e)?e:Sm(e),r=lm(arguments,1);return Tm[++km]=function(){om(t,void 0,r)},H_(km),km},mm=function(e){delete Tm[e]},vm?H_=function(e){ym.nextTick(Rm(e))}:gm&&gm.now?H_=function(e){gm.now(Rm(e))}:Em&&!pm?(K_=(z_=new Em).port2,z_.port1.onmessage=Cm,H_=am(K_.postMessage,K_)):im.addEventListener&&sm(im.postMessage)&&!im.importScripts&&G_&&"file:"!==G_.protocol&&!um(wm)?(H_=wm,im.addEventListener("message",Cm,!1)):H_=Im in hm("script")?function(e){dm.appendChild(hm("script")).onreadystatechange=function(){dm.removeChild(this),Am(e)}}:function(e){setTimeout(Rm(e),0)});var Om,xm,Pm,Dm,Nm,Mm,Lm,Um,Vm={set:_m,clear:mm},Fm=ce,Bm=/ipad|iphone|ipod/i.test(rt)&&void 0!==Fm.Pebble,jm=/web0s(?!.*chrome)/i.test(rt),Gm=ce,Hm=ga,zm=ue.f,Km=Vm.set,Xm=nm,Wm=Bm,qm=jm,Ym=$p,Jm=Gm.MutationObserver||Gm.WebKitMutationObserver,Qm=Gm.document,Zm=Gm.process,$m=Gm.Promise,ey=zm(Gm,"queueMicrotask"),ty=ey&&ey.value;ty||(Om=function(){var e,t;for(Ym&&(e=Zm.domain)&&e.exit();xm;){t=xm.fn,xm=xm.next;try{t()}catch(EZ){throw xm?Dm():Pm=void 0,EZ}}Pm=void 0,e&&e.enter()},Xm||Ym||qm||!Jm||!Qm?!Wm&&$m&&$m.resolve?((Lm=$m.resolve(void 0)).constructor=$m,Um=Hm(Lm.then,Lm),Dm=function(){Um(Om)}):Ym?Dm=function(){Zm.nextTick(Om)}:(Km=Hm(Km,Gm),Dm=function(){Km(Om)}):(Nm=!0,Mm=Qm.createTextNode(""),new Jm(Om).observe(Mm,{characterData:!0}),Dm=function(){Mm.data=Nm=!Nm}));var ry=ty||function(e){var t={fn:e,next:void 0};Pm&&(Pm.next=t),xm||(xm=t,Dm()),Pm=t},ny=ce,iy=function(e){try{return{error:!1,value:e()}}catch(EZ){return{error:!0,value:EZ}}},oy=function(){this.head=null,this.tail=null};oy.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var ay=oy,sy=ce.Promise,cy="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,uy=!cy&&!$p&&"object"==typeof window&&"object"==typeof document,dy=ce,ly=sy,hy=We,fy=qi,py=pn,vy=sr,_y=uy,my=cy,yy=ut;ly&&ly.prototype;var gy=vy("species"),Sy=!1,Ey=hy(dy.PromiseRejectionEvent),by={CONSTRUCTOR:fy("Promise",(function(){var e=py(ly),t=e!==String(ly);if(!t&&66===yy)return!0;if(!yy||yy<51||!/native code/.test(e)){var r=new ly((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[gy]=n,!(Sy=r.then((function(){}))instanceof n))return!0}return!t&&(_y||my)&&!Ey})),REJECTION_EVENT:Ey,SUBCLASSING:Sy},ky={},Ty=Tt,Iy=TypeError,Ay=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Iy("Bad Promise constructor");t=e,r=n})),this.resolve=Ty(t),this.reject=Ty(r)};ky.f=function(e){return new Ay(e)};var Ry,Cy,wy,Oy=ro,xy=$p,Py=ce,Dy=ve,Ny=$n,My=Xd,Ly=Pd,Uy=If,Vy=Tt,Fy=We,By=Je,jy=Xh,Gy=em,Hy=Vm.set,zy=ry,Ky=function(e,t){var r=ny.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},Xy=iy,Wy=ay,qy=Ln,Yy=sy,Jy=ky,Qy="Promise",Zy=by.CONSTRUCTOR,$y=by.REJECTION_EVENT,eg=by.SUBCLASSING,tg=qy.getterFor(Qy),rg=qy.set,ng=Yy&&Yy.prototype,ig=Yy,og=ng,ag=Py.TypeError,sg=Py.document,cg=Py.process,ug=Jy.f,dg=ug,lg=!!(sg&&sg.createEvent&&Py.dispatchEvent),hg="unhandledrejection",fg=function(e){var t;return!(!By(e)||!Fy(t=e.then))&&t},pg=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&gg(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(ag("Promise-chain cycle")):(n=fg(r))?Dy(n,r,c,u):c(r)):u(o)}catch(EZ){d&&!i&&d.exit(),u(EZ)}},vg=function(e,t){e.notified||(e.notified=!0,zy((function(){for(var r,n=e.reactions;r=n.get();)pg(r,e);e.notified=!1,t&&!e.rejection&&mg(e)})))},_g=function(e,t,r){var n,i;lg?((n=sg.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),Py.dispatchEvent(n)):n={promise:t,reason:r},!$y&&(i=Py["on"+e])?i(n):e===hg&&Ky("Unhandled promise rejection",r)},mg=function(e){Dy(Hy,Py,(function(){var t,r=e.facade,n=e.value;if(yg(e)&&(t=Xy((function(){xy?cg.emit("unhandledRejection",n,r):_g(hg,r,n)})),e.rejection=xy||yg(e)?2:1,t.error))throw t.value}))},yg=function(e){return 1!==e.rejection&&!e.parent},gg=function(e){Dy(Hy,Py,(function(){var t=e.facade;xy?cg.emit("rejectionHandled",t):_g("rejectionhandled",t,e.value)}))},Sg=function(e,t,r){return function(n){e(t,n,r)}},Eg=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,vg(e,!0))},bg=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw ag("Promise can't be resolved itself");var n=fg(t);n?zy((function(){var r={done:!1};try{Dy(n,t,Sg(bg,r,e),Sg(Eg,r,e))}catch(EZ){Eg(r,EZ,e)}})):(e.value=t,e.state=1,vg(e,!1))}catch(EZ){Eg({done:!1},EZ,e)}}};if(Zy&&(og=(ig=function(e){jy(this,og),Vy(e),Dy(Ry,this);var t=tg(this);try{e(Sg(bg,t),Sg(Eg,t))}catch(EZ){Eg(t,EZ)}}).prototype,(Ry=function(e){rg(this,{type:Qy,done:!1,notified:!1,parent:!1,reactions:new Wy,rejection:!1,state:0,value:void 0})}).prototype=Ny(og,"then",(function(e,t){var r=tg(this),n=ug(Gy(this,ig));return r.parent=!0,n.ok=!Fy(e)||e,n.fail=Fy(t)&&t,n.domain=xy?cg.domain:void 0,0==r.state?r.reactions.add(n):zy((function(){pg(n,r)})),n.promise})),Cy=function(){var e=new Ry,t=tg(e);this.promise=e,this.resolve=Sg(bg,t),this.reject=Sg(Eg,t)},Jy.f=ug=function(e){return e===ig||undefined===e?new Cy(e):dg(e)},Fy(Yy)&&ng!==Object.prototype)){wy=ng.then,eg||Ny(ng,"then",(function(e,t){var r=this;return new ig((function(e,t){Dy(wy,r,e,t)})).then(e,t)}),{unsafe:!0});try{delete ng.constructor}catch(EZ){}My&&My(ng,og)}Oy({global:!0,constructor:!0,wrap:!0,forced:Zy},{Promise:ig}),Ly(ig,Qy,!1),Uy(Qy);var kg=sy,Tg=by.CONSTRUCTOR||!Qh((function(e){kg.all(e).then(void 0,(function(){}))})),Ig=ve,Ag=Tt,Rg=ky,Cg=iy,wg=Hh;ro({target:"Promise",stat:!0,forced:Tg},{all:function(e){var t=this,r=Rg.f(t),n=r.resolve,i=r.reject,o=Cg((function(){var r=Ag(t.resolve),o=[],a=0,s=1;wg(e,(function(e){var c=a++,u=!1;s++,Ig(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var Og=ro,xg=by.CONSTRUCTOR,Pg=sy,Dg=et,Ng=We,Mg=$n,Lg=Pg&&Pg.prototype;if(Og({target:"Promise",proto:!0,forced:xg,real:!0},{catch:function(e){return this.then(void 0,e)}}),Ng(Pg)){var Ug=Dg("Promise").prototype.catch;Lg.catch!==Ug&&Mg(Lg,"catch",Ug,{unsafe:!0})}var Vg=ve,Fg=Tt,Bg=ky,jg=iy,Gg=Hh;ro({target:"Promise",stat:!0,forced:Tg},{race:function(e){var t=this,r=Bg.f(t),n=r.reject,i=jg((function(){var i=Fg(t.resolve);Gg(e,(function(e){Vg(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var Hg=ve,zg=ky;ro({target:"Promise",stat:!0,forced:by.CONSTRUCTOR},{reject:function(e){var t=zg.f(this);return Hg(t.reject,void 0,e),t.promise}});var Kg=Fr,Xg=Je,Wg=ky,qg=function(e,t){if(Kg(e),Xg(t)&&t.constructor===e)return t;var r=Wg.f(e);return(0,r.resolve)(t),r.promise},Yg=ro,Jg=by.CONSTRUCTOR,Qg=qg;et("Promise"),Yg({target:"Promise",stat:!0,forced:Jg},{resolve:function(e){return Qg(this,e)}});var Zg=$p,$g=en.exports,eS=Nr,tS=function(e,t,r){return r.get&&$g(r.get,t,{getter:!0}),r.set&&$g(r.set,t,{setter:!0}),eS.f(e,t,r)},rS=le,nS=de,iS=Fr,oS=cs,aS=pp,sS=Error.prototype.toString,cS=nS((function(){if(rS){var e=oS(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==sS.call(e))return!0}return"2: 1"!==sS.call({message:1,name:2})||"Error"!==sS.call({})}))?function(){var e=iS(this),t=aS(e.name,"Error"),r=aS(e.message);return t?r?t+": "+r:t:r}:sS,uS={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}},dS=ro,lS=function(e){try{if(Zg)return Function('return require("'+e+'")')()}catch(EZ){}},hS=et,fS=de,pS=cs,vS=be,_S=Nr.f,mS=$n,yS=tS,gS=Kt,SS=Xh,ES=Fr,bS=cS,kS=pp,TS=uS,IS=bp,AS=Ln,RS=le,CS="DOMException",wS="DATA_CLONE_ERR",OS=hS("Error"),xS=hS(CS)||function(){try{(new(hS("MessageChannel")||lS("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(EZ){if(EZ.name==wS&&25==EZ.code)return EZ.constructor}}(),PS=xS&&xS.prototype,DS=OS.prototype,NS=AS.set,MS=AS.getterFor(CS),LS="stack"in OS(CS),US=function(e){return gS(TS,e)&&TS[e].m?TS[e].c:0},VS=function(){SS(this,FS);var e=arguments.length,t=kS(e<1?void 0:arguments[0]),r=kS(e<2?void 0:arguments[1],"Error"),n=US(r);if(NS(this,{type:CS,name:r,message:t,code:n}),RS||(this.name=r,this.message=t,this.code=n),LS){var i=OS(t);i.name=CS,_S(this,"stack",vS(1,IS(i.stack,1)))}},FS=VS.prototype=pS(DS),BS=function(e){return{enumerable:!0,configurable:!0,get:e}},jS=function(e){return BS((function(){return MS(this)[e]}))};RS&&(yS(FS,"code",jS("code")),yS(FS,"message",jS("message")),yS(FS,"name",jS("name"))),_S(FS,"constructor",vS(1,VS));var GS=fS((function(){return!(new xS instanceof OS)})),HS=GS||fS((function(){return DS.toString!==bS||"2: 1"!==String(new xS(1,2))})),zS=GS||fS((function(){return 25!==new xS(1,"DataCloneError").code}));GS||25!==xS.DATA_CLONE_ERR||PS.DATA_CLONE_ERR;dS({global:!0,constructor:!0,forced:GS},{DOMException:GS?VS:xS});var KS=hS(CS),XS=KS.prototype;for(var WS in HS&&xS===KS&&mS(XS,"toString",bS),zS&&RS&&xS===KS&&yS(XS,"code",BS((function(){return US(ES(this).name)}))),TS)if(gS(TS,WS)){var qS=TS[WS],YS=qS.s,JS=vS(6,qS.c);gS(KS,YS)||_S(KS,YS,JS),gS(XS,YS)||_S(XS,YS,JS)}var QS=ro,ZS=ce,$S=et,eE=be,tE=Nr.f,rE=Kt,nE=Xh,iE=tf,oE=pp,aE=uS,sE=bp,cE=le,uE="DOMException",dE=$S("Error"),lE=$S(uE),hE=function(){nE(this,fE);var e=arguments.length,t=oE(e<1?void 0:arguments[0]),r=oE(e<2?void 0:arguments[1],"Error"),n=new lE(t,r),i=dE(t);return i.name=uE,tE(n,"stack",eE(1,sE(i.stack,1))),iE(n,this,hE),n},fE=hE.prototype=lE.prototype,pE="stack"in dE(uE),vE="stack"in new lE(1,2),_E=lE&&cE&&Object.getOwnPropertyDescriptor(ZS,uE),mE=!(!_E||_E.writable&&_E.configurable),yE=pE&&!mE&&!vE;QS({global:!0,constructor:!0,forced:yE},{DOMException:yE?hE:lE});var gE=$S(uE),SE=gE.prototype;if(SE.constructor!==gE)for(var EE in tE(SE,"constructor",eE(1,gE)),aE)if(rE(aE,EE)){var bE=aE[EE],kE=bE.s;rE(gE,kE)||tE(gE,kE,eE(6,bE.c))}var TE="DOMException";Pd(et(TE),TE);var IE=Ra.filter;ro({target:"Array",proto:!0,forced:!Ko("filter")},{filter:function(e){return IE(this,e,arguments.length>1?arguments[1]:void 0)}});var AE=Re,RE=Gt,CE=Math.floor,wE=AE("".charAt),OE=AE("".replace),xE=AE("".slice),PE=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,DE=/\$([$&'`]|\d{1,2})/g,NE=Wc,ME=ve,LE=Re,UE=Ac,VE=de,FE=Fr,BE=We,jE=Ue,GE=ii,HE=li,zE=As,KE=Be,XE=xu,WE=Rt,qE=function(e,t,r,n,i,o){var a=r+e.length,s=n.length,c=DE;return void 0!==i&&(i=RE(i),c=PE),OE(o,c,(function(o,c){var u;switch(wE(c,0)){case"$":return"$";case"&":return e;case"`":return xE(t,0,r);case"'":return xE(t,a);case"<":u=i[xE(c,1,-1)];break;default:var d=+c;if(0===d)return o;if(d>s){var l=CE(d/10);return 0===l?o:l<=s?void 0===n[l-1]?wE(c,1):n[l-1]+wE(c,1):o}u=n[d-1]}return void 0===u?"":u}))},YE=Nc,JE=sr("replace"),QE=Math.max,ZE=Math.min,$E=LE([].concat),eb=LE([].push),tb=LE("".indexOf),rb=LE("".slice),nb="$0"==="a".replace(/./,"$0"),ib=!!/./[JE]&&""===/./[JE]("a","$0"),ob=!VE((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));UE("replace",(function(e,t,r){var n=ib?"$":"$0";return[function(e,r){var n=KE(this),i=jE(e)?void 0:WE(e,JE);return i?ME(i,e,n,r):ME(t,zE(n),e,r)},function(e,i){var o=FE(this),a=zE(e);if("string"==typeof i&&-1===tb(i,n)&&-1===tb(i,"$<")){var s=r(t,o,a,i);if(s.done)return s.value}var c=BE(i);c||(i=zE(i));var u=o.global;if(u){var d=o.unicode;o.lastIndex=0}for(var l=[];;){var h=YE(o,a);if(null===h)break;if(eb(l,h),!u)break;""===zE(h[0])&&(o.lastIndex=XE(a,HE(o.lastIndex),d))}for(var f,p="",v=0,_=0;_<l.length;_++){for(var m=zE((h=l[_])[0]),y=QE(ZE(GE(h.index),a.length),0),g=[],S=1;S<h.length;S++)eb(g,void 0===(f=h[S])?f:String(f));var E=h.groups;if(c){var b=$E([m],g,y,a);void 0!==E&&eb(b,E);var k=zE(NE(i,void 0,b))}else k=qE(m,a,y,g,E,i);y>=v&&(p+=rb(a,v,y)+k,v=y+m.length)}return p+rb(a,v)}]}),!ob||!nb||ib);var ab=ve,sb=Kt,cb=tt,ub=Vs,db=RegExp.prototype,lb=function(e){var t=e.flags;return void 0!==t||"flags"in db||sb(e,"flags")||!cb(db,e)?t:ab(ub,e)},hb=le,fb=ce,pb=Re,vb=qi,_b=tf,mb=$r,yb=ei.f,gb=tt,Sb=Ss,Eb=As,bb=lb,kb=zs,Tb=hp,Ib=$n,Ab=de,Rb=Kt,Cb=Ln.enforce,wb=If,Ob=Ws,xb=Js,Pb=sr("match"),Db=fb.RegExp,Nb=Db.prototype,Mb=fb.SyntaxError,Lb=pb(Nb.exec),Ub=pb("".charAt),Vb=pb("".replace),Fb=pb("".indexOf),Bb=pb("".slice),jb=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Gb=/a/g,Hb=/a/g,zb=new Db(Gb)!==Gb,Kb=kb.MISSED_STICKY,Xb=kb.UNSUPPORTED_Y,Wb=hb&&(!zb||Kb||Ob||xb||Ab((function(){return Hb[Pb]=!1,Db(Gb)!=Gb||Db(Hb)==Hb||"/a/i"!=Db(Gb,"i")})));if(vb("RegExp",Wb)){for(var qb=function(e,t){var r,n,i,o,a,s,c=gb(Nb,this),u=Sb(e),d=void 0===t,l=[],h=e;if(!c&&u&&d&&e.constructor===qb)return e;if((u||gb(Nb,e))&&(e=e.source,d&&(t=bb(h))),e=void 0===e?"":Eb(e),t=void 0===t?"":Eb(t),h=e,Ob&&"dotAll"in Gb&&(n=!!t&&Fb(t,"s")>-1)&&(t=Vb(t,/s/g,"")),r=t,Kb&&"sticky"in Gb&&(i=!!t&&Fb(t,"y")>-1)&&Xb&&(t=Vb(t,/y/g,"")),xb&&(o=function(e){for(var t,r=e.length,n=0,i="",o=[],a={},s=!1,c=!1,u=0,d="";n<=r;n++){if("\\"===(t=Ub(e,n)))t+=Ub(e,++n);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:Lb(jb,Bb(e,n+1))&&(n+=2,c=!0),i+=t,u++;continue;case">"===t&&c:if(""===d||Rb(a,d))throw new Mb("Invalid capture group name");a[d]=!0,o[o.length]=[d,u],c=!1,d="";continue}c?d+=t:i+=t}return[i,o]}(e),e=o[0],l=o[1]),a=_b(Db(e,t),c?this:Nb,qb),(n||i||l.length)&&(s=Cb(a),n&&(s.dotAll=!0,s.raw=qb(function(e){for(var t,r=e.length,n=0,i="",o=!1;n<=r;n++)"\\"!==(t=Ub(e,n))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+Ub(e,++n);return i}(e),r)),i&&(s.sticky=!0),l.length&&(s.groups=l)),e!==h)try{mb(a,"source",""===h?"(?:)":h)}catch(EZ){}return a},Yb=yb(Db),Jb=0;Yb.length>Jb;)Tb(qb,Db,Yb[Jb++]);Nb.constructor=qb,qb.prototype=Nb,Ib(fb,"RegExp",qb,{constructor:!0})}wb("RegExp");var Qb=le,Zb=Ws,$b=xe,ek=tS,tk=Ln.get,rk=RegExp.prototype,nk=TypeError;Qb&&Zb&&ek(rk,"dotAll",{configurable:!0,get:function(){if(this!==rk){if("RegExp"===$b(this))return!!tk(this).dotAll;throw nk("Incompatible receiver, RegExp required")}}});var ik=le,ok=zs.MISSED_STICKY,ak=xe,sk=tS,ck=Ln.get,uk=RegExp.prototype,dk=TypeError;ik&&ok&&sk(uk,"sticky",{configurable:!0,get:function(){if(this!==uk){if("RegExp"===ak(this))return!!ck(this).sticky;throw dk("Incompatible receiver, RegExp required")}}});var lk=sn.PROPER,hk=$n,fk=Fr,pk=As,vk=de,_k=lb,mk="toString",yk=RegExp.prototype.toString,gk=vk((function(){return"/a/b"!=yk.call({source:"a",flags:"b"})})),Sk=lk&&yk.name!=mk;(gk||Sk)&&hk(RegExp.prototype,mk,(function(){var e=fk(this);return"/"+pk(e.source)+"/"+pk(_k(e))}),{unsafe:!0});var Ek=ro,bk=de,kk=He,Tk=ue.f,Ik=le,Ak=bk((function(){Tk(1)}));Ek({target:"Object",stat:!0,forced:!Ik||Ak,sham:!Ik},{getOwnPropertyDescriptor:function(e,t){return Tk(kk(e),t)}});var Rk=qv;function Ck(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==a(e)||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach((function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var n="object"===a(e[r])?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",r)]=n.ideal,t.optional.push(o),(o={})[i("max",r)]=n.ideal,t.optional.push(o)):(o[i("",r)]=n.ideal,t.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[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"===a(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===a(e.video)){var s=e.video.facingMode;s=s&&("object"===a(s)?s:{ideal:s});var c,u=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||u))if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?c=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(c=["front"]),c)return r.mediaDevices.enumerateDevices().then((function(t){var r=(t=t.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return c.some((function(t){return e.label.toLowerCase().includes(t)}))}));return!r&&t.length&&c.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=s.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),Rk("chrome: "+JSON.stringify(e)),i(e)}));e.video=n(e.video)}return Rk("chrome: "+JSON.stringify(e)),i(e)},o=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:function(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return s(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Promise.reject(o(e))}))}))}}}}function wk(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Ok(e){if("object"===a(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find((function(e){return e.track&&e.track.id===n.track.id})):{track:n.track};var o=new Event("track");o.track=n.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],r.dispatchEvent(o)})),t.stream.getTracks().forEach((function(n){var i;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find((function(e){return e.track&&e.track.id===n.id})):{track:n};var o=new Event("track");o.track=n,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],r.dispatchEvent(o)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Kv(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function xk(e){if("object"===a(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var 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()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r=t._senders.find((function(t){return t.track===e}));r&&t._senders.splice(t._senders.indexOf(r),1)}))}}else if("object"===a(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=s.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Pk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){return new Map(Object.keys(e).map((function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Promise((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function Dk(e){if("object"===a(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return e_(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),Kv(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return e_(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Nk(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((function(t){return e._shimmedLocalStreams[t][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){if(t.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var n=this.getSenders();r.apply(this,arguments);var i=this.getSenders().filter((function(e){return-1===n.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(i)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((function(r){var n=t._shimmedLocalStreams[r].indexOf(e);-1!==n&&t._shimmedLocalStreams[r].splice(n,1),1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function Mk(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Nk(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map((function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){if(r.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;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,r){var n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find((function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var o=this.getSenders().find((function(e){return e.track===t}));if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var a=this._streams[r.id];if(a)a.addTrack(t),Promise.resolve().then((function(){n.dispatchEvent(new Event("negotiationneeded"))}));else{var s=new e.MediaStream([t]);this._streams[r.id]=s,this._reverseStreams[s.id]=r,this.addStream(s)}return this.getSenders().find((function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=h({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=this;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");this._streams=this._streams||{},Object.keys(this._streams).forEach((function(n){r._streams[n].getTracks().find((function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function Lk(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=h({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function Uk(e,t){Kv(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var Vk,Fk,Bk=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:wk,shimOnTrack:Ok,shimGetSendersWithDtmf:xk,shimGetStats:Pk,shimSenderReceiverGetStats:Dk,shimAddTrackRemoveTrackWithNative:Nk,shimAddTrackRemoveTrack:Mk,shimPeerConnection:Lk,fixNegotiationNeeded:Uk,shimGetUserMedia:Ck,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}},Symbol.toStringTag,{value:"Module"})),jk=ro,Gk=ve,Hk=We,zk=Fr,Kk=As,Xk=(Vk=!1,(Fk=/[ac]/).exec=function(){return Vk=!0,/./.exec.apply(this,arguments)},!0===Fk.test("abc")&&Vk),Wk=/./.test;jk({target:"RegExp",proto:!0,forced:!Xk},{test:function(e){var t=zk(this),r=Kk(e),n=t.exec;if(!Hk(n))return Gk(Wk,t,r);var i=Gk(n,t,r);return null!==i&&(zk(i),!0)}});var qk=ce,Yk=de,Jk=As,Qk=Yu.trim,Zk=Re("".charAt),$k=qk.parseFloat,eT=qk.Symbol,tT=eT&&eT.iterator,rT=1/$k("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0||tT&&!Yk((function(){$k(Object(tT))}))?function(e){var t=Qk(Jk(e)),r=$k(t);return 0===r&&"-"==Zk(t,0)?-0:r}:$k;ro({global:!0,forced:parseFloat!=rT},{parseFloat:rT});var nT=ro,iT=sy,oT=de,aT=et,sT=We,cT=em,uT=qg,dT=$n,lT=iT&&iT.prototype;if(nT({target:"Promise",proto:!0,real:!0,forced:!!iT&&oT((function(){lT.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=cT(this,aT("Promise")),r=sT(e);return this.then(r?function(r){return uT(t,e()).then((function(){return r}))}:e,r?function(r){return uT(t,e()).then((function(){throw r}))}:e)}}),sT(iT)){var hT=aT("Promise").prototype.finally;lT.finally!==hT&&dT(lT,"finally",hT,{unsafe:!0})}function fT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){Yv("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===a(e)&&"object"===a(e.audio)&&(e=JSON.parse(JSON.stringify(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var s=n.prototype.getSettings;n.prototype.getSettings=function(){var e=s.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var c=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===a(e)&&(e=JSON.parse(JSON.stringify(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),c.apply(this,[e])}}}}function pT(e){"object"===a(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function vT(e,t){if("object"===a(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=h({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(n){if("TypeError"!==n.name)throw n;e.forEach((function(t,n){e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function _T(e){if("object"===a(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.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 mT(e){if("object"===a(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),Kv(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function yT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;Yv("removeStream","removeTrack"),this.getSenders().forEach((function(r){r.track&&e.getTracks().includes(r.track)&&t.removeTrack(r)}))})}function gT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function ST(e){if("object"===a(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=k(e)).length>0;r&&e.forEach((function(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")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===Object.keys(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function ET(e){if("object"===a(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}}function bT(e){if("object"===a(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function kT(e){if("object"===a(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var TT=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:pT,shimPeerConnection:vT,shimSenderGetStats:_T,shimReceiverGetStats:mT,shimRemoveStream:yT,shimRTCDataChannel:gT,shimAddTransceiver:ST,shimGetParameters:ET,shimCreateOffer:bT,shimCreateAnswer:kT,shimGetUserMedia:fT,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function IT(e){if("object"===a(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)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(n){return t.call(r,n,e)})),e.getVideoTracks().forEach((function(n){return t.call(r,n,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){r._localStreams?r._localStreams.includes(e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._localStreams||(this._localStreams=[]);var r=this._localStreams.indexOf(e);if(-1!==r){this._localStreams.splice(r,1);var n=e.getTracks();this.getSenders().forEach((function(e){n.includes(e.track)&&t.removeTrack(e)}))}})}}function AT(e){if("object"===a(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:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){if(t._remoteStreams||(t._remoteStreams=[]),!t._remoteStreams.includes(e)){t._remoteStreams.push(e);var r=new Event("addstream");r.stream=e,t.dispatchEvent(r)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}}))}),t.apply(e,arguments)}}}function RT(e){if("object"===a(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};var c=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=c,c=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=c,c=function(e,t,r){var n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=c}}function CT(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(wT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function wT(e){return e&&void 0!==e.video?Object.assign({},e,{video:Zv(e.video)}):e}function OT(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(Yv("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(JSON.stringify(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function xT(e){"object"===a(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function PT(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var r=this.getTransceivers().find((function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveAudio||r||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var n=this.getTransceivers().find((function(e){return"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",{direction:"recvonly"})}return t.apply(this,arguments)}}function DT(e){"object"!==a(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var NT=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:IT,shimRemoteStreamsAPI:AT,shimCallbacksAPI:RT,shimGetUserMedia:CT,shimConstraints:wT,shimRTCIceServerUrls:OT,shimTrackEventTransceiver:xT,shimCreateOfferLegacy:PT,shimAudioContext:DT},Symbol.toStringTag,{value:"Module"})),MT=ve;ro({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return MT(URL.prototype.toString,this)}});var LT=Re(1..valueOf),UT=le,VT=ce,FT=Re,BT=qi,jT=$n,GT=Kt,HT=tf,zT=tt,KT=yt,XT=vr,WT=de,qT=ei.f,YT=ue.f,JT=Nr.f,QT=LT,ZT=Yu.trim,$T="Number",eI=VT.Number,tI=eI.prototype,rI=VT.TypeError,nI=FT("".slice),iI=FT("".charCodeAt),oI=function(e){var t=XT(e,"number");return"bigint"==typeof t?t:aI(t)},aI=function(e){var t,r,n,i,o,a,s,c,u=XT(e,"number");if(KT(u))throw rI("Cannot convert a Symbol value to a number");if("string"==typeof u&&u.length>2)if(u=ZT(u),43===(t=iI(u,0))||45===t){if(88===(r=iI(u,2))||120===r)return NaN}else if(48===t){switch(iI(u,1)){case 66:case 98:n=2,i=49;break;case 79:case 111:n=8,i=55;break;default:return+u}for(a=(o=nI(u,2)).length,s=0;s<a;s++)if((c=iI(o,s))<48||c>i)return NaN;return parseInt(o,n)}return+u};if(BT($T,!eI(" 0o1")||!eI("0b1")||eI("+0x1"))){for(var sI,cI=function(e){var t=arguments.length<1?0:eI(oI(e)),r=this;return zT(tI,r)&&WT((function(){QT(r)}))?HT(Object(t),r,cI):t},uI=UT?qT(eI):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),dI=0;uI.length>dI;dI++)GT(eI,sI=uI[dI])&&!GT(cI,sI)&&JT(cI,sI,YT(eI,sI));cI.prototype=tI,tI.constructor=cI,jT(VT,$T,cI,{constructor:!0})}var lI=sn.PROPER,hI=de,fI=ju,pI=Yu.trim;ro({target:"String",proto:!0,forced:function(e){return hI((function(){return!!fI[e]()||"​…᠎"!=="​…᠎"[e]()||lI&&fI[e].name!==e}))}("trim")},{trim:function(){return pI(this)}});var vI,_I,mI={exports:{}};vI=mI,(_I={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=_I.generateIdentifier(),_I.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},_I.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},_I.getDescription=function(e){var t=_I.splitSections(e);return t&&t[0]},_I.getMediaSections=function(e){var t=_I.splitSections(e);return t.shift(),t},_I.matchPrefix=function(e,t){return _I.splitLines(e).filter((function(e){return 0===e.indexOf(t)}))},_I.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=parseInt(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},_I.writeCandidate=function(e){var t=[];t.push(e.foundation);var r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),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(" ")},_I.parseIceOptions=function(e){return e.substr(14).split(" ")},_I.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},_I.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},_I.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]}},_I.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},_I.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<n.length;i++)r[(t=n[i].trim().split("="))[0].trim()]=t[1];return r},_I.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var n=[];Object.keys(e.parameters).forEach((function(t){void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},_I.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},_I.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},_I.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},_I.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},_I.getMid=function(e){var t=_I.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},_I.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},_I.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:_I.matchPrefix(e+t,"a=fingerprint:").map(_I.parseFingerprint)}},_I.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},_I.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)}},_I.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===a(e.keyParams)?_I.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},_I.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}},_I.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},_I.getCryptoParameters=function(e,t){return _I.matchPrefix(e+t,"a=crypto:").map(_I.parseCryptoLine)},_I.getIceParameters=function(e,t){var r=_I.matchPrefix(e+t,"a=ice-ufrag:")[0],n=_I.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},_I.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},_I.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=_I.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=_I.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a=_I.parseRtpMap(o),s=_I.matchPrefix(e,"a=fmtp:"+i+" ");switch(a.parameters=s.length?_I.parseFmtp(s[0]):{},a.rtcpFeedback=_I.matchPrefix(e,"a=rtcp-fb:"+i+" ").map(_I.parseRtcpFb),t.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(a.name.toUpperCase())}}}return _I.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(_I.parseExtmap(e))})),t},_I.writeRtpDescription=function(e,t){var r="";r+="m="+e+" ",r+=t.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.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",t.codecs.forEach((function(e){r+=_I.writeRtpMap(e),r+=_I.writeFmtp(e),r+=_I.writeRtcpFb(e)}));var n=0;return t.codecs.forEach((function(e){e.maxptime>n&&(n=e.maxptime)})),n>0&&(r+="a=maxptime:"+n+"\r\n"),t.headerExtensions&&t.headerExtensions.forEach((function(e){r+=_I.writeExtmap(e)})),r},_I.parseRtpEncodingParameters=function(e){var t,r=[],n=_I.parseRtpParameters(e),i=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),a=_I.matchPrefix(e,"a=ssrc:").map((function(e){return _I.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),s=a.length>0&&a[0].ssrc,c=_I.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));c.length>0&&c[0].length>1&&c[0][0]===s&&(t=c[0][1]),n.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&t&&(n.rtx={ssrc:t}),r.push(n),i&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:s,mechanism:o?"red+ulpfec":"red"},r.push(n))}})),0===r.length&&s&&r.push({ssrc:s});var u=_I.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=u}))),r},_I.parseRtcpParameters=function(e){var t={},r=_I.matchPrefix(e,"a=ssrc:").map((function(e){return _I.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var n=_I.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=n.length>0,t.compound=0===n.length;var i=_I.matchPrefix(e,"a=rtcp-mux");return t.mux=i.length>0,t},_I.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},_I.parseMsid=function(e){var t,r=_I.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var n=_I.matchPrefix(e,"a=ssrc:").map((function(e){return _I.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return n.length>0?{stream:(t=n[0].value.split(" "))[0],track:t[1]}:void 0},_I.parseSctpDescription=function(e){var t,r=_I.parseMLine(e),n=_I.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=parseInt(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=_I.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:parseInt(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=_I.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:t}}},_I.writeSctpDescription=function(e,t){var r=[];return r="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&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},_I.generateSessionId=function(){return Math.random().toString().substr(2,21)},_I.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||_I.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},_I.getDirection=function(e,t){for(var r=_I.splitLines(e),n=0;n<r.length;n++)switch(r[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[n].substr(2)}return t?_I.getDirection(t):"sendrecv"},_I.getKind=function(e){return _I.splitLines(e)[0].split(" ")[0].substr(2)},_I.isRejected=function(e){return"0"===e.split(" ",2)[1]},_I.parseMLine=function(e){var t=_I.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},_I.parseOLine=function(e){var t=_I.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:parseInt(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},_I.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=_I.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},vI.exports=_I;var yI=mI.exports,gI=e({__proto__:null,default:yI},[mI.exports]);function SI(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===a(e)&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var r=new t(e),n=yI.parseCandidate(e.candidate),i=Object.assign(r,n);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,Kv(e,"icecandidate",(function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function EI(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||Kv(e,"icecandidate",(function(e){if(e.candidate){var t=yI.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function bI(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=yI.splitSections(e.sdp);return t.shift(),t.some((function(e){var t=yI.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=yI.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};Object.defineProperty(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return a.apply(this,arguments)}}}function kI(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e,this),e},Kv(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.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 r.apply(e,arguments)}}}function TI(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(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((function(e){var r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function II(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var n=t.sdp.split("\n").filter((function(e){return"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 r.apply(this,arguments)}}}function AI(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.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():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function RI(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==a(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var CI=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:SI,shimRTCIceCandidateRelayProtocol:EI,shimMaxMessageSize:bI,shimSendThrowTypeError:kI,shimConnectionState:TI,removeExtmapAllowMixed:II,shimAddIceCandidateNullOrEmpty:AI,shimParameterlessSetLocalDescription:RI},Symbol.toStringTag,{value:"Module"}));!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=qv,i=Jv(t),o={browserDetails:i,commonShim:CI,extractVersion:zv,disableLog:Xv,disableWarnings:Wv,sdp:gI};switch(i.browser){case"chrome":if(!Bk||!Lk||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=Bk,AI(t,i),RI(t),Ck(t,i),wk(t),Lk(t,i),Ok(t),Mk(t,i),xk(t),Pk(t),Dk(t),Uk(t,i),SI(t),EI(t),TI(t),bI(t,i),kI(t),II(t,i);break;case"firefox":if(!TT||!vT||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=TT,AI(t,i),RI(t),fT(t,i),vT(t,i),pT(t),yT(t),_T(t),mT(t),gT(t),ST(t),ET(t),bT(t),kT(t),SI(t),TI(t),bI(t,i),kI(t);break;case"safari":if(!NT||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=NT,AI(t,i),RI(t),OT(t),PT(t),RT(t),IT(t),AT(t),xT(t),CT(t),DT(t),SI(t),EI(t),bI(t,i),kI(t),II(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var wI=Nl,OI=Math.floor,xI=function(e,t){var r=e.length,n=OI(r/2);return r<8?PI(e,t):DI(e,xI(wI(e,0,n),t),xI(wI(e,n),t),t)},PI=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},DI=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},NI=xI,MI=rt.match(/firefox\/(\d+)/i),LI=!!MI&&+MI[1],UI=/MSIE|Trident/.test(rt),VI=rt.match(/AppleWebKit\/(\d+)\./),FI=!!VI&&+VI[1],BI=ro,jI=Re,GI=Tt,HI=Gt,zI=fi,KI=C_,XI=As,WI=de,qI=NI,YI=wa,JI=LI,QI=UI,ZI=ut,$I=FI,eA=[],tA=jI(eA.sort),rA=jI(eA.push),nA=WI((function(){eA.sort(void 0)})),iA=WI((function(){eA.sort(null)})),oA=YI("sort"),aA=!WI((function(){if(ZI)return ZI<70;if(!(JI&&JI>3)){if(QI)return!0;if($I)return $I<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)eA.push({k:t+n,v:r})}for(eA.sort((function(e,t){return t.v-e.v})),n=0;n<eA.length;n++)t=eA[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));BI({target:"Array",proto:!0,forced:nA||!iA||!oA||!aA},{sort:function(e){void 0!==e&&GI(e);var t=HI(this);if(aA)return void 0===e?tA(t):tA(t,e);var r,n,i=[],o=zI(t);for(n=0;n<o;n++)n in t&&rA(i,t[n]);for(qI(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:XI(t)>XI(r)?1:-1}}(e)),r=zI(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)KI(t,n++);return t}});var sA,cA,uA,dA={exports:{}},lA="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,hA=lA,fA=le,pA=ce,vA=We,_A=Je,mA=Kt,yA=So,gA=St,SA=$r,EA=$n,bA=Nr.f,kA=tt,TA=Sd,IA=Xd,AA=sr,RA=Jt,CA=Ln.enforce,wA=Ln.get,OA=pA.Int8Array,xA=OA&&OA.prototype,PA=pA.Uint8ClampedArray,DA=PA&&PA.prototype,NA=OA&&TA(OA),MA=xA&&TA(xA),LA=Object.prototype,UA=pA.TypeError,VA=AA("toStringTag"),FA=RA("TYPED_ARRAY_TAG"),BA="TypedArrayConstructor",jA=hA&&!!IA&&"Opera"!==yA(pA.opera),GA=!1,HA={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},zA={BigInt64Array:8,BigUint64Array:8},KA=function(e){var t=TA(e);if(_A(t)){var r=wA(t);return r&&mA(r,BA)?r.TypedArrayConstructor:KA(t)}},XA=function(e){if(!_A(e))return!1;var t=yA(e);return mA(HA,t)||mA(zA,t)};for(sA in HA)(uA=(cA=pA[sA])&&cA.prototype)?CA(uA).TypedArrayConstructor=cA:jA=!1;for(sA in zA)(uA=(cA=pA[sA])&&cA.prototype)&&(CA(uA).TypedArrayConstructor=cA);if((!jA||!vA(NA)||NA===Function.prototype)&&(NA=function(){throw UA("Incorrect invocation")},jA))for(sA in HA)pA[sA]&&IA(pA[sA],NA);if((!jA||!MA||MA===LA)&&(MA=NA.prototype,jA))for(sA in HA)pA[sA]&&IA(pA[sA].prototype,MA);if(jA&&TA(DA)!==MA&&IA(DA,MA),fA&&!mA(MA,VA))for(sA in GA=!0,bA(MA,VA,{get:function(){return _A(this)?this[FA]:void 0}}),HA)pA[sA]&&SA(pA[sA],FA,sA);var WA={NATIVE_ARRAY_BUFFER_VIEWS:jA,TYPED_ARRAY_TAG:GA&&FA,aTypedArray:function(e){if(XA(e))return e;throw UA("Target is not a typed array")},aTypedArrayConstructor:function(e){if(vA(e)&&(!IA||kA(NA,e)))return e;throw UA(gA(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,n){if(fA){if(r)for(var i in HA){var o=pA[i];if(o&&mA(o.prototype,e))try{delete o.prototype[e]}catch(EZ){try{o.prototype[e]=t}catch(a){}}}MA[e]&&!r||EA(MA,e,r?t:jA&&xA[e]||t,n)}},exportTypedArrayStaticMethod:function(e,t,r){var n,i;if(fA){if(IA){if(r)for(n in HA)if((i=pA[n])&&mA(i,e))try{delete i[e]}catch(EZ){}if(NA[e]&&!r)return;try{return EA(NA,e,r?t:jA&&NA[e]||t)}catch(EZ){}}for(n in HA)!(i=pA[n])||i[e]&&!r||EA(i,e,t)}},getTypedArrayConstructor:KA,isView:function(e){if(!_A(e))return!1;var t=yA(e);return"DataView"===t||mA(HA,t)||mA(zA,t)},isTypedArray:XA,TypedArray:NA,TypedArrayPrototype:MA},qA=ce,YA=de,JA=Qh,QA=WA.NATIVE_ARRAY_BUFFER_VIEWS,ZA=qA.ArrayBuffer,$A=qA.Int8Array,eR=!QA||!YA((function(){$A(1)}))||!YA((function(){new $A(-1)}))||!JA((function(e){new $A,new $A(null),new $A(1.5),new $A(e)}),!0)||YA((function(){return 1!==new $A(new ZA(2),1,void 0).length})),tR=ii,rR=li,nR=RangeError,iR=function(e){if(void 0===e)return 0;var t=tR(e),r=rR(t);if(t!==r)throw nR("Wrong length or index");return r},oR=Array,aR=Math.abs,sR=Math.pow,cR=Math.floor,uR=Math.log,dR=Math.LN2,lR=Gt,hR=ci,fR=fi,pR=function(e){for(var t=lR(this),r=fR(t),n=arguments.length,i=hR(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:hR(o,r);a>i;)t[i++]=e;return t},vR=ce,_R=Re,mR=le,yR=lA,gR=sn,SR=$r,ER=Sf,bR=de,kR=Xh,TR=ii,IR=li,AR=iR,RR={pack:function(e,t,r){var n,i,o,a=oR(r),s=8*r-t-1,c=(1<<s)-1,u=c>>1,d=23===t?sR(2,-24)-sR(2,-77):0,l=e<0||0===e&&1/e<0?1:0,h=0;for((e=aR(e))!=e||e===1/0?(i=e!=e?1:0,n=c):(n=cR(uR(e)/dR),e*(o=sR(2,-n))<1&&(n--,o*=2),(e+=n+u>=1?d/o:d*sR(2,1-u))*o>=2&&(n++,o/=2),n+u>=c?(i=0,n=c):n+u>=1?(i=(e*o-1)*sR(2,t),n+=u):(i=e*sR(2,u-1)*sR(2,t),n=0));t>=8;)a[h++]=255&i,i/=256,t-=8;for(n=n<<t|i,s+=t;s>0;)a[h++]=255&n,n/=256,s-=8;return a[--h]|=128*l,a},unpack:function(e,t){var r,n=e.length,i=8*n-t-1,o=(1<<i)-1,a=o>>1,s=i-7,c=n-1,u=e[c--],d=127&u;for(u>>=7;s>0;)d=256*d+e[c--],s-=8;for(r=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)r=256*r+e[c--],s-=8;if(0===d)d=1-a;else{if(d===o)return r?NaN:u?-1/0:1/0;r+=sR(2,t),d-=a}return(u?-1:1)*r*sR(2,d-t)}},CR=Sd,wR=Xd,OR=ei.f,xR=Nr.f,PR=pR,DR=Nl,NR=Pd,MR=gR.PROPER,LR=gR.CONFIGURABLE,UR=Ln.get,VR=Ln.set,FR="ArrayBuffer",BR="DataView",jR="Wrong index",GR=vR.ArrayBuffer,HR=GR,zR=HR&&HR.prototype,KR=vR.DataView,XR=KR&&KR.prototype,WR=Object.prototype,qR=vR.Array,YR=vR.RangeError,JR=_R(PR),QR=_R([].reverse),ZR=RR.pack,$R=RR.unpack,eC=function(e){return[255&e]},tC=function(e){return[255&e,e>>8&255]},rC=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},nC=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},iC=function(e){return ZR(e,23,4)},oC=function(e){return ZR(e,52,8)},aC=function(e,t){xR(e.prototype,t,{get:function(){return UR(this)[t]}})},sC=function(e,t,r,n){var i=AR(r),o=UR(e);if(i+t>o.byteLength)throw YR(jR);var a=UR(o.buffer).bytes,s=i+o.byteOffset,c=DR(a,s,s+t);return n?c:QR(c)},cC=function(e,t,r,n,i,o){var a=AR(r),s=UR(e);if(a+t>s.byteLength)throw YR(jR);for(var c=UR(s.buffer).bytes,u=a+s.byteOffset,d=n(+i),l=0;l<t;l++)c[u+l]=d[o?l:t-l-1]};if(yR){var uC=MR&&GR.name!==FR;if(bR((function(){GR(1)}))&&bR((function(){new GR(-1)}))&&!bR((function(){return new GR,new GR(1.5),new GR(NaN),1!=GR.length||uC&&!LR})))uC&&LR&&SR(GR,"name",FR);else{(HR=function(e){return kR(this,zR),new GR(AR(e))}).prototype=zR;for(var dC,lC=OR(GR),hC=0;lC.length>hC;)(dC=lC[hC++])in HR||SR(HR,dC,GR[dC]);zR.constructor=HR}wR&&CR(XR)!==WR&&wR(XR,WR);var fC=new KR(new HR(2)),pC=_R(XR.setInt8);fC.setInt8(0,2147483648),fC.setInt8(1,2147483649),!fC.getInt8(0)&&fC.getInt8(1)||ER(XR,{setInt8:function(e,t){pC(this,e,t<<24>>24)},setUint8:function(e,t){pC(this,e,t<<24>>24)}},{unsafe:!0})}else zR=(HR=function(e){kR(this,zR);var t=AR(e);VR(this,{bytes:JR(qR(t),0),byteLength:t}),mR||(this.byteLength=t)}).prototype,XR=(KR=function(e,t,r){kR(this,XR),kR(e,zR);var n=UR(e).byteLength,i=TR(t);if(i<0||i>n)throw YR("Wrong offset");if(i+(r=void 0===r?n-i:IR(r))>n)throw YR("Wrong length");VR(this,{buffer:e,byteLength:r,byteOffset:i}),mR||(this.buffer=e,this.byteLength=r,this.byteOffset=i)}).prototype,mR&&(aC(HR,"byteLength"),aC(KR,"buffer"),aC(KR,"byteLength"),aC(KR,"byteOffset")),ER(XR,{getInt8:function(e){return sC(this,1,e)[0]<<24>>24},getUint8:function(e){return sC(this,1,e)[0]},getInt16:function(e){var t=sC(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=sC(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return nC(sC(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return nC(sC(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return $R(sC(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return $R(sC(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){cC(this,1,e,eC,t)},setUint8:function(e,t){cC(this,1,e,eC,t)},setInt16:function(e,t){cC(this,2,e,tC,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){cC(this,2,e,tC,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){cC(this,4,e,rC,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){cC(this,4,e,rC,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){cC(this,4,e,iC,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){cC(this,8,e,oC,t,arguments.length>2?arguments[2]:void 0)}});NR(HR,FR),NR(KR,BR);var vC={ArrayBuffer:HR,DataView:KR},_C=Je,mC=Math.floor,yC=Number.isInteger||function(e){return!_C(e)&&isFinite(e)&&mC(e)===e},gC=ii,SC=RangeError,EC=function(e){var t=gC(e);if(t<0)throw SC("The argument can't be less than 0");return t},bC=RangeError,kC=function(e,t){var r=EC(e);if(r%t)throw bC("Wrong offset");return r},TC=So,IC=Re("".slice),AC=function(e){return"Big"===IC(TC(e),0,3)},RC=vr,CC=TypeError,wC=function(e){var t=RC(e,"number");if("number"==typeof t)throw CC("Can't convert number to bigint");return BigInt(t)},OC=ga,xC=ve,PC=Y_,DC=Gt,NC=fi,MC=Ih,LC=yh,UC=hh,VC=AC,FC=WA.aTypedArrayConstructor,BC=wC,jC=ro,GC=ce,HC=ve,zC=le,KC=eR,XC=WA,WC=vC,qC=Xh,YC=be,JC=$r,QC=yC,ZC=li,$C=iR,ew=kC,tw=yr,rw=Kt,nw=So,iw=Je,ow=yt,aw=cs,sw=tt,cw=Xd,uw=ei.f,dw=function(e){var t,r,n,i,o,a,s,c,u=PC(this),d=DC(e),l=arguments.length,h=l>1?arguments[1]:void 0,f=void 0!==h,p=LC(d);if(p&&!UC(p))for(c=(s=MC(d,p)).next,d=[];!(a=xC(c,s)).done;)d.push(a.value);for(f&&l>2&&(h=OC(h,arguments[2])),r=NC(d),n=new(FC(u))(r),i=VC(n),t=0;r>t;t++)o=f?h(d[t],t):d[t],n[t]=i?BC(o):+o;return n},lw=Ra.forEach,hw=If,fw=Nr,pw=ue,vw=tf,_w=Ln.get,mw=Ln.set,yw=Ln.enforce,gw=fw.f,Sw=pw.f,Ew=Math.round,bw=GC.RangeError,kw=WC.ArrayBuffer,Tw=kw.prototype,Iw=WC.DataView,Aw=XC.NATIVE_ARRAY_BUFFER_VIEWS,Rw=XC.TYPED_ARRAY_TAG,Cw=XC.TypedArray,ww=XC.TypedArrayPrototype,Ow=XC.aTypedArrayConstructor,xw=XC.isTypedArray,Pw="BYTES_PER_ELEMENT",Dw="Wrong length",Nw=function(e,t){Ow(e);for(var r=0,n=t.length,i=new e(n);n>r;)i[r]=t[r++];return i},Mw=function(e,t){gw(e,t,{get:function(){return _w(this)[t]}})},Lw=function(e){var t;return sw(Tw,e)||"ArrayBuffer"==(t=nw(e))||"SharedArrayBuffer"==t},Uw=function(e,t){return xw(e)&&!ow(t)&&t in e&&QC(+t)&&t>=0},Vw=function(e,t){return t=tw(t),Uw(e,t)?YC(2,e[t]):Sw(e,t)},Fw=function(e,t,r){return t=tw(t),!(Uw(e,t)&&iw(r)&&rw(r,"value"))||rw(r,"get")||rw(r,"set")||r.configurable||rw(r,"writable")&&!r.writable||rw(r,"enumerable")&&!r.enumerable?gw(e,t,r):(e[t]=r.value,e)};zC?(Aw||(pw.f=Vw,fw.f=Fw,Mw(ww,"buffer"),Mw(ww,"byteOffset"),Mw(ww,"byteLength"),Mw(ww,"length")),jC({target:"Object",stat:!0,forced:!Aw},{getOwnPropertyDescriptor:Vw,defineProperty:Fw}),dA.exports=function(e,t,r){var n=e.match(/\d+$/)[0]/8,i=e+(r?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=GC[i],c=s,u=c&&c.prototype,d={},l=function(e,t){gw(e,t,{get:function(){return function(e,t){var r=_w(e);return r.view[o](t*n+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var o=_w(e);r&&(i=(i=Ew(i))<0?0:i>255?255:255&i),o.view[a](t*n+o.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};Aw?KC&&(c=t((function(e,t,r,i){return qC(e,u),vw(iw(t)?Lw(t)?void 0!==i?new s(t,ew(r,n),i):void 0!==r?new s(t,ew(r,n)):new s(t):xw(t)?Nw(c,t):HC(dw,c,t):new s($C(t)),e,c)})),cw&&cw(c,Cw),lw(uw(s),(function(e){e in c||JC(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,r,i){qC(e,u);var o,a,s,d=0,h=0;if(iw(t)){if(!Lw(t))return xw(t)?Nw(c,t):HC(dw,c,t);o=t,h=ew(r,n);var f=t.byteLength;if(void 0===i){if(f%n)throw bw(Dw);if((a=f-h)<0)throw bw(Dw)}else if((a=ZC(i)*n)+h>f)throw bw(Dw);s=a/n}else s=$C(t),o=new kw(a=s*n);for(mw(e,{buffer:o,byteOffset:h,byteLength:a,length:s,view:new Iw(o)});d<s;)l(e,d++)})),cw&&cw(c,Cw),u=c.prototype=aw(ww)),u.constructor!==c&&JC(u,"constructor",c),yw(u).TypedArrayConstructor=c,Rw&&JC(u,Rw,i);var h=c!=s;d[i]=c,jC({global:!0,constructor:!0,forced:h,sham:!Aw},d),Pw in c||JC(c,Pw,n),Pw in u||JC(u,Pw,n),hw(i)}):dA.exports=function(){},(0,dA.exports)("Uint8",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var Bw=fi,jw=ii,Gw=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("at",(function(e){var t=Gw(this),r=Bw(t),n=jw(e),i=n>=0?n:r+n;return i<0||i>=r?void 0:t[i]}));var Hw=Gt,zw=ci,Kw=fi,Xw=C_,Ww=Math.min,qw=[].copyWithin||function(e,t){var r=Hw(this),n=Kw(r),i=zw(e,n),o=zw(t,n),a=arguments.length>2?arguments[2]:void 0,s=Ww((void 0===a?n:zw(a,n))-o,n-i),c=1;for(o<i&&i<o+s&&(c=-1,o+=s-1,i+=s-1);s-- >0;)o in r?r[i]=r[o]:Xw(r,i),i+=c,o+=c;return r},Yw=WA,Jw=Re(qw),Qw=Yw.aTypedArray;(0,Yw.exportTypedArrayMethod)("copyWithin",(function(e,t){return Jw(Qw(this),e,t,arguments.length>2?arguments[2]:void 0)}));var Zw=Ra.every,$w=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("every",(function(e){return Zw($w(this),e,arguments.length>1?arguments[1]:void 0)}));var eO=pR,tO=wC,rO=So,nO=ve,iO=de,oO=WA.aTypedArray,aO=WA.exportTypedArrayMethod,sO=Re("".slice),cO=iO((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}));aO("fill",(function(e){var t=arguments.length;oO(this);var r="Big"===sO(rO(this),0,3)?tO(e):+e;return nO(eO,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),cO);var uO=fi,dO=function(e,t){for(var r=0,n=uO(t),i=new e(n);n>r;)i[r]=t[r++];return i},lO=em,hO=WA.aTypedArrayConstructor,fO=WA.getTypedArrayConstructor,pO=function(e){return hO(lO(e,fO(e)))},vO=dO,_O=pO,mO=Ra.filter,yO=function(e,t){return vO(_O(e),t)},gO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("filter",(function(e){var t=mO(gO(this),e,arguments.length>1?arguments[1]:void 0);return yO(this,t)}));var SO=Ra.find,EO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("find",(function(e){return SO(EO(this),e,arguments.length>1?arguments[1]:void 0)}));var bO=Ra.findIndex,kO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("findIndex",(function(e){return bO(kO(this),e,arguments.length>1?arguments[1]:void 0)}));var TO=ga,IO=Le,AO=Gt,RO=fi,CO=function(e){var t=1==e;return function(r,n,i){for(var o,a=AO(r),s=IO(a),c=TO(n,i),u=RO(s);u-- >0;)if(c(o=s[u],u,a))switch(e){case 0:return o;case 1:return u}return t?-1:void 0}},wO={findLast:CO(0),findLastIndex:CO(1)},OO=wO.findLast,xO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("findLast",(function(e){return OO(xO(this),e,arguments.length>1?arguments[1]:void 0)}));var PO=wO.findLastIndex,DO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("findLastIndex",(function(e){return PO(DO(this),e,arguments.length>1?arguments[1]:void 0)}));var NO=Ra.forEach,MO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("forEach",(function(e){NO(MO(this),e,arguments.length>1?arguments[1]:void 0)}));var LO=yi.includes,UO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("includes",(function(e){return LO(UO(this),e,arguments.length>1?arguments[1]:void 0)}));var VO=yi.indexOf,FO=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("indexOf",(function(e){return VO(FO(this),e,arguments.length>1?arguments[1]:void 0)}));var BO=ce,jO=de,GO=Re,HO=WA,zO=Il,KO=sr("iterator"),XO=BO.Uint8Array,WO=GO(zO.values),qO=GO(zO.keys),YO=GO(zO.entries),JO=HO.aTypedArray,QO=HO.exportTypedArrayMethod,ZO=XO&&XO.prototype,$O=!jO((function(){ZO[KO].call([1])})),ex=!!ZO&&ZO.values&&ZO[KO]===ZO.values&&"values"===ZO.values.name,tx=function(){return WO(JO(this))};QO("entries",(function(){return YO(JO(this))}),$O),QO("keys",(function(){return qO(JO(this))}),$O),QO("values",tx,$O||!ex,{name:"values"}),QO(KO,tx,$O||!ex,{name:"values"});var rx=WA.aTypedArray,nx=WA.exportTypedArrayMethod,ix=Re([].join);nx("join",(function(e){return ix(rx(this),e)}));var ox=Wc,ax=He,sx=ii,cx=fi,ux=wa,dx=Math.min,lx=[].lastIndexOf,hx=!!lx&&1/[1].lastIndexOf(1,-0)<0,fx=ux("lastIndexOf"),px=hx||!fx?function(e){if(hx)return ox(lx,this,arguments)||0;var t=ax(this),r=cx(t),n=r-1;for(arguments.length>1&&(n=dx(n,sx(arguments[1]))),n<0&&(n=r+n);n>=0;n--)if(n in t&&t[n]===e)return n||0;return-1}:lx,vx=Wc,_x=px,mx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("lastIndexOf",(function(e){var t=arguments.length;return vx(_x,mx(this),t>1?[e,arguments[1]]:[e])}));var yx=Ra.map,gx=pO,Sx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("map",(function(e){return yx(Sx(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(gx(e))(t)}))}));var Ex=Zp.left,bx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("reduce",(function(e){var t=arguments.length;return Ex(bx(this),e,t,t>1?arguments[1]:void 0)}));var kx=Zp.right,Tx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("reduceRight",(function(e){var t=arguments.length;return kx(Tx(this),e,t,t>1?arguments[1]:void 0)}));var Ix=WA.aTypedArray,Ax=WA.exportTypedArrayMethod,Rx=Math.floor;Ax("reverse",(function(){for(var e,t=this,r=Ix(t).length,n=Rx(r/2),i=0;i<n;)e=t[i],t[i++]=t[--r],t[r]=e;return t}));var Cx=ce,wx=ve,Ox=WA,xx=fi,Px=kC,Dx=Gt,Nx=de,Mx=Cx.RangeError,Lx=Cx.Int8Array,Ux=Lx&&Lx.prototype,Vx=Ux&&Ux.set,Fx=Ox.aTypedArray,Bx=Ox.exportTypedArrayMethod,jx=!Nx((function(){var e=new Uint8ClampedArray(2);return wx(Vx,e,{length:1,0:3},1),3!==e[1]})),Gx=jx&&Ox.NATIVE_ARRAY_BUFFER_VIEWS&&Nx((function(){var e=new Lx(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));Bx("set",(function(e){Fx(this);var t=Px(arguments.length>1?arguments[1]:void 0,1),r=Dx(e);if(jx)return wx(Vx,this,r,t);var n=this.length,i=xx(r),o=0;if(i+t>n)throw Mx("Wrong length");for(;o<i;)this[t+o]=r[o++]}),!jx||Gx);var Hx=pO,zx=qc,Kx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("slice",(function(e,t){for(var r=zx(Kx(this),e,t),n=Hx(this),i=0,o=r.length,a=new n(o);o>i;)a[i]=r[i++];return a}),de((function(){new Int8Array(1).slice()})));var Xx=Ra.some,Wx=WA.aTypedArray;(0,WA.exportTypedArrayMethod)("some",(function(e){return Xx(Wx(this),e,arguments.length>1?arguments[1]:void 0)}));var qx=va,Yx=de,Jx=Tt,Qx=NI,Zx=LI,$x=UI,eP=ut,tP=FI,rP=WA.aTypedArray,nP=WA.exportTypedArrayMethod,iP=ce.Uint16Array,oP=iP&&qx(iP.prototype.sort),aP=!(!oP||Yx((function(){oP(new iP(2),null)}))&&Yx((function(){oP(new iP(2),{})}))),sP=!!oP&&!Yx((function(){if(eP)return eP<74;if(Zx)return Zx<67;if($x)return!0;if(tP)return tP<602;var e,t,r=new iP(516),n=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,n[e]=e-2*t+3;for(oP(r,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(r[e]!==n[e])return!0}));nP("sort",(function(e){return void 0!==e&&Jx(e),sP?oP(this,e):Qx(rP(this),function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?-1:t!=t?1:0===t&&0===r?1/t>0&&1/r<0?1:-1:t>r}}(e))}),!sP||aP);var cP=Wc,uP=WA,dP=de,lP=qc,hP=ce.Int8Array,fP=uP.aTypedArray,pP=uP.exportTypedArrayMethod,vP=[].toLocaleString,_P=!!hP&&dP((function(){vP.call(new hP(1))}));pP("toLocaleString",(function(){return cP(vP,_P?lP(fP(this)):fP(this),lP(arguments))}),dP((function(){return[1,2].toLocaleString()!=new hP([1,2]).toLocaleString()}))||!dP((function(){hP.prototype.toLocaleString.call([1,2])})));var mP=WA.exportTypedArrayMethod,yP=de,gP=Re,SP=ce.Uint8Array,EP=SP&&SP.prototype||{},bP=[].toString,kP=gP([].join);yP((function(){bP.call({})}))&&(bP=function(){return kP(this)});var TP=EP.toString!=bP;mP("toString",bP,TP);var IP=fi,AP=function(e,t){for(var r=IP(e),n=new t(r),i=0;i<r;i++)n[i]=e[r-i-1];return n},RP=WA.aTypedArray,CP=WA.getTypedArrayConstructor;(0,WA.exportTypedArrayMethod)("toReversed",(function(){return AP(RP(this),CP(this))}));var wP=Tt,OP=dO,xP=WA.aTypedArray,PP=WA.getTypedArrayConstructor,DP=WA.exportTypedArrayMethod,NP=Re(WA.TypedArrayPrototype.sort);DP("toSorted",(function(e){void 0!==e&&wP(e);var t=xP(this),r=OP(PP(t),t);return NP(r,e)}));var MP=fi,LP=ii,UP=RangeError,VP=function(e,t,r,n){var i=MP(e),o=LP(r),a=o<0?i+o:o;if(a>=i||a<0)throw UP("Incorrect index");for(var s=new t(i),c=0;c<i;c++)s[c]=c===a?n:e[c];return s},FP=AC,BP=ii,jP=wC,GP=WA.aTypedArray,HP=WA.getTypedArrayConstructor,zP=WA.exportTypedArrayMethod,KP=!!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(EZ){return 8===EZ}}();zP("with",{with:function(e,t){var r=GP(this),n=BP(e),i=FP(r)?jP(t):+t;return VP(r,HP(r),n,i)}}.with,!KP);var XP=ro,WP=Ra.findIndex,qP=ps,YP="findIndex",JP=!0;YP in[]&&Array(1).findIndex((function(){JP=!1})),XP({target:"Array",proto:!0,forced:JP},{findIndex:function(e){return WP(this,e,arguments.length>1?arguments[1]:void 0)}}),qP(YP);var QP=ro,ZP=va,$P=ue.f,eD=li,tD=As,rD=ks,nD=Be,iD=Cs,oD=ZP("".startsWith),aD=ZP("".slice),sD=Math.min,cD=iD("startsWith"),uD=!cD&&!!function(){var e=$P(String.prototype,"startsWith");return e&&!e.writable}();QP({target:"String",proto:!0,forced:!uD&&!cD},{startsWith:function(e){var t=tD(nD(this));rD(e);var r=eD(sD(arguments.length>1?arguments[1]:void 0,t.length)),n=tD(e);return oD?oD(t,n,r):aD(t,r,r+n.length)===n}});var dD=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e}(dD||{}),lD=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(lD||{}),hD=l((function e(t,r,n){u(this,e),h(this,"code",void 0),h(this,"message",void 0),h(this,"error",void 0),this.code=t,this.message=r,this.error=n})),fD=le,pD=Re,vD=Ga,_D=He,mD=pD(_e.f),yD=pD([].push),gD=function(e){return function(t){for(var r,n=_D(t),i=vD(n),o=i.length,a=0,s=[];o>a;)r=i[a++],fD&&!mD(n,r)||yD(s,e?[r,n[r]]:n[r]);return s}},SD={entries:gD(!0),values:gD(!1)}.entries;ro({target:"Object",stat:!0},{entries:function(e){return SD(e)}});var ED=ii,bD=As,kD=Be,TD=RangeError,ID=Re,AD=li,RD=As,CD=function(e){var t=bD(kD(this)),r="",n=ED(e);if(n<0||n==1/0)throw TD("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},wD=Be,OD=ID(CD),xD=ID("".slice),PD=Math.ceil,DD=function(e){return function(t,r,n){var i,o,a=RD(wD(t)),s=AD(r),c=a.length,u=void 0===n?" ":RD(n);return s<=c||""==u?a:((o=OD(u,PD((i=s-c)/u.length))).length>i&&(o=xD(o,0,i)),e?a+o:o+a)}},ND={start:DD(!1),end:DD(!0)},MD=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(rt),LD=ND.end;ro({target:"String",proto:!0,forced:MD},{padEnd:function(e){return LD(this,e,arguments.length>1?arguments[1]:void 0)}});var UD=sd;ro({target:"Number",stat:!0,forced:Number.parseInt!=UD},{parseInt:UD});var VD=Fr,FD=wh,BD=ga,jD=ve,GD=Gt,HD=function(e,t,r,n){try{return n?t(VD(r)[0],r[1]):t(r)}catch(EZ){FD(e,"throw",EZ)}},zD=hh,KD=No,XD=fi,WD=lo,qD=Ih,YD=yh,JD=Array,QD=function(e){var t=GD(e),r=KD(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=BD(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=YD(t),f=0;if(!h||this===JD&&zD(h))for(a=XD(t),s=r?new this(a):JD(a);a>f;f++)l=o?i(t[f],f):t[f],WD(s,f,l);else for(d=(u=qD(t,h)).next,s=r?new this:[];!(c=jD(d,u)).done;f++)l=o?HD(u,i,[c.value,f],!0):c.value,WD(s,f,l);return s.length=f,s},ZD=QD;ro({target:"Array",stat:!0,forced:!Qh((function(e){Array.from(e)}))},{from:ZD});var $D=Math.log,eN=Math.LOG10E;ro({target:"Math",stat:!0},{log10:Math.log10||function(e){return $D(e)*eN}});for(var tN="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",rN={},nN=0;nN<66;nN++)rN[tN.charAt(nN)]=nN;var iN,oN=ro,aN=et,sN=Re,cN=de,uN=As,dN=Kt,lN=rm,hN={itoc:tN,ctoi:rN}.ctoi,fN=/[^\d+/a-z]/i,pN=/[\t\n\f\r ]+/g,vN=/[=]+$/,_N=aN("atob"),mN=String.fromCharCode,yN=sN("".charAt),gN=sN("".replace),SN=sN(fN.exec),EN=cN((function(){return""!==_N(" ")})),bN=!cN((function(){_N("a")})),kN=!EN&&!bN&&!cN((function(){_N()})),TN=!EN&&!bN&&1!==_N.length;oN({global:!0,enumerable:!0,forced:EN||bN||kN||TN},{atob:function(e){if(lN(arguments.length,1),kN||TN)return _N(e);var t,r,n=gN(uN(e),pN,""),i="",o=0,a=0;if(n.length%4==0&&(n=gN(n,vN,"")),n.length%4==1||SN(fN,n))throw new(aN("DOMException"))("The string is not correctly encoded","InvalidCharacterError");for(;t=yN(n,o++);)dN(hN,t)&&(r=a%4?64*r+hN[t]:hN[t],a++%4&&(i+=mN(255&r>>(-2*a&6))));return i}});var IN=new Uint8Array(16);function AN(){if(!iN&&!(iN="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return iN(IN)}var RN=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function CN(e){return"string"==typeof e&&RN.test(e)}for(var wN=[],ON=0;ON<256;++ON)wN.push((ON+256).toString(16).substr(1));function xN(e,t,r){var n=(e=e||{}).random||(e.rng||AN)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(wN[e[t+0]]+wN[e[t+1]]+wN[e[t+2]]+wN[e[t+3]]+"-"+wN[e[t+4]]+wN[e[t+5]]+"-"+wN[e[t+6]]+wN[e[t+7]]+"-"+wN[e[t+8]]+wN[e[t+9]]+"-"+wN[e[t+10]]+wN[e[t+11]]+wN[e[t+12]]+wN[e[t+13]]+wN[e[t+14]]+wN[e[t+15]]).toLowerCase();if(!CN(r))throw TypeError("Stringified UUID is invalid");return r}(n)}(0,dA.exports)("Uint32",(function(e){return function(t,r,n){return e(this,t,r,n)}})),(0,dA.exports)("Int8",(function(e){return function(t,r,n){return e(this,t,r,n)}})),(0,dA.exports)("Uint8",(function(e){return function(t,r,n){return e(this,t,r,n)}}),!0),(0,dA.exports)("Int16",(function(e){return function(t,r,n){return e(this,t,r,n)}})),(0,dA.exports)("Uint16",(function(e){return function(t,r,n){return e(this,t,r,n)}})),(0,dA.exports)("Int32",(function(e){return function(t,r,n){return e(this,t,r,n)}})),(0,dA.exports)("Float32",(function(e){return function(t,r,n){return e(this,t,r,n)}})),(0,dA.exports)("Float64",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var PN={exports:{}},DN=ce;ro({global:!0,forced:DN.globalThis!==DN},{globalThis:DN});var NN={exports:{}};!function(e,t){var r;e.exports=(r=r||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==ae&&ae.crypto&&(r=ae.crypto),!r)try{r=require("crypto")}catch(v){}var n=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(v){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(v){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o={},a=o.lib={},s=a.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=s.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(n());return new c.init(t,e)}}),u=o.enc={},d=u.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},l=u.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},h=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},f=a.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),u=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,d=e.min(4*u,o);if(u){for(var l=0;l<u;l+=a)this._doProcessBlock(i,l);r=i.splice(0,u),n.sigBytes-=d}return new c.init(r,d)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});a.Hasher=f.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new p.HMAC.init(e,r).finalize(t)}}});var p=o.algo={};return o}(Math),r)}(NN),function(e,t){var r;e.exports=(r=NN.exports,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}(PN);var MN=PN.exports,LN={exports:{}},UN={exports:{}};!function(e,t){var r;e.exports=(r=NN.exports,function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}(UN);var VN={exports:{}};!function(e,t){var r;e.exports=(r=NN.exports,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],v=e[t+4],_=e[t+5],m=e[t+6],y=e[t+7],g=e[t+8],S=e[t+9],E=e[t+10],b=e[t+11],k=e[t+12],T=e[t+13],I=e[t+14],A=e[t+15],R=o[0],C=o[1],w=o[2],O=o[3];R=u(R,C,w,O,a,7,s[0]),O=u(O,R,C,w,c,12,s[1]),w=u(w,O,R,C,f,17,s[2]),C=u(C,w,O,R,p,22,s[3]),R=u(R,C,w,O,v,7,s[4]),O=u(O,R,C,w,_,12,s[5]),w=u(w,O,R,C,m,17,s[6]),C=u(C,w,O,R,y,22,s[7]),R=u(R,C,w,O,g,7,s[8]),O=u(O,R,C,w,S,12,s[9]),w=u(w,O,R,C,E,17,s[10]),C=u(C,w,O,R,b,22,s[11]),R=u(R,C,w,O,k,7,s[12]),O=u(O,R,C,w,T,12,s[13]),w=u(w,O,R,C,I,17,s[14]),R=d(R,C=u(C,w,O,R,A,22,s[15]),w,O,c,5,s[16]),O=d(O,R,C,w,m,9,s[17]),w=d(w,O,R,C,b,14,s[18]),C=d(C,w,O,R,a,20,s[19]),R=d(R,C,w,O,_,5,s[20]),O=d(O,R,C,w,E,9,s[21]),w=d(w,O,R,C,A,14,s[22]),C=d(C,w,O,R,v,20,s[23]),R=d(R,C,w,O,S,5,s[24]),O=d(O,R,C,w,I,9,s[25]),w=d(w,O,R,C,p,14,s[26]),C=d(C,w,O,R,g,20,s[27]),R=d(R,C,w,O,T,5,s[28]),O=d(O,R,C,w,f,9,s[29]),w=d(w,O,R,C,y,14,s[30]),R=l(R,C=d(C,w,O,R,k,20,s[31]),w,O,_,4,s[32]),O=l(O,R,C,w,g,11,s[33]),w=l(w,O,R,C,b,16,s[34]),C=l(C,w,O,R,I,23,s[35]),R=l(R,C,w,O,c,4,s[36]),O=l(O,R,C,w,v,11,s[37]),w=l(w,O,R,C,y,16,s[38]),C=l(C,w,O,R,E,23,s[39]),R=l(R,C,w,O,T,4,s[40]),O=l(O,R,C,w,a,11,s[41]),w=l(w,O,R,C,p,16,s[42]),C=l(C,w,O,R,m,23,s[43]),R=l(R,C,w,O,S,4,s[44]),O=l(O,R,C,w,k,11,s[45]),w=l(w,O,R,C,A,16,s[46]),R=h(R,C=l(C,w,O,R,f,23,s[47]),w,O,a,6,s[48]),O=h(O,R,C,w,y,10,s[49]),w=h(w,O,R,C,I,15,s[50]),C=h(C,w,O,R,_,21,s[51]),R=h(R,C,w,O,k,6,s[52]),O=h(O,R,C,w,p,10,s[53]),w=h(w,O,R,C,E,15,s[54]),C=h(C,w,O,R,c,21,s[55]),R=h(R,C,w,O,g,6,s[56]),O=h(O,R,C,w,A,10,s[57]),w=h(w,O,R,C,m,15,s[58]),C=h(C,w,O,R,T,21,s[59]),R=h(R,C,w,O,v,6,s[60]),O=h(O,R,C,w,b,10,s[61]),w=h(w,O,R,C,f,15,s[62]),C=h(C,w,O,R,S,21,s[63]),o[0]=o[0]+R|0,o[1]=o[1]+C|0,o[2]=o[2]+w|0,o[3]=o[3]+O|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function h(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}(VN);var FN={exports:{}},BN={exports:{}};!function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=NN.exports).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=d<<1|d>>>31}var l=(n<<5|n>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),u.SHA1)}(BN);var jN={exports:{}};!function(e,t){var r,n,i;e.exports=(n=(r=NN.exports).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))}(jN),function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=NN.exports).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,u=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var d=1;d<u;d++)r=i.finalize(r),i.reset();a.concat(r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},u.EvpKDF)}(FN);var GN={exports:{}};!function(e,t){var r;e.exports=void((r=NN.exports).lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,u=t.algo.EvpKDF,d=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?g:m}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},h=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=l.CBC=function(){var t=h.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=e.slice(t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=e.slice(t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),p=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=d.extend({cfg:d.cfg.extend({mode:f,padding:p}),reset:function(){var e;d.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var v=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?o.create([1398893684,1701076831]).concat(r).concat(t):t).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),v.create({ciphertext:r,salt:t})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return v.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){if(n||(n=o.random(8)),i)a=u.create({keySize:t+r,hasher:i}).compute(e,n);else var a=u.create({keySize:t+r}).compute(e,n);var s=o.create(a.words.slice(t),4*r);return a.sigBytes=4*t,v.create({key:a,iv:s,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:y}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=m.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,m.decrypt.call(this,e,t,i.key,n)}})}())}(GN),function(e,t){var r;e.exports=(r=NN.exports,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],u=[],d=[],l=[],h=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var p=n^n<<1^n<<2^n<<3^n<<4;p=p>>>8^255&p^99,i[r]=p,o[p]=r;var v=e[r],_=e[v],m=e[_],y=257*e[p]^16843008*p;a[r]=y<<24|y>>>8,s[r]=y<<16|y>>>16,c[r]=y<<8|y>>>24,u[r]=y,y=16843009*m^65537*_^257*v^16843008*r,d[p]=y<<24|y>>>8,l[p]=y<<16|y>>>16,h[p]=y<<8|y>>>24,f[p]=y,r?(r=v^e[e[e[m^v]]],n^=e[e[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],v=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(u=o[a-1],a%r?r>6&&a%r==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=p[a/r|0]<<24),o[a]=o[a-r]^u);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var u=o[a];else u=o[a-4];s[c]=c<4||a<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^f[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,f,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],h=e[t+3]^r[3],f=4,p=1;p<c;p++){var v=n[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^a[255&h]^r[f++],_=n[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^a[255&u]^r[f++],m=n[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&d]^r[f++],y=n[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&l]^r[f++];u=v,d=_,l=m,h=y}v=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[l>>>8&255]<<8|s[255&h])^r[f++],_=(s[d>>>24]<<24|s[l>>>16&255]<<16|s[h>>>8&255]<<8|s[255&u])^r[f++],m=(s[l>>>24]<<24|s[h>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[f++],y=(s[h>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&l])^r[f++],e[t]=v,e[t+1]=_,e[t+2]=m,e[t+3]=y},keySize:8});e.AES=t._createHelper(v)}(),r.AES)}(LN);var HN={exports:{}};!function(e,t){e.exports=NN.exports.enc.Hex}(HN);var zN=HN.exports,KN={exports:{}};!function(e,t){var r,n,i;e.exports=((i=NN.exports).mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=i.slice(0),this._iv=void 0);var a=o.slice(0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}(KN);var XN=KN.exports,WN={exports:{}};!function(e,t){var r;e.exports=((r=NN.exports).pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}(WN);var qN,YN=WN.exports,JN=new TextDecoder,QN=new TextEncoder,ZN=function(){return xN()},$N=function(){return Date.now()};function eM(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,d=0,l=n;d<l.length;d++){var h=l[d];c.set(h,u),u+=h.length}return c}var tM=function(){return"undefined"==typeof window},rM=function(){function e(){u(this,e)}var t,r;return l(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){return window.btoa([e,t,r].filter((function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=Object.entries(t);n<i.length;n++){var o=b(i[n],2),s=o[0],c=o[1];null!==c&&"object"===a(c)?e.merge(t[s],r[s]):void 0!==r[s]&&(t[s]=r[s])}}},{key:"ab2str",value:function(e){return JN.decode(e)}},{key:"ab2obj",value:function(t){try{var r=e.ab2str(t);return JSON.parse(r)}catch(n){return{}}}},{key:"str2ab",value:function(e){return QN.encode(e).buffer}},{key:"ab2b64str",value:(r=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,"+t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function nM(){var e="none";return tM()||(null!==window.navigator.userAgent.match("Firefox")?e="mozilla":null!==window.navigator.userAgent.match("Chrome")?(e="chrome-stable",null!==window.navigator.userAgent.match("Electron")&&(e="electron")):(null!==window.navigator.userAgent.match("Safari")||null!==window.navigator.userAgent.match("AppleWebKit"))&&(e="safari")),e}var iM=function(){if("chrome-stable"===nM()){var e=window.navigator.userAgent.match(/Chrome\/([\d.]+)/);if(e&&e.length>1)if(Number(e[1].split(".")[0])<114)return!0}return!1}(),oM="mozilla"===nM(),aM="safari"===nM(),sM=0,cM=!tM()&&(null===(qN=navigator.userAgent.match(/version\/(\d+)/i))||void 0===qN?void 0:qN[1]);aM&&cM&&(sM=+cM);var uM=sM,dM=!tM()&&!!/(iPhone|iPad|iPod)/i.exec(navigator.userAgent);!tM()&&/(iPhone|iPod)/i.exec(navigator.userAgent);var lM=!tM()&&(!!/(iPad)/i.exec(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&"ontouchend"in document),hM=!tM()&&/MicroMessenger/i.test(navigator.userAgent),fM=!tM()&&/Android/i.test(navigator.userAgent),pM=!tM()&&navigator.userAgent.toLowerCase().includes("mobile"),vM=!tM()&&/chrome\/(86)|(87)|(88)|(89)|(90)|(91)|(92)/i.test(navigator.userAgent);function _M(){for(var e=(+"".concat(Math.random()).slice(-7).padEnd(7,"0")).toString(2).padEnd(28,"1").split(""),t=[];e.length;)t.push(e.splice(0,7));return t.map((function(e,r){var n=r===t.length-1?"0":"1";return Number.parseInt(n+e.join(""),2)}))}var mM=function(){return Math.floor(65535*Math.random())};function yM(e){return"string"==typeof e&&e.indexOf("__web__rtc__rtt__")>-1}function gM(e){return e.map((function e(t){if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var r=ArrayBuffer.isView(t)?t.buffer:t,n=r.byteLength,i=[];if(n>10){var o=new DataView(r),a=Array.from({length:5}).map((function(e,t){return o.getUint8(t)})),s=Array.from({length:5}).map((function(e,t){return n-1-t})).reverse().map((function(e){return o.getUint8(e)}));i=[].concat(k(a),["..."],k(s))}else i=Array.from(new Uint8Array(r));return"".concat(t.constructor.name,"(").concat(n,") [").concat(i.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return t.map(e);if("[object Object]"===Object.prototype.toString.call(t)){var c={};for(var u in t)c[u]=e(t[u]);return c}return t}))}var SM=function(){var e=c(o().mark((function e(){var t,r,n,i=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),EM=function(e){return new Promise((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function bM(e){return+Math.max(-127,10*Math.log10(Math.pow(e/255,2))).toFixed(2)}function kM(e){return(e&U.AUDIO)===U.AUDIO}function TM(e){return(e&U.VIDEO)===U.VIDEO}function IM(e){var t={};return Object.keys(e).forEach((function(r){"object"===a(e[r])?t[r]=IM(e[r]):r.startsWith("_")||(t[r]=e[r])})),t}function AM(e){var t=new DataView(e.buffer);if(t.byteLength<=4||65535!==t.getUint16(0))return{seiCount:1,seis:[e]};for(var r={seiCount:0,seis:[]},n=!1,i=2;i<t.byteLength;){var o=t.getUint16(i);if(i+=2,t.byteLength-i<o){n=!0;break}var a=new Uint8Array(e.buffer,i,o);if(i+=o,t.byteLength-i>0&&t.byteLength-i<=2){n=!0;break}r.seiCount++,r.seis.push(a)}return n&&(r.seiCount=1,r.seis=[e]),r}function RM(e){return null==e?"undefined | null":"string"==typeof e?e:JSON.stringify({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function CM(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function wM(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function OM(e,t,r){var n=xM(e),i=xM(t),o=xM(r);return function(e){for(var t=e.toString(zN),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=parseInt(t.substr(n,2),16);return r}(LN.exports.encrypt(n,i,{iv:o,mode:XN,padding:YN}).ciphertext)}function xM(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return MN.create(t,e.length)}function PM(e,t){if("boolean"!=typeof e)throw new hD(dD.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function DM(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i=new hD(dD.INVALID_PARAMS,"Invalid ".concat(t,": the value range is [").concat(r,", ").concat(n,"]. integer only"));throw i}}function NM(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new hD(dD.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!BM(e,r,n))throw new hD(dD.INVALID_PARAMS,"Invalid ".concat(t,": The value should be string type. Length of the string: [").concat(r,",").concat(n,"]"))}function MM(e,t,r){if(!r.includes(e))throw new hD(dD.INVALID_PARAMS,"Invalid ".concat(t,": The value can only be set as ").concat(JSON.stringify(r)))}function LM(e){if(!(e instanceof MediaStreamTrack))throw new hD(dD.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function UM(e,t){if(jM(e))throw new hD(dD.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function VM(e,t){if(!(e instanceof ArrayBuffer))throw new hD(dD.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function FM(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=Object.keys(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function BM(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;return"string"==typeof e&&e.length<=r&&e.length>=t}function jM(e){return null==e}function GM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new hD(dD.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function HM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new hD(dD.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function zM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new hD(dD.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function KM(e){UM(e,"userInfo"),HM(e.userId),jM(e.extraInfo)||NM(e.extraInfo,"userInfo.extraInfo",1,200)}function XM(e){UM(e,"roomConfig"),PM(e.isAutoPublish,"roomConfig.isAutoPublish"),PM(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),PM(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo")}function WM(e){UM(e,"videoPlayerOption")}function qM(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new hD(dD.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:rM.str2ab(JSON.stringify(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new hD(dD.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function YM(e){return![oe.onRemoteStreamStats,oe.onLocalStreamStats,oe.onAudioVolumeIndication,oe.onLocalAudioPropertiesReport,oe.onRemoteAudioPropertiesReport].includes(e)}function JM(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new hD(dD.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}var QM={},ZM=sr;QM.f=ZM;var $M=ce,eL=Kt,tL=QM,rL=Nr.f,nL=ve,iL=et,oL=sr,aL=$n,sL=ro,cL=ce,uL=ve,dL=Re,lL=le,hL=ht,fL=de,pL=Kt,vL=tt,_L=Fr,mL=He,yL=yr,gL=As,SL=be,EL=cs,bL=Ga,kL=ei,TL=Cl,IL=Ci,AL=ue,RL=Nr,CL=Fa,wL=_e,OL=$n,xL=Pt.exports,PL=bn,DL=Jt,NL=sr,ML=QM,LL=function(e){var t=$M.Symbol||($M.Symbol={});eL(t,e)||rL(t,e,{value:tL.f(e)})},UL=function(){var e=iL("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=oL("toPrimitive");t&&!t[n]&&aL(t,n,(function(e){return nL(r,this)}),{arity:1})},VL=Pd,FL=Ln,BL=Ra.forEach,jL=En("hidden"),GL="Symbol",HL=FL.set,zL=FL.getterFor(GL),KL=Object.prototype,XL=cL.Symbol,WL=XL&&XL.prototype,qL=cL.TypeError,YL=cL.QObject,JL=AL.f,QL=RL.f,ZL=TL.f,$L=wL.f,eU=dL([].push),tU=xL("symbols"),rU=xL("op-symbols"),nU=xL("wks"),iU=!YL||!YL.prototype||!YL.prototype.findChild,oU=lL&&fL((function(){return 7!=EL(QL({},"a",{get:function(){return QL(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=JL(KL,t);n&&delete KL[t],QL(e,t,r),n&&e!==KL&&QL(KL,t,n)}:QL,aU=function(e,t){var r=tU[e]=EL(WL);return HL(r,{type:GL,tag:e,description:t}),lL||(r.description=t),r},sU=function(e,t,r){e===KL&&sU(rU,t,r),_L(e);var n=yL(t);return _L(r),pL(tU,n)?(r.enumerable?(pL(e,jL)&&e[jL][n]&&(e[jL][n]=!1),r=EL(r,{enumerable:SL(0,!1)})):(pL(e,jL)||QL(e,jL,SL(1,{})),e[jL][n]=!0),oU(e,n,r)):QL(e,n,r)},cU=function(e,t){_L(e);var r=mL(t),n=bL(r).concat(hU(r));return BL(n,(function(t){lL&&!uL(uU,r,t)||sU(e,t,r[t])})),e},uU=function(e){var t=yL(e),r=uL($L,this,t);return!(this===KL&&pL(tU,t)&&!pL(rU,t))&&(!(r||!pL(this,t)||!pL(tU,t)||pL(this,jL)&&this[jL][t])||r)},dU=function(e,t){var r=mL(e),n=yL(t);if(r!==KL||!pL(tU,n)||pL(rU,n)){var i=JL(r,n);return!i||!pL(tU,n)||pL(r,jL)&&r[jL][n]||(i.enumerable=!0),i}},lU=function(e){var t=ZL(mL(e)),r=[];return BL(t,(function(e){pL(tU,e)||pL(PL,e)||eU(r,e)})),r},hU=function(e){var t=e===KL,r=ZL(t?rU:mL(e)),n=[];return BL(r,(function(e){!pL(tU,e)||t&&!pL(KL,e)||eU(n,tU[e])})),n};hL||(XL=function(){if(vL(WL,this))throw qL("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?gL(arguments[0]):void 0,t=DL(e),r=function(e){this===KL&&uL(r,rU,e),pL(this,jL)&&pL(this[jL],t)&&(this[jL][t]=!1),oU(this,t,SL(1,e))};return lL&&iU&&oU(KL,t,{configurable:!0,set:r}),aU(t,e)},OL(WL=XL.prototype,"toString",(function(){return zL(this).tag})),OL(XL,"withoutSetter",(function(e){return aU(DL(e),e)})),wL.f=uU,RL.f=sU,CL.f=cU,AL.f=dU,kL.f=TL.f=lU,IL.f=hU,ML.f=function(e){return aU(NL(e),e)},lL&&(QL(WL,"description",{configurable:!0,get:function(){return zL(this).description}}),OL(KL,"propertyIsEnumerable",uU,{unsafe:!0}))),sL({global:!0,constructor:!0,wrap:!0,forced:!hL,sham:!hL},{Symbol:XL}),BL(bL(nU),(function(e){LL(e)})),sL({target:GL,stat:!0,forced:!hL},{useSetter:function(){iU=!0},useSimple:function(){iU=!1}}),sL({target:"Object",stat:!0,forced:!hL,sham:!lL},{create:function(e,t){return void 0===t?EL(e):cU(EL(e),t)},defineProperty:sU,defineProperties:cU,getOwnPropertyDescriptor:dU}),sL({target:"Object",stat:!0,forced:!hL},{getOwnPropertyNames:lU}),UL(),VL(XL,GL),PL[jL]=!0;var fU=ht&&!!Symbol.for&&!!Symbol.keyFor,pU=ro,vU=et,_U=Kt,mU=As,yU=Pt.exports,gU=fU,SU=yU("string-to-symbol-registry"),EU=yU("symbol-to-string-registry");pU({target:"Symbol",stat:!0,forced:!gU},{for:function(e){var t=mU(e);if(_U(SU,t))return SU[t];var r=vU("Symbol")(t);return SU[t]=r,EU[r]=t,r}});var bU=ro,kU=Kt,TU=yt,IU=St,AU=fU,RU=(0,Pt.exports)("symbol-to-string-registry");bU({target:"Symbol",stat:!0,forced:!AU},{keyFor:function(e){if(!TU(e))throw TypeError(IU(e)+" is not a symbol");if(kU(RU,e))return RU[e]}});var CU=Ci,wU=Gt;ro({target:"Object",stat:!0,forced:!ht||de((function(){CU.f(1)}))},{getOwnPropertySymbols:function(e){var t=CU.f;return t?t(wU(e)):[]}});var OU={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,f=d.length;for(u=0;u<f;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(OU);var xU=OU.exports,PU="@byted/ve-rtc",DU="@byted/ve-rtc-cache-size",NU=function(){function e(){u(this,e),h(this,"storeKey",void 0),h(this,"logLevel",void 0),h(this,"LogfileSize",void 0),h(this,"db",void 0),h(this,"logId",void 0),h(this,"cacheLog",void 0),h(this,"cachedSize",void 0),h(this,"preCacheTime",void 0),h(this,"timer",void 0),h(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return l(e,[{key:"_createStore",value:function(){var e=this;if(!tM()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(PU);try{localStorage.removeItem(DU)}catch(EZ){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(DU);t?this.cachedSize=+t:this.values().then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(EZ){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(DU,"".concat(this.cachedSize))}catch(EZ){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(PU,e).objectStore(PU)}},{key:"set",value:function(e){var t=this;return new Promise((function(r,n){if("none"===t.logLevel)return r();if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+="\n\n".concat(t.logId,": ").concat(e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var i=t._getStore("readwrite");if(!i)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var o=i.get(t.storeKey);o.onsuccess=function(){try{var a="".concat(o.result||"").concat(t.cacheLog),s=e?"".concat(a?"\n\n":"").concat(t.logId,": ").concat(e):"";i.put("".concat(a).concat(s),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize(["".concat(t.cacheLog).concat(s)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(c){if(!e)return n(c);t.cacheLog+="\n\n".concat(t.logId,": ").concat(e),t.logId++,n(c)}},o.onerror=function(r){if(!e)return n(r);t.cacheLog+="\n\n".concat(t.logId,": ").concat(e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Promise((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new Promise((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return this.keys().then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new Promise((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new Promise((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,"+(t||""),r.click()}))}}]),e}(),MU=new NU,LU="[VERTC]",UU=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],VU=!tM()&&window.location.search.includes("_rtc_debug_"),FU=function(){function e(t,r,n){u(this,e),h(this,"_indent",void 0),h(this,"_module",void 0),h(this,"_id",void 0),this._module=t,this._indent=r}return l(e,[{key:"print",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var o=n.shift();try{var a=[].concat(n),s="".concat(o).replace(/\%o/gi,(function(){var e=a.shift();return JSON.stringify(e)}));MU.set("".concat(LU,"[").concat(this._module,".").concat(e,"] ").concat(s," ").concat(a.map((function(e){return JSON.stringify(e)})).join(", ")))}catch(EZ){}if(VU){for(var c="",u=0;u<this._indent;u++)c+=" ";(t=console).log.apply(t,["%c".concat(BU(),"-").concat(LU).concat(c,"[").concat(this._module,".").concat(e,"] ").concat(o),"color:".concat(UU[this._indent],";")].concat(n))}}}]),e}(),BU=function(){var e=new Date;return e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()},jU=new FU("VERTC",0),GU=function(e){f(r,e);var t=g(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(n=E(p(r.prototype),"emit",this)).call.apply(n,[this,e].concat(o))}catch(EZ){return jU.print("safaEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,EZ),console.error(EZ),Boolean(t)}}}]),r}(OU.exports.EventEmitter),HU=Kt,zU=function(e){return void 0!==e&&(HU(e,"value")||HU(e,"writable"))},KU=ve,XU=Je,WU=Fr,qU=zU,YU=ue,JU=Sd;ro({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return WU(t)===o?t[r]:(n=YU.f(t,r))?qU(n)?n.value:void 0===n.get?void 0:KU(n.get,o):XU(i=JU(t))?e(i,r,o):void 0}});var QU=ce,ZU=Pd;ro({global:!0},{Reflect:{}}),ZU(QU.Reflect,"Reflect",!0);var $U=ve,eV=Fr,tV=Je,rV=zU,nV=Nr,iV=ue,oV=Sd,aV=be;ro({target:"Reflect",stat:!0,forced:de((function(){var e=function(){},t=nV.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=iV.f(eV(t),r);if(!c){if(tV(o=oV(t)))return e(o,r,n,s);c=aV(0)}if(rV(c)){if(!1===c.writable||!tV(s))return!1;if(i=iV.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,nV.f(s,r,i)}else nV.f(s,r,aV(0,n))}else{if(void 0===(a=c.set))return!1;$U(a,s,n)}return!0}});var sV=ro,cV=Gt,uV=fi,dV=Nv,lV=C_,hV=ao,fV=1!==[].unshift(0),pV=!function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(EZ){return EZ instanceof TypeError}}();sV({target:"Array",proto:!0,arity:1,forced:fV||pV},{unshift:function(e){var t=cV(this),r=uV(t),n=arguments.length;if(n){hV(r+n);for(var i=r;i--;){var o=i+n;i in t?t[o]=t[i]:lV(t,o)}for(var a=0;a<n;a++)t[a]=arguments[a]}return dV(t,r+n)}});var vV={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==a(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return[].concat.apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(vV);var _V={},mV={},yV={},gV=vV;function SV(e){for(var t=e.length;--t>=0;)e[t]=0}var EV=256,bV=286,kV=30,TV=15,IV=[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],AV=[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],RV=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],CV=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],wV=new Array(576);SV(wV);var OV=new Array(60);SV(OV);var xV=new Array(512);SV(xV);var PV=new Array(256);SV(PV);var DV=new Array(29);SV(DV);var NV,MV,LV,UV=new Array(kV);function VV(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function FV(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function BV(e){return e<256?xV[e]:xV[256+(e>>>7)]}function jV(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function GV(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,jV(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function HV(e,t,r){GV(e,r[2*t],r[2*t+1])}function zV(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function KV(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=TV;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=zV(o[s]++,s))}}function XV(e){var t;for(t=0;t<bV;t++)e.dyn_ltree[2*t]=0;for(t=0;t<kV;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.last_lit=e.matches=0}function WV(e){e.bi_valid>8?jV(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function qV(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function YV(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&qV(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!qV(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function JV(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?HV(e,i,t):(HV(e,(o=PV[i])+EV+1,t),0!==(a=IV[o])&&GV(e,i-=DV[o],a),HV(e,o=BV(--n),r),0!==(a=AV[o])&&GV(e,n-=UV[o],a))}while(s<e.last_lit);HV(e,256,t)}function QV(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)YV(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],YV(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,YV(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,p=t.stat_desc.max_length,v=0;for(o=0;o<=TV;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>p&&(o=p,v++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=f&&(a=h[n-f]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==v){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,v-=2}while(v>0);for(o=p;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),KV(o,u,e.bl_count)}function ZV(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function $V(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{HV(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(HV(e,i,e.bl_tree),s--),HV(e,16,e.bl_tree),GV(e,s-3,2)):s<=10?(HV(e,17,e.bl_tree),GV(e,s-3,3)):(HV(e,18,e.bl_tree),GV(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}SV(UV);var eF=!1;function tF(e,t,r,n){GV(e,0+(n?1:0),3),function(e,t,r,n){WV(e),n&&(jV(e,r),jV(e,~r)),gV.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}yV._tr_init=function(e){eF||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(DV[n]=r,e=0;e<1<<IV[n];e++)PV[r++]=n;for(PV[r-1]=n,i=0,n=0;n<16;n++)for(UV[n]=i,e=0;e<1<<AV[n];e++)xV[i++]=n;for(i>>=7;n<kV;n++)for(UV[n]=i<<7,e=0;e<1<<AV[n]-7;e++)xV[256+i++]=n;for(t=0;t<=TV;t++)o[t]=0;for(e=0;e<=143;)wV[2*e+1]=8,e++,o[8]++;for(;e<=255;)wV[2*e+1]=9,e++,o[9]++;for(;e<=279;)wV[2*e+1]=7,e++,o[7]++;for(;e<=287;)wV[2*e+1]=8,e++,o[8]++;for(KV(wV,287,o),e=0;e<kV;e++)OV[2*e+1]=5,OV[2*e]=zV(e,5);NV=new VV(wV,IV,257,bV,TV),MV=new VV(OV,AV,0,kV,TV),LV=new VV(new Array(0),RV,0,19,7)}(),eF=!0),e.l_desc=new FV(e.dyn_ltree,NV),e.d_desc=new FV(e.dyn_dtree,MV),e.bl_desc=new FV(e.bl_tree,LV),e.bi_buf=0,e.bi_valid=0,XV(e)},yV._tr_stored_block=tF,yV._tr_flush_block=function(e,t,r,n){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&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<EV;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),QV(e,e.l_desc),QV(e,e.d_desc),a=function(e){var t;for(ZV(e,e.dyn_ltree,e.l_desc.max_code),ZV(e,e.dyn_dtree,e.d_desc.max_code),QV(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*CV[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?tF(e,t,r,n):4===e.strategy||o===i?(GV(e,2+(n?1:0),3),JV(e,wV,OV)):(GV(e,4+(n?1:0),3),function(e,t,r,n){var i;for(GV(e,t-257,5),GV(e,r-1,5),GV(e,n-4,4),i=0;i<n;i++)GV(e,e.bl_tree[2*CV[i]+1],3);$V(e,e.dyn_ltree,t-1),$V(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),JV(e,e.dyn_ltree,e.dyn_dtree)),XV(e),n&&WV(e)},yV._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(PV[r]+EV+1)]++,e.dyn_dtree[2*BV(t)]++),e.last_lit===e.lit_bufsize-1},yV._tr_align=function(e){GV(e,2,3),HV(e,256,wV),function(e){16===e.bi_valid?(jV(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 rF=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var nF=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var iF,oF=function(e,t,r,n){var i=nF,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},aF={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"},sF=vV,cF=yV,uF=rF,dF=oF,lF=aF,hF=-2,fF=258,pF=262,vF=103,_F=113,mF=666;function yF(e,t){return e.msg=lF[t],t}function gF(e){return(e<<1)-(e>4?9:0)}function SF(e){for(var t=e.length;--t>=0;)e[t]=0}function EF(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(sF.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function bF(e,t){cF._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,EF(e.strm)}function kF(e,t){e.pending_buf[e.pending++]=t}function TF(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function IF(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-pF?e.strstart-(e.w_size-pF):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+fF,f=u[o+a-1],p=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===f&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=fF-(h-o),o=h-fF,n>a){if(e.match_start=t,a=n,n>=s)break;f=u[o+a-1],p=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function AF(e){var t,r,n,i,o,a,s,c,u,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-pF)){sF.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,d=void 0,(d=a.avail_in)>u&&(d=u),r=0===d?0:(a.avail_in-=d,sF.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=uF(a.adler,s,d,c):2===a.state.wrap&&(a.adler=dF(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<pF&&0!==e.strm.avail_in)}function RF(e,t){for(var r,n;;){if(e.lookahead<pF){if(AF(e),e.lookahead<pF&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-pF&&(e.match_length=IF(e,r)),e.match_length>=3)if(n=cF._tr_tally(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=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=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=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=cF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(bF(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(bF(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(bF(e,!1),0===e.strm.avail_out)?1:2}function CF(e,t){for(var r,n,i;;){if(e.lookahead<pF){if(AF(e),e.lookahead<pF&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=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!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-pF&&(e.match_length=IF(e,r),e.match_length<=5&&(1===e.strategy||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,n=cF._tr_tally(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=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=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++,n&&(bF(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=cF._tr_tally(e,0,e.window[e.strstart-1]))&&bF(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&&(n=cF._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(bF(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(bF(e,!1),0===e.strm.avail_out)?1:2}function wF(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function OF(){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=8,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 sF.Buf16(1146),this.dyn_dtree=new sF.Buf16(122),this.bl_tree=new sF.Buf16(78),SF(this.dyn_ltree),SF(this.dyn_dtree),SF(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new sF.Buf16(16),this.heap=new sF.Buf16(573),SF(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new sF.Buf16(573),SF(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function xF(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:_F,e.adler=2===t.wrap?0:1,t.last_flush=0,cF._tr_init(t),0):yF(e,hF)}function PF(e){var t,r=xF(e);return 0===r&&((t=e.state).window_size=2*t.w_size,SF(t.head),t.max_lazy_match=iF[t.level].max_lazy,t.good_match=iF[t.level].good_length,t.nice_match=iF[t.level].nice_length,t.max_chain_length=iF[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function DF(e,t,r,n,i,o){if(!e)return hF;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return yF(e,hF);8===n&&(n=9);var s=new OF;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,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 sF.Buf8(2*s.w_size),s.head=new sF.Buf16(s.hash_size),s.prev=new sF.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new sF.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,PF(e)}iF=[new wF(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(AF(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,bF(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-pF&&(bF(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(bF(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(bF(e,!1),e.strm.avail_out),1)})),new wF(4,4,8,4,RF),new wF(4,5,16,8,RF),new wF(4,6,32,32,RF),new wF(4,4,16,16,CF),new wF(8,16,32,32,CF),new wF(8,16,128,128,CF),new wF(8,32,128,256,CF),new wF(32,128,258,1024,CF),new wF(32,258,258,4096,CF)],mV.deflateInit=function(e,t){return DF(e,t,8,15,8,0)},mV.deflateInit2=DF,mV.deflateReset=PF,mV.deflateResetKeep=xF,mV.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?hF:(e.state.gzhead=t,0):hF},mV.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?yF(e,hF):hF;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===mF&&4!==t)return yF(e,0===e.avail_out?-5:hF);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,kF(n,31),kF(n,139),kF(n,8),n.gzhead?(kF(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)),kF(n,255&n.gzhead.time),kF(n,n.gzhead.time>>8&255),kF(n,n.gzhead.time>>16&255),kF(n,n.gzhead.time>>24&255),kF(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),kF(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(kF(n,255&n.gzhead.extra.length),kF(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=dF(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(kF(n,0),kF(n,0),kF(n,0),kF(n,0),kF(n,0),kF(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),kF(n,3),n.status=_F);else{var a=8+(n.w_bits-8<<4)<<8;a|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=_F,TF(n,a),0!==n.strstart&&(TF(n,e.adler>>>16),TF(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=dF(e.adler,n.pending_buf,n.pending-i,i)),EF(e),i=n.pending,n.pending!==n.pending_buf_size));)kF(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=dF(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=dF(e.adler,n.pending_buf,n.pending-i,i)),EF(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,kF(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=dF(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=dF(e.adler,n.pending_buf,n.pending-i,i)),EF(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,kF(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=dF(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=vF)}else n.status=vF;if(n.status===vF&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&EF(e),n.pending+2<=n.pending_buf_size&&(kF(n,255&e.adler),kF(n,e.adler>>8&255),e.adler=0,n.status=_F)):n.status=_F),0!==n.pending){if(EF(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&gF(t)<=gF(r)&&4!==t)return yF(e,-5);if(n.status===mF&&0!==e.avail_in)return yF(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==mF){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(AF(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=cF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(bF(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(bF(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(bF(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=fF){if(AF(e),e.lookahead<=fF&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+fF;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=fF-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=cF._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=cF._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(bF(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(bF(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(bF(e,!1),0===e.strm.avail_out)?1:2}(n,t):iF[n.level].func(n,t);if(3!==s&&4!==s||(n.status=mF),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?cF._tr_align(n):5!==t&&(cF._tr_stored_block(n,0,0,!1),3===t&&(SF(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),EF(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(kF(n,255&e.adler),kF(n,e.adler>>8&255),kF(n,e.adler>>16&255),kF(n,e.adler>>24&255),kF(n,255&e.total_in),kF(n,e.total_in>>8&255),kF(n,e.total_in>>16&255),kF(n,e.total_in>>24&255)):(TF(n,e.adler>>>16),TF(n,65535&e.adler)),EF(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},mV.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==vF&&t!==_F&&t!==mF?yF(e,hF):(e.state=null,t===_F?yF(e,-3):0):hF},mV.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return hF;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return hF;for(1===o&&(e.adler=uF(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(SF(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new sF.Buf8(r.w_size),sF.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=d,e.next_in=0,e.input=t,AF(r);r.lookahead>=3;){n=r.strstart,i=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=2,AF(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=s,e.input=c,e.avail_in=a,r.wrap=o,0},mV.deflateInfo="pako deflate (from Nodeca project)";var NF={},MF=vV,LF=!0,UF=!0;try{String.fromCharCode.apply(null,[0])}catch(bZ){LF=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(bZ){UF=!1}for(var VF=new MF.Buf8(256),FF=0;FF<256;FF++)VF[FF]=FF>=252?6:FF>=248?5:FF>=240?4:FF>=224?3:FF>=192?2:1;function BF(e,t){if(t<65534&&(e.subarray&&UF||!e.subarray&&LF))return String.fromCharCode.apply(null,MF.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}VF[254]=VF[254]=1,NF.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new MF.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},NF.buf2binstring=function(e){return BF(e,e.length)},NF.binstring2buf=function(e){for(var t=new MF.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},NF.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=VF[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return BF(s,n)},NF.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+VF[e[r]]>t?r:t};var jF=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},GF=mV,HF=vV,zF=NF,KF=aF,XF=jF,WF=Object.prototype.toString;function qF(e){if(!(this instanceof qF))return new qF(e);this.options=HF.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new XF,this.strm.avail_out=0;var r=GF.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(KF[r]);if(t.header&&GF.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?zF.string2buf(t.dictionary):"[object ArrayBuffer]"===WF.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=GF.deflateSetDictionary(this.strm,n)))throw new Error(KF[r]);this._dict_set=!0}}function YF(e,t){var r=new qF(t);if(r.push(e,!0),r.err)throw r.msg||KF[r.err];return r.result}qF.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=zF.string2buf(e):"[object ArrayBuffer]"===WF.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new HF.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=GF.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(zF.buf2binstring(HF.shrinkBuf(i.output,i.next_out))):this.onData(HF.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=GF.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},qF.prototype.onData=function(e){this.chunks.push(e)},qF.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=HF.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},_V.Deflate=qF,_V.deflate=YF,_V.deflateRaw=function(e,t){return(t=t||{}).raw=!0,YF(e,t)},_V.gzip=function(e,t){return(t=t||{}).gzip=!0,YF(e,t)};var JF={},QF=le,ZF=tS,$F=Vs,eB=de,tB=ce.RegExp,rB=tB.prototype;QF&&eB((function(){var e=!0;try{tB(".","d")}catch(EZ){e=!1}var t={},r="",n=e?"dgimsy":"gimsy",i=function(e,n){Object.defineProperty(t,e,{get:function(){return r+=n,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(o.hasIndices="d"),o)i(a,o[a]);return Object.getOwnPropertyDescriptor(rB,"flags").get.call(t)!==n||r!==n}))&&ZF(rB,"flags",{configurable:!0,get:$F});var nB={},iB=vV,oB=15,aB=[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],sB=[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],cB=[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],uB=[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],dB=vV,lB=rF,hB=oF,fB=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,A=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,f=r.hold,p=r.bits,v=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,y=(1<<r.distbits)-1;e:do{p<15&&(f+=I[n++]<<p,p+=8,f+=I[n++]<<p,p+=8),g=v[f&m];t:for(;;){if(f>>>=S=g>>>24,p-=S,0===(S=g>>>16&255))A[o++]=65535&g;else{if(!(16&S)){if(0==(64&S)){g=v[(65535&g)+(f&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}E=65535&g,(S&=15)&&(p<S&&(f+=I[n++]<<p,p+=8),E+=f&(1<<S)-1,f>>>=S,p-=S),p<15&&(f+=I[n++]<<p,p+=8,f+=I[n++]<<p,p+=8),g=_[f&y];r:for(;;){if(f>>>=S=g>>>24,p-=S,!(16&(S=g>>>16&255))){if(0==(64&S)){g=_[(65535&g)+(f&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(b=65535&g,p<(S&=15)&&(f+=I[n++]<<p,(p+=8)<S&&(f+=I[n++]<<p,p+=8)),(b+=f&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(f>>>=S,p-=S,b>(S=o-a)){if((S=b-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=u-S,S<E){E-=S;do{A[o++]=h[k++]}while(--S);k=o-b,T=A}}else if(l<S){if(k+=u+l-S,(S-=l)<E){E-=S;do{A[o++]=h[k++]}while(--S);if(k=0,l<E){E-=S=l;do{A[o++]=h[k++]}while(--S);k=o-b,T=A}}}else if(k+=l-S,S<E){E-=S;do{A[o++]=h[k++]}while(--S);k=o-b,T=A}for(;E>2;)A[o++]=T[k++],A[o++]=T[k++],A[o++]=T[k++],E-=3;E&&(A[o++]=T[k++],E>1&&(A[o++]=T[k++]))}else{k=o-b;do{A[o++]=A[k++],A[o++]=A[k++],A[o++]=A[k++],E-=3}while(E>2);E&&(A[o++]=A[k++],E>1&&(A[o++]=A[k++]))}break}}break}}while(n<i&&o<s);n-=E=p>>3,f&=(1<<(p-=E<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=f,r.bits=p},pB=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,f,p,v,_,m=s.bits,y=0,g=0,S=0,E=0,b=0,k=0,T=0,I=0,A=0,R=0,C=null,w=0,O=new iB.Buf16(16),x=new iB.Buf16(16),P=null,D=0;for(y=0;y<=oB;y++)O[y]=0;for(g=0;g<n;g++)O[t[r+g]]++;for(b=m,E=oB;E>=1&&0===O[E];E--);if(b>E&&(b=E),0===E)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<E&&0===O[S];S++);for(b<S&&(b=S),I=1,y=1;y<=oB;y++)if(I<<=1,(I-=O[y])<0)return-1;if(I>0&&(0===e||1!==E))return-1;for(x[1]=0,y=1;y<oB;y++)x[y+1]=x[y]+O[y];for(g=0;g<n;g++)0!==t[r+g]&&(a[x[t[r+g]]++]=g);if(0===e?(C=P=a,f=19):1===e?(C=aB,w-=257,P=sB,D-=257,f=256):(C=cB,P=uB,f=-1),R=0,g=0,y=S,h=o,k=b,T=0,d=-1,l=(A=1<<b)-1,1===e&&A>852||2===e&&A>592)return 1;for(;;){p=y-T,a[g]<f?(v=0,_=a[g]):a[g]>f?(v=P[D+a[g]],_=C[w+a[g]]):(v=96,_=0),c=1<<y-T,S=u=1<<k;do{i[h+(R>>T)+(u-=c)]=p<<24|v<<16|_|0}while(0!==u);for(c=1<<y-1;R&c;)c>>=1;if(0!==c?(R&=c-1,R+=c):R=0,g++,0==--O[y]){if(y===E)break;y=t[r+a[g]]}if(y>b&&(R&l)!==d){for(0===T&&(T=b),h+=S,I=1<<(k=y-T);k+T<E&&!((I-=O[k+T])<=0);)k++,I<<=1;if(A+=1<<k,1===e&&A>852||2===e&&A>592)return 1;i[d=R&l]=b<<24|k<<16|h-o|0}}return 0!==R&&(i[h+R]=y-T<<24|64<<16|0),s.bits=b,0},vB=-2,_B=12,mB=30;function yB(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function gB(){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 dB.Buf16(320),this.work=new dB.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function SB(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new dB.Buf32(852),t.distcode=t.distdyn=new dB.Buf32(592),t.sane=1,t.back=-1,0):vB}function EB(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,SB(e)):vB}function bB(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?vB:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,EB(e))):vB}function kB(e,t){var r,n;return e?(n=new gB,e.state=n,n.window=null,0!==(r=bB(e,t))&&(e.state=null),r):vB}var TB,IB,AB=!0;function RB(e){if(AB){var t;for(TB=new dB.Buf32(512),IB=new dB.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(pB(1,e.lens,0,288,TB,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;pB(2,e.lens,0,32,IB,0,e.work,{bits:5}),AB=!1}e.lencode=TB,e.lenbits=9,e.distcode=IB,e.distbits=5}function CB(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new dB.Buf8(o.wsize)),n>=o.wsize?(dB.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),dB.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(dB.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}nB.inflateReset=EB,nB.inflateReset2=bB,nB.inflateResetKeep=SB,nB.inflateInit=function(e){return kB(e,15)},nB.inflateInit2=kB,nB.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A=0,R=new dB.Buf8(4),C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return vB;(r=e.state).mode===_B&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,k=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===u){r.check=0,R[0]=255&u,R[1]=u>>>8&255,r.check=hB(r.check,R,2,0),u=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=mB;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=mB;break}if(d-=4,b=8+(15&(u>>>=4)),0===r.wbits)r.wbits=b;else if(b>r.wbits){e.msg="invalid window size",r.mode=mB;break}r.dmax=1<<b,e.adler=r.check=1,r.mode=512&u?10:_B,u=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.flags=u,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=mB;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=mB;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(R[0]=255&u,R[1]=u>>>8&255,r.check=hB(r.check,R,2,0)),u=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.time=u),512&r.flags&&(R[0]=255&u,R[1]=u>>>8&255,R[2]=u>>>16&255,R[3]=u>>>24&255,r.check=hB(r.check,R,4,0)),u=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(R[0]=255&u,R[1]=u>>>8&255,r.check=hB(r.check,R,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&r.flags){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(R[0]=255&u,R[1]=u>>>8&255,r.check=hB(r.check,R,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((f=r.length)>s&&(f=s),f&&(r.head&&(b=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),dB.arraySet(r.head.extra,n,o,f,b)),512&r.flags&&(r.check=hB(r.check,n,f,o)),s-=f,o+=f,r.length-=f),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;f=0;do{b=n[o+f++],r.head&&b&&r.length<65536&&(r.head.name+=String.fromCharCode(b))}while(b&&f<s);if(512&r.flags&&(r.check=hB(r.check,n,f,o)),s-=f,o+=f,b)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===s)break e;f=0;do{b=n[o+f++],r.head&&b&&r.length<65536&&(r.head.comment+=String.fromCharCode(b))}while(b&&f<s);if(512&r.flags&&(r.check=hB(r.check,n,f,o)),s-=f,o+=f,b)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=mB;break}u=0,d=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=_B;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=yB(u),u=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=_B;case _B:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(RB(r),r.mode=20,6===t){u>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=mB}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=mB;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(f=r.length){if(f>s&&(f=s),f>c&&(f=c),0===f)break e;dB.arraySet(i,n,o,f,a),s-=f,o+=f,c-=f,a+=f,r.length-=f;break}r.mode=_B;break;case 17:for(;d<14;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=mB;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[C[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[C[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T={bits:r.lenbits},k=pB(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=mB;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(A=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(y<16)u>>>=_,d-=_,r.lens[r.have++]=y;else{if(16===y){for(I=_+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=mB;break}b=r.lens[r.have-1],f=3+(3&u),u>>>=2,d-=2}else if(17===y){for(I=_+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,b=0,f=3+(7&(u>>>=_)),u>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,b=0,f=11+(127&(u>>>=_)),u>>>=7,d-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=mB;break}for(;f--;)r.lens[r.have++]=b}}if(r.mode===mB)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=mB;break}if(r.lenbits=9,T={bits:r.lenbits},k=pB(1,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=mB;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=pB(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=mB;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,fB(e,h),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,r.mode===_B&&(r.back=-1);break}for(r.back=0;m=(A=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(g=_,S=m,E=y;m=(A=r.lencode[E+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&A,!(g+(_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,r.length=y,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=_B;break}if(64&m){e.msg="invalid literal/length code",r.mode=mB;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(A=r.distcode[u&(1<<r.distbits)-1])>>>16&255,y=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(g=_,S=m,E=y;m=(A=r.distcode[E+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&A,!(g+(_=A>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=mB;break}r.offset=y,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=mB;break}r.mode=25;case 25:if(0===c)break e;if(f=h-c,r.offset>f){if((f=r.offset-f)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=mB;break}f>r.wnext?(f-=r.wnext,p=r.wsize-f):p=r.wnext-f,f>r.length&&(f=r.length),v=r.window}else v=i,p=a-r.offset,f=r.length;f>c&&(f=c),c-=f,r.length-=f;do{i[a++]=v[p++]}while(--f);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=r.flags?hB(r.check,i,h,a-h):lB(r.check,i,h,a-h)),h=c,(r.flags?u:yB(u))!==r.check){e.msg="incorrect data check",r.mode=mB;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=mB;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case mB:k=-3;break e;case 31:return-4;default:return vB}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<mB&&(r.mode<27||4!==t))&&CB(e,e.output,e.next_out,h-e.avail_out),l-=e.avail_in,h-=e.avail_out,e.total_in+=l,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=r.flags?hB(r.check,i,h,e.next_out-h):lB(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===_B?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===k&&(k=-5),k},nB.inflateEnd=function(e){if(!e||!e.state)return vB;var t=e.state;return t.window&&(t.window=null),e.state=null,0},nB.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?vB:(r.head=t,t.done=!1,0):vB},nB.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?vB:11===r.mode&&lB(1,t,n,0)!==r.check?-3:CB(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):vB},nB.inflateInfo="pako inflate (from Nodeca project)";var wB={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_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};var OB=nB,xB=vV,PB=NF,DB=wB,NB=aF,MB=jF,LB=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},UB=Object.prototype.toString;function VB(e){if(!(this instanceof VB))return new VB(e);this.options=xB.assign({chunkSize:16384,windowBits:0,to:""},e||{});var 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&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new MB,this.strm.avail_out=0;var r=OB.inflateInit2(this.strm,t.windowBits);if(r!==DB.Z_OK)throw new Error(NB[r]);if(this.header=new LB,OB.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=PB.string2buf(t.dictionary):"[object ArrayBuffer]"===UB.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=OB.inflateSetDictionary(this.strm,t.dictionary))!==DB.Z_OK))throw new Error(NB[r])}function FB(e,t){var r=new VB(t);if(r.push(e,!0),r.err)throw r.msg||NB[r.err];return r.result}VB.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?DB.Z_FINISH:DB.Z_NO_FLUSH,"string"==typeof e?s.input=PB.binstring2buf(e):"[object ArrayBuffer]"===UB.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new xB.Buf8(c),s.next_out=0,s.avail_out=c),(r=OB.inflate(s,DB.Z_NO_FLUSH))===DB.Z_NEED_DICT&&u&&(r=OB.inflateSetDictionary(this.strm,u)),r===DB.Z_BUF_ERROR&&!0===d&&(r=DB.Z_OK,d=!1),r!==DB.Z_STREAM_END&&r!==DB.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==DB.Z_STREAM_END&&(0!==s.avail_in||n!==DB.Z_FINISH&&n!==DB.Z_SYNC_FLUSH)||("string"===this.options.to?(i=PB.utf8border(s.output,s.next_out),o=s.next_out-i,a=PB.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&xB.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(xB.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==DB.Z_STREAM_END);return r===DB.Z_STREAM_END&&(n=DB.Z_FINISH),n===DB.Z_FINISH?(r=OB.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===DB.Z_OK):n!==DB.Z_SYNC_FLUSH||(this.onEnd(DB.Z_OK),s.avail_out=0,!0)},VB.prototype.onData=function(e){this.chunks.push(e)},VB.prototype.onEnd=function(e){e===DB.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=xB.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},JF.Inflate=VB,JF.inflate=FB,JF.inflateRaw=function(e,t){return(t=t||{}).raw=!0,FB(e,t)},JF.ungzip=FB;var BB={};(0,vV.assign)(BB,_V,JF,wB);var jB=BB,GB="BytePlusRTC",HB=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},zB=function(){function e(t){u(this,e),h(this,"storeName",void 0),h(this,"pendingList",[]),this.storeName=t,!tM()&&HB()&&this._checkAndCreateStore(t)}var t,r;return l(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?HB().open(GB,r):HB().open(GB);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=c(o().mark((function e(t){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,a=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:s=e.sent,i(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),a();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(a){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new Promise((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",value:(r=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new Promise((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new Promise((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();h(zB,"db",void 0),h(zB,"state","init");var KB=function(e){return e.RTC="rtc",e}(KB||{}),XB=function(e){return e.W_5="5",e}(XB||{}),WB=function(e){return e.IOS="ios",e.ANDROID="android",e.WEB="web",e.WINDOWS="windows",e.MAC="mac",e.LINUX="linux",e}(WB||{}),qB=function(e){return e.REQUEST="request",e.RESPONSE="response",e}(qB||{}),YB=function(e){return e.WEBSOCKET_RECONNECTING="websocket reconnecting",e.PEERCONNECTION_RECONNECTING="peerconnection reconnecting",e.DISCONNECTED="DISCONNECTED",e.LAN="LAN",e.WIFI="WIFI",e.W_2="2G",e.W_3="3G",e.W_4="4G",e.W_5="5G",e.UNKNOWN="UNKNOWN",e}(YB||{}),JB=function(e){return e.WEBSOCKET="websocket",e.NETWORKCHANGED="networkChanged",e.PEERCONNECTION="peerconnection",e}(JB||{}),QB=function(e){return e.WEBSOCKET_RECONNECTED="websocket reconnected",e.PEERCONNECTION_RECONNECTED="peerconnection reconnected",e}(QB||{}),ZB=function(e){return e.WEBSOCKET="websocket",e.NETWORKCHANGED="networkChanged",e.PEERCONNECTION="peerconnection",e}(ZB||{}),$B=function(e){return e.REQUEST="request",e.RESPONSE="response",e.KCP_REQUEST="kcp request",e.KCP_RESPONSE="kcp response",e.QUIC_REQUEST="quic request",e.QUIC_RESPONSE="quic response",e}($B||{}),ej=function(e){return e.NEW="NEW",e.CHECKING="CHECKING",e.CONNECTED="CONNECTED",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.DISCONNECTED="DISCONNECTED",e.CLOSED="CLOSED",e.DATACHANNEL_CONNECTING="DATACHANNEL_CONNECTING",e.DATACHANNEL_OPEN="DATACHANNEL_OPEN",e.DATACHANNEL_CLOSING="DATACHANNEL_CLOSING",e.DATACHANNEL_CLOSED="DATACHANNEL_CLOSED",e}(ej||{}),tj=function(e){return e.SUCCEED="succeed",e.MESSAGE_ID_ERROR="message id error",e.ZIP_FAILED="zip failed",e.UNZIP_FAILED="unzip failed",e.MESSAGE_KEY_EMPTY="message key empty",e.MESSAGE_KEY_PARSE_FAILED="message key parse failed",e.MESSAGE_KEY_INVALID="message key invalid",e.ENCRYPT_FAILED="encrypt failed",e.DECRYPT_FAILED="decrypt failed",e.MESSAGE_TOO_BIG="message too big",e.INVALID_DATA="invalid data",e.MESSAGE_PARSE_FAILED="message parse failed",e}(tj||{}),rj=function(e){return e.UP="up",e.DOWN="down",e.DIRECT="direct",e}(rj||{}),nj=function(e){return e.UP="up",e.DOWN="down",e.PRE="pre",e}(nj||{}),ij=function(e){return e.UP="up",e.DOWN="down",e.PRE="pre",e}(ij||{}),oj=function(e){return e.W_0="0",e.W_1="1",e}(oj||{}),aj=function(e){return e.UP="up",e.DOWN="down",e}(aj||{}),sj=function(e){return e.ANSWER="answer",e.INCRANSWER="incranswer",e}(sj||{}),cj=function(e){return e.UP="up",e.DOWN="down",e}(cj||{}),uj=function(e){return e.SUCCESS="success",e.FAIL="fail",e}(uj||{}),dj=function(e){return e.W_0="0",e.W_1="1",e}(dj||{}),lj=function(e){return e.LEAVE_ROOM="leave room",e.ACK_FAILED="ack failed",e.SET_ANSWER_SDP_FAILED="set answer sdp failed",e.ICE_FAILED="ice failed",e.STREAM_FAILED="stream failed",e.NETWORK_RECONNECTED="network reconnected",e.JOIN_ROOM_ACK_FAILED="join room ack failed",e.UNKNOWN="unknown",e}(lj||{}),hj=function(e){return e.SUCCESS="success",e.FAIL="fail",e.IGNORE="ignore",e}(hj||{}),fj=function(e){return e.LEAVE_ROOM="leave room",e.ACK_FAILED="ack failed",e.SET_ANSWER_SDP_FAILED="set answer sdp failed",e.ICE_FAILED="ice failed",e.STREAM_FAILED="stream failed",e.NETWORK_RECONNECTED="network reconnected",e.ON_STREAM_REMOVE="on stream remove",e.PUBLISH_MUTE="publish mute",e.UNKNOWN="unknown",e.ON_STREAM_REMOVE_CLIENT_UNPUBLISHED="on stream remove:client unpublished",e.ON_STREAM_REMOVE_PUBLISH_FAILED="on stream remove:publish failed",e.ON_STREAM_REMOVE_STREAM_REMOVED="on stream remove:stream removed",e.ON_STREAM_REMOVE_CLIENT_DISCONNECTED="on stream remove:client disconnected",e.ON_STREAM_REMOVE_CLIENT_REPUBLISH="on stream remove:client republish",e}(fj||{}),pj=function(e){return e.PLAYOUT_DEVICE_SWITCH="playout_device_switch",e.RECORD_DEVICE_SWITCH="record_device_switch",e.UNKNOWN="unknown",e}(pj||{}),vj=function(e){return e.BEGIN_SEND="begin_send",e.SENT_END="sent_end",e.BEGIN_RECV="begin_recv",e.RECV_END="recv_end",e}(vj||{}),_j=function(e){return e.AUDIO="audio",e.VIDEO="video",e.SCREEN_VIDEO="screen_video",e.SCREEN_AUDIO="screen_audio",e}(_j||{}),mj=function(e){return e.LOGIN="login",e.PUBLISHER="publisher",e.UNMUTE="unmute",e.ENABLE="enable",e.PUSH="push",e.PUBLISH="publish",e.ONDEMAND="ondemand",e.SUBSCRIBE="subscribe",e.PUSH_TRACK="push_track",e.REMOTE_UNMUTE="remote_unmute",e.P2P="p2p",e}(mj||{}),yj=function(e){return e.TIMEOUT="timeout",e.AUDIENCE="audience",e.MUTE="mute",e.DISABLE="disable",e.STOP_PUSH="stop_push",e.UNPUBLISH="unpublish",e.NO_DEMAND="no_demand",e.LEAVE_ROOM="leave_room",e.UNSUBSCRIBE="unsubscribe",e.REMOVE_TRACK="remove_track",e.REMOTE_MUTE="remote_mute",e.USER_LEAVE="user_leave",e}(yj||{}),gj=function(e){return e.BEGIN="begin",e.END="end",e}(gj||{}),Sj=function(e){return e.BEGIN="begin",e.END="end",e}(Sj||{}),Ej=function(e){return e.LEAVE_ROOM="leave_room",e.ACK_FAILED="ack_failed",e.TOKEN_ERROR="token_error",e.SIGNALING_ERROR="signaling_error",e.TIMEOUT_10="timeout_10",e.TIMEOUT_60="timeout_60",e}(Ej||{}),bj=function(e){return e.P2P="p2p",e.P2P_OUTSIDE_ROOM="p2p_outside_room",e.P2SERVER="p2server",e}(bj||{}),kj=function(e){return e.START="start",e.START_CAPTURE_RESULT="start_capture_result",e.STARTED="started",e.RUNNING_FAILED="running_failed",e.STOP="stop",e.STOPPED="stopped",e}(kj||{}),Tj=function(e){return e.SUCCESS="success",e.CAMERA_DEVICE_NO_PERMISSION="camera_device_no_permission",e.CAMERA_DEVICE_BUSY="camera_device_busy",e.CAMERA_DEVICE_FAILURE="camera_device_failure",e.CAMERA_DEVICE_NOT_FOUND="camera_device_not_found",e.CAMERA_DEVICE_DISCONNECTED="camera_device_disconnected",e.TIMEOUT="timeout",e.ABORT="abort",e}(Tj||{}),Ij=function(){function e(t){u(this,e),h(this,"_event_key",void 0),h(this,"_device_id",void 0),h(this,"_rtc_app_id",void 0),h(this,"_product_line",void 0),h(this,"_report_version",void 0),h(this,"_os",void 0),h(this,"_rtc_sdk_version",void 0),h(this,"_rtc_timestamp",void 0),h(this,"_rtc_sdk_git_commit",void 0),h(this,"_report_id",void 0),h(this,"_connection_id",void 0),h(this,"_rtc_sid",void 0),h(this,"_engine_session_id",void 0),h(this,"_rtc_business_id",void 0),h(this,"_app_state",void 0),h(this,"_project_key",void 0),h(this,"_network_type",void 0),h(this,"_app_version",void 0),h(this,"_aid",void 0),h(this,"_device_model",void 0),h(this,"_device_brand",void 0),h(this,"_common_extra_info",void 0),h(this,"_had_selected_p2p",void 0),h(this,"_rtc_env_type",void 0),h(this,"_room_id",void 0),h(this,"_user_id",void 0),h(this,"_rtc_session_id",void 0),h(this,"_user_agent",void 0),h(this,"_auto_play_policy",void 0),h(this,"_platform",void 0),h(this,"_product",void 0),h(this,"_log_cache_key",void 0),h(this,"_overSea","0"),this.monitor=t}return l(e,[{key:"setStats",value:function(e){var t=this;Object.keys(e).forEach((function(r){t["_"+r]=e[r]})),this.monitor.StartUp()}},{key:"event_key",get:function(){return this._event_key}},{key:"device_id",get:function(){return this._device_id}},{key:"rtc_app_id",get:function(){return this._rtc_app_id}},{key:"product_line",get:function(){return this._product_line}},{key:"report_version",get:function(){return this._report_version}},{key:"os",get:function(){return this._os}},{key:"rtc_sdk_version",get:function(){return this._rtc_sdk_version}},{key:"rtc_timestamp",get:function(){return this._rtc_timestamp}},{key:"rtc_sdk_git_commit",get:function(){return this._rtc_sdk_git_commit}},{key:"report_id",get:function(){return this._report_id}},{key:"connection_id",get:function(){return this._connection_id}},{key:"rtc_sid",get:function(){return this._rtc_sid}},{key:"engine_session_id",get:function(){return this._engine_session_id}},{key:"rtc_business_id",get:function(){return this._rtc_business_id}},{key:"app_state",get:function(){return this._app_state}},{key:"project_key",get:function(){return this._project_key}},{key:"network_type",get:function(){return this._network_type}},{key:"app_version",get:function(){return this._app_version}},{key:"aid",get:function(){return this._aid}},{key:"device_model",get:function(){return this._device_model}},{key:"device_brand",get:function(){return this._device_brand}},{key:"common_extra_info",get:function(){return this._common_extra_info}},{key:"had_selected_p2p",get:function(){return this._had_selected_p2p}},{key:"rtc_env_type",get:function(){return this._rtc_env_type}},{key:"room_id",get:function(){return this._room_id}},{key:"user_id",get:function(){return this._user_id}},{key:"rtc_session_id",get:function(){return this._rtc_session_id}},{key:"user_agent",get:function(){return this._user_agent}},{key:"auto_play_policy",get:function(){return this._auto_play_policy}},{key:"platform",get:function(){return this._platform||"web"}},{key:"product",get:function(){return this._product||"webrtc"}},{key:"log_cache_key",get:function(){return this._log_cache_key}},{key:"overSea",get:function(){return this._overSea}}]),e}(),Aj="ReportErrorBuffer",Rj=function(){function e(){u(this,e),h(this,"_buffer",new zB(Aj))}var t,r;return l(e,[{key:"set",value:(r=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,Aj);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(Aj);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),Cj=function(e){f(n,e);var t,r=g(n);function n(){var e;return u(this,n),h(m(e=r.call(this)),"report_id",void 0),h(m(e),"report_common",void 0),h(m(e),"modify_ids",void 0),h(m(e),"dataBuffer",void 0),h(m(e),"posting",void 0),h(m(e),"sucSendTimer",void 0),h(m(e),"preSucTime",void 0),h(m(e),"errSendTimer",void 0),h(m(e),"errSendDelay",void 0),h(m(e),"errSendBuffer",void 0),h(m(e),"commonStats",void 0),h(m(e),"_retryCount",0),e.report_id=0,e.dataBuffer=[],e.posting=!1,e.report_common={},e.modify_ids={},e.preSucTime=0,e.errSendDelay=100,e.commonStats=new Ij(m(e)),tM()||window.addEventListener("beforeunload",(function(){clearTimeout(e.errSendTimer),clearTimeout(e.sucSendTimer),e.send(null,!0)})),e}return l(n,[{key:"push",value:function(e,t){t?this.send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send()))}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new Rj,this.loadErrorBuffer()}},{key:"unshift",value:function(e){this.dataBuffer=e.concat(this.dataBuffer)}},{key:"send",value:function(e,t){var r=this;if(e||this.dataBuffer.length){var n={data:e||this.dataBuffer.splice(0,4e3),header:i(i({},this.report_common),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},o=new XMLHttpRequest;o.timeout=1e4,o.onreadystatechange=function(){if(4===o.readyState){var i,a,s,c;if(e||(r.posting=!1),200===o.status||304===o.status)try{i=JSON.parse(o.responseText)}catch(EZ){a=EZ}if(i&&0===i.StatusCode){if(!e&&!t)!tM()&&location.search.includes("_rtc_autotest_")&&r.safeEmit("report_event",n),null===(s=r.errSendBuffer)||void 0===s||s.set([]),r.sucSend()}else if(setTimeout((function(){var e;r.rtcError("reportor error, res:".concat(null===(e=i)||void 0===e?void 0:e.toString()," err:").concat(a),o.status,a)}),0),e)r.send(e);else r.unshift(n.data),null===(c=r.errSendBuffer)||void 0===c||c.set(k(r.dataBuffer)),t?r.send():r.errSend()}};var a=tG.LOG_SERVER_URL;if(o.open("POST",a,!0),e||(this.posting=!0),!tM()&&location.search.includes("_rtc_debug_"))o.send(JSON.stringify(n));else{var s=jB.gzip(JSON.stringify(n));o.setRequestHeader("Content-Encoding","gzip"),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),o.send(s)}}}},{key:"sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=setTimeout(this.send.bind(this),2e3)}},{key:"errSend",value:function(){var e=this;this.errSendTimer=setTimeout((function(){e.send(),e.errSendTimer=null}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=c(o().mark((function e(){var t,r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"StartUp",value:function(){var e=this.report_common,t=this.commonStats,r=t.event_key,n=t.device_id,i=t.rtc_app_id,o=t.product_line,a=t.report_version,s=t.os,c=t.rtc_sdk_version,u=t.rtc_timestamp,d=t.rtc_sdk_git_commit,l=t.report_id,h=t.rtc_sid,f=t.engine_session_id,p=t.rtc_business_id,v=t.project_key,_=t.network_type,m=t.app_version,y=t.aid,g=t.device_model,S=t.device_brand,E=t.common_extra_info,b=t.had_selected_p2p,k=t.rtc_env_type,T=t.user_agent,I=t.auto_play_policy,A=t.platform,R=t.product,C=t.log_cache_key,w=t.overSea;Object.assign(e,{event_key:r,device_id:n,rtc_app_id:i,product_line:o,report_version:a,os:s,rtc_sdk_version:c,rtc_timestamp:u,rtc_sdk_git_commit:d,report_id:l,rtc_sid:h,engine_session_id:f,rtc_business_id:p,project_key:v,network_type:_,app_version:m,aid:y,device_model:g,device_brand:S,common_extra_info:E,had_selected_p2p:b,rtc_env_type:k,user_agent:T,auto_play_policy:I,platform:A,product:R,log_cache_key:C,extra_is_oversea:w}),this.modify_ids.room_id=this.commonStats.room_id,this.modify_ids.user_id=this.commonStats.user_id,this.modify_ids.rtc_session_id=this.commonStats.rtc_session_id,this.modify_ids.connection_id=this.commonStats.connection_id,this.modify_ids.app_state=this.commonStats.app_state}},{key:"rtcSdkApiCall",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_sdk_api_call",report_id:this.report_id++,rtc_timestamp:Date.now(),sdk_api_name:e,error_code:t,message:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});n.streamId&&(o.stream_id=n.streamId),this.push(o)}},{key:"rtcSdkCallback",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_sdk_callback",report_id:this.report_id++,rtc_timestamp:Date.now(),sdk_callback_name:e,error_code:t,message:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcGetConfig",value:function(e,t,r,n,o,a,s){var c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},u=i(i({event_key:"rtc_get_config",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r,host:n,type:o,config_id:a,enable_cloud_proxy:s},this.modify_ids),{},{common_extra_info:JSON.stringify(c)});this.push(u)}},{key:"rtcReconnect",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"rtc_reconnect",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reconnect_id:r,reconnect_type:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcReconnected",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"rtc_reconnected",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,reconnect_type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcGetAccess",value:function(e,t,r,n,o,a){var s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},c=i(i({event_key:"rtc_get_access",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r,type:n,host:o,connect_session_id:a},this.modify_ids),{},{common_extra_info:JSON.stringify(s)});this.push(c)}},{key:"rtcPreIceState",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_pre_ice_state",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,ice_state:t},this.modify_ids),{},{connection_id:r,common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcNodeChange",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_node_change",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reason:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcSignalingMsgError",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_signaling_msg_error",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reason:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcSignaling",value:function(e,t,r,n,o,a,s){var c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},u=i(i({event_key:"rtc_signaling",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,signaling_event:r,signaling_type:n,stream_id:o,stream_user_id:a,direction:s},this.modify_ids),{},{common_extra_info:JSON.stringify(c)});this.push(u)}},{key:"rtcJoinRoom",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"rtc_join_room",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,deviceModel:t,deviceManufacturer:r,elapse:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcLeaveRoom",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_leave_room",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcBeginCreateOffer",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_begin_create_offer",report_id:this.report_id++,rtc_timestamp:Date.now(),direction:e,stream_id:t,stream_user_id:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcCreateOffer",value:function(e,t,r,n,o){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=i(i({event_key:"rtc_create_offer",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,direction:t,stream_id:r,stream_user_id:n,elapse:o},this.modify_ids),{},{common_extra_info:JSON.stringify(a)});this.push(s)}},{key:"rtcSetDescription",value:function(e,t,r,n,o,a,s,c){var u=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{},d=i(i({event_key:"rtc_set_description",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,is_local:r,direction:n,stream_id:o,stream_user_id:a,elapse:s},this.modify_ids),{},{connection_id:c,common_extra_info:JSON.stringify(u)});this.push(d)}},{key:"rtcRecvAnswer",value:function(e,t,r,n,o,a,s){var c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},u=i(i({event_key:"rtc_recv_answer",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,answer_type:t,sequence_id:r,message:n,direction:o,stream_id:a,stream_user_id:s},this.modify_ids),{},{common_extra_info:JSON.stringify(c)});this.push(u)}},{key:"firstRemoteAudioRender",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"first_remote_audio_render",report_id:this.report_id++,rtc_timestamp:Date.now(),stream_id:e,stream_user_id:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"firstRemoteVideoRender",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"first_remote_video_render",report_id:this.report_id++,rtc_timestamp:Date.now(),stream_id:e,stream_user_id:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcPublishStat",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"rtc_publish_stat",report_id:this.report_id++,rtc_timestamp:Date.now(),result:e,is_screen:t,start:r,message:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcSubscribeStat",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"rtc_subscribe_stat",report_id:this.report_id++,rtc_timestamp:Date.now(),result:e,start:t,message:r,stream_user_id:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcAudioDevice",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_audio_device",report_id:this.report_id++,rtc_timestamp:Date.now(),audio_event:e,message:t,error_code:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcMediaStatistics",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_media_statistics",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcMessageStatistics",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i(i({event_key:"rtc_message_statistics",report_id:this.report_id++,rtc_timestamp:Date.now(),dc_user_message:e,dc_room_message:t,media_server_ip:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(o)}},{key:"rtcError",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"rtc_error",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,error_code:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcInvokeStatus",value:function(e,t,r,n,o){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"",c=i(i({event_key:"rtc_invoke_status",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,error_code:t,sdk_api_name:r,stream_id:n,elapse:o},this.modify_ids),{},{connection_id:s,common_extra_info:JSON.stringify(a),direction:a.direction});this.push(c)}},{key:"rtcFirstFrame",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i(i(i({event_key:"rtc_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcMuteRemote",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"rtc_mute_remote",report_id:this.report_id++,rtc_timestamp:Date.now(),mute_info:e,media_type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"sdkInitEngine",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"sdk_init_engine",report_id:this.report_id++,rtc_timestamp:Date.now(),start:e,type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"joinRoom",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i(i({event_key:"join_room",report_id:this.report_id++,rtc_timestamp:Date.now(),type:e,start:t,result:r,reason:n},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"p2pConnectionStatus",value:function(e,t,r,n,o){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=i(i({event_key:"p2p_connection_status",report_id:this.report_id++,rtc_timestamp:Date.now(),room_id:e,user_id:t,peer_user_id:r,status:n,elapse:o},this.modify_ids),{},{common_extra_info:JSON.stringify(a)});this.push(s)}},{key:"p2pConnectClosed",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i(i({event_key:"p2p_connect_closed",report_id:this.report_id++,rtc_timestamp:Date.now(),p2p_selected:e},this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcDeviceError",value:function(e,t,r,n,o,a,s,c,u,d,l,h,f,p,v,_){var m=arguments.length>16&&void 0!==arguments[16]?arguments[16]:{},y=i(i({event_key:"rtc_device_error",report_id:this.report_id++,rtc_timestamp:Date.now(),device_type:e,device_stage:t,error_code:r,system_error_code:n,system_api:o,call_parameters:a,location:s,message:c,media_device_id:u,media_device_name:d,elapse:l,scenario:h,event_session_id:f,device_pid:p,device_vid:v,media_mode:_},this.modify_ids),{},{common_extra_info:JSON.stringify(m)});this.push(y)}},{key:"rtcVideoDevice",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i({event_key:"rtc_video_device",report_id:this.report_id++,rtc_timestamp:Date.now(),media_device_id:e,media_device_name:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcVideoCaptureEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i(i(i({event_key:"rtc_video_capture_event",report_id:this.report_id++,rtc_timestamp:Date.now()},e),this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcEncodeFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_encode_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcFirstFrameEncoded",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_first_frame_encoded",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcSendFirstPacket",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_send_first_packet",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcRecvFirstPacket",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_recv_first_packet",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcRecvFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_recv_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcDecodeFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(i(i(i({event_key:"rtc_decode_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}}]),n}(GU),wj=new Cj,Oj=new Cj,xj=new Cj,Pj=wj.commonStats,Dj=Oj.commonStats,Nj=xj.commonStats;function Mj(e){Pj.setStats({app_state:e}),Dj.setStats({app_state:e}),Nj.setStats({app_state:e})}!tM()&&(Mj("active"),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?Mj("active"):"hidden"===document.visibilityState&&Mj("background")})));var Lj={default:wj,rtm:Oj,outsideRoom:xj},Uj=function(e,t,r){wj.rtcSdkApiCall(e,t,r)},Vj=function(e,t,r){wj.rtcSdkCallback(e,t,r)};function Fj(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return function(t,n,i){if("function"==typeof i.value){var o=i.value;i.value=function(){for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];var s={};r.forEach((function(e,t){s[e]=i[t]})),"joinRoom"===n&&Pj.setStats({room_id:i[1]}),Lj[e].rtcSdkApiCall(n,0,JSON.stringify(gM(i)),s);var c=o.apply(this,i);return"function"==typeof(null==c?void 0:c.then)?c.then((function(t){return Lj[e].rtcSdkCallback(n,0,JSON.stringify(gM([t||{}]))),t})).catch((function(t){throw Lj[e].rtcSdkCallback(n,t.code,JSON.stringify(t.message)),t})):(Lj[e].rtcSdkCallback(n,0,JSON.stringify(gM([c||{}]))),c)}}}}function Bj(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e===oe.onUserMessageReceivedOutsideRoom||e===oe.onUserBinaryMessageReceivedOutsideRoom;(n?Oj:wj).rtcSdkCallback(e,r,JSON.stringify(t))}function jj(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};(n?Oj:wj).rtcInvokeStatus(JSON.stringify(t),r,e,"",0,o,i)}var Gj="BytePlus",Hj="RTC_DEVICE_ID",zj="RTC_ACCESS_NODE",Kj="RTC_ACCESS_URLS",Xj="engine_BAC",Wj="SERVER_CONFIG",qj=function(){function e(){u(this,e)}return l(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(n){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,JSON.stringify(n)),!0}catch(i){return!1}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),Yj=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"_accessVersion","v2"),e}return l(r,[{key:"getDeviceId",value:function(){if(tM())return"";var e=this.get(Hj);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return[Pj,Dj,Nj].forEach((function(t){return t.setStats({device_id:e})})),this.set(Hj,e),e}},{key:"getAccessNode",value:function(e){return this.get("".concat(zj,"_").concat(e,"-").concat(Gj,"-").concat(this._accessVersion))}},{key:"setAccessNode",value:function(e,t,r){return this.set("".concat(zj,"_").concat(e,"-").concat(Gj,"-").concat(this._accessVersion),t,1e3*r)}},{key:"clearAccessNode",value:function(e){this.delete("".concat(zj,"_").concat(e,"-").concat(Gj))}},{key:"getAccessUrls",value:function(){return this.get("".concat(Kj,"-").concat(Gj))}},{key:"setAccessUrls",value:function(e){var t=e.map((function(e){var t=e.host,r=e.path;return"https://".concat(t).concat(r)}));return this.set("".concat(Kj,"-").concat(Gj),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(Kj,"-").concat(Gj))}},{key:"getAudioProfile",value:function(){return this.get(Xj)}},{key:"setAudioProfile",value:function(e){return this.set(Xj,e)}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(Wj);return(null==n||null===(t=n.find((function(e){return e.key===r})))||void 0===t?void 0:t.config)||{}}},{key:"setServerConfig",value:function(e,t){if(t){var r="".concat(e),n=this.get(Wj)||[];return(n=n.filter((function(e){return e.key!==r}))).push({key:r,config:t}),this.set(Wj,n.slice(-5))}}}]),r}(qj),Jj=new Yj,Qj="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function Zj(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var $j="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",eG="rtc.rtcplus.com".split(","),tG={VERSION:"4.49.16",ICE_CONFIG_REQUEST_URLS_INTERNAL:Qj.map(Zj),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:$j,CONFIG_REQUEST_DOMAINS:eG,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,ENABLE_REPORT_ERROR_BUFFER:!1,ENABLE_FALLBACK_HANDLER:!1};function rG(e,t){if(wj.rtcSdkApiCall("setParameter",0,"key: ".concat(e,", value: ").concat(t)),"VERSION"!==e){if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(tG.ICE_CONFIG_REQUEST_URLS=t.map(Zj));if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t)if("LOG_SERVER_URL"!==e||t!==j.overseas)if("LOG_SERVER_URL"!==e||t!==j.domestic)if("LOG_SERVER_URL"!==e||"string"!=typeof t){if("OVERSEA"===e)return Pj.setStats({overSea:t?"1":"0"}),void(tG.OVERSEA=t);"DEVICE_ID"===e&&Jj.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&wj.enableErrorBuffer(),tG[e]=t}else tG.LOG_SERVER_URL=t;else tG.LOG_SERVER_URL=$j;else tG.LOG_SERVER_URL="https://web-log-report.rtcplus.com/video/v1/webrtc_log/";else Pj.setStats({product:t});else Pj.setStats({platform:t})}}function nG(e){return"DEVICE_ID"===e?Jj.getDeviceId():tG[e]}function iG(e,t,r){var n,i,o,a,s,c,u,d,l;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||z.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:l.map((function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var oG,aG={width:640,height:360,frameRate:15,maxKbps:600},sG={width:1920,height:1080,frameRate:15,maxKbps:3e3},cG=function(e){return e.streamRemovedBySchedule308="stream removed",e.clientRePublish="client republish",e.publishStreamFaied="publish failed",e.clientUnPublish="client unpublished",e.clientDisconnected="client disconnected",e.videoMuted="video muted",e}(cG||{}),uG=function(e){return e.PushLimitWarn="PushLimitWarn",e}(uG||{}),dG=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SCENE_CONFIG="onSceneConfig",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e}(dG||{}),lG=function(e){return e.RSCP="RSCP",e.RTT="RTT",e}(lG||{}),hG=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(hG||{}),fG=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(fG||{}),pG=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(pG||{}),vG=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(vG||{}),_G=function(e){return e[e.P2P=0]="P2P",e[e.SIGNAL=1]="SIGNAL",e[e.BROADCAST=2]="BROADCAST",e[e.BUSINESS_SERVER=3]="BUSINESS_SERVER",e}(_G||{}),mG=function(e){return e[e.SUCCESS=0]="SUCCESS",e[e.TIMEOUT=1]="TIMEOUT",e[e.BROKEN=2]="BROKEN",e[e.NO_RECEIVER=3]="NO_RECEIVER",e[e.NO_RELAYPATH=4]="NO_RELAYPATH",e[e.SEND_TO_SERVER_ERROR=17]="SEND_TO_SERVER_ERROR",e[e.SERVER_RESPONSE_ERROR=18]="SERVER_RESPONSE_ERROR",e[e.NOT_JOIN=100]="NOT_JOIN",e[e.INIT=101]="INIT",e[e.NO_CONNECTION=102]="NO_CONNECTION",e[e.NOT_LOGIN=105]="NOT_LOGIN",e[e.SERVER_PARAMS_NOTSET=106]="SERVER_PARAMS_NOTSET",e[e.UNKNOWN=1e3]="UNKNOWN",e}(mG||{}),yG=(h(oG={},0,[0,"success"]),h(oG,1,[dD.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),h(oG,2,[dD.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),h(oG,3,[dD.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),h(oG,4,[dD.USER_MESSAGE_NO_RELAYPATH,"cannot find relay path."]),h(oG,17,[dD.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),h(oG,18,[dD.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),h(oG,100,[dD.USER_MESSAGE_NOT_JOIN,"not join room"]),h(oG,101,[dD.USER_MESSAGE_INIT,"not init."]),h(oG,102,[dD.USER_MESSAGE_NO_CONNECTION,"no connection."]),h(oG,105,[dD.USER_MESSAGE_NOT_LOGIN,"not login."]),h(oG,106,[dD.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),h(oG,1e3,[dD.USER_MESSAGE_UNKNOWN,"unknown."]),oG),gG=["msg"],SG=new FU("DataChannelSignaling",3),EG=["onSpeakerChange"],bG=function(e){return e[e.C2S=0]="C2S",e[e.C2C=1]="C2C",e[e.C2GW=2]="C2GW",e[e.C2CDirect=3]="C2CDirect",e[e.C2RTM=4]="C2RTM",e}(bG||{}),kG=6e4,TG=function(e){f(a,e);var t,r,n=g(a);function a(e){var t;return u(this,a),h(m(t=n.call(this)),"_singlingCache",new Map),h(m(t),"_p2pCache",new Map),h(m(t),"_rttIds",{}),h(m(t),"_p2pMessageId",0),h(m(t),"_clearDataChannelListener",void 0),t._dataChannel=e,t._clearDataChannelListener=t._handleHandler(),window.__rtc_mock_signaling__=t.emit.bind(m(t)),t}return l(a,[{key:"destroy",value:function(){this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=0,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n=this;return wj.rtcSignaling(0,JSON.stringify(t),"call-".concat(e),"Send",t.streamId,t.streamUserId,rj.UP),new Promise((function(i,o){var a=n._genHeader(r);a.id=_M();var s=a.id.join("-"),c=setTimeout((function(){n._singlingCache.delete(s),o(new hD(dD.TIME_OUT,"".concat(e," message time out")))}),kG);n._singlingCache.set(s,{signalingType:e,success:function(e){clearTimeout(c),i(e)},error:function(e){clearTimeout(c),o(e)}}),SG.print("Signal",">>>>>> [".concat(e,"][").concat(s,"]"),t),n._sendMessage(e,a,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(r=c(o().mark((function e(t,r){var n,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,a=_(t,gG),s=n instanceof ArrayBuffer,e.t0=this,e.t1=i,e.t2=i({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:vG.SEND,type:_G.P2P,err:mG.SUCCESS},a),e.t3={},e.t4=s,!s){e.next=13;break}return e.next=10,rM.ab2b64str(n);case 10:e.t5=e.sent,e.next=14;break;case 13:e.t5=n;case 14:return e.t6=e.t5,e.t7={binary:e.t4,msg:e.t6},e.t8=(0,e.t1)(e.t2,e.t3,e.t7),e.t9=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t8,e.t9));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_sendP2PMessage",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return yM(e.msg)?this._rttIds[e.id]=e.id:e.dir===vG.SEND&&SG.print("_sendP2PMessage [DC Signaling p2p >>]",JSON.stringify(e)),new Promise((function(n,o){var a=t._genHeader(i(i({needAck:!0,functionType:1},r),{},{id:_M()}));if(e.dir===vG.SEND){var s=setTimeout((function(){t._p2pCache.delete(e.id),o(new hD(dD.TIME_OUT,"P2P message timeout"))}),kG);t._p2pCache.set(e.id,{success:function(e,t){clearTimeout(s),n(t)},error:function(e){clearTimeout(s);var t=b(yG[e.err]||[dD.USER_MESSAGE_UNKNOWN,"err: ".concat(e.err,", msg: ").concat(e.msg)],2),r=t[0],n=t[1];o({err:e.err,code:r,message:e.msg||n})}})}t._sendMessage("p2p",a,e)}))}},{key:"_sendMessage",value:function(e,t,r){if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new hD(dD.SIGNALING_CHANNEL_NOT_OPEN,"DataChannel not open");var n=t.version+(+t.zip<<5)+(+t.encrypt<<6),i=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),o=rM.str2ab(JSON.stringify([e,r])),a=eM(Uint8Array,[n,i].concat(k(t.id||[])),new Uint8Array(o));this._dataChannel.send(a.buffer)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(128!=(128&t[r])){r++;break}o.id=Array.from(t.slice(2,r))}return{header:o,data:t.slice(r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n=this._genHeader({needAck:!0,direction:1,id:e.split("-").map((function(e){return+e}))});EG.includes(t)||SG.print("Signal",">>>>>> [".concat(t,"-res][").concat(e,"]")),this._sendMessage("".concat(t,"-res"),n,r)}},{key:"_handleMessage",value:(t=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,k,T,I,A,R,C,w,O,x,P,D,N,M,L;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=this._dispartData(t),d=u.data,(l=u.header).zip&&((h=new jB.Inflate).push(d,!0),d=h.result),f=rM.ab2str(d),p=[],e.prev=6,p=JSON.parse(f),e.next=14;break;case 10:return e.prev=10,e.t0=e.catch(6),e.t0 instanceof Error&&wj.rtcSignalingMsgError(-1,e.t0.message,tj.MESSAGE_PARSE_FAILED),e.abrupt("return");case 14:e.t1=l.functionType,e.next=0===e.t1?17:1===e.t1?34:2===e.t1?83:101;break;case 17:if(v=(null===(r=l.id)||void 0===r?void 0:r.join("-"))||"",1!==l.direction){e.next=22;break}this._handleAckMessage(v,p[0]||{},f),e.next=33;break;case 22:if(!Array.isArray(p)){e.next=33;break}if(_=p[0],p=p[1],EG.includes(_)||SG.print("Signal","<<<<<< ".concat(_),p,v),this._feedbackSignaling(v,_,_===dG.ON_CUSTOM_MESSAGE?i(i({},p),{},{message:""}):""),!p.binary||"string"!=typeof p.message){e.next=31;break}return e.next=30,rM.b64str2ab(p.message);case 30:p.message=e.sent;case 31:this.emit(_,i({},p)),wj.rtcSignaling(0,f,"on-".concat(_),"Recv",p.streamId,p.clientId,rj.DOWN);case 33:return e.abrupt("break",102);case 34:Array.isArray(p)&&(p=p[1]),m=null===(n=p)||void 0===n?void 0:n.id,this._rttIds[m]||(null===(a=p)||void 0===a?void 0:a.dir)===vG.FEEDBACK||yM(null===(s=p)||void 0===s?void 0:s.msg)?delete this._rttIds[m]:SG.print("Signal","<<<<<< p2p response",p),e.t2=p.dir,e.next=e.t2===vG.SEND?40:e.t2===vG.FEEDBACK?78:81;break;case 40:if(yM(null===(c=p)||void 0===c?void 0:c.msg)){e.next=76;break}if(g=(y=p).binary,S=y.msg,E=y.room,k=y.to,T=y.from,I=""===E?g?dG.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:dG.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:g?dG.USER_BINARY_MESSAGE_RECEIVED:dG.USER_MESSAGE_RECEIVED,k){e.next=60;break}if(e.t3=this,e.t4=dG.ON_CUSTOM_MESSAGE,e.t5=T,e.t6=g,!g){e.next=54;break}return e.next=51,rM.b64str2ab(S);case 51:e.t7=e.sent,e.next=55;break;case 54:e.t7=S;case 55:e.t8=e.t7,e.t9={clientId:e.t5,binary:e.t6,message:e.t8},e.t3.emit.call(e.t3,e.t4,e.t9),e.next=76;break;case 60:if(e.t10=this,e.t11=I,e.t12=i,e.t13=i({},p),e.t14={},!g){e.next=71;break}return e.next=68,rM.b64str2ab(S);case 68:e.t15=e.sent,e.next=72;break;case 71:e.t15=S;case 72:e.t16=e.t15,e.t17={msg:e.t16},e.t18=(0,e.t12)(e.t13,e.t14,e.t17),e.t10.emit.call(e.t10,e.t11,e.t18);case 76:return this._sendP2PMessage(i(i({},p),{},{dir:vG.FEEDBACK,msg:""})),e.abrupt("break",82);case 78:return(A=this._p2pCache.get(p.id))&&(this._p2pCache.delete(p.id),p.err===mG.SUCCESS?A.success(p.id,p):A.error(p)),e.abrupt("break",82);case 81:return e.abrupt("break",82);case 82:return e.abrupt("break",102);case 83:if(1!==l.direction){e.next=88;break}C=(null===(R=l.id)||void 0===R?void 0:R.join("-"))||"",this._handleAckMessage(C,p[0]||{},f),e.next=100;break;case 88:if(w=b(p,2),O=w[0],x=w[1],P=void 0===x?{}:x,"RXMediaMsg"!==O){e.next=100;break}D=P.type,N=P.data,wj.rtcSignaling(0,f,"on-".concat(D),"Recv","","",rj.DOWN),e.t19=D,e.next="RSCP"===e.t19?95:"RTT"===e.t19?97:99;break;case 95:try{M=JSON.parse(N),Array.isArray(M)&&this.emit(D,M)}catch(o){}return e.abrupt("break",100);case 97:try{(L=JSON.parse(N)).length&&this.emit(D,L[0])}catch(o){}return e.abrupt("break",100);case 99:return e.abrupt("break",100);case 100:case 101:return e.abrupt("break",102);case 102:case"end":return e.stop()}}),e,this,[[6,10]])}))),function(e){return t.apply(this,arguments)})},{key:"_handleHandler",value:function(){var e=this,t=function(t){SG.print("_handleHandler","dataChannel close",t),e.emit("close",t)},r=function(t){SG.print("_handleHandler","dataChannel error",t),e.emit("close",t)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n=this._singlingCache.get(e);n&&(this._singlingCache.delete(e),200===t.code?n.success(t):n.error(t),SG.print("Signal","<<<<<< [".concat(n.signalingType,"-ack] ").concat(e),t)),wj.rtcSignaling(0,r,null==n?void 0:n.signalingType,"Ack","","",rj.DOWN)}}]),a}(OU.exports.EventEmitter),IG=function(){function e(){u(this,e),h(this,"xhr",void 0),h(this,"isSending",void 0),h(this,"timeout",void 0),this.isSending=!1}return l(e,[{key:"ajax",value:function(e){var t=this,r=e.method,n=e.url,i=e.body,o=void 0===i?{}:i,a=e.headers,s=void 0===a?{}:a,c=e.stringify,u=void 0===c||c;return new Promise((function(e,i){t.isSending=!0;var a=new XMLHttpRequest;a.open(r,n,!0);for(var c=0,d=Object.entries(s);c<d.length;c++){var l=b(d[c],2),h=l[0],f=l[1];a.setRequestHeader(h,f)}a.onreadystatechange=function(){if(4===a.readyState)if(t.isSending=!1,200===a.status)e(JSON.parse(a.responseText));else{var r=a.statusText,n=a.status;if(a.responseText)try{var o=JSON.parse(a.responseText);o.errMessage&&(r=o.errMessage),o.code&&(n=o.code)}catch(s){}i({message:r,code:n})}},a.onabort=function(){i({code:0,message:"Request abort"})},a.onerror=function(e){t.isSending=!1,i({code:-1,message:a.responseText||"unknown"})},t.timeout&&(a.timeout=t.timeout),u&&(o=JSON.stringify(o)),a.send(o),t.xhr=a}))}},{key:"get",value:function(e,t){return this.ajax({method:"GET",url:e,headers:t})}},{key:"post",value:function(e,t,r,n){return this.ajax({method:"POST",url:e,body:t,headers:r,stringify:n})}},{key:"abort",value:function(){var e;null===(e=this.xhr)||void 0===e||e.abort()}}]),e}(),AG=new FU("ICE Request",3),RG=function(){function e(){u(this,e),h(this,"_request",void 0),this._request=new IG}var t,r,n;return l(e,[{key:"getAccessNode",value:(n=c(o().mark((function e(t,r,n,i,a,s,c,u){var d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(d=Jj.getAccessNode(t))){e.next=9;break}if(this.getAccessNodeFromServer(t,r,n,i,a,s,c,u),jj("es.R.node.cache",d),!Array.isArray(d)){e.next=8;break}return e.abrupt("return",Promise.resolve(d));case 8:return e.abrupt("return",Promise.resolve([d]));case 9:return e.abrupt("return",this.getAccessNodeFromServer(t,r,n,i,a,s,c,u));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o,a,s,c){return n.apply(this,arguments)})},{key:"getAccessNodeFromServer",value:(r=c(o().mark((function e(t,r,n,i,a,s,c,u){var d,l,h,f,p=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h=Jj.getAccessUrls(),f=!0,jj("es.R.req.cache.urls",h),(null===(d=h)||void 0===d?void 0:d.length)>0||(h=tG.ICE_CONFIG_REQUEST_URLS,f=!1,jj("es.R.req.external.urls",h)),(null===(l=h)||void 0===l?void 0:l.length)>0||(h=tG.ICE_CONFIG_REQUEST_URLS_INTERNAL,f=!1,jj("es.R.req.internal.urls",h)),e.abrupt("return",this.getICEConfigFromServer(h,t,r,n,i,a,s,c,u).then((function(e){var r=e.nodes;return Jj.setAccessNode(t,r,e.ttl||11200),e.dispatchDomains&&Jj.setAccessUrls(e.dispatchDomains),r})).catch((function(e){if(f)return jj("es.R.req.fallback",""),Jj.clearAccessUrls(),p.getAccessNodeFromServer(t,r,n,i,a,s,c);throw e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o,a,s,c){return r.apply(this,arguments)})},{key:"getICEConfigFromServer",value:(t=c(o().mark((function e(t,r,n,i,a,s,u,d,l){var h,f,p,v,_=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h={appID:r,userID:i,deviceID:a,connectSessionID:ZN(),os:"web",sdkVersion:tG.VERSION,isOversea:tG.OVERSEA,expectedAddr:nG("EXPECTED_ADDR"),productPlatform:"BytePlus",accessParams:JSON.stringify({requireICEUfragV2:!0})},s&&u&&(h.feedbackInfo=[{feedbackIP:null===(f=u.publicIPs[0])||void 0===f?void 0:f.ip,feedbackReason:{type:"NODE_CHANGED",reason:s}}],delete h.expectedAddr),p=Date.now(),wj.rtcGetAccess(0,JSON.stringify(h),0,$B.REQUEST,t.join(","),h.connectSessionID),v=t.map(function(){var e=c(o().mark((function e(t,r){var n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_._request.post(t,h);case 3:n=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new hD(dD.ICE_SERVER_WRONG,"get ICE config failed",e.t0);case 9:if(200===n.code){e.next=11;break}throw new hD(dD.ICE_SERVER_WRONG,"get ICE config failed",{server_code:n.code,message:JSON.stringify(n)});case 11:if(i=n.nodes[0]){e.next=14;break}throw new hD(dD.ICE_SERVER_WRONG,"ICE config server return empty nodes",{code:n.code,message:JSON.stringify(n)});case 14:return e.abrupt("return",{result:n,firstNode:i,index:r});case 15:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",EM(v).then((function(e){var r=e.result;e.firstNode;var n=e.index;return wj.rtcGetAccess(200,JSON.stringify(r),Date.now()-p,$B.RESPONSE,t[n],h.connectSessionID),r})).catch((function(e){var r,n,i=null===(r=e[0])||void 0===r?void 0:r.error;throw wj.rtcGetAccess(+((null==i?void 0:i.code)||(null==i?void 0:i.server_code)),null===(n=e[0])||void 0===n?void 0:n.message,Date.now()-p,$B.RESPONSE,t.join(","),h.connectSessionID,{error:JSON.stringify(i)}),i})));case 6:case"end":return e.stop()}}),e)}))),function(e,r,n,i,o,a,s,c,u){return t.apply(this,arguments)})},{key:"abort",value:function(){this._request.isSending&&(AG.print("abort","HTTP Request of [getICEConfigFromServer] abort"),this._request.abort())}}]),e}(),CG=function(){function e(){u(this,e),h(this,"_request",void 0),this._request=new IG}return l(e,[{key:"getAudioProfile",value:function(){var e=this,t={keys:["engine_BAC"],labelSelector:"",sdkVersion:"4.49.16",deviceType:"web"},r=tG.CONFIG_REQUEST_DOMAINS.map((function(e){return"https://".concat(e,"/decision/v1/multi")}));wj.rtcGetConfig(0,JSON.stringify(t),0,r.join(","),qB.REQUEST,"",!1);var n=r.map(function(){var r=c(o().mark((function r(n,i){var a,s;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,e._request.post(n,t);case 3:s=r.sent,r.next=9;break;case 6:throw r.prev=6,r.t0=r.catch(0),new hD(dD.ICE_SERVER_WRONG,"get config failed");case 9:if(Array.isArray(null===(a=s)||void 0===a?void 0:a.engine_BAC)){r.next=11;break}throw new hD(dD.ICE_SERVER_WRONG,"get config failed");case 11:return r.abrupt("return",{result:s,index:i});case 12:case"end":return r.stop()}}),r,null,[[0,6]])})));return function(e,t){return r.apply(this,arguments)}}());return new Promise((function(e){EM(n).then((function(t){var n=t.result,i=t.index;Jj.setAudioProfile(n.engine_BAC),wj.rtcGetConfig(200,JSON.stringify(n),0,r[i],qB.RESPONSE,"",!1),e(n.engine_BAC)})).catch((function(t){wj.rtcGetConfig(500,t.message,0,"",qB.RESPONSE,"",!1),e(Jj.getAudioProfile()||[])}))}))}},{key:"getWebRtcConfig",value:function(e){var t=this,r=e.appId,n=e.deviceId,i={keys:["web_rtc_config"],labelSelector:"",sdkVersion:"4.49.16",deviceType:"web",appId:r,deviceId:n,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},a=tG.CONFIG_REQUEST_DOMAINS.map((function(e){return"https://".concat(e,"/decision/v1/multi")}));wj.rtcGetConfig(0,JSON.stringify(i),0,a.join(","),qB.REQUEST,"",!1);var s=a.map(function(){var e=c(o().mark((function e(r,n){var a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t._request.post(r,i);case 3:a=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new hD(dD.ICE_SERVER_WRONG,"get config failed");case 9:return e.abrupt("return",{result:a,index:n});case 10:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}());return new Promise((function(e){EM(s).then((function(t){var n=t.result,i=t.index;Jj.setServerConfig(r,n),wj.rtcGetConfig(200,JSON.stringify(n),0,a[i],qB.RESPONSE,"",!1),e(n.web_rtc_config)})).catch((function(t){wj.rtcGetConfig(500,t.message,0,"",qB.RESPONSE,"",!1),e(Jj.getServerConfig(r).web_rtc_config||{})}))}))}}]),e}();function wG(e,t){var r=1,n=e;(e.width>t.width||e.height>t.height)&&(r=e.width/e.height>t.width/t.height?e.width/t.width:e.height/t.height,n={width:Math.floor(e.width/r),height:Math.floor(e.height/r)});return i(i({},n),{},{scaleResolutionDownBy:r})}var OG=[{width:1920,height:1080,maxLayers:3,totalPixels:2073600},{width:1280,height:720,maxLayers:3,totalPixels:921600},{width:960,height:540,maxLayers:3,totalPixels:518400},{width:640,height:360,maxLayers:2,totalPixels:230400},{width:480,height:270,maxLayers:2,totalPixels:129600},{width:320,height:180,maxLayers:1,totalPixels:57600},{width:0,height:0,maxLayers:1,totalPixels:0}];var xG={width:160,height:90,frameRate:15,maxkbps:100},PG={width:480,height:270,frameRate:15,maxkbps:400};yf("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Bf);var DG=new Map,NG=function(){var e=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){var n=nG("STATS_SCALLBACK_SUPPORT");if("chrome-stable"===nM()&&void 0===window.InstallTrigger&&iM&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!FG.includes(e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(i(i({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return r.filter((function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(EZ){r(EZ)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),MG=function(){var e=c(o().mark((function e(t){var r,n,i,a,s,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return i=e.sent,a={all:[]},s=new Map,i.forEach((function(e){var t=s.get(e.type)||new Map;t.set(e.id,e),s.set(e.type,t),a.all.push(e)})),c=function(e,t){e.forEach((function(e){var r,n,i,o,a,c,u=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=s.get(VG.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=s.get(VG.transport))||void 0===n||n.forEach((function(e){e.id===d&&(a=e,t.add(e))})),null===(i=s.get(VG.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(o=s.get(VG.mediaPlayout))||void 0===o||o.forEach((function(e){e.id===h&&t.add(e)})),a){var f,p,v=a,_=v.localCertificateId,m=v.remoteCertificateId,y=v.selectedCandidatePairId;null===(f=s.get(VG.certificate))||void 0===f||f.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(p=s.get(VG.candidatePair))||void 0===p||p.forEach((function(e){e.id===y&&(c=e,t.add(e))}))}if(c){var g,S,E=c,b=E.localCandidateId,k=E.remoteCandidateId;null===(g=s.get(VG.localCandidate))||void 0===g||g.forEach((function(e){e.id===b&&t.add(e)})),null===(S=s.get(VG.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},null===(r=s.get(VG.mediaSource))||void 0===r||r.forEach((function(e){var t,r=new Set;r.add(e);var n=[];null===(t=s.get(VG.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=s.get(VG.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),c(n,r),a[e.trackIdentifier]=Array.from(r)})),null===(n=s.get(VG.inboundRtp))||void 0===n||n.forEach((function(e){var t,r=new Set;r.add(e),null===(t=s.get(VG.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),c([e],r);var n,i=e.trackIdentifier;i||(null===(n=s.get(VG.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(i=t.trackIdentifier)})));a[i]=Array.from(r)})),e.abrupt("return",a);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),LG=function(){var e=c(o().mark((function e(t,r,n){var i,a,s,c,u,d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!oM&&!aM){e.next=10;break}return a=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){a.push(e)})),e.abrupt("return",a);case 10:return(!(s=DG.get(t))||Date.now()-s.timestamp>150)&&(s={timestamp:Date.now(),statsPromise:MG(t),extraStatsPromise:NG(t)},DG.set(t,s)),e.next=14,s.statsPromise;case 14:if(c=e.sent,u=(i?c[i]:c.all)||[],n){e.next=21;break}return e.next=19,s.extraStatsPromise;case 19:d=e.sent,u=u.concat((i?d.getTrackStats(i):d.all)||[]);case 21:return e.abrupt("return",u);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();nM();var UG,VG=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(VG||{}),FG=["codec","inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","media-source","csrc","peer-connection","data-channel","stream","track","transceiver","sender","receiver","transport","sctp-transport","candidate-pair","local-candidate","remote-candidate","certificate","ice-server"],BG=new FU("isSupported",0),jG=function(){var e=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!tM()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,GG();case 5:return t=e.sent,e.abrupt("return",(null==t?void 0:t.includes("H264"))||(null==t?void 0:t.includes("vp8")));case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(){return e.apply(this,arguments)}}(),GG=function(){var e=c(o().mark((function e(){var t,r,n,i,a,s,c,u,d,l,h,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.print("internalGetSupportedCodecs()","Invoke, cachedSupportedCodecs: %o",UG),!UG){e.next=3;break}return e.abrupt("return",UG);case 3:if(t=[],e.prev=4,!navigator.userAgent.includes("VivoBrowser")){e.next=8;break}return e.next=8,SM();case 8:return e.next=10,SM();case 10:if(r=e.sent){e.next=13;break}return e.abrupt("return",t);case 13:n=r.split("\n"),i=!1,a=A(n),e.prev=16,a.s();case 18:if((s=a.n()).done){e.next=25;break}if(!((c=s.value).includes("level-asymmetry-allowed=1")&&c.includes("packetization-mode=1")&&c.includes("profile-level-id=42e0"))){e.next=23;break}return i=!0,e.abrupt("break",25);case 23:e.next=18;break;case 25:e.next=30;break;case 27:e.prev=27,e.t0=e.catch(16),a.e(e.t0);case 30:return e.prev=30,a.f(),e.finish(30);case 33:if(i){for(u=navigator.userAgent.toLowerCase(),d=!1,l=0,h=["miuibrowser"];l<h.length;l++)f=h[l],u.includes(f)&&(d=!0);!d&&t.push("H264")}else BG.print("internalGetSupportedCodecs()","sdp: %s",r);return null!=r&&r.includes("VP8")&&t.push("vp8"),UG=t,e.abrupt("return",t);case 39:return e.prev=39,e.t1=e.catch(4),e.abrupt("return",t);case 42:case"end":return e.stop()}}),e,null,[[4,39],[16,27,30,33]])})));return function(){return e.apply(this,arguments)}}(),HG=function(){var e=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,GG();case 2:return t=e.sent,e.abrupt("return",t.map((function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),zG=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},KG={},XG=Wc,WG=ve,qG=Re,YG=Ac,JG=Fr,QG=Ue,ZG=Ss,$G=Be,eH=em,tH=xu,rH=li,nH=As,iH=Rt,oH=Nl,aH=Nc,sH=mc,cH=de,uH=zs.UNSUPPORTED_Y,dH=4294967295,lH=Math.min,hH=[].push,fH=qG(/./.exec),pH=qG(hH),vH=qG("".slice),_H=!cH((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var r="ab".split(e);return 2!==r.length||"a"!==r[0]||"b"!==r[1]}));YG("split",(function(e,t,r){var n;return n="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,r){var n=nH($G(this)),i=void 0===r?dH:r>>>0;if(0===i)return[];if(void 0===e)return[n];if(!ZG(e))return WG(t,n,e,i);for(var o,a,s,c=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),d=0,l=new RegExp(e.source,u+"g");(o=WG(sH,l,n))&&!((a=l.lastIndex)>d&&(pH(c,vH(n,d,o.index)),o.length>1&&o.index<n.length&&XG(hH,c,oH(o,1)),s=o[0].length,d=a,c.length>=i));)l.lastIndex===o.index&&l.lastIndex++;return d===n.length?!s&&fH(l,"")||pH(c,""):pH(c,vH(n,d)),c.length>i?oH(c,0,i):c}:"0".split(void 0,0).length?function(e,r){return void 0===e&&0===r?[]:WG(t,this,e,r)}:t,[function(t,r){var i=$G(this),o=QG(t)?void 0:iH(t,e);return o?WG(o,t,i,r):WG(n,nH(i),t,r)},function(e,i){var o=JG(this),a=nH(e),s=r(n,o,a,i,n!==t);if(s.done)return s.value;var c=eH(o,RegExp),u=o.unicode,d=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(uH?"g":"y"),l=new c(uH?"^(?:"+o.source+")":o,d),h=void 0===i?dH:i>>>0;if(0===h)return[];if(0===a.length)return null===aH(l,a)?[a]:[];for(var f=0,p=0,v=[];p<a.length;){l.lastIndex=uH?0:p;var _,m=aH(l,uH?vH(a,p):a);if(null===m||(_=lH(rH(l.lastIndex+(uH?p:0)),a.length))===f)p=tH(a,p,u);else{if(pH(v,vH(a,f,p)),v.length===h)return v;for(var y=1;y<=m.length-1;y++)if(pH(v,m[y]),v.length===h)return v;p=f=_}}return pH(v,vH(a,f)),v}]}),!_H,uH);var mH={},yH={exports:{}},gH=yH.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(gH).forEach((function(e){gH[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=yH.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;s<(n[t]||[]).length;s+=1){var c=n[t][s];if(c.reg.test(i))return r(c,a,i)}})),t.media=o,t};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;i<n.length;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(mH);var SH=yH.exports,EH=/%[sdv%]/g,bH=function(e){var t=1,r=arguments,n=r.length;return e.replace(EH,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},kH=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?n.push(r[t.name][o]):n.push(r[t.names[i]])}else n.push(r[t.name]);return bH.apply(null,n)},TH=["v","o","s","i","u","e","p","c","b","t","r","z","a"],IH=["i","c","b","a"],AH=mH,RH=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||TH,n=t.innerOrder||IH,i=[];return r.forEach((function(t){SH[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(kH(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(kH(t,r,e))}))}))})),e.media.forEach((function(e){i.push(kH("m",SH.m[0],e)),n.forEach((function(t){SH[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(kH(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(kH(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};KG.write=RH,KG.parse=AH.parse,KG.parseParams=AH.parseParams,KG.parseFmtpConfig=AH.parseFmtpConfig,KG.parsePayloads=AH.parsePayloads,KG.parseRemoteCandidates=AH.parseRemoteCandidates,KG.parseImageAttributes=AH.parseImageAttributes,KG.parseSimulcastStreamList=AH.parseSimulcastStreamList;var CH=ps;ro({target:"Array",proto:!0},{fill:pR}),CH("fill");var wH=new FU("FirefoxHandler",3),OH=Math.pow(2,32),xH="kp34Za0H+aVf862l",PH="o/i14u9pJrxRKAsu";function DH(e){return e>OH-18?(wH.print("generateAllSsrc","reset start id",e),DH(e=e-OH+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var NH=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:PH;return[{id:r,attribute:"cname",value:n},{id:r,attribute:"msid",value:"".concat(e," ").concat(e,"-").concat(t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:"".concat(e,"-").concat(t)}]},MH=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=t.video,i=t.videoRtx,o=t.videoFec,a=[n,i],s=r.cname,c=r.flexfec;c&&a.push(o);var u=a.reduce((function(t,r){return t.concat(NH(e,"video",r,s))}),[]),d=[{semantics:"FID",ssrcs:"".concat(n," ").concat(i)}];return c&&d.push({semantics:"FEC-FR",ssrcs:"".concat(n," ").concat(o)}),{ssrcs:u,ssrcGroups:d}};function LH(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.bundleOnly,e}var UH=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=i(i({},e),{},{media:[]});return n&&(o.invalid=[{value:"realx-exts:rscp"}]),t&&o.media.push(t),r&&o.media.push(r),delete o.groups,delete o.msidSemantic,KG.write(o)};function VH(e){return FH.apply(this,arguments)}function FH(){return(FH=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,a=t.iceParams,s=t.iceConfig,r.fingerprint={type:"sha-256",hash:i},r.icePwd=a.serverIcePwd,e.next=6,jH(a.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=BH(n,s),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function BH(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,o=[];return e.forEach((function(e){var a={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){o.push(i(i({},a),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){o.push(i(i({},a),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),o}var jH=function(){var e=c(o().mark((function e(t){var r,n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,rM.b64str2ab(t);case 5:return e.t1=e.sent,i=new e.t0(e.t1),a=new Uint8Array(4),crypto.getRandomValues(a),(s=new Uint8Array(2))[0]=0,s[1]=1,c=eM(Uint8Array,n,i,a,s),e.next=15,rM.ab2b64str(c.buffer);case 15:return u=e.sent,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),GH=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(GH||{});function HH(e){var t=e.random,r=e.serverUfrag,n=e.serverPwd,i=e.clientPwd,o=e.options,a=(new TextEncoder).encode("WPRE");t||(t=new Uint8Array(4),crypto.getRandomValues(t));var s=CM(r);s.byteLength;var c=OM(CM(i),CM(n).subarray(0,16),CM(r).subarray(0,16));c.byteLength;var u=new Uint8Array(Object.keys(o).reduce((function(e,t){var r=Number(t);return e.push(r),e.push(o[r]?1:0),e}),[]));u.byteLength;var d=eM(Uint8Array,a,t,[s.byteLength],s,[c.byteLength],c,u);return d.byteLength%3!=0&&(d=eM(Uint8Array,d,new Uint8Array(3-d.byteLength%3).fill(255))),[wM(d),wM(eM(Uint8Array,t,s.subarray(0,20)))]}var zH,KH=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=A(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(o.config.includes("level-asymmetry-allowed=1")&&o.config.includes("packetization-mode=1")&&o.config.includes("profile-level-id=42e0")){r=o.payload;break}}}catch(u){i.e(u)}finally{i.f()}for(var a=0;a<e.rtp.length;a++){var s=e.rtp[a];if("H264"===t){if(s.payload===r){e.rtp.unshift(e.rtp.splice(a,1)[0]);break}}else if(s.codec===t){e.rtp.unshift(e.rtp.splice(a,1)[0]);break}}var c=[];e.rtp.forEach((function(e){return c.push(e.payload)})),e.payloads=c.join(" ")}},XH=new FU("BasicHandler",3),WH={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!zG()||void 0};function qH(e){if(void 0===zH){var t=navigator.userAgent.toLowerCase();zH=t.includes("mobile")}return zH?Math.ceil(e):e}var YH=function(e){f(d,e);var t,r,n,a,s=g(d);function d(e,t){var r;return u(this,d),h(m(r=s.call(this)),"_peerConnection",void 0),h(m(r),"_dataChannel",void 0),h(m(r),"_context",void 0),h(m(r),"monitor",void 0),h(m(r),"_offerIce",{}),h(m(r),"_answerIce",{}),h(m(r),"_initSctpEvents",!1),h(m(r),"_nextSsrc",Math.floor(Math.random()*OH+1e4)),h(m(r),"_aSendonlyAnswerTpl",void 0),h(m(r),"_vSendonlyAnswerTpl",void 0),h(m(r),"_enableSubFlexfec",!1),h(m(r),"audioTrack4ff",void 0),h(m(r),"connection_id",""),h(m(r),"ms_addr",""),r.monitor=e,r._peerConnection=new RTCPeerConnection(WH),r._dataChannel=r._peerConnection.createDataChannel("signaling",{negotiated:!0,id:100}),r._context=t,r._dataChannel.binaryType="arraybuffer",r._peerConnection.ontrack=function(e){var t,n,i=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;XH.print("constructor","pc.ontrack ".concat(e.track.kind," ").concat(e.track.id," ").concat(i)),"ff-stream"===i&&(r.audioTrack4ff=e.track),r.emit("ontrack",e)},r._peerConnection.onconnectionstatechange=function(e){XH.print("constructor","onconnectionstatechange ".concat(r._peerConnection.iceConnectionState," -> ").concat(r._peerConnection.connectionState)),"failed"!==r._peerConnection.iceConnectionState&&"closed"!==r._peerConnection.iceConnectionState&&"failed"!==r._peerConnection.connectionState||r.emit("disconnect")},r._peerConnection.oniceconnectionstatechange=function(){var t=r._peerConnection.iceConnectionState;e.rtcPreIceState(t,ej["".concat(t.toUpperCase())],r.connection_id,{ms_addr:r.ms_addr})},r}return l(d,[{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){XH.print("destroy"),this.disconnect(),this._context=void 0}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"_simulcast",value:function(e,t,r,n,o){var a=[];1===e.videoEncodeConfig.length?(a=function(e,t){var r=[];if(t<=1)return r;var n=1,i=1;return e.width/e.height>16/9?(n=e.width/xG.width,i=e.width/PG.width):(n=e.height/xG.height,i=e.height/PG.height),r.push({maxkbps:xG.maxkbps,scaleResolutionDownBy:n,frameRate:xG.frameRate,width:Math.floor(e.width/n),height:Math.floor(e.height/n)}),t<=2||n>2&&r.unshift({maxkbps:PG.maxkbps,scaleResolutionDownBy:i,frameRate:PG.frameRate,width:Math.floor(e.width/i),height:Math.floor(e.height/i)}),r}(t,o),XH.print("simulcast() ","simulcastLayers: %o",a)):(a=e.videoEncodeConfig.slice(1).slice(1-o).map((function(e){return i({frameRate:e.frameRate||15,maxkbps:e.maxKbps||600},wG(t,e))})),XH.print("simulcast() ","simulcastLayers2: %o",a)),a.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:qH(e.scaleResolutionDownBy),rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)})}))}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,o=e.enableSimulcast,a=e.pubAudio,s=e.pubVideo,c={direction:"sendonly",streams:[t]},u={direction:"sendonly",streams:[t]},d=[],l=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var h=null==r?void 0:r.getTrack(),f={width:640,height:360,frameRate:30};if(h){var p=null==h?void 0:h.getSettings();f={width:Math.floor(p.width),height:Math.floor(p.height),frameRate:Math.floor(p.frameRate)}}var v=null==e?void 0:e.videoEncodeConfig[0],_=wG(f,v);e.prevScaleResolutionDownBy=_.scaleResolutionDownBy,e.prevBitrate=v.maxKbps,e.videoInputConfig=f;var m={maxBitrate:1e3*v.maxKbps,scaleResolutionDownBy:qH(_.scaleResolutionDownBy),rid:"0",maxFramerate:v.frameRate||15};if(u.sendEncodings=[m],d.push({width:_.width,height:_.height,framerate:v.frameRate,maxkbps:v.maxKbps,rid:"0"}),!oM&&o){var y,g,S=function(e){for(var t=0,r=e.width*e.height,n=0;n<OG.length;n++)if(r>=OG[n].totalPixels){t=n;break}if(0===t)return OG[t].maxLayers;var i=OG[t-1].totalPixels;return(i-r)/(i-OG[t].totalPixels)<.1?OG[t-1].maxLayers:OG[t].maxLayers}(_);if(XH.print("simulcast() ","maxLayers: %o",S),S>1)this._simulcast(e,f,u,d,S),null!==(y=this._context)&&void 0!==y&&null!==(g=y.serverConfig)&&void 0!==g&&g.simulcastOnDemand&&(l=d.map((function(e,t){return i(i({},e),{},{video_index:t,sub_index:t})}))),XH.print("subVideoDesc","desc: %o ",l)}}XH.print("publish videoTransceiverInit videoDescriptions","",u,d);var E=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==re.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(E=null==n?void 0:n.mixedAudioTrack),E=a&&E?E:"audio";var b=null==r?void 0:r.getTrack("preprocessing");b=s&&b?b:"video";try{this.monitor.rtcInvokeStatus(JSON.stringify({aTrack:RM(E),vTrack:RM(b),audioTransceiverInit:c,videoTransceiverInit:u}),0,"Handler.internalPublish","",0)}catch(EZ){}return{semantics:"unified-plan",videoDescriptions:d,subVideoDescriptions:l,audioTransceiverInit:{track:E,init:c},videoTransceiverInit:{track:b,init:u}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;XH.print("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void XH.print("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var u;c.encodings=null==c||null===(u=c.encodings)||void 0===u?void 0:u.map((function(t){var r,n=+t.rid||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this.monitor.rtcInvokeStatus(JSON.stringify(c.encodings),0,"Handler.updateScaleResolutionDownBy","",0)}catch(EZ){}}}else XH.print("updateMaxBitrate()","no pub")}},{key:"updateScaleResolutionDownBy",value:(a=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(XH.print("updateScaleResolutionDownBy()"),i=null===(r=t.videoTrack)||void 0===r?void 0:r.getTrack(),a=t.videoTransceiver,i&&t.pubVideo&&a){e.next=6;break}return XH.print("updateScaleResolutionDownBy()","no pub"),e.abrupt("return");case 6:if(s=null==i?void 0:i.getSettings(),c={width:Math.floor(s.width),height:Math.floor(s.height),frameRate:Math.floor(s.frameRate)},(u=wG(c,t.videoEncodeConfig[0])).scaleResolutionDownBy===t.prevScaleResolutionDownBy&&XH.print("updateScaleResolutionDownBy()","no change %o",t.prevScaleResolutionDownBy),d=null===(n=a.sender)||void 0===n?void 0:n.getParameters()){h=u.scaleResolutionDownBy/t.prevScaleResolutionDownBy,d.encodings=null==d||null===(l=d.encodings)||void 0===l?void 0:l.map((function(e){var r;Math.max(e.scaleResolutionDownBy=(e.scaleResolutionDownBy||1)*h,1);var n=+e.rid||0;return e.maxFramerate=(null===(r=t.videoEncodeConfig[n])||void 0===r?void 0:r.frameRate)||e.maxFramerate,e})),t.prevScaleResolutionDownBy=u.scaleResolutionDownBy,t.videoInputConfig=c,null==a||a.sender.setParameters(d);try{this.monitor.rtcInvokeStatus(JSON.stringify(d.encodings),0,"Handler.updateScaleResolutionDownBy","",0)}catch(EZ){}}case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getStats",value:function(e,t){return LG(this._peerConnection,e,t)}},{key:"setLocalDescription",value:(n=c(o().mark((function e(t,r){var n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=$N(),e.prev=1,e.next=4,this._peerConnection.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:t}));case 4:this.monitor.rtcSetDescription(0,t,oj.W_1,"local"===(null==r?void 0:r.streamUserId)?aj.UP:aj.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",$N()-n,this.connection_id,{type:"offer",ms_addr:this.ms_addr}),this._initSctpEvents||(this._initSctpEvents=!0,(a=null===(i=this._peerConnection)||void 0===i?void 0:i.sctp)&&(a.onstatechange=function(){s.monitor.rtcInvokeStatus("sctp state change TO: ".concat(a.state),0,"sctp","",0,{ms_addr:s.ms_addr},s.connection_id)},a.transport&&(a.transport.onstatechange=function(){var e;s.monitor.rtcInvokeStatus("dtls state change TO: ".concat(null==a||null===(e=a.transport)||void 0===e?void 0:e.state),0,"dtls","",0,{ms_addr:s.ms_addr},s.connection_id)}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this.monitor.rtcSetDescription(-1,e.t0.message+t,oj.W_1,"local"===(null==r?void 0:r.streamUserId)?aj.UP:aj.DOWN,"","",$N()-n,this.connection_id,{type:"offer",ms_addr:this.ms_addr});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=$N(),e.prev=1,e.next=4,this._peerConnection.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this.monitor.rtcSetDescription(0,t,oj.W_0,"local"===(null==r?void 0:r.streamUserId)?aj.UP:aj.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",$N()-n,this.connection_id,{type:"answer",ms_addr:this.ms_addr}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this.monitor.rtcSetDescription(-1,e.t0.message+t,oj.W_1,"local"===(null==r?void 0:r.streamUserId)?aj.UP:aj.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",$N()-n,this.connection_id,{type:"answer",ms_addr:this.ms_addr});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineAnswerTpl",value:function(e){var t=this;KG.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r=null==e?void 0:e.rtp.find((function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n=null==e?void 0:e.fmtp.find((function(e){return e.payload===r.payload}));n&&t._context&&(n.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&r.includes("flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n=r.codec,i=r.payload;if(["vp8","h264"].includes(n.toLocaleLowerCase())){var o=e.fmtp.find((function(e){return e.payload===i}));o?o.config=[].concat(k(o.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";"):e.fmtp.push({payload:i,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}}]),d}(OU.exports.EventEmitter),JH=Re,QH=Sf,ZH=Rl.exports.getWeakData,$H=Xh,ez=Fr,tz=Ue,rz=Je,nz=Hh,iz=Kt,oz=Ln.set,az=Ln.getterFor,sz=Ra.find,cz=Ra.findIndex,uz=JH([].splice),dz=0,lz=function(e){return e.frozen||(e.frozen=new hz)},hz=function(){this.entries=[]},fz=function(e,t){return sz(e.entries,(function(e){return e[0]===t}))};hz.prototype={get:function(e){var t=fz(this,e);if(t)return t[1]},has:function(e){return!!fz(this,e)},set:function(e,t){var r=fz(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=cz(this.entries,(function(t){return t[0]===e}));return~t&&uz(this.entries,t,1),!!~t}};var pz,vz={getConstructor:function(e,t,r,n){var i=e((function(e,i){$H(e,o),oz(e,{type:t,id:dz++,frozen:void 0}),tz(i)||nz(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=az(t),s=function(e,t,r){var n=a(e),i=ZH(ez(t),!0);return!0===i?lz(n).set(t,r):i[n.id]=r,e};return QH(o,{delete:function(e){var t=a(this);if(!rz(e))return!1;var r=ZH(e);return!0===r?lz(t).delete(e):r&&iz(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!rz(e))return!1;var r=ZH(e);return!0===r?lz(t).has(e):r&&iz(r,t.id)}}),QH(o,r?{get:function(e){var t=a(this);if(rz(e)){var r=ZH(e);return!0===r?lz(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},_z=ce,mz=Re,yz=Sf,gz=Rl.exports,Sz=yf,Ez=vz,bz=Je,kz=Xl,Tz=Ln.enforce,Iz=mn,Az=!_z.ActiveXObject&&"ActiveXObject"in _z,Rz=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Cz=Sz("WeakMap",Rz,Ez);if(Iz&&Az){pz=Ez.getConstructor(Rz,"WeakMap",!0),gz.enable();var wz=Cz.prototype,Oz=mz(wz.delete),xz=mz(wz.has),Pz=mz(wz.get),Dz=mz(wz.set);yz(wz,{delete:function(e){if(bz(e)&&!kz(e)){var t=Tz(this);return t.frozen||(t.frozen=new pz),Oz(this,e)||t.frozen.delete(e)}return Oz(this,e)},has:function(e){if(bz(e)&&!kz(e)){var t=Tz(this);return t.frozen||(t.frozen=new pz),xz(this,e)||t.frozen.has(e)}return xz(this,e)},get:function(e){if(bz(e)&&!kz(e)){var t=Tz(this);return t.frozen||(t.frozen=new pz),xz(this,e)?Pz(this,e):t.frozen.get(e)}return Pz(this,e)},set:function(e,t){if(bz(e)&&!kz(e)){var r=Tz(this);r.frozen||(r.frozen=new pz),xz(this,e)?Dz(this,e,t):r.frozen.set(e,t)}else Dz(this,e,t);return this}})}var Nz=function(e){f(E,e);var t,r,n,i,a,s,d,p,v,_,y,S=g(E);function E(){var e,t,r;return u(this,E),h(m(r=S.call(this)),"inited",!1),h(m(r),"deviceMap",{audioinput:new Map,audiooutput:new Map,videoinput:new Map}),h(m(r),"checkDeviceChangeTimer",null),h(m(r),"isSupportedPermissionsQuery",!1),h(m(r),"isGrantedMicrophonePermission",!1),h(m(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!tM()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(m(r)),!tM()&&r.refreshDevices(),r}return l(E,[{key:"refreshDevices",value:(y=c(o().mark((function e(){var t,r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!oM){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return y.apply(this,arguments)})},{key:"initListener",value:(_=c(o().mark((function e(){var t,r,n,i,a=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){a._handleDeviceChange(),setTimeout((function(){a._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){a._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){a.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){a.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return _.apply(this,arguments)})},{key:"_handleDeviceChange",value:(v=c(o().mark((function e(){var t,r,n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,!oM){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:t=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:r=(r=e.sent).filter((function(e){return!!e.deviceId})),t&&t.getTracks().forEach((function(e){return e.stop()})),n=Array.from([].concat(k(this.deviceMap.audioinput.values()),k(this.deviceMap.videoinput.values()),k(this.deviceMap.audiooutput.values()))),r.forEach((function(e){var t=i.deviceMap[e.kind].get(e.deviceId);i.deviceMap[e.kind].set(e.deviceId,e),t||(e.kind.includes("video")?i.emit(oe.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):e.kind.includes("audio")&&i.emit(oe.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),n.forEach((function(e){r.find((function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(i.deviceMap[e.kind].delete(e.deviceId),e.kind.includes("video")?i.emit(oe.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):e.kind.includes("audio")&&i.emit(oe.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"getUserMedia",value:(p=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(d=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=r.filter((function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=r.filter((function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return d.apply(this,arguments)})},{key:"getPermissions",value:(s=c(o().mark((function e(){var t,r,n,i,a,s,c,u=this,d=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=d.length>0&&void 0!==d[0]?d[0]:{},n=r.audio,i=r.video,a=r.force,n||i||(n=!0,i=!0),s={audio:!1,video:!1},a){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return s.audio=!0,s.video=!0,e.abrupt("return",s);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return s.audio=this.isGrantedMicrophonePermission,s.video=this.isGrantedCameraPermission,e.abrupt("return",s);case 18:case 26:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(c=e.sent,!n||!i){e.next=28;break}if(!c.audio||!c.video){e.next=26;break}return e.abrupt("return",c);case 28:if(!(n&&c.audio||i&&c.video)){e.next=30;break}return e.abrupt("return",c);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=33;break}return e.next=33,navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),n&&(s.audio=!0,u.isGrantedMicrophonePermission=!0),i&&(s.video=!0,u.isGrantedCameraPermission=!0))})).catch((function(){}));case 33:return e.next=35,this.refreshDevices();case 35:return e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"enumerateDevices",value:(a=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Array.from([].concat(k(this.deviceMap.audioinput.values()),k(this.deviceMap.videoinput.values()),k(this.deviceMap.audiooutput.values()))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Array.from(this.deviceMap.audioinput.values()));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Array.from(this.deviceMap.videoinput.values()));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Array.from(this.deviceMap.audiooutput.values()));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",r.find((function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),E}(GU),Mz=new Nz;!tM()&&(window.__rtc_dd__=Mz);var Lz=function(){function e(){u(this,e),h(this,"_audioContextInstance",void 0)}return l(e,[{key:"getAudioContextInstance",value:function(){if(!this._audioContextInstance){var e=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new e}return this._audioContextInstance}}]),e}(),Uz=function(){function e(t){u(this,e),h(this,"_ctx",void 0),h(this,"_analyserNode",void 0),h(this,"_audioSource",void 0);var r=Vz.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;return l(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;return t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))})),r/128*255}},{key:"resume",value:(t=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),Vz=new Lz,Fz=function(e){return e[e.CAPTURE=0]="CAPTURE",e[e.PRE_PROCESSING=1]="PRE_PROCESSING",e[e.ENCODE=2]="ENCODE",e[e.TRANSFER=3]="TRANSFER",e[e.POST_PROCESSING=4]="POST_PROCESSING",e[e.DECODE=5]="DECODE",e[e.RENDERING=6]="RENDERING",e}(Fz||{}),Bz=function(){function e(){u(this,e),h(this,"_plugins",new Map),h(this,"_monitor",void 0)}var t;return l(e,[{key:"setMinotor",value:function(e){this._monitor=e}},{key:"register",value:function(e){e.monitor=this._monitor;var t=this._plugins.get(e.type)||[];if(t.findIndex((function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){return(this._plugins.get(e)||[]).find((function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=A(r),e.prev=3,i.s();case 5:if((a=i.n()).done){e.next=12;break}return s=a.value,e.next=9,s.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),jz=new FU("VERTC",0),Gz=new WeakMap,Hz=function(e){f(r,e);var t=g(r);function r(e,n){var i;return u(this,r),h(m(i=t.call(this)),"sourceType",1),h(m(i),"mediaType",void 0),h(m(i),"_trackId",void 0),i._trackId=e,i.mediaType=n,i}return l(r,[{key:"getId",value:function(){return this._trackId}}]),r}(GU),zz=function(e){f(n,e);var t,r=g(n);function n(e,t,i){var o;return u(this,n),h(m(o=r.call(this,t,i)),"_mediaTrack",void 0),h(m(o),"_preProcessingTrack",void 0),h(m(o),"handleTrackEnded",(function(){wj.rtcError("track-ended mediaType: ".concat(o._mediaTrack.kind),-1001),o.emit("track-ended",m(o))})),o._mediaTrack=e,o._initListeners(),o}return l(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.getPreProcessingTrack(this);case 3:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.error(e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(e){return t.apply(this,arguments)})},{key:"close",value:function(){var e,t,r;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._mediaTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._preProcessingTrack)||void 0===t||t.stop(),null===(r=this._mediaTrack)||void 0===r?void 0:r.stop()}},{key:"_initListeners",value:function(){this._mediaTrack instanceof MediaStreamTrack&&this._mediaTrack.addEventListener("ended",this.handleTrackEnded)}}]),n}(Hz),Kz=function(e){f(r,e);var t=g(r);function r(e,n,i){var o;return u(this,r),h(m(o=t.call(this,n,i)),"_mediaTrack",void 0),o._mediaTrack=e,o}return l(r,[{key:"getTrack",value:function(){return this._mediaTrack}}]),r}(Hz),Xz=function(e){f(n,e);var t,r=g(n);function n(e,t){var i;return u(this,n),h(m(i=r.call(this,e,t,"video")),"resolution",void 0),h(m(i),"dummy",!1),i.resolution={width:0,height:0},i}return l(n,[{key:"updateVideoCaptureConfig",value:(t=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return jz.print("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=i({},t)).contentHint,e.next=7,this.getTrack().applyConstraints(r);case 7:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){this._mediaTrack&&"contentHint"in this._mediaTrack&&["text","motion","detail"].includes(e)&&(this._mediaTrack.contentHint=e)}}]),n}(zz),Wz=function(e){f(n,e);var t,r=g(n);function n(e,t){var i;return u(this,n),h(m(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),h(m(i),"_audioLevelFetcher",void 0),h(m(i),"mixedAudioTrack",void 0),h(m(i),"mixType",re.PLAYOUT_AND_PUBLISH),i}return l(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new Uz(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return jz.print("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(zz),qz=function(e){f(r,e);var t=g(r);function r(e,n){return u(this,r),t.call(this,e,n,"video")}return l(r)}(Kz),Yz=function(e){f(r,e);var t=g(r);function r(e,n){var i;return u(this,r),h(m(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return l(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new Uz(this.getTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(Kz),Jz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_MAIN),e}return l(r)}(Wz),Qz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_MAIN),e}return l(r)}(Xz),Zz=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_MAIN),h(m(e),"sourceType",0),e}return l(r)}(Xz),$z=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_MAIN),h(m(e),"sourceType",0),e}return l(r)}(Wz),eK=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_SCREEN),e}return l(r)}(Xz),tK=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_SCREEN),e}return l(r)}(Wz),rK=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_SCREEN),h(m(e),"sourceType",0),e}return l(r)}(Xz),nK=function(e){f(r,e);var t=g(r);function r(){var e;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return h(m(e=t.call.apply(t,[this].concat(i))),"streamIndex",L.STREAM_INDEX_SCREEN),h(m(e),"sourceType",0),e}return l(r)}(Wz);function iK(e,t){return oK.apply(this,arguments)}function oK(){return(oK=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new Qz(t,ZN())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function aK(e,t){return sK.apply(this,arguments)}function sK(){return(sK=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new eK(t,ZN())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function cK(e,t){return uK.apply(this,arguments)}function uK(){return(uK=c(o().mark((function e(t,r){var n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",e.prev=1,jz.print("createCameraVideoTrack","constraints:",t),wj.rtcVideoCaptureEvent({event_type:kj.START,media_device_id:a}),s=$N(),e.next=7,Mz.getUserMedia({video:t});case 7:i=e.sent,wj.rtcVideoCaptureEvent({event_type:kj.START_CAPTURE_RESULT,media_device_id:a,reason:Tj.SUCCESS,elapse:$N()-s}),e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(1),wj.rtcVideoCaptureEvent({event_type:kj.RUNNING_FAILED,media_device_id:a,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new hD(dD.GET_VIDEO_TRACK_FAILED,"throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ").concat(e.t0.message||"unknown message","."),e.t0);case 15:return c=i.getVideoTracks()[0],Gz.set(c,i),u=new Qz(c,ZN()),e.next=20,u.generatePreProcessingTrack(r);case 20:return e.abrupt("return",u);case 21:case"end":return e.stop()}}),e,null,[[1,11]])})))).apply(this,arguments)}function dK(e,t,r){return lK.apply(this,arguments)}function lK(){return(lK=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v,_,m;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jz.print("createMicrophoneAudioTrack","constraints:",t),s=(null==t||null===(i=t.deviceId)||void 0===i?void 0:i.exact)||"default",c=(null==n?void 0:n.config)||{},u=c.sampleRate,d=c.channel,l=c.agc,h=c.ans,f=c.aec,void 0===t.sampleRate&&(t.sampleRate=u),void 0===t.channelCount&&(t.channelCount=d),void 0===t.autoGainControl&&(t.autoGainControl=l),void 0===t.noiseSuppression&&(t.noiseSuppression=h),void 0===t.echoCancellation&&(t.echoCancellation=f),e.prev=8,wj.rtcVideoCaptureEvent({event_type:kj.START,media_device_id:s}),p=$N(),(v=r.getPluginByName(Fz.PRE_PROCESSING,"RTCAIAnsExtension"))&&(v.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=15,Mz.getUserMedia({audio:t});case 15:a=e.sent,wj.rtcVideoCaptureEvent({event_type:kj.START_CAPTURE_RESULT,media_device_id:s,reason:Tj.SUCCESS,elapse:$N()-p}),e.next=23;break;case 19:throw e.prev=19,e.t0=e.catch(8),wj.rtcVideoCaptureEvent({event_type:kj.RUNNING_FAILED,media_device_id:s,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new hD(dD.GET_AUDIO_TRACK_FAILED,"throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ").concat(e.t0.message||"unknown message","."),e.t0);case 23:return _=a.getAudioTracks()[0],Gz.set(_,a),m=new Jz(_,ZN()),e.next=28,m.generatePreProcessingTrack(r);case 28:return e.abrupt("return",m);case 29:case"end":return e.stop()}}),e,null,[[8,19]])})))).apply(this,arguments)}function hK(){return fK.apply(this,arguments)}function fK(){return fK=c(o().mark((function e(){var t,r,n,i,a,s,c,u,d,l=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]&&l[0],r=l.length>1?l[1]:void 0,n=l.length>2?l[2]:void 0,jz.print("createScreenTracks","withAudio: %o, constraints: %o",t,n),e.prev=4,wj.rtcVideoCaptureEvent({event_type:kj.START,media_device_id:"screen"}),a=$N(),e.next=9,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!aM||16!==uM))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 9:i=e.sent,wj.rtcVideoCaptureEvent({event_type:kj.START_CAPTURE_RESULT,media_device_id:"screen",reason:Tj.SUCCESS,elapse:$N()-a}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(4),wj.rtcVideoCaptureEvent({event_type:kj.RUNNING_FAILED,media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new hD(dD.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 17:return s=i.getVideoTracks()[0],c=new eK(s,ZN()),e.next=21,c.generatePreProcessingTrack(r);case 21:if(!(u=i.getAudioTracks()[0])){e.next=27;break}return d=new tK(u,ZN()),e.next=26,d.generatePreProcessingTrack(r);case 26:return e.abrupt("return",[c,d]);case 27:return e.abrupt("return",[c,void 0]);case 28:case"end":return e.stop()}}),e,null,[[4,13]])}))),fK.apply(this,arguments)}function pK(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ZN();return new Yz(e,t)}function vK(e,t){return _K.apply(this,arguments)}function _K(){return(_K=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Zz(t,ZN()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mK(e,t){return yK.apply(this,arguments)}function yK(){return(yK=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new $z(t,ZN()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function gK(e,t){return SK.apply(this,arguments)}function SK(){return(SK=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new rK(t,ZN()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function EK(e,t){return bK.apply(this,arguments)}function bK(){return(bK=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new nK(t,ZN()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var kK=Wz,TK=function(e){return e[e.NONE=0]="NONE",e}(TK||{}),IK=function(){function e(){u(this,e)}return l(e,null,[{key:"getNalunits",value:function(t){if(t.length-t.position<4)return[];var r=t.position;return 1===t.getInt32(r)||0===t.getInt16(r)&&1===t.getInt8(r+2)?e.getAnnexbNals(t):e.getAvccNals(t)}},{key:"getAnnexbNals",value:function(t){for(var r=[],n=e.getHeaderPositionAnnexB(t),i=n.pos,o=i;i<t.length-4;){var a=new Uint8Array(t.buffer.slice(i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var s={header:a,body:new Uint8Array(t.buffer.slice(i+a.byteLength,o)),type:-1};e.analyseNal(s),s.type<=9&&0!==s.type&&r.push(s),t.skip(o-t.position),i=o}return r}},{key:"getAvccNals",value:function(t){for(var r=[];t.position<t.length-4;){var n=t.getInt32(t.position);if(!(t.length-t.position>=n))break;var i=new Uint8Array(t.buffer.slice(t.position,t.position+4));t.skip(4);var o=new Uint8Array(t.buffer.slice(t.position,t.position+n));t.skip(n);var a={header:i,body:o,type:-1};e.analyseNal(a),a.type<=9&&0!==a.type&&r.push(a)}return r}},{key:"analyseNal",value:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}}]),e}(),AK=function(){function e(t){u(this,e),h(this,"_position",0),h(this,"_dataview",void 0),this._dataview=new DataView(t)}return l(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),RK=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(RK||{}),CK=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),wK=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),OK=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)};function xK(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function PK(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0;255===e[t]&&t<e.byteLength;)t++,r+=255;return t<e.byteLength&&(r+=e[t++]),[r,t]}var DK=function(){function e(){u(this,e)}return l(e,null,[{key:"generateSEI",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Uint8Array([0,0,0,1]),n=new Uint8Array([6]),i=new Uint8Array([5]),o=t?CK:wK,a=xK(e.byteLength+o.byteLength),s=OK(e);return new Uint8Array([].concat(k(r),k(n),k(i),k(a),k(o),k(s),[128]))}},{key:"decodeSeiBody",value:function(e){var t=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)}(e=e.slice(0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=b(PK(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=wK.byteLength&&i>=wK.byteLength&&t.slice(r,r+wK.byteLength).toString()===wK.toString()?(r+=wK.byteLength,o=1):t.byteLength>=wK.byteLength&&i>=wK.byteLength&&t.slice(r,r+CK.byteLength).toString()===CK.toString()&&(r+=CK.byteLength,o=0),{type:o,payload:t.slice(r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new Map,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=b(PK(e.payload,r),2),i=n[0];r=n[1];var o=b(PK(e.payload,r),2),a=o[0];if(r=o[1],t.get(i)||!(a<=e.payload.byteLength-r))break;t.set(i,e.payload.slice(r,r+a)),r+=a}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=A(e);try{for(n.s();!(t=n.n()).done;){var i=b(t.value,2),o=i[0],a=i[1],s=xK(o),c=xK(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=r.reduce((function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return r.reduce((function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),NK=function(){function e(t){u(this,e),h(this,"player",void 0),h(this,"_stream",void 0),h(this,"_timer",void 0),h(this,"client",void 0),h(this,"handler",void 0),h(this,"monitor",void 0),this._stream=t}return l(e,[{key:"setVar",value:function(e,t,r){this.client=e,this.handler=t,this.monitor=r}},{key:"delStatsEvtInterval",value:function(){var e;clearTimeout(this._timer),this._timer=void 0,null===(e=this.monitor)||void 0===e||e.rtcInvokeStatus("".concat((new Error).stack),0,"del_media_statistics_timer",this._stream.streamId||"",0)}},{key:"filterIllegal",value:function(e){var t={};return Object.keys(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){var e;null===(e=this.monitor)||void 0===e||e.rtcInvokeStatus("".concat((new Error).stack),0,"media_statistics_destroy","".concat(this._stream.streamId),0),this.delStatsEvtInterval()}}]),e}(),MK=function(e){f(i,e);var t,r,n=g(i);function i(e){var t;return u(this,i),(t=n.call(this,e))._stream=e,t}return l(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t,r){var n,i,a,s=this;if(!this._timer){this.setVar(e,t,r),e.once(hG.ABNORMAL_DISCONNECTION,(function(){s.destroy()}));var u={audio:{},video:{}},d=this._stream,l=null===(n=d.audioTrack)||void 0===n?void 0:n.getTrack("preprocessing"),h=null===(i=d.videoTrack)||void 0===i?void 0:i.getTrack("preprocessing");this.getAudioStats(l,u,null===(a=d.audioTrack)||void 0===a?void 0:a.getAudioLevel()),this.getVideoStats(h,u),this.delStatsEvtInterval();var f=function(){var e=c(o().mark((function e(){var t,r,n,i,a,c,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=d.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),a=null===(r=d.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,s.getAudioStats(i,u,null===(n=d.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return c=e.sent,e.next=7,s.getVideoStats(a,u);case 7:return l=e.sent,e.abrupt("return",{audioStats:c,videoStats:l,isScreen:d.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),p=function(){var e=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f();case 2:r=e.sent,null===(t=s.client)||void 0===t||t.emit("onLocalStreamStats",r),s._timer&&clearTimeout(s._timer),s._timer=setTimeout(p,2e3);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();this._timer&&clearTimeout(this._timer),this._timer=setTimeout(p,2e3)}}},{key:"unpublish",value:function(){this.delStatsEvtInterval()}},{key:"getAudioStats",value:(r=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i={},a={timestamp:Date.now()},s=this._stream,c=s.streamId,u=s.audioMid,d=s.isScreen,l=s.pubAttributes,h=s.pubAudio,f={media_type:"audio",is_screen:!!d,direction:"up",stream_id:c,vid:u,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:l.localaudio?"capture_state_on":"capture_state_off",mute_state:h?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",i);case 6:return e.next=8,this.handler.getStats(t);case 8:if((p=e.sent).length){e.next=11;break}return e.abrupt("return",i);case 11:if(p.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,o=e.bytesSent,s=e.clockRate,c=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,_=e.nominated,m=e.id,y=e.currentRoundTripTime,g=e.state,S=e.writable,E=e.requestsReceived,b=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,A=e.jitter,R=e.candidateType,C=e.ip,w=e.address,O=e.networkType,x=e.port,P=e.protocol,D=e.nackCount,N=e.retransmittedBytesSent,M=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(a.packetsSent=r,a.bytesSent=o,f.bytes=o,f.packetsSent=r,f.nackCount=D,f.ssrc=U,f.retransmitted_bytes_sent=N,f.retransmitted_packets_sent=M,a.retransmittedBytesSent=N,a.retransmittedPacketsSent=M):"remote-inbound-rtp"===t?(a.packetsLost=n,f.packetsLost=n,f.net_jitter=1e3*A,i.rtt=1e3*c,f.rtt=i.rtt,i._fractionLost=j||0):"codec"===t?(i.recordSampleRate=s,i.numChannels=u,f.codecName=l):"media-source"===t&&void 0!==d?(f.audio_level=d?-10*Math.log10(Math.pow(d,2)):d,f.volume=255*d,f.total_audio_energy=V,f.totalInputDuration=F):"ssrc"===t&&"audio"===B?f.send_level=L:"candidate-pair"===t?(f.ice_available_incoming_bitrate=h,f.ice_available_outgoing_bitrate=p,f.ice_bytes_received=v,f.ice_bytes_sent=o,f.ice_nominated=+_,f.ice_pair_id=m,f.ice_pair_rtt=y,f.ice_pair_state=g,f.ice_pair_writable=S,f.recv_ping_requests=E,f.recv_ping_responses=b,f.sent_ping_requests_before_first_response=k,f.sent_ping_requests_total=k+(T||0),f.sent_ping_responses=I):"local-candidate"===t?(f.local_candidate_type=R,f.local_ip=C||w,f.local_network_type=O,f.local_port=x,f.protocol=P):"remote-candidate"===t&&(f.remote_candidate_type=R,f.remote_ip=C||w,f.remote_port=x);var G=nG("STATS_SCALLBACK_SUPPORT");iM&&G||"media-source"===t&&(f.send_level=d)})),void 0===f.volume&&void 0!==n&&(f.volume=n,f.audio_level=n?-10*Math.log10(Math.pow(n/255,2)):n),(v=r.audio).timestamp){e.next=17;break}return r.audio=a,e.abrupt("return",this.filterIllegal(i));case 17:return void 0!==a.packetsLost&&(i.audioLossRate=(a.packetsLost-v.packetsLost)/(a.packetsSent-v.packetsSent),i.audioLossRate=Number.isNaN(i.audioLossRate)?0:i.audioLossRate,f.fraction_lost=i.audioLossRate),i.statsInterval=a.timestamp-v.timestamp,f.stats_interval=i.statsInterval,i.sendKBitrate=(a.bytesSent-v.bytesSent||0)/i.statsInterval*8,f.mediaBitratebps=Math.round(1e3*i.sendKBitrate),f.bandwidth=Math.round(f.mediaBitratebps/1024),void 0!==a.retransmittedBytesSent&&(f.retransmitBitratebps=(a.retransmittedBytesSent-v.retransmittedBytesSent||0)/i.statsInterval),r.audio=a,this.monitor.rtcMediaStatistics(f,{}),i._retransmittedRate=(a.retransmittedPacketsSent-v.retransmittedPacketsSent)/(a.packetsSent-v.packetsSent),void 0===i.audioLossRate&&(i.audioLossRate=i._retransmittedRate,f.fraction_lost=i.audioLossRate),i._fractionLost=Math.max(i._fractionLost,i.audioLossRate),e.abrupt("return",this.filterIllegal(i));case 30:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i={},a={timestamp:Date.now(),simulcast:{}},s=this._stream,c=s.streamId,u=s.videoMid,d=s.isScreen,l=s.pubAttributes,h=s.enableSimulcast,f=s.pubVideo,p={media_type:"video",is_screen:!!d,direction:"up",stream_id:c,vid:u,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:l.localvideo?"capture_state_on":"capture_state_off",mute_state:f?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",i);case 6:return p.cap_frame_width=t.getSettings().width,p.cap_frame_height=t.getSettings().height,i.isScreen=d,e.next=11,this.handler.getStats(t);case 11:if((v=e.sent).length){e.next=14;break}return e.abrupt("return",i);case 14:if(null===(n=this.monitor)||void 0===n||n.rtcInvokeStatus("reports.length: ".concat(v.length,"; videoTrack: ").concat(t.id),0,"get_video_stats",c||"",0),_=0,v.forEach((function(e){var n=e.type,o=e.framesEncoded,s=e.packetsLost,c=e.bytesSent,u=e.framesSent,d=e.retransmittedBytesSent,l=e.totalPacketSendDelay,f=e.totalEncodeTime,v=e.firCount,m=e.targetBitrate,y=e.roundTripTime,g=e.mimeType,S=e.frameWidth,E=e.frameHeight,b=e.packetsSent,k=e.googActualEncBitrate,T=e.googAvailableReceiveBandwidth,I=e.googAvailableSendBandwidth,A=e.googAvgEncodeMs,R=e.googBucketDelay,C=e.googEncodeUsagePercent,w=e.googFrameRateInput,O=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,P=e.bytesReceived,D=e.nominated,N=e.id,M=e.currentRoundTripTime,L=e.state,U=e.writable,V=e.candidateType,F=e.ip,B=e.address,j=e.networkType,G=e.port,H=e.nackCount,z=e.pliCount,K=e.protocol,X=e.qpSum,W=e.requestsReceived,q=e.responsesReceived,Y=e.googRetransmitBitrate,J=e.requestsSent,Q=e.consentRequestsSent,Z=e.responsesSent,$=e.ssrc,ee=e.googTargetEncBitrate,te=e.googTransmitBitrate,re=e.retransmittedPacketsSent,ne=e.encoderImplementation,ie=e.jitter,oe=e.rid,ae=e.fractionLost,se=e.googAdaptationChanges,ce=e.qualityLimitationReason,ue=e.qualityLimitationDurations,de=e.googFirsReceived,le=e.googFrameRateSent,he=e.keyFramesEncoded;"outbound-rtp"===n?(h&&(oe?a.simulcast[oe]=e:a.simulcast[_]=e,_++),a.framesEncoded=o||a.framesEncoded||0,p.key_frames_encoded=he||0,a.bytesSent=c||a.bytesSent||0,a.framesSent=u||a.framesSent||0,p.bytes=c||p.bytes||0,a.packetsSent=b||a.packetsSent||0,p.packetsSent=b||p.packetsSent||0,p.nackCount=H||p.nackCount||0,p.pli_count=z||p.pli_count||0,p.qp_sum=X||p.qp_sum||0,p.ssrc=$||p.ssrc||0,p.retransmitted_packets_sent=re,a.retransmittedPacketsSent=re,a.retransmittedBytesSent=d,p.encoder_implementation=ne,p.qualityLimitationReason=ce,p.qualityLimitationDurations=ue,void 0!==S&&((!i.encodedFrameWidth||S>i.encodedFrameWidth)&&(i.encodedFrameWidth=S),(!i.encodedFrameHeight||E>i.encodedFrameHeight)&&(i.encodedFrameHeight=E),p.frame_size_height=E,p.frame_size_width=S)):"track"===n?(i.encodedFrameWidth=S,i.encodedFrameHeight=E,p.frame_size_height=E,p.frame_size_width=S):"remote-inbound-rtp"===n?(a.packetsLost=s,i.rtt=1e3*y,p.rtt=i.rtt,p.jitter=ie,p.packetsLost=s,i._fractionLost=ae||0):"codec"===n?(i.codecType=g,p.codecName=g):"candidate-pair"===n?(p.ice_available_incoming_bitrate=O,p.ice_available_outgoing_bitrate=x,p.ice_bytes_received=P,p.ice_bytes_sent=c,p.ice_nominated=+D,p.ice_pair_id=N,p.ice_pair_rtt=M,p.ice_pair_state=L,p.ice_pair_writable=U,p.recv_ping_requests=W,p.recv_ping_responses=q,p.sent_ping_requests_before_first_response=J,p.sent_ping_requests_total=J+Q,p.sent_ping_responses=Z):"local-candidate"===n?(p.local_candidate_type=V,p.local_ip=F||B,p.local_network_type=j,p.local_port=G,p.protocol=K):"remote-candidate"===n?(p.remote_candidate_type=V,p.remote_ip=F||B,p.remote_port=G):"VideoBwe"===n?(p.encBitratebps=k,p.available_receive_bandwidth=T,p.available_send_bandwidth=I,p.bucket_delay=R,p.retransmitBitratebps=Y,p.targetEncBitratebps=ee,p.transmit_bitrate=te,i._sendBandWidth=+I):"ssrc"===n&&(p.avg_encode_ms=A,p.encodeUsage=C,p.frame_rate_input=w,p.orignal_input_Framerate=+w,p.ddaptationChanges=se,p.firsReceived=de,p.frameRateSent=le);var fe=nG("STATS_SCALLBACK_SUPPORT");if(!iM||!fe){var pe=r.video,ve=a.timestamp-pe.timestamp;if("outbound-rtp"===n){var _e=c-pe.bytesSent,me=d-pe.retransmittedBytesSent;p.encBitratebps=Math.round(8e3*(_e-me)/ve),p.bucket_delay=l/b,p.retransmitBitratebps=Math.round(8e3*me/ve),p.targetEncBitratebps=m,p.transmit_bitrate=Math.round(1e3*(c-pe.bytesSent)*8/ve),p.avg_encode_ms=1e3*f/o,p.firsReceived=v+z,p.qualityLimitationReason="bandwidth"===ce,p.qualityLimitationDurations="cpu"===ce}else"candidate-pair"===n&&(p.available_send_bandwidth=x,i._sendBandWidth=x);if(t){var ye=null==t?void 0:t.getSettings().frameRate;p.orignal_input_Framerate=ye,p.frameRateSent=t.getSettings().frameRate}}})),(m=r.video).timestamp){e.next=21;break}return r.video=a,e.abrupt("return",this.filterIllegal(i));case 21:return i.statsInterval=a.timestamp-m.timestamp,p.stats_interval=i.statsInterval,y=Object.keys(a.simulcast),h?(p.sim_enc_width=[],p.sim_enc_height=[],p.sim_enc_bps=[],p.sim_enc_framerate=[],p.sim_enc_key_frames=[],p.sim_rids=[],p.sim_enc_bandwidth=[],p.sim_sent_framerate=[],p.sim_fraction_lost=[],p.sim_keyencoded=[],p.active_sim_streams=[],p.sim_retransmittedRate=[],g=!1,y.sort((function(e,t){return+e-+t})).forEach((function(e){var t=a.simulcast[e],r=t.frameWidth,n=t.frameHeight,o=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,h=t.qualityLimitationDurations,f=t.qualityLimitationResolutionChanges,v=t.retransmittedPacketsSent,_=t.pliCount,y=t.keyFramesEncoded;void 0!==l&&(p.sim_qualityLimitationReason||(p.sim_qualityLimitationReason=[],p.sim_qualityLimitationDurations=[],p.sim_qualityLimitationResolutionChanges=[]),p.sim_qualityLimitationReason.push(l),p.sim_qualityLimitationDurations.push(h),p.sim_qualityLimitationResolutionChanges.push(f));var S=m.simulcast[e];if(p.sim_enc_width.push(r||0),p.sim_enc_height.push(n||0),p.sim_enc_key_frames.push(y||0),S){var E=(o-S.bytesSent||0)/i.statsInterval;p.sim_enc_bps.push(Math.round(8e3*E)),p.sim_enc_bandwidth.push(Math.round(8e3*E/1024));var b=1e3*(s-S.framesEncoded)/i.statsInterval;p.sim_enc_framerate.push(Math.round(b)),p.sim_rids.push(e);var k=void 0!==c?c-S.framesSent:s-S.framesEncoded,T=1e3*k/i.statsInterval;p.sim_sent_framerate.push(Math.round(T));var I=(u-S.packetsLost)/(d-S.packetsSent);i._retransmittedRate=(v-S.retransmittedPacketsSent)/(d-S.packetsSent),I=Number.isNaN(I)?0:I,p.sim_fraction_lost.push(I),p.sim_keyencoded.push(_-S.pliCount>0),p.active_sim_streams.push(E>=0),p.sim_retransmittedRate.push(i._retransmittedRate),r>0&&!g&&(i.sentKBitrate=8*E,i.encoderOutputFrameRate=b,i.encodedFrameCount=k,i.sentFrameRate=T,i.videoLossRate=I,g=!0)}})),this.monitor.rtcMediaStatistics(p,{})):(i.encodedFrameCount=void 0!==a.framesSent?a.framesSent-m.framesSent:a.framesEncoded-m.framesEncoded,i.sentKBitrate=(a.bytesSent-m.bytesSent||0)/i.statsInterval*8,p.bitrate=Math.round(1e3*i.sentKBitrate),p.bandwidth=Math.round(p.bitrate/1024),i.encoderOutputFrameRate=1e3*(a.framesEncoded-m.framesEncoded)/i.statsInterval,p.frame_rate_encoded=Math.round(i.encoderOutputFrameRate),i.sentFrameRate=1e3*i.encodedFrameCount/i.statsInterval,p.frame_rate_sent=Math.round(i.sentFrameRate),i.videoLossRate=(a.packetsLost-m.packetsLost)/(a.packetsSent-m.packetsSent),i.videoLossRate=Number.isNaN(i.videoLossRate)?0:i.videoLossRate,p.fraction_lost=i.videoLossRate,i._retransmittedRate=(a.retransmittedPacketsSent-m.retransmittedPacketsSent)/(a.packetsSent-m.packetsSent),this.monitor.rtcMediaStatistics(p,{})),r.video=a,i._fractionLost=Math.max(i._fractionLost,i.videoLossRate),e.abrupt("return",this.filterIllegal(i));case 28:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(NK),LK=function(e){f(a,e);var t,r,n,i=g(a);function a(e){var t;return u(this,a),h(m(t=i.call(this,e)),"isPaused",void 0),h(m(t),"pauseStart",void 0),h(m(t),"pauseDuration",void 0),h(m(t),"_audioStallCount",void 0),h(m(t),"_setAudioStallCount",void 0),h(m(t),"_audioStallTimer",void 0),h(m(t),"_audioStallInterval",void 0),h(m(t),"_audioStallRatio",void 0),h(m(t),"_videoInWaiting",void 0),h(m(t),"_context",void 0),t._videoInWaiting=!1,t.pauseDuration=0,t}return l(a,[{key:"setRemoteStreamStatsEvtInterval",value:(n=c(o().mark((function e(t,r,n,i){var s,u,d,l,h,f,p,v,_,m,y,g,S,E,b=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return this.setVar(t,r,n),this._context=i,t.once(hG.ABNORMAL_DISCONNECTION,(function(){b.destroy()})),this._audioStallInterval=a.audioStallInterval||100,this._audioStallRatio=a.audioStallRatio||.6,d={audio:{},video:{}},l=this._stream,h=null===(s=l.audioTrack)||void 0===s?void 0:s.getTrack(),f=null===(u=l.videoTrack)||void 0===u?void 0:u.getTrack(),this.getRemoteVideoStats(f,d),e.next=14,this.getRemoteAudioStats(h,d);case 14:this.delStatsEvtInterval(),p=0,v=0,m=[],y=0,g=$N(),this._setAudioStallCount=function(){if(tG.AUDIO_STALL&&b._audioStallInterval>0&&void 0!==d.audio.concealedSamples){var e=d.audio.concealedSamples,t=d.audio.totalSamplesReceived;g=$N();var r={isStall:!1,counted:!1,diff:0},n=.5*b._audioStallInterval;b._audioStallCount=c(o().mark((function i(){var a,s,c,u,d,h,f,_,S,E,k,T,I,A,R;return o().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(s=l.hasAudio,c=l.subAudio,s&&c){i.next=7;break}return r.isStall=!1,r.counted=!1,m.push({reason:"hasAudio: ".concat(s,", subAudio: ").concat(c)}),g=$N(),i.abrupt("return",{stall_count:p,stall_duration:v,stall_list:m,stats_count:y});case 7:return u=null===(a=l.audioTrack)||void 0===a?void 0:a.getTrack(),d=Date.now(),i.next=11,b.handler.getStats(u,!0);case 11:if(h=i.sent,f=Date.now(),_=$N(),!((S=_-g)<n)){i.next=18;break}return m.push({diff:S,start:g,end:_,get_stats_cost:f-d,get_stats_start:d,get_stats_end:f,reason:"diff(".concat(S,") < minInterval(").concat(n,")")}),i.abrupt("return",{stall_count:p,stall_duration:v,stall_list:m,stats_count:y});case 18:if(E=h.length,k=h.find((function(e){return"inbound-rtp"===e.type}))){i.next=23;break}return m.push({diff:S,start:g,end:_,get_stats_cost:f-d,get_stats_start:d,get_stats_end:f,reason:E?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:p,stall_duration:v,stall_list:m,stats_count:y});case 23:return T=k.concealedSamples,I=k.totalSamplesReceived,R=I-t,(A=T-e)>=0&&R>=0&&A>=b._audioStallRatio*R?(m.push({concealed:A,received:R,diff:S,start:g,end:_,get_stats_cost:f-d,get_stats_start:d,get_stats_end:f,is_stall:!0}),r.isStall?(r.counted?v+=S:(v=v+r.diff+S,p++),r.counted=!0):S>=200?(v+=S,p++,r.counted=!0):(r.counted=!1,r.diff=S),r.isStall=!0):(m.push({concealed:A,received:R,diff:S,start:g,end:_,get_stats_cost:f-d,get_stats_start:d,get_stats_end:f}),r.isStall=!1,r.counted=!1),e=T,t=I,g=_,y++,i.abrupt("return",{stall_count:p,stall_duration:v,stall_list:m,stats_count:y});case 32:case"end":return i.stop()}}),i)}))),_=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!b._audioStallCount&&b._setAudioStallCount&&b._setAudioStallCount(),!b._audioStallCount){e.next=6;break}return e.next=4,b._audioStallCount();case 4:b._audioStallTimer&&clearTimeout(b._audioStallTimer),b._audioStallTimer=setTimeout(_,b._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),b._audioStallTimer&&clearTimeout(b._audioStallTimer),b._audioStallTimer=setTimeout(_,b._audioStallInterval)}},this._setAudioStallCount(),S=function(){var e=c(o().mark((function e(){var t,r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null===(t=l.audioTrack)||void 0===t?void 0:t.getTrack(),i=null===(r=l.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,b.getRemoteAudioStats(n,d);case 4:return a=e.sent,p=0,v=0,m=[],y=0,e.next=11,b.getRemoteVideoStats(i,d);case 11:return s=e.sent,e.abrupt("return",{audioStats:a,videoStats:s,isScreen:l.isScreen,userId:l.userId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),E=function(){var e=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S();case 2:r=e.sent,null===(t=b.client)||void 0===t||t.emit("onRemoteStreamStats",r),_&&(g=$N(),b._audioStallTimer&&clearTimeout(b._audioStallTimer),b._audioStallTimer=setTimeout(_,b._audioStallInterval)),b._timer&&clearTimeout(b._timer),b._timer=setTimeout(E,2e3);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(E,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"delStatsEvtInterval",value:function(){E(p(a.prototype),"delStatsEvtInterval",this).call(this),clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){this.delStatsEvtInterval(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},i={},a=this._stream,s=a.streamId,c=a.userId,u=a.isScreen,d=a.audioMid,l=a.subMediaType,h=a._attributes,f=a.virtual,p={media_type:"audio",is_screen:!!u,direction:"down",stream_id:s,stream_user_id:c,vid:d,audio_mux:f,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:kM(l)?"mute_state_off":"mute_state_on",remote_user_capture_state:h.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:h.localaudio&&h.audiostream?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6:return e.next=8,this.handler.getStats(t);case 8:if((v=e.sent).length){e.next=11;break}return e.abrupt("return",n);case 11:if(v.forEach((function(e){var t=e.type,r=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,c=e.jitterBufferDelay,u=e.jitterBufferEmittedCount,d=e.clockRate,l=e.channels,h=e.totalSamplesReceived,f=e.concealedSamples,v=e.silentConcealedSamples,_=e.concealmentEvents,m=e.totalRoundTripTime,y=e.packetsDiscarded,g=e.state,S=e.currentRoundTripTime,E=e.audioLevel,b=e.totalAudioEnergy,T=e.totalSamplesDuration,I=e.mimeType,A=e.googDecodingNormal,R=e.googDecodingMuted,C=e.availableIncomingBitrate,w=e.availableOutgoingBitrate,O=e.bytesSent,x=e.nominated,P=e.id,D=e.writable,N=e.jitter,M=e.candidateType,L=e.ip,U=e.address,V=e.networkType,F=e.port,B=e.protocol,j=e.audioOutputLevel,G=e.requestsReceived,H=e.responsesReceived,z=e.requestsSent,K=e.consentRequestsSent,X=e.responsesSent,W=e.ssrc;e.kind;var q=e.nackCount,Y=e.lastPacketReceivedTimestamp,J=e.concealmentevents,Q=e.fecPacketsReceived;if("inbound-rtp"===t)i.packetsLost=r,i.packetsReceived=o,p.packetsReceived=o,p.packetsDiscarded=y,p.nackCount=q,p.lastPacketReceivedTimestamp=Y,p.concealmentevents=J,i.bytesReceived=a,void 0!==c&&(n.jitterBufferDelay=c/u*1e3,p.average_jitter_buffer_delay_ms=n.jitterBufferDelay),void 0!==h&&(i.totalSamplesReceived=h,n.concealedSamples=f,i.concealedSamples=f,i.silentConcealedSamples=v,p.concealedSamples=f,n.concealmentEvents=_,p.totalSamplesReceived=h),void 0!==Q&&(p.fec_packets_received=Q,i.fecPacketsReceived=Q),p.jitter=1e3*N,p.ssrc=W,void 0!==E&&(p.audio_level=E?-10*Math.log10(Math.pow(E,2)):E),void 0!==E&&(p.volume=255*E),void 0!==b&&(p.total_audio_energy=b),void 0!==T&&(p.totalAudioDuration=T);else if("codec"===t)n.recordSampleRate=d,l&&(n.numChannels=l),p.codecName=I;else if("candidate-pair"===t){var Z,$,ee;p.ice_available_incoming_bitrate=C,p.ice_available_outgoing_bitrate=w,p.ice_bytes_received=a,p.ice_bytes_sent=O,p.ice_nominated=+x,p.ice_pair_id=P,p.ice_pair_rtt=S,p.rtt=1e3*S,p.rtt&&null!==(Z=k._context)&&void 0!==Z&&null!==($=Z.streamRTT)&&void 0!==$&&null!==(ee=$[s])&&void 0!==ee&&ee.audio&&(p.total_rtt_ms=p.rtt+k._context.streamRTT[s].audio),p.ice_pair_state=g,p.ice_pair_writable=D,p.recv_ping_requests=G,p.recv_ping_responses=H,p.sent_ping_requests_before_first_response=z,p.sent_ping_requests_total=z+(K||0),p.sent_ping_responses=X,"succeeded"===g&&(n.rtt=1e3*S,n.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(p.audio_level=E?-10*Math.log10(Math.pow(E,2)):E,p.volume=255*E,p.total_audio_energy=b,p.totalAudioDuration=T):"ssrc"===t?(p.decodingNormal=A,p.recvAudioLevel=j,p.decodingMuted=R):"local-candidate"===t?(p.local_candidate_type=M,p.local_ip=L||U,p.local_network_type=V,p.local_port=F,p.protocol=B):"remote-candidate"===t&&(p.remote_candidate_type=M,p.remote_ip=L||U,p.remote_port=F)})),(_=r.audio).timestamp){e.next=17;break}return i.timestamp=Date.now(),r.audio=i,e.abrupt("return",this.filterIllegal(n));case 17:if(m={},void 0!==i.concealedSamples&&(p.interval_concealed_samples=i.concealedSamples-_.concealedSamples,p.interval_samples_received=i.totalSamplesReceived-_.totalSamplesReceived,p.interval_silent_concealed_samples=i.silentConcealedSamples-_.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==_.concealedSamples)){e.next=35;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=35;break}return e.next=25,this._audioStallCount();case 25:y=e.sent,g=y.stall_count,S=y.stall_duration,E=y.stall_list,b=y.stats_count,m.stall_list=E,m.stats_count=b,p.concealedSamples===p.interval_concealed_samples&&p.totalSamplesReceived===p.interval_samples_received?(p.stall_count=0,p.stall_duration=0):(p.stall_count=g,p.stall_duration=S),n.stallCount=p.stall_count,n.stallDuration=p.stall_duration;case 35:return i.timestamp=Date.now(),n.audioLossRate=(i.packetsLost-_.packetsLost)/(i.packetsReceived-_.packetsReceived+(i.packetsLost-_.packetsLost)),n.audioLossRate=Number.isNaN(n.audioLossRate)?0:n.audioLossRate,p.packetsLost=Math.round(i.packetsLost-_.packetsLost),p.fraction_lost=n.audioLossRate,n.statsInterval=i.timestamp-_.timestamp,p.stats_interval=n.statsInterval,n.receivedKBitrate=(i.bytesReceived-_.bytesReceived||0)/n.statsInterval*8,p.bandwidth=Math.round(1e3*n.receivedKBitrate/1024),void 0!==i.concealedSamples&&(n.receivedSampleRate=1e3*p.interval_samples_received/n.statsInterval),void 0!==i.fecPacketsReceived&&(p.fecBitratebps=(i.fecPacketsReceived-_.fecPacketsReceived||0)/n.statsInterval),r.audio=i,this.monitor.rtcMediaStatistics(p,{},m),e.abrupt("return",this.filterIllegal(n));case 49:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i={},a={timestamp:Date.now()},s=this._stream,c=s.streamId,u=s.userId,d=s.isScreen,l=s.subMediaType,h=s._attributes,f={media_type:"video",is_screen:!!d,direction:"down",stream_id:c,stream_user_id:u,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:TM(l)?"mute_state_off":"mute_state_on",remote_user_capture_state:h.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:h.localvideo&&h.videostream?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",i);case 6:return i.isScreen=d,e.next=9,this.handler.getStats(t);case 9:if(p=e.sent,null===(n=this.monitor)||void 0===n||n.rtcInvokeStatus("reports.length: ".concat(p.length,"; videoTrack: ").concat(t.id),0,"get_remote_video_stats",c,0),p.length){e.next=13;break}return e.abrupt("return",i);case 13:if(p.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,o=e.packetsLost,s=e.packetsReceived,u=e.bytesReceived,d=e.framesDecoded,l=e.jitterBufferDelay,h=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,_=e.availableIncomingBitrate,y=e.availableOutgoingBitrate,g=e.bytesSent,S=e.nominated,E=e.id,b=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,A=e.ip,R=e.address,C=e.networkType,w=e.port,O=e.nackCount,x=e.pliCount,P=e.protocol,D=e.requestsReceived,N=e.responsesReceived,M=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,G=e.decoderImplementation,H=e.lastPacketReceivedTimestamp;if("inbound-rtp"===t)a.packetsLost=o,f.packetsLost=o,a.packetsReceived=s,f.packetsReceived=s,a.bytesReceived=u,f.bytes=u,a.framesDecoded=d,void 0!==l&&(a.jitterBufferDelay=l/h*1e3,f.average_jitter_buffer_delay_ms=a.jitterBufferDelay),f.fir_count=v,f.nackCount=O,a.nackCount=O,f.pli_count=x,f.ssrc=V,f.jitter=F,f.framesReceived=B,a.framesReceived=B,f.framesDecoded=d,f.key_frames_decoded=j,f.decoder_name=G,f.last_packet_received_timestamp=H,void 0!==n&&(i.width=n,f.frame_size_width=n,i.height=r,f.frame_size_height=r);else if("track"===t&&void 0!==n)i.width=n,f.frame_size_width=n,i.height=r,f.frame_size_height=r,void 0!==B&&(f.framesReceived=B,a.framesReceived=B);else if("codec"===t)f.codecName=p;else if("candidate-pair"===t){var z,K,X;f.ice_available_incoming_bitrate=_,f.ice_available_outgoing_bitrate=y,f.ice_bytes_received=u,f.ice_bytes_sent=g,f.ice_nominated=+S,f.ice_pair_id=E,f.ice_pair_rtt=b,f.rtt=1e3*b,f.rtt&&null!==(z=m._context)&&void 0!==z&&null!==(K=z.streamRTT)&&void 0!==K&&null!==(X=K[c])&&void 0!==X&&X.video&&(f.total_rtt_ms=f.rtt+m._context.streamRTT[c].video),i.rtt=f.rtt,f.ice_pair_state=k,f.ice_pair_writable=T,f.recv_ping_requests=D,f.recv_ping_responses=N,f.sent_ping_requests_before_first_response=M,f.sent_ping_requests_total=M+(L||0),f.sent_ping_responses=U}else"local-candidate"===t?(f.local_candidate_type=I,f.local_ip=A||R,f.local_network_type=C,f.local_port=w,f.protocol=P):"remote-candidate"===t&&(f.remote_candidate_type=I,f.remote_ip=A||R,f.remote_port=w)})),(v=r.video).timestamp){e.next=18;break}return r.video=a,e.abrupt("return",this.filterIllegal(i));case 18:return i.videoLossRate=(a.packetsLost-v.packetsLost)/(a.packetsReceived-v.packetsReceived+(a.packetsLost-v.packetsLost)),i._retransmittedRate=(a.nackCount-v.nackCount)/(a.packetsReceived-v.packetsReceived+(a.packetsLost-v.packetsLost)),i.videoLossRate=Number.isNaN(i.videoLossRate)?0:i.videoLossRate,f.fraction_lost=i.videoLossRate,i.statsInterval=a.timestamp-v.timestamp,f.stats_interval=i.statsInterval,i.receivedKBitrate=(a.bytesReceived-v.bytesReceived||0)/i.statsInterval*8,f.bitrate=Math.round(1e3*i.receivedKBitrate),f.bandwidth=Math.round(f.bitrate/1024),i.decoderOutputFrameRate=1e3*(a.framesDecoded-v.framesDecoded)/i.statsInterval,i.receivedFrameRate=1e3*(a.framesReceived-v.framesReceived)/i.statsInterval,f.frame_rate_decoded=Math.round(i.decoderOutputFrameRate),f.frame_rate_received=Math.round(i.receivedFrameRate),r.video=a,this.processStall(this._stream,f,i,d),this.isPaused?(_=a.timestamp-(this.pauseStart||0),f.pause_duration=this.pauseDuration+(_>500?_:0),this.pauseStart=a.timestamp):f.pause_duration=this.pauseDuration,f.pause_duration=Math.min(f.stall_duration,f.pause_duration),this.pauseDuration=0,this.monitor.rtcMediaStatistics(f,{}),e.abrupt("return",this.filterIllegal(i));case 38:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=o,t.stall_duration=void 0):(t.stall_duration=o,t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){E(p(a.prototype),"destroy",this).call(this),this.delStatsEvtInterval(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){a.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,a.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),a}(NK);h(LK,"audioStallInterval",void 0),h(LK,"audioStallRatio",void 0);var UK,VK,FK,BK=new FU("Stream",0),jK=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(jK||{}),GK=function(){function e(){u(this,e),h(this,"isScreen",!1),h(this,"stream",void 0),h(this,"streamId",void 0),h(this,"audioMid",void 0),h(this,"videoMid",void 0),h(this,"seiList",[]),h(this,"videoTrack",void 0),h(this,"audioTrack",void 0),h(this,"videoTransceiver",void 0),h(this,"audioTransceiver",void 0),h(this,"videoInputConfig",void 0),h(this,"videoEncodeConfig",[aG]),h(this,"subVideoDescriptions",[]),h(this,"enableSimulcast",!1),h(this,"observer",void 0),h(this,"statsReport",void 0),h(this,"prevScaleResolutionDownBy",1),h(this,"prevBitrate",0),h(this,"pubAudio",!1),h(this,"pubVideo",!1),h(this,"pubAttributes",void 0),this.stream=new MediaStream,this.videoInputConfig={width:640,height:360,frameRate:30},this.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},this.statsReport=new MK(this)}return l(e,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return this.audioMid&&this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(zG()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i=DK.generateSEI(n.content),o=new Uint8Array(i.byteLength+t.data.byteLength);0===n.repeatCount&&e.seiList.splice(0,1),n.repeatCount--,o.set(new Uint8Array(t.data)),o.set(i,t.data.byteLength),t.data=o.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else BK.print("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else BK.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){var e;wj.rtcInvokeStatus("".concat((new Error).stack),0,"localstream_clean",this.streamId||"",0),this.audioMid=void 0,this.videoMid=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,null===(e=this.observer)||void 0===e||e.reset(),this.statsReport.destroy(),this.prevScaleResolutionDownBy=1,this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),e}(),HK=function(e){f(r,e);var t=g(r);function r(e,n,i,o){var a;return u(this,r),h(m(a=t.call(this)),"streamId",void 0),h(m(a),"userId",void 0),h(m(a),"isScreen",void 0),h(m(a),"hasVideo",void 0),h(m(a),"hasAudio",void 0),h(m(a),"_attributes",void 0),h(m(a),"streamState",void 0),h(m(a),"observer",void 0),h(m(a),"statsReport",void 0),h(m(a),"subVideo",void 0),h(m(a),"subAudio",void 0),h(m(a),"subMediaType",void 0),h(m(a),"subLayer",void 0),h(m(a),"audioMid",void 0),h(m(a),"videoMid",void 0),h(m(a),"_sequenceId",void 0),h(m(a),"stream",void 0),h(m(a),"videoTrack",void 0),h(m(a),"audioTrack",void 0),h(m(a),"videoTransceiver",void 0),h(m(a),"audioTransceiver",void 0),h(m(a),"recordedVideoFrames",void 0),h(m(a),"stillExist",void 0),h(m(a),"originalMediaType",void 0),h(m(a),"originalStreamIndex",0),h(m(a),"virtual",void 0),a.virtual=!1,a.userId=e,a.isScreen=i,a.streamId=n,a.hasAudio=o.audiostream&&o.localaudio,a.hasVideo=o.videostream&&o.localvideo,a._attributes=o,a.subVideo=!1,a.subAudio=!1,a._sequenceId=0,a.subMediaType=TK.NONE,a.subLayer={spatialLayer:0,spatialSubLayer:-1},a.streamState=0,a.statsReport=new LK(m(a)),a}return l(r,[{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){IK.getNalunits(new AK(t.data)).forEach((function(t){if(t.sei){var r=DK.decodeSeiBody(t.body);r&&r.type!==RK.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else BK.print("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else BK.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{wj.rtcInvokeStatus(JSON.stringify({uid:this.userId,streamId:this.streamId,streams:e.streams.reduce((function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:JSON.stringify({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:JSON.stringify({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:JSON.stringify({track:RM(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:JSON.stringify({track:RM(o.track)}))})),track:RM(e.track)}),0,"Stream.ontrack","",0)}catch(EZ){}if(null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&n.includes(this.streamId)){var s,c=e.track;"video"===(null==c?void 0:c.kind)?this._setVideoTrack(c):"audio"===(null===(s=e.track)||void 0===s?void 0:s.kind)&&this._setAudioTrack(c),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e;BK.print("clean","exec stream.clean ".concat(this.streamId," ").concat(this.userId)),wj.rtcInvokeStatus("".concat((new Error).stack),0,"remotestream_clean",this.streamId,0),this.subAudio=!1,this.subVideo=!1,this.audioMid=void 0,this.videoMid=void 0,this.sequenceId=0,this.videoTrack=void 0,this.audioTrack=void 0,this.stream=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,this.recordedVideoFrames=void 0,null===(e=this.observer)||void 0===e||e.reset(),this.statsReport.destroy()}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=pK(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ZN();return new qz(e,t)}(e),this.emit("ontrack",this.videoTrack))}},{key:"_getSubLayerBySpatialLayer",value:function(e){var t=this._attributes,r=t.videoDescriptions,n=t.subVideoDescriptions,i=void 0===n?[]:n,o=r[e],a=o.width,s=o.height,c=i.find((function(e){return e.width===a&&e.height===s}));return{spatialLayer:e,spatialSubLayer:(null==c?void 0:c.sub_index)||-1}}}]),r}(GU),zK=new FU("queue",4),KK=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(KK||{}),XK=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(XK||{}),WK=(h(UK={},"publish","unpublish"),h(UK,"subscribe","unsubscribe"),h(UK,"pushtrack","removetrack"),UK),qK=(h(VK={},"publish",0),h(VK,"subscribe",0),h(VK,"pushtrack",0),h(VK,"unpublish",1),h(VK,"unsubscribe",1),h(VK,"removetrack",1),VK),YK=function(e){f(r,e);var t=g(r);function r(){var e;return u(this,r),h(m(e=t.call(this)),"_queue",void 0),e._queue=[],e}return l(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t=this._queue.length,r="";return this._queue=this._queue.filter((function(t){return t.streamId!==e.streamId||e.action!==WK[t.action]||(r=t.streamId,zK.print("offsetStreamId",r),!1)})),this._queue.length===t&&this._queue.push(e),this.emit("start"),r}},{key:"dequeue",value:function(){if(!this._queue.length)return null;var e=this._queue.length;vM&&(e=Math.min(this._queue.length,5));for(var t=qK[this._queue[0].action],r=1;r<e;r++)if(qK[this._queue[r].action]!==t)return{sdpStrategy:t,items:this._queue.splice(0,r)};return{sdpStrategy:t,items:this._queue.splice(0,e)}}}]),r}(xU),JK=new FU("ChromeHandler",3),QK=zG(),ZK=function(e){f(T,e);var r,n,a,s,d,v,_,y,S,k=g(T);function T(e,t){var r;return u(this,T),h(m(r=k.call(this,e,t)),"name","chrome"),h(m(r),"_queueBusy",!1),h(m(r),"_sdpQueue",void 0),h(m(r),"_aSendonlyOfferTpl",void 0),h(m(r),"_vSendonlyOfferTpl",void 0),h(m(r),"_aRecvonlyOfferTpl",void 0),h(m(r),"_vRecvonlyOfferTpl",void 0),h(m(r),"_mid",10),h(m(r),"_offerSession",void 0),h(m(r),"_answerSession",void 0),h(m(r),"_offerMlines",[]),h(m(r),"_answerMlines",[]),h(m(r),"_inactiveMlineIndex",[]),h(m(r),"_mlinesCache",{}),r._sdpQueue=new YK,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(JK.print("dequeue start"),r.dequeue())})),r}return l(T,[{key:"connect",value:(S=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,f,p,v,_,m,y,g=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return JK.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,VH(t);case 4:return this._answerIce=e.sent,this.connection_id=this._answerIce.iceUfrag||"",this.ms_addr=JSON.stringify((null==t||null===(a=t.publicIPs)||void 0===a?void 0:a.map((function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[]),e.next=9,this._peerConnection.createOffer();case 9:return s=e.sent,c=KG.parse(s.sdp),!this._offerIce.iceUfrag&&!this._offerIce.icePwd&&((f="renomination"===(null===(u=c.media[0])||void 0===u?void 0:u.iceOptions))||(delete this._offerIce.iceOptions,delete this._answerIce.iceOptions),delete this._offerIce.iceUfrag,delete this._offerIce.icePwd,p=HH({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(d=c.media[0])||void 0===d?void 0:d.icePwd,options:(l={},h(l,GH.kICEConfigTypeSrtpDtlsType,!0),h(l,GH.kICEConfigTypeRenominationType,f),l)}),v=b(p,1),_=v[0],this._answerIce.iceUfrag=_,JK.print("use serverUfrag v2",JSON.stringify({dtls:!0,renomination:f}))),m=b(c.media,1),y=m[0],this._offerIce.fingerprint=c.fingerprint||y.fingerprint,delete c.media,this._offerSession=i({},c),this._answerSession=i({},c),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[i(i(i({},y),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[i(i(i({},y),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription(),e.next=25,new Promise((function(e,t){g._dataChannel.onopen=function(){JK.print("connect","dataChannel open"),jj("es.dc.open","",0,!1,g.connection_id,{ms_addr:g.ms_addr}),e("")},g._dataChannel.onerror=function(e){wj.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,tj.INVALID_DATA),jj("es.dc.error","",0,!1,g.connection_id,{ms_addr:g.ms_addr}),t(e)},g._dataChannel.onclose=function(e){jj("es.dc.close","",0,!1,g.connection_id,{ms_addr:g.ms_addr}),t(e)},g._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==g._peerConnection.iceConnectionState&&"closed"!==g._peerConnection.iceConnectionState&&"failed"!==g._peerConnection.connectionState||t(e)}))}));case 25:return JK.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){E(p(T.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(y=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h,f,v,_,m,y,g,S,k,I,A,R,C,w,O,x,P,D,N,M,L,U;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=t.stream,u=t.enableSimulcast,d=E(p(T.prototype),"internalPublish",this).call(this,t),l=d.videoDescriptions,h=d.subVideoDescriptions,f=d.audioTransceiverInit,v=d.videoTransceiverInit,_=DH(this._nextSsrc),this._nextSsrc=_.next,m="".concat(this._mid++),y="".concat(this._mid++),g=i(i(i({},this._aSendonlyOfferTpl),this._offerIce),{},{mid:m,msid:"".concat(c.id," ").concat(c.id,"-audio"),ssrcs:NH(c.id,"audio",_.audio,xH)}),S=i(i(i({},this._vSendonlyOfferTpl),this._offerIce),{},{mid:y,msid:"".concat(c.id," ").concat(c.id,"-video")}),u?(JK.print("subVideoDesc","desc: %o ",h),delete S.ssrcGroups,delete S.ssrcs,k=[],S.rids=l.map((function(e){var t=e.rid;return k.unshift(t),{id:t,direction:"send"}})),S.simulcast={dir1:"send",list1:k.join(";")}):(I=MH(c.id,_,{cname:xH}),A=I.ssrcs,R=I.ssrcGroups,S.ssrcs=A,S.ssrcGroups=R),null!==(r=this._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.audioRed&&Array.isArray(g.rtp)&&(-1!==(C=g.rtp.findIndex((function(e){return"red"===e.codec})))&&(w=g.rtp.splice(C,1),O=b(w,1),x=O[0],g.rtp.unshift(x)),P=[],g.rtp.forEach((function(e){return P.push(e.payload)})),g.payloads=P.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&KH(S,null===(D=this._context)||void 0===D||null===(N=D.serverConfig)||void 0===N?void 0:N.videoCodec),(aM||dM)&&Array.isArray(S.ext)&&(S.ext=S.ext.filter((function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&t.includes("video-orientation"))}))),(M=null==g?void 0:g.rtp.find((function(e){return"opus"===e.codec})))&&g.fmtp&&(U=g.fmtp.find((function(e){return e.payload===M.payload})))&&null!==(L=this._context)&&void 0!==L&&L.audioProfileManager&&(U.config+=this._context.audioProfileManager.getOpusConfigStr()),u||aM||this.addBitrateLimit(S,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[g,S],e.abrupt("return",{partialSdp:UH(this._offerSession,g,S),audioMid:m,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:l,subVideoDescriptions:h,audioTransceiverInit:f,videoTransceiverInit:v});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"subscribe",value:(_=c(o().mark((function e(t,r){var n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A,R,C,w=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(JK.print("subscribe"),s="incroffer",c="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return u=e.sent,e.next=9,this.createAVMlineOfferTpl(u);case 9:if(d="",l="",h=!1,f=!1,p=void 0,v=void 0,this._mlinesCache[t.streamId]=[p,v],t.virtual?(d="".concat(this._mid++),h=!0):r.multiChatMode?(d="".concat(this._mid++),l="".concat(this._mid++),f=!0):(h=!0,f=!0,d="".concat(this._mid++),l="".concat(this._mid++)),d&&(p=i(i({},this._aRecvonlyOfferTpl),{},{mid:d})),h&&(this._mlinesCache[t.streamId][0]=p,_={track:"audio",init:{direction:"recvonly"}}),l&&(v=i(i({},this._vRecvonlyOfferTpl),{},{mid:l})),f&&(this._mlinesCache[t.streamId][1]=v,m={track:"video",init:{direction:"recvonly"}}),y=UH(this._offerSession,p,v),g=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=32;break}return g=DH(this._nextSsrc),this._nextSsrc=g.next,k=i(i(i({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:d,msid:"".concat(t.streamId).concat(null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ").concat(t.streamId,"-audio"),ssrcs:NH(t.streamId,"audio",g.audio)}),T=i(i(i({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:l,msid:"".concat(t.streamId).concat(null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-video"," ").concat(t.streamId,"-video")},MH(t.streamId,g,{flexfec:this._enableSubFlexfec})),I=new Promise((function(e){w._sdpQueue.enqueue({action:XK.subscribe,streamId:t.streamId,audioMid:d,videoMid:l,audioTransceiverInit:_,videoTransceiverInit:m,signalingAck:{sdp:KG.write(i(i({},w._answerSession),{},{media:[k,T]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:y,onSuccess:function(){JK.print("subscribe()","sub success"),e(0)}})})),e.next=31,I;case 31:null===(b=g)||void 0===b||delete b.next;case 32:return(A=null===(n=p)||void 0===n?void 0:n.rtp.find((function(e){return"opus"===e.codec})))&&null!==(a=p)&&void 0!==a&&a.fmtp&&(C=null===(R=p)||void 0===R?void 0:R.fmtp.find((function(e){return e.payload===A.payload})))&&this._context&&(C.config+=";stereo=1;sprop-stereo=1"),e.abrupt("return",{partialSdp:y,audioMid:d,videoMid:l,type:s,semantics:c,audioTransceiverInit:_,videoTransceiverInit:m,allSsrc:g});case 35:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"handleAck",value:(v=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(JK.print("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return JK.print("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"dequeue",value:(d=c(o().mark((function e(){var r,n,a,s,c,u,d,l,h,f,p,v,_=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,r=this._sdpQueue.dequeue(),JK.print("dequeue()","ret: %o",r),r){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,n=r.items,a=r.sdpStrategy,s=[],c=[],u=[],a!==KK.ADD){e.next=15;break}return e.delegateYield(o().mark((function e(){var r,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(r=i({},_._answerIce)).candidates,d=!1,l=!1,e.prev=4,f=t(n);case 6:return e.next=8,f.next();case 8:if(!(d=!(p=e.sent).done)){e.next=16;break}if(a=p.value,"break"!==function(){var e=a.audioMid,t=a.videoMid,n=a.action,o=a.audioTransceiverInit,d=a.videoTransceiverInit,l=a.signalingAck,h=a.stream,f=h instanceof HK;if(a.onSuccess&&u.push(a.onSuccess),f&&(null==l?void 0:l.sequenceId)<h.sequenceId)return"break";var p={},v={},m=KG.parse(l.sdp);Array.isArray(m.media)&&m.media.sort((function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(n){"audio"===(n=i(i({},n),r)).type?(p=n).mid=e:(v=n).mid=t}));var y,g=h.streamId;if(n===XK.publish&&(g=null===(y=h.stream)||void 0===y?void 0:y.id),!_._mlinesCache[g])return"break";var S=b(_._mlinesCache[g],2),E=S[0],k=S[1];if(o&&E){h.audioTransceiver=_._peerConnection.addTransceiver(o.track,o.init),_.monitor.rtcInvokeStatus(JSON.stringify({audioStreamTrack:RM(o.track)}),0,"chromeHandler.addTrack","",0);var T=_._inactiveMlineIndex.shift();T||(T=_._offerMlines.length),_._offerMlines[T]=i({},E),_._answerMlines[T]=p,QK&&h.initAudioEncodedTransform()}if(d&&k){var I;n===XK.publish&&pM&&(null==d||null===(I=d.init)||void 0===I||delete I.sendEncodings),h.videoTransceiver=_._peerConnection.addTransceiver(d.track,d.init),_.monitor.rtcInvokeStatus(JSON.stringify({videoStreamTrack:RM(d.track)}),0,"chromeHandler.addTrack","",0);var A=_._inactiveMlineIndex.shift();A||(A=_._offerMlines.length),_._offerMlines[A]=i({},k),_._answerMlines[A]=v,QK&&h.initVideoEncodedTransform()}s.push(h.streamId||""),c.push(f?h.userId:"local"),f&&(h.sequenceId=null==l?void 0:l.sequenceId),delete _._mlinesCache[g]}()){e.next=13;break}return e.abrupt("break",16);case 13:d=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),l=!0,h=e.t0;case 22:if(e.prev=22,e.prev=23,!d||null==f.return){e.next=27;break}return e.next=27,f.return();case 27:if(e.prev=27,!l){e.next=30;break}throw h;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:v={},n.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;v[t]=t,n!==XK.removetrack&&(v[r]=r),v[t]=t})),this._offerMlines=this._offerMlines.map((function(e,t){return v[e.mid]&&(e=LH(e),_._inactiveMlineIndex.push(t)),e})),this._inactiveMlineIndex.sort((function(e,t){return e-t})),this._answerMlines=this._answerMlines.map((function(e){return v[e.mid]&&(e=LH(e)),e}));case 20:return e.next=22,this.setDescription(s.length?{streamId:s.join(","),streamUserId:c.join(",")}:void 0);case 22:try{u.forEach((function(e){return e()}))}catch(EZ){}JK.print("dequeue","loop"),e.next=29;break;case 26:e.prev=26,e.t1=e.catch(6),JK.print("dequeue","unknown error: %o",e.t1);case 29:return e.prev=29,this.dequeue(),e.finish(29);case 32:case"end":return e.stop()}}),e,this,[[6,26,29,32]])}))),function(){return d.apply(this,arguments)})},{key:"setDescription",value:(s=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return JK.print("setDescription"),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=$N(),t&&wj.rtcBeginCreateOffer("local"===t.streamUserId?nj.UP:nj.DOWN,t.streamId,t.streamUserId),e.next=10,this._peerConnection.createOffer();case 10:return t&&wj.rtcCreateOffer(0,"local"===t.streamUserId?ij.UP:ij.DOWN,t.streamId,t.streamUserId,$N()-n),e.next=13,this.setLocalDescription(KG.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(KG.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getDefaultSdp",value:(a=c(o().mark((function e(){var t,r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return t=e.sent,this.createAVMlineOfferTpl(t),r=KG.parse(t),n=[],r.media=r.media.filter((function(e){return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=e.ext.filter((function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),n.push(e.mid+""),!0)})),r.groups=[{mids:n.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:KG.write(r),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(n=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;KG.parse(e).media.forEach((function(e){"audio"===e.type?"sendonly"===e.direction?t._aSendonlyOfferTpl=e:(Array.isArray(e.ext)&&(e.ext=e.ext.filter((function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),t._aRecvonlyOfferTpl=e):"video"===e.type&&("sendonly"===e.direction?t._vSendonlyOfferTpl=e:(Array.isArray(e.ext)&&(e.ext=e.ext.filter((function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),t._vRecvonlyOfferTpl=e))}))}},{key:"_genOfferSdp",value:(r=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,SM(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new hD(dD.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return r.apply(this,arguments)})}]),T}(YH),$K=new FU("FirefoxHandler",3),eX=function(e){f(k,e);var t,r,n,a,s,d,v,_,y,S=g(k);function k(){var e;u(this,k);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return h(m(e=S.call.apply(S,[this].concat(r))),"name","firefox"),h(m(e),"_aRecvonlyOfferTpl",void 0),e}return l(k,[{key:"connect",value:(y=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,f,p,v,_,m,y,g,S=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $K.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,VH(t);case 4:return this._answerIce=e.sent,this.connection_id=this._answerIce.iceUfrag||"",this.ms_addr=JSON.stringify((null==t||null===(a=t.publicIPs)||void 0===a?void 0:a.map((function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[]),this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=11,this._peerConnection.createOffer();case 11:return s=e.sent,c=KG.parse(s.sdp),!this._offerIce.iceUfrag&&!this._offerIce.icePwd&&((f="renomination"===(null===(u=c.media[0])||void 0===u?void 0:u.iceOptions))||(delete this._offerIce.iceOptions,delete this._answerIce.iceOptions),delete this._offerIce.iceUfrag,delete this._offerIce.icePwd,p=HH({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(d=c.media[0])||void 0===d?void 0:d.icePwd,options:(l={},h(l,GH.kICEConfigTypeSrtpDtlsType,!0),h(l,GH.kICEConfigTypeRenominationType,f),l)}),v=b(p,1),_=v[0],this._answerIce.iceUfrag=_,$K.print("use serverUfrag v2",JSON.stringify({dtls:!0,renomination:f}))),m=b(c.media,1),y=m[0],this._offerIce.fingerprint=c.fingerprint||y.fingerprint,c.media=c.media.map((function(e){return i(i({},e),S._offerIce)})),c.media.map((function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return-1===e.uri.indexOf("abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:r.filter((function(e){return"goog-remb"!==e.type})))})),(g=i({},c)).fingerprint=this._answerIce.fingerprint,g.media=g.media.map((function(e){return delete(e=i(i({},e),S._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),e.next=24,this.setLocalDescription(KG.write(c));case 24:return e.next=26,this.setRemoteDescription(KG.write(g));case 26:return e.next=28,new Promise((function(e,t){S._dataChannel.onopen=function(){$K.print("connect","dataChannel open"),jj("es.dc.open","",0,!1,S.connection_id,{ms_addr:S.ms_addr}),e("")},S._dataChannel.onerror=function(e){wj.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,tj.INVALID_DATA),jj("es.dc.error","",0,!1,S.connection_id,{ms_addr:S.ms_addr}),t(e)},S._dataChannel.onclose=function(e){jj("es.dc.close","",0,!1,S.connection_id,{ms_addr:S.ms_addr}),t(e)},S._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==S._peerConnection.iceConnectionState&&"closed"!==S._peerConnection.iceConnectionState&&"failed"!==S._peerConnection.connectionState||t(e)}))}));case 28:return $K.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 30:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"publish",value:(_=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h,f,v,_,m,y,g=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=E(p(k.prototype),"internalPublish",this).call(this,t),s=a.videoDescriptions,c=a.subVideoDescriptions,u=a.audioTransceiverInit,d=a.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(u.track,u.init),t.videoTransceiver=this._peerConnection.addTransceiver(d.track,d.init),l=$N(),wj.rtcBeginCreateOffer(nj.UP,"",""),e.next=7,this._peerConnection.createOffer();case 7:return h=e.sent,wj.rtcCreateOffer(0,ij.UP,"","",$N()-l),(f=KG.parse(h.sdp)).media=null===(r=f.media)||void 0===r?void 0:r.map((function(e){return i(i({},e),g._offerIce)})),e.next=13,this.setLocalDescription(KG.write(f));case 13:return v=t.audioTransceiver.mid,_=t.videoTransceiver.mid,m=null,y=null,f.media=null===(n=f.media)||void 0===n?void 0:n.map((function(e){if("".concat(e.mid)===v){var t,r=null===(t=m=e)||void 0===t?void 0:t.rtp.find((function(e){return"opus"===e.codec}));if(r&&m.fmtp){var n,i=m.fmtp.find((function(e){return e.payload===r.payload}));i&&null!==(n=g._context)&&void 0!==n&&n.audioProfileManager&&(i.config+=g._context.audioProfileManager.getOpusConfigStr())}}else if("".concat(e.mid)===_){var o,a,s,c;null!==(o=g._context)&&void 0!==o&&null!==(a=o.serverConfig)&&void 0!==a&&a.videoCodec&&KH(e,null===(s=g._context)||void 0===s||null===(c=s.serverConfig)||void 0===c?void 0:c.videoCodec),y=e}return e})),this.addBitrateLimit(y,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(KG.write(f));case 21:return e.abrupt("return",{partialSdp:UH(f,m,y,!1),audioMid:v,videoMid:_,type:"incroffer",semantics:"unified-plan",videoDescriptions:s,subVideoDescriptions:c,audioTransceiverInit:u,videoTransceiverInit:d});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"subscribe",value:(v=c(o().mark((function e(t,r){var n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $K.print("subscribe()"),u="",d="",l=!1,h=!1,f=void 0,p=void 0,t.virtual?l=!0:(r.multiChatMode||(l=!0),h=!0),l&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),h&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=$N(),wj.rtcBeginCreateOffer(nj.UP,t.streamId,t.userId),e.next=14,this._peerConnection.createOffer();case 14:return _=e.sent,wj.rtcCreateOffer(0,ij.UP,t.streamId,t.userId,$N()-v),(m=KG.parse(_.sdp)).media=null===(n=m.media)||void 0===n?void 0:n.map((function(e){return i(i({},e),T._offerIce)})),m.media.map((function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return-1===e.uri.indexOf("abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:r.filter((function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(KG.write(m),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(u=null===(a=t.audioTransceiver)||void 0===a?void 0:a.mid,d=null===(s=t.videoTransceiver)||void 0===s?void 0:s.mid,null===(c=m.media)||void 0===c||c.forEach((function(e){"".concat(e.mid)===u?f=e:"".concat(e.mid)===d&&(p=e)})),u&&f||(u="audio_".concat(d),f=i(i({},this._aRecvonlyOfferTpl),{},{mid:u})),t.audioMid=u,t.videoMid=d,y=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return y=DH(this._nextSsrc),this._nextSsrc=y.next,b=i(i(i({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:u,msid:"".concat(t.streamId).concat(null!==(g=this._context)&&void 0!==g&&g.avSync?"":"-audio"," ").concat(t.streamId,"-audio"),ssrcs:NH(t.streamId,"audio",y.audio)}),k=i(i(i({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:d,msid:"".concat(t.streamId).concat(null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-video"," ").concat(t.streamId,"-video")},MH(t.streamId,y,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([b,k],t);case 35:null===(E=y)||void 0===E||delete E.next;case 36:return e.abrupt("return",{partialSdp:UH(m,f,p,!1),audioMid:u,videoMid:d,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:y});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"handleAck",value:(d=c(o().mark((function e(t){var r,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==XK.unpublish&&i!==XK.unsubscribe&&i!==XK.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return $K.print("already set remote"),e.abrupt("return","");case 8:return a=KG.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(a.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(s=c(o().mark((function e(t,r){var n,a,s,c,u,d,l=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=KG.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=i(i({},e),l._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=KG.parse(null===(a=this._peerConnection.localDescription)||void 0===a?void 0:a.sdp),d=u.media.map((function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,c.media.map((function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return-1===e.uri.indexOf("abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:r.filter((function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(KG.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"getDefaultSdp",value:(a=c(o().mark((function e(){var t,r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=KG.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),i=[],n.media=n.media.filter((function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,i.push(e.mid+""),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:KG.write(n),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(n=c(o().mark((function e(t,r,n){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $K.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=c(o().mark((function e(t,r){var n,a,s,c,u,d,l,h=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $K.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=KG.parse(null==c?void 0:c.sdp)).media=u.media.map((function(e){return a[e.mid]&&(e=LH(e)),"inactive"!==e.direction&&s.push(e.mid),i(i({},e),h._offerIce)})),d=KG.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=u.media.map((function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(KG.write(u));case 17:return e.next=19,this.setRemoteDescription(KG.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;KG.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),k}(YH),tX=new FU("FallbackHandler",3),rX=function(e){f(k,e);var t,r,n,a,s,d,v,_,y,S=g(k);function k(e,t){var r;return u(this,k),h(m(r=S.call(this,e,t)),"name","fallback"),h(m(r),"_aRecvonlyOfferTpl",void 0),tX.print("ctor","using fallback handler"),e.rtcError("using fallback handler",-1),r}return l(k,[{key:"connect",value:(y=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,f,p,v,_,m,y,g,S=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tX.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,VH(t);case 4:return this._answerIce=e.sent,this.connection_id=this._answerIce.iceUfrag||"",this.ms_addr=JSON.stringify((null==t||null===(a=t.publicIPs)||void 0===a?void 0:a.map((function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[]),this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=11,this._peerConnection.createOffer();case 11:return s=e.sent,c=KG.parse(s.sdp),!this._offerIce.iceUfrag&&!this._offerIce.icePwd&&((f="renomination"===(null===(u=c.media[0])||void 0===u?void 0:u.iceOptions))||(delete this._offerIce.iceOptions,delete this._answerIce.iceOptions),delete this._offerIce.iceUfrag,delete this._offerIce.icePwd,p=HH({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(d=c.media[0])||void 0===d?void 0:d.icePwd,options:(l={},h(l,GH.kICEConfigTypeSrtpDtlsType,!0),h(l,GH.kICEConfigTypeRenominationType,f),l)}),v=b(p,1),_=v[0],this._answerIce.iceUfrag=_,tX.print("use serverUfrag v2",JSON.stringify({dtls:!0,renomination:f}))),m=b(c.media,1),y=m[0],this._offerIce.fingerprint=c.fingerprint||y.fingerprint,c.media=c.media.map((function(e){return i(i({},e),S._offerIce)})),c.media.map((function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return-1===e.uri.indexOf("abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:r.filter((function(e){return"goog-remb"!==e.type})))})),(g=i({},c)).fingerprint=this._answerIce.fingerprint,g.media=g.media.map((function(e){return delete(e=i(i({},e),S._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),e.next=24,this.setLocalDescription(s.sdp);case 24:return e.next=26,this.setRemoteDescription(KG.write(g));case 26:return e.next=28,new Promise((function(e,t){S._dataChannel.onopen=function(){tX.print("connect","dataChannel open"),jj("es.dc.open","",0,!1,S.connection_id,{ms_addr:S.ms_addr}),e("")},S._dataChannel.onerror=function(e){wj.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,tj.INVALID_DATA),jj("es.dc.error","",0,!1,S.connection_id,{ms_addr:S.ms_addr}),t(e)},S._dataChannel.onclose=function(e){jj("es.dc.close","",0,!1,S.connection_id,{ms_addr:S.ms_addr}),t(e)},S._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==S._peerConnection.iceConnectionState&&"closed"!==S._peerConnection.iceConnectionState&&"failed"!==S._peerConnection.connectionState||t(e)}))}));case 28:return tX.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 30:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"publish",value:(_=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,v,_;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=E(p(k.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,a=n.subVideoDescriptions,s=n.audioTransceiverInit,c=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=$N(),wj.rtcBeginCreateOffer(nj.UP,"",""),e.next=7,this._peerConnection.createOffer();case 7:return d=e.sent,wj.rtcCreateOffer(0,ij.UP,"","",$N()-u),l=KG.parse(d.sdp),e.next=12,this.setLocalDescription(d.sdp);case 12:return h=t.audioTransceiver.mid,f=t.videoTransceiver.mid,v=null,_=null,l.media=null===(r=l.media)||void 0===r?void 0:r.map((function(e){return"".concat(e.mid)===h?v=e:"".concat(e.mid)===f&&(_=e),e})),zG()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:UH(l,v,_,!1),audioMid:h,videoMid:f,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c});case 19:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"subscribe",value:(v=c(o().mark((function e(t,r){var n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tX.print("subscribe()"),c="",u="",d=!1,l=!1,h=void 0,f=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),p=$N(),wj.rtcBeginCreateOffer(nj.UP,t.streamId,t.userId),e.next=14,this._peerConnection.createOffer();case 14:return v=e.sent,wj.rtcCreateOffer(0,ij.UP,t.streamId,t.userId,$N()-p),_=KG.parse(v.sdp),e.next=19,this.setLocalDescription(v.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:if(c=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(f=e)})),c&&h||(c="audio_".concat(u),h=i(i({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=34;break}return m=DH(this._nextSsrc),this._nextSsrc=m.next,E=i(i(i({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:c,msid:"".concat(t.streamId).concat(null!==(y=this._context)&&void 0!==y&&y.avSync?"":"-audio"," ").concat(t.streamId,"-audio"),ssrcs:NH(t.streamId,"audio",m.audio)}),b=i(i(i({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:u,msid:"".concat(t.streamId).concat(null!==(g=this._context)&&void 0!==g&&g.avSync?"":"-video"," ").concat(t.streamId,"-video")},MH(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=33,this._internalSetRemoteDescription([E,b],t);case 33:null===(S=m)||void 0===S||delete S.next;case 34:return zG()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:UH(_,h,f,!1),audioMid:c,videoMid:u,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"handleAck",value:(d=c(o().mark((function e(t){var r,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==XK.unpublish&&i!==XK.unsubscribe&&i!==XK.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return tX.print("already set remote"),e.abrupt("return","");case 8:return a=KG.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(a.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(s=c(o().mark((function e(t,r){var n,a,s,c,u,d,l=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=KG.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=i(i({},e),l._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=KG.parse(null===(a=this._peerConnection.localDescription)||void 0===a?void 0:a.sdp),d=u.media.map((function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,c.media.map((function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return-1===e.uri.indexOf("abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:r.filter((function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(KG.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"getDefaultSdp",value:(a=c(o().mark((function e(){var t,r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=KG.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),i=[],n.media=n.media.filter((function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,i.push("".concat(e.mid)),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:KG.write(n),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(n=c(o().mark((function e(t,r,n){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tX.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=c(o().mark((function e(t,r){var n,a,s,c,u,d,l,h=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tX.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=KG.parse(null==c?void 0:c.sdp)).media=u.media.map((function(e){return a[e.mid]&&(e=LH(e)),"inactive"!==e.direction&&s.push(e.mid),i(i({},e),h._offerIce)})),d=KG.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=u.media.map((function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(null==c?void 0:c.sdp);case 17:return e.next=19,this.setRemoteDescription(KG.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;KG.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),k}(YH),nX=function(e,t){return null!=t&&t.enableFallbackHandler?new rX(e,t):oM?new eX(e,t):new ZK(e,t)},iX=new FU("Locker",2),oX=1,aX=function(){function e(t){u(this,e),h(this,"lockingPromise",Promise.resolve()),h(this,"locks",0),h(this,"name",""),h(this,"lockId",void 0),this.lockId=oX++,t&&(this.name=t),iX.print("[lock-".concat(this.name,"-").concat(this.lockId,"] is created."))}return l(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1,iX.print("[lock-".concat(this.name,"-").concat(this.lockId,"] locked, current queue ").concat(this.locks,"."));var r=new Promise((function(r){e=function(){t.locks-=1,iX.print("[lock-".concat(t.name,"-").concat(t.lockId,"] unlocked, current queue ").concat(t.locks,".")),r()}})),n=this.lockingPromise.then((function(){return e}));return this.lockingPromise=this.lockingPromise.then((function(){return r})),n}}]),e}(),sX=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e}(sX||{}),cX=function(e){return e[e.START=1]="START",e[e.START_SUCCESS=2]="START_SUCCESS",e[e.START_FAILED=3]="START_FAILED",e[e.UPDATE=4]="UPDATE",e[e.UPDATE_SUCCESS=5]="UPDATE_SUCCESS",e[e.UPDATE_FAILED=6]="UPDATE_FAILED",e[e.STOP=7]="STOP",e[e.STOP_SUCCESS=8]="STOP_SUCCESS",e[e.STOP_FAILED=9]="STOP_FAILED",e}(cX||{}),uX=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(uX||{}),dX=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(dX||{}),lX=(h(FK={},Y.communication,[0]),h(FK,Y.chat,[0]),h(FK,Y.chatRoom,[1,"IES_chatroom"]),h(FK,Y.coHost,[1,"IES_PK"]),h(FK,Y.meeting,[16]),h(FK,Y.classRoom,[0]),FK),hX=Object.defineProperty,fX=Object.getOwnPropertyDescriptor,pX=function(e,t,r,n){for(var i,o=n>1?void 0:n?fX(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&hX(t,r,o),o},vX=new FU("MediaServerClient",2),_X=6e4,mX=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(mX||{}),yX=function(e,t){vX.print(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},gX=function(e){f(P,e);var t,r,n,a,s,d,p,v,_,y,S,E,k,T,I,A,R,C,w,O,x=g(P);function P(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wj;return u(this,P),h(m(t=x.call(this)),"_token",void 0),h(m(t),"_appId",void 0),h(m(t),"_roomId",void 0),h(m(t),"_roomAttributes",void 0),h(m(t),"_clientId",void 0),h(m(t),"_businessId",void 0),h(m(t),"_userInfo",void 0),h(m(t),"_useCloudProxy",void 0),h(m(t),"_expectedIDC",void 0),h(m(t),"_authorization",void 0),h(m(t),"_sessionId",void 0),h(m(t),"_iceConfigRequestManager",void 0),h(m(t),"_ontrackCallbackMap",new Map),h(m(t),"_subResolves",{}),h(m(t),"supportConcurrent",!1),h(m(t),"_handler",void 0),h(m(t),"_pubSubLock",void 0),h(m(t),"_joinLeaveLock",void 0),h(m(t),"_state",void 0),h(m(t),"_dataChannelSignal",void 0),h(m(t),"_subConfig",{}),h(m(t),"monitor",void 0),h(m(t),"_roomProfile",Y.communication),h(m(t),"_context",void 0),h(m(t),"_subStreamQueue",{}),t.monitor=r,t._pubSubLock=new aX("pubSubLock"),t._joinLeaveLock=new aX("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t}return l(P,[{key:"_addHandlerEvents",value:function(){var e,t=this;null===(e=this._handler)||void 0===e||e.once("disconnect",(function(){vX.print("emit ABNORMAL_DISCONNECTION ice"),t.safeEmit(hG.ABNORMAL_DISCONNECTION)}))}},{key:"_addSignalEventHandler",value:function(){var e,t=this;[dG.ON_ADD_STREAM,dG.ON_ADD_STREAM_LIST,dG.ON_REMOVE_STREAM,dG.ON_REMOVE_STREAM_LIST,dG.USER_CONNECTION,dG.USER_CONNECTION_LIST,dG.USER_DISCONNECTION,dG.USER_DISCONNECTION_LIST,dG.ON_UPDATE_STREAM_ATTRIBUTES,dG.ON_UPDATE_ROOM_ATTRIBUTES,dG.ON_PUSH_TRACK,dG.NODE_CHANGE,dG.ON_CUSTOM_MESSAGE,dG.USER_MESSAGE_RECEIVED,dG.USER_BINARY_MESSAGE_RECEIVED,dG.POST_PROCESSING_MESSAGE,dG.ON_USER_TOKEN_WILL_EXPIRE,dG.STREAM_CONTROL_MESSAGE,dG.ON_SCENE_CONFIG,dG.ON_UPDATE_USER_ATTRIBUTES,dG.ON_SPEAKER_CHANGE,lG.RSCP,lG.RTT,dG.ON_STREAM_FAILED].forEach((function(e){var r;null===(r=t._dataChannelSignal)||void 0===r||r.on(e,(function(r){t.safeEmit(e,r)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.once("close",(function(){vX.print("emit ABNORMAL_DISCONNECTION datachannel"),t.safeEmit(hG.ABNORMAL_DISCONNECTION)}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(hG.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"connect",value:(O=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l=this,h=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=h.length>1&&void 0!==h[1]?h[1]:"",n=h.length>2&&void 0!==h[2]?h[2]:"",i=h.length>3&&void 0!==h[3]?h[3]:{},this.connectionState="connecting",this._appId=t,this._handler&&(this._removeSignalEventHandler(),this._handler.destroy()),!i.node){e.next=11;break}a=[i.node],jj("es.join.nodeChange",i),e.next=20;break;case 11:return Promise.resolve().then((function(){return l.emit("onGetIceConfigHook")})),this._iceConfigRequestManager=new RG,e.next=15,null===(s=this._iceConfigRequestManager)||void 0===s?void 0:s.getAccessNode(t,r,n,Jj.getDeviceId(),null==i?void 0:i.reason,null==i?void 0:i.feedbackNode,this._useCloudProxy,this._expectedIDC);case 15:if(a=e.sent){e.next=19;break}throw jj("es.join.getNodeFailed",""),new hD(dD.ICE_SERVER_WRONG,"get ICE config failed");case 19:jj("es.join.getNodeSuccess",a);case 20:return Promise.resolve().then((function(){return l.emit("onEstablishConnectionHook")})),e.prev=21,u=!1,d=a.map((function(e){var t=nX(l.monitor,l._context);return t.connect(e).then((function(r){var n;l.emit("onConnectSuccessHook",null===(n=a)||void 0===n?void 0:n.length),u?t.destroy():(u=!0,c=r,l.safeEmit("prevIceNode",e),l._handler=t,Pj.setStats({connection_id:t.connection_id}),l.supportConcurrent="chrome"===t.name,l._addHandlerEvents())})).catch((function(e){throw t.destroy(),e}))})),e.next=26,EM(d);case 26:vX.print("join","establish peerConnection success"),e.next=33;break;case 29:throw e.prev=29,e.t0=e.catch(21),this.connectionState="disconnected",new hD(dD.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t0);case 33:if(!c){e.next=39;break}this._dataChannelSignal=new TG(c),this._addSignalEventHandler(),this._dataChannelSignal.sendPingSignaling(),e.next=41;break;case 39:throw this.connectionState="disconnected",new hD(dD.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed");case 41:case"end":return e.stop()}}),e,this,[[21,29]])}))),function(e){return O.apply(this,arguments)})},{key:"join",value:(w=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I=this,A=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=A.length>1&&void 0!==A[1]?A[1]:{},i=A.length>2&&void 0!==A[2]&&A[2],a=A.length>3?A[3]:void 0,vX.print("join()","info: %o, params: %o, reconnect: %o, controlMessage: %o",t,n,i,a),this._appId=t.appId,this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._useCloudProxy=t.useCloudProxy,this._expectedIDC=t.expectedIDC,this._roomProfile=t.roomProfile,this._sessionId=n.sessionId,e.next=16,this.connect(this._appId,this._roomId,this._clientId,n);case 16:return e.t0=rM.token2auth(this._appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId||"",e.t2=Date.now(),e.t3=a,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=23,null===(r=this._handler)||void 0===r?void 0:r.getDefaultSdp();case 23:return e.t5=e.sent,e.next=26,GG();case 26:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=tG.VERSION,e.t9=Jj.getDeviceId(),e.t10=this._appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._useCloudProxy,e.t15=lX[this._roomProfile]?lX[this._roomProfile][0]+"":"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0},e.t18=JSON.stringify({requireICEUfragV2:!0}),s={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17,accessParams:e.t18},Promise.resolve().then((function(){return I.emit("onSendingJoinMessageHook")})),e.prev=41,_=i?"reconnected":"joinRoom",e.next=45,this._dataChannelSignal.sendSignaling(_,s);case 45:return m=e.sent,vX.print("join","send join message success"),this._authorization=s.Authorization,this.connectionState="connected",this._context&&(k=null===(y=m.config)||void 0===y?void 0:y.engine_WEB,this._context.serverConfig={videoCodec:(null==k?void 0:k.video_codec)||"H264",audioRed:!(null==k||!k.pub_audio_red),muteReplaceUnsub:!(null===(g=m.config)||void 0===g||!g.mute_replace_unsub),simulcastOnDemand:!(oM||!1===(null===(S=m.config)||void 0===S||null===(E=S.engine_VPM)||void 0===E||null===(b=E.ondemand)||void 0===b?void 0:b.enable))},"boolean"==typeof(null==k?void 0:k.av_sync)&&(this._context.avSync=k.av_sync)),LK.audioStallConfig=null===(c=m.config)||void 0===c?void 0:c.engine_WEB,null===(u=this._context)||void 0===u||null===(d=u.audioProfileManager)||void 0===d||d.updateEngineBAC(null===(l=m.config)||void 0===l?void 0:l.engine_BAC),null===(h=this._context)||void 0===h||null===(f=h.audioProfileManager)||void 0===f||f.updateEngineANM(null===(p=m.config)||void 0===p?void 0:p.engine_ANM),null!=m&&null!==(v=m.relayMessage)&&void 0!==v&&v.sdp&&(null===(T=this._handler)||void 0===T||T.createAVMlineAnswerTpl(m.relayMessage.sdp)),e.abrupt("return",m);case 57:if(e.prev=57,e.t19=e.catch(41),this.connectionState="disconnected",!((null===e.t19||void 0===e.t19?void 0:e.t19.code)>=700&&(null===e.t19||void 0===e.t19?void 0:e.t19.code)<800)){e.next=62;break}throw new hD(dD.INVALID_TOKEN,(null===e.t19||void 0===e.t19?void 0:e.t19.message)||"Invalid token");case 62:if(200===(null===e.t19||void 0===e.t19?void 0:e.t19.code)){e.next=64;break}throw new hD(dD.JOIN_ROOM_FAILED,(null===e.t19||void 0===e.t19?void 0:e.t19.message)||"Join room failed");case 64:case"end":return e.stop()}}),e,this,[[41,57]])}))),function(e){return w.apply(this,arguments)})},{key:"publish",value:(C=c(o().mark((function e(t){var r,n,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return vX.print("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,a=$N(),s="",c="",e.prev=6,e.next=9,null===(u=this._handler)||void 0===u?void 0:u.publish(t);case 9:if(m=e.sent){e.next=12;break}throw new hD(dD.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 12:return s=m.audioMid,c=m.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof Zz),extaudio:!!(n instanceof $z)},y={attributes:i({videoDescriptions:m.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:s,videoMid:c,sdpInfo:{msid:t.stream.id,type:m.type,sdp:m.partialSdp,semantics:m.semantics}},t.enableSimulcast&&null!==(d=this._context)&&void 0!==d&&null!==(l=d.serverConfig)&&void 0!==l&&l.simulcastOnDemand&&null!==(h=m.subVideoDescriptions)&&void 0!==h&&h.length&&(y.attributes.subVideoDescriptions=m.subVideoDescriptions),e.next=19,null===(f=this._dataChannelSignal)||void 0===f?void 0:f.sendSignaling("publish",y);case 19:if(200===(null==(g=e.sent)?void 0:g.code)){e.next=22;break}throw new hD(dD.PUBLISH_FAILED,(null==g?void 0:g.message)||"publish failed");case 22:if(wj.rtcRecvAnswer(0,sj.INCRANSWER,(null==g||null===(p=g.relayMessage)||void 0===p?void 0:p.sequenceId)||0,null==g||null===(v=g.relayMessage)||void 0===v?void 0:v.sdp,cj.UP,"",""),S=new Promise((function(e,r){var n,i,o;null===(n=b._handler)||void 0===n||n.handleAck({action:XK.publish,streamId:g.streamId,audioMid:s,videoMid:c,audioTransceiverInit:null==m?void 0:m.audioTransceiverInit,videoTransceiverInit:null==m?void 0:m.videoTransceiverInit,signalingAck:{sdp:null==g||null===(i=g.relayMessage)||void 0===i?void 0:i.sdp,sequenceId:null==g||null===(o=g.relayMessage)||void 0===o?void 0:o.sequenceId},sdp:m.sdp,stream:t,onSuccess:function(){vX.print("publish()","publish success"),e(0)}})})),"chrome"!==(null===(_=this.handler)||void 0===_?void 0:_.name)){e.next=27;break}return e.next=27,S;case 27:return t.streamId=g.streamId,t.videoMid=c,t.audioMid=s,t.subVideoDescriptions=m.subVideoDescriptions,this.monitor.rtcPublishStat(uj.SUCCESS,dj.W_0,a,lj.UNKNOWN),t.statsReport.setLocalStreamStatsEvtInterval(this,this._handler,this.monitor),e.abrupt("return");case 36:return e.prev=36,e.t0=e.catch(6),e.t0 instanceof Error&&this.monitor.rtcPublishStat(uj.FAIL,dj.W_0,a,e.t0.message),e.next=41,null===(E=this._handler)||void 0===E?void 0:E.rollback(t.stream.id,t);case 41:throw e.t0;case 42:case"end":return e.stop()}}),e,this,[[6,36]])}))),function(e){return C.apply(this,arguments)})},{key:"updatePubTrack",value:(R=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,k,T,I,A,R,C,w,O,x,P,D,N,M;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:vX.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,a=t.audioTrack,s=t.pubAudio,c=t.pubVideo,u=null==a?void 0:a.getTrack("preprocessing"),d=null==i?void 0:i.getTrack("preprocessing"),c&&d?null===(l=t.videoTransceiver)||void 0===l||l.sender.replaceTrack(d):null===(h=t.videoTransceiver)||void 0===h||h.sender.replaceTrack(null),pM||null===(f=this._handler)||void 0===f||f.updateScaleResolutionDownBy(t),null===(r=this._handler)||void 0===r||r.updateMaxBitrate(t),s&&u?(v=a.mixType,(_=a.mixedAudioTrack)&&v!==re.PLAYOUT&&!0===u.enabled&&(u=_),null===(p=t.audioTransceiver)||void 0===p||p.sender.replaceTrack(u)):(null===(m=t.audioTransceiver)||void 0===m||m.sender.replaceTrack(null),this.monitor.rtcInvokeStatus("null",0,"MediaClient.updatePubTrack(audio)","",0));try{this.monitor.rtcInvokeStatus(JSON.stringify({audioStreamTrack:RM(u),videoStreamTrack:RM(d)}),0,"MediaClient.updatePubTrack","",0)}catch(EZ){}for(y={localaudio:!!a,localvideo:!!i,videostream:c,audiostream:s,extvideo:!!(i instanceof Zz),extaudio:!!(a instanceof $z)},g={},S=0,E=Object.entries(y);S<E.length;S++)k=b(E[S],2),T=k[0],(I=k[1])!==Reflect.get(t.pubAttributes,T)&&Reflect.set(g,T,I);if(Object.keys(g).length){e.next=14;break}return e.abrupt("return");case 14:return t.observer&&(A=t.observer,R=g.audiostream,C=g.videostream,w=g.localaudio,O=g.localvideo,x=g.extaudio,P=g.extvideo,void 0!==O?void 0!==P?A.setPushVideo(P):A.setEnableVideo(O):void 0!==C&&A.setUnmuteVideo(C),void 0!==w?void 0!==x?A.setPushAudio(x):A.setEnableAudio(w):void 0!==R&&A.setUnmuteAudio(R)),t.pubAttributes=y,D={roomId:this._roomId,streamId:t.streamId,attributes:g},e.next=19,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateStreamAttributes",D);case 19:if(200===(null==(N=e.sent)?void 0:N.code)){e.next=22;break}throw new hD(dD.UPDATE_TRACK_FAILED,(null==N?void 0:N.message)||"update track failed");case 22:if(!oM){e.next=25;break}return e.next=25,null===(M=this._handler)||void 0===M?void 0:M.setCurrentDescription();case 25:case"end":return e.stop()}}),e,this)}))),function(e){return R.apply(this,arguments)})},{key:"updateToken",value:(A=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(vX.print("updateToken()","newToken: %o",t),this._token=t,this._appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(a=this._dataChannelSignal)||void 0===a?void 0:a.sendSignaling("updateToken",i);case 8:if(200===(null==(s=e.sent)?void 0:s.code)){e.next=11;break}throw new hD(dD.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new hD(dD.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return A.apply(this,arguments)})},{key:"unpublish",value:(I=c(o().mark((function e(t){var r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return vX.print("unpublish()","localStream: %o",t),i={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",i),e.next=5,null===(n=this._handler)||void 0===n?void 0:n.handleAck({action:XK.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 5:t.statsReport.unpublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"subscribe",value:(T=c(o().mark((function e(t,r,n){var i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=c(o().mark((function e(a,s){var c,u,d,l,f,p,v,_,m,y,g,S,E,b,k,T,I,A,R,C,w,O,x,P,D,N,M,L,U,V;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==jK.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,dX.SUB).then(a,s));case 2:if(t.streamState!==jK.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),vX.print("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:a,reject:s}),e.abrupt("return");case 7:if(vX.print("subscribe()","mediaType: %o",r),yX("subscribe()",t),t.streamState=jK.SUB_ING,u=!1,d=!1,kM(r)&&(d=!0),TM(r)&&(u=!0),u||!i.multiChatMode()){e.next=17;break}return t.streamState=jK.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",a(null));case 17:return l=$N(),f=t.subVideo,p=[],v=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),p.push(new Promise((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new hD(dD.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),_X);t.on("ontrack",(function r(i){"video"===i.mediaType&&(vX.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v&&p.push(new Promise((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new hD(dD.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),_X);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(vX.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_=function(e){t.ontrack(e)},null===(c=i._handler)||void 0===c||c.on("ontrack",_),i._ontrackCallbackMap.set(t,_),e.prev=27,e.next=30,null===(m=i._handler)||void 0===m?void 0:m.subscribe(t,{multiChatMode:i.multiChatMode()});case 30:if(I=e.sent){e.next=33;break}throw new hD(dD.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 33:return A=I.audioMid,R=I.videoMid,t.subVideo=u,C={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},w={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:R,audioMid:A,sdpInfo:{sdp:null==I?void 0:I.partialSdp,semantics:null==I?void 0:I.semantics,type:null==I?void 0:I.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||d,video:u},qualityLayer:C},extra:{enableSendRTT:!0}},O=i._context||{},x=O.subscribeFallbackOption,P=O.userPriority,"number"==typeof x&&(w.config.fallbackOption=x),null!=P&&P.has(t.userId)&&(w.config.priority=P.get(t.userId)),null!=I&&I.allSsrc&&(w.extra.subscribeSSRC=I.allSsrc),e.next=44,null===(y=i._dataChannelSignal)||void 0===y?void 0:y.sendSignaling("subscribe",w);case 44:if(200===(null==(D=e.sent)?void 0:D.code)){e.next=47;break}throw new hD(dD.SUBSCRIBE_FAILED,(null==D?void 0:D.message)||"subscribe failed");case 47:return N=null==D?void 0:D.relayMessage,M=N.audioMid,L=N.videoMid,h(g={},A,M),h(g,R,L),U=g,vX.print("sub midmap",t.userId,U),t.videoMid=R,t.audioMid=A,t.subMediaType=r,t.streamState=jK.SUB_ED,t.subLayer=C,wj.rtcRecvAnswer(0,sj.INCRANSWER,(null==D||null===(S=D.relayMessage)||void 0===S?void 0:S.sequenceId)||0,null==D||null===(E=D.relayMessage)||void 0===E?void 0:E.sdp,cj.DOWN,t.streamId,t.userId),e.next=58,null===(b=i._handler)||void 0===b?void 0:b.handleAck({action:XK.subscribe,streamId:t.streamId,audioMid:A,videoMid:R,audioTransceiverInit:null==I?void 0:I.audioTransceiverInit,videoTransceiverInit:null==I?void 0:I.videoTransceiverInit,signalingAck:{sdp:null==D||null===(k=D.relayMessage)||void 0===k?void 0:k.sdp,sequenceId:null==D||null===(T=D.relayMessage)||void 0===T?void 0:T.sequenceId},stream:t,sdp:I.sdp,generatorSsrc:!!I.allSsrc});case 58:return e.next=60,Promise.all(p);case 60:i.multiChatMode()||(t.subAudio=d),i.monitor.rtcSubscribeStat(hj.SUCCESS,l,fj.UNKNOWN,t.userId),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval(i,i._handler,i.monitor,i._context),a(null),i.emit("SUB_END",t.streamId),e.next=76;break;case 67:return e.prev=67,e.t0=e.catch(27),e.t0 instanceof Error&&i.monitor.rtcSubscribeStat(hj.FAIL,l,e.t0.message,t.userId),t.subVideo=f,t.streamState=jK.INIT,e.next=74,null===(V=i._handler)||void 0===V?void 0:V.rollback(t.streamId,t);case 74:s(e.t0),i.emit("SUB_END",t.streamId);case 76:case"end":return e.stop()}}),e,null,[[27,67]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return T.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){vX.print("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else vX.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(k=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return vX.print("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"updateUserAttributes",value:(E=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return vX.print("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"updateSubTrack",value:(S=c(o().mark((function e(t,r,n){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return S.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(y=c(o().mark((function e(t,r){var n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(vX.print("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return vX.print("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=10;break}throw new hD(dD.UPDATE_TRACK_FAILED,(null==a?void 0:a.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return y.apply(this,arguments)})},{key:"_updateSubTrack",value:(_=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(vX.print("updateSubTrack()","mediaType: %o",r),yX("updateSubTrack()",t),!this.multiChatMode()||r!==U.AUDIO){e.next=5;break}return vX.print("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return s=0,s=n===dX.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),vX.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,s),t.subMediaType===s&&vX.print("updateSubTrack","mediaType no change"),c=!1,u=!1,kM(s)&&(u=!0),TM(s)&&(c=!0),d={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:c,audio:!!this.multiChatMode()||u}}},l=this._context||{},h=l.subscribeFallbackOption,f=l.userPriority,"number"==typeof h&&(d.config.fallbackOption=h),null!=f&&f.has(t.userId)&&(d.config.priority=f.get(t.userId)),e.next=18,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",d);case 18:if(200===(null==(p=e.sent)?void 0:p.code)){e.next=21;break}throw new hD(dD.UPDATE_TRACK_FAILED,(null==p?void 0:p.message)||"update track failed");case 21:return this.multiChatMode()||(null===(v=t.observer)||void 0===v||v.setUnmuteAudio(u),t.subAudio=u),null===(a=t.observer)||void 0===a||a.setUnmuteVideo(c),t.subVideo=c,t.subMediaType=s,e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(v=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return vX.print("subscribe4pushTrack()","streamInfo: %o",r),yX("subscribe4pushTrack()",t),t.subAudio=!0,null===(n=t.observer)||void 0===n||n.setPushTrack(!0),e.next=6,null===(i=this._handler)||void 0===i?void 0:i.subscribe(t,{multiChatMode:this.multiChatMode()});case 6:if(c=e.sent){e.next=9;break}throw new hD(dD.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 9:return u=c.audioMid,d=c.videoMid,(l=[]).push(new Promise((function(e,r){var n=setTimeout((function(){return r(new hD(dD.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),_X);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(vX.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),h=function(e){t.ontrack(e)},null===(a=this._handler)||void 0===a||a.on("ontrack",h),this._ontrackCallbackMap.set(t,h),e.next=18,null===(s=this._handler)||void 0===s?void 0:s.handleAck({action:XK.pushtrack,streamId:t.streamId,audioMid:u,videoMid:d,stream:t,audioTransceiverInit:null==c?void 0:c.audioTransceiverInit,videoTransceiverInit:null==c?void 0:c.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:c.sdp});case 18:return e.next=20,Promise.all(l);case 20:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval(this,this._handler,this.monitor,this._context);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(p=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:yX("unsubscribe4removeTrack()",t),vX.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return p.apply(this,arguments)})},{key:"unsubscribe",value:(d=c(o().mark((function e(t,r){var n,i,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=a.length>2&&void 0!==a[2]&&a[2],yX("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!TM(r)){e.next=6;break}return e.abrupt("return",this._unsubscribe(t,r));case 6:if(i=t.subMediaType-(t.subMediaType&r),this.multiChatMode()||i!==TK.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,dX.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"_unsubscribe",value:(s=c(o().mark((function e(t,r){var n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.hasSubscribed){e.next=2;break}return e.abrupt("return");case 2:if(!this._subConfig.muteReplaceUnsub){e.next=4;break}return e.abrupt("return",this._updateSubTrack(t,r,dX.UNSUB));case 4:return c={roomId:this._roomId,streamId:t.streamId,userId:t.userId},null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",c).catch((function(){})),t.streamState=jK.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(a=t.observer)||void 0===a||a.setSubscribeAudio(!1)),e.next=13,null===(s=this._handler)||void 0===s?void 0:s.handleAck({action:XK.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 13:u=e.sent,this._subResolves[u]&&this._subResolves[u].forEach((function(e){return e(0)})),vX.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t,r=this._ontrackCallbackMap.get(e);r&&(null===(t=this._handler)||void 0===t||t.off("ontrack",r),this._ontrackCallbackMap.delete(e))}},{key:"handleRemoveStream",value:(a=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yX("handleRemoveStream()",t),t.subVideo=!1,t.hasSubscribed){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,U.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"leave",value:(n=c(o().mark((function e(){var t,r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(vX.print("leave()"),"connected"!==this.connectionState){e.next=22;break}return this.connectionState="disconnecting",t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=6,this._joinLeaveLock.lock();case 6:return r=e.sent,e.prev=7,e.next=10,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 10:this.connectionState="disconnected",e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),this.connectionState="connected",e.t0;case 17:return e.prev=17,r(),e.finish(17);case 20:e.next=23;break;case 22:return e.abrupt("return",Promise.reject(new hD(dD.NOT_CONNECTED_YET,"server not connected")));case 23:case"end":return e.stop()}}),e,this,[[7,13,17,20]])}))),function(){return n.apply(this,arguments)})},{key:"subscribePublicStream",value:(r=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new hD(dD.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=$N(),u=s.audioMid,d=s.videoMid,e.t0=this._appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,GG();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=tG.VERSION,e.t8=Jj.getDeviceId(),e.t9=this._appId,e.t10=this._businessId,e.t11=this._useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,f=[],this._subResolves[t.streamId]=[],f.push(new Promise((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new hD(dD.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),_X);t.on("ontrack",(function r(i){"video"===i.mediaType&&(vX.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),f.push(new Promise((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new hD(dD.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),_X);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(vX.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",p),this._ontrackCallbackMap.set(t,p),v=null==h?void 0:h.relayMessage,_=v.sequenceId,m=v.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=_,t.streamState=jK.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:XK.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:_},stream:t});case 44:return e.next=46,Promise.all(f);case 46:this.monitor.rtcSubscribeStat(hj.SUCCESS,c,fj.UNKNOWN,t.userId),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval(this,this._handler,this.monitor,this._context);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(t=c(o().mark((function e(t){var r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yX("unsubscribePublicStream()",t),n={appId:this._appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=jK.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:XK.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;vX.print("destroy()"),this._token=void 0,this._appId=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId=void 0,this._context=void 0,null===(e=this._handler)||void 0===e||e.destroy(),null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),null===(r=this._iceConfigRequestManager)||void 0===r||r.abort(),this._handler=void 0,this._dataChannelSignal=void 0,this._iceConfigRequestManager=void 0,this._removeSignalEventHandler(),this.connectionState="disconnected",this.emit("INTERRUPT")}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}}]),P}(GU);function SX(e,t,r){var n=r.value;return r.value=c(o().mark((function e(){var r,i,a,s=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=s.length,i=new Array(r),a=0;a<r;a++)i[a]=s[a];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new hD(dD.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function EX(e,t,r){var n=r.value;return r.value=c(o().mark((function e(){var t,r,i,a,s=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=s.length,i=new Array(r),a=0;a<r;a++)i[a]=s[a];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}pX([function(e,t,r){var n=r.value;return r.value=c(o().mark((function e(){var t,r,i,a,s=this,u=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=u.length,r=new Array(t),i=0;i<t;i++)r[i]=u[i];return a=!1,e.abrupt("return",new Promise(function(){var e=c(o().mark((function e(t,i){var c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s.on("INTERRUPT",(function(){a=!0,i(new hD(dD.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(s,r);case 4:c=e.sent,t(c),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),a||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],gX.prototype,"join",1),pX([EX,SX],gX.prototype,"publish",1),pX([EX,SX],gX.prototype,"updatePubTrack",1),pX([EX,SX],gX.prototype,"unpublish",1),pX([EX,SX],gX.prototype,"subscribe",1),pX([SX],gX.prototype,"controlMessage",1),pX([SX],gX.prototype,"updateUserAttributes",1),pX([SX],gX.prototype,"updateSubTrack",1),pX([SX],gX.prototype,"updateSubTrackLayer",1),pX([EX,SX],gX.prototype,"subscribe4pushTrack",1),pX([EX,SX],gX.prototype,"unsubscribe4removeTrack",1),pX([EX,SX],gX.prototype,"unsubscribe",1),pX([SX],gX.prototype,"handleRemoveStream",1),pX([EX],gX.prototype,"subscribePublicStream",1),pX([EX],gX.prototype,"unsubscribePublicStream",1);var bX,kX=function(){function e(t,r){u(this,e),h(this,"_audioEventSessionId",mM()),h(this,"_videoEventSessionId",mM()),h(this,"_handler",void 0),h(this,"_stream",void 0),h(this,"_firstAudioFrameTimer",void 0),h(this,"_firstVideoFrameTimer",void 0),h(this,"_transportDelayInterval",void 0),h(this,"_transportDelay",void 0),h(this,"_firstVideoFrameInterval",void 0),h(this,"_firstAudioFrameInterval",void 0),h(this,"_isScreen",!1),h(this,"_audioFirstFrameState",0),h(this,"_videoFirstFrameState",0),h(this,"_timeout",1e4),h(this,"_currentAudioRecv",{startTime:0,eventSessionId:0,type:mj.LOGIN}),h(this,"_currentVideoRecv",{startTime:0,eventSessionId:0,type:mj.LOGIN}),h(this,"_login",!1),h(this,"_unMuteAudio",!1),h(this,"_enableAudio",!1),h(this,"_unMuteVideo",!1),h(this,"_enableVideo",!1),h(this,"_remoteUnmuteAudio",!1),h(this,"_remoteUnmuteVideo",!1),h(this,"_audioExternal",!1),h(this,"_pushAudio",!1),h(this,"_videoExternal",!1),h(this,"_pushVideo",!1),h(this,"_autoSubscribeVideo",!1),h(this,"_autoSubscribeAudio",!1),h(this,"_autoSubscribe",!1),h(this,"_publishVideo",!1),h(this,"_publishAudio",!1),h(this,"_subscribeAudio",!1),h(this,"_subscribeVideo",!1),h(this,"_subscribe",!1),h(this,"_pushTrack",!1),h(this,"_multiChatMode",!1),this._stream=t,this._handler=r,this.getTransportDelay()}var t,r,n,i;return l(e,[{key:"beginRecvFrame",value:(i=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:n=this._transportDelay,i=!0,a=mj.LOGIN,s=mj.UNMUTE,c=mj.SUBSCRIBE,u=mj.PUSH_TRACK,[a,s,c,u].indexOf(r)>=0&&(n=0,i=!1),t===_j.AUDIO?(i||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},h={media_type:t,event_type:vj.BEGIN_RECV,type:r,start:null===(d=this._currentAudioRecv)||void 0===d?void 0:d.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(l=this._stream)||void 0===l?void 0:l.userId,transport_delay:n},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){m.stopRecvFrame(_j.AUDIO,yj.TIMEOUT),m._firstAudioFrameInterval&&window.clearInterval(m._firstAudioFrameInterval)}),this._timeout),wj.rtcFirstFrame(h),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):t===_j.VIDEO&&(i||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},_={media_type:null!==(f=this._stream)&&void 0!==f&&f.isScreen?_j.SCREEN_VIDEO:t,event_type:vj.BEGIN_RECV,type:r,start:null===(p=this._currentVideoRecv)||void 0===p?void 0:p.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(v=this._stream)||void 0===v?void 0:v.userId,transport_delay:n},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){m.stopRecvFrame(_j.VIDEO,yj.TIMEOUT),m._firstVideoFrameInterval&&window.clearInterval(m._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),wj.rtcFirstFrame(_),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if(e===_j.AUDIO){var r,n,i;if(1!==this._audioFirstFrameState)return;var o={event_type:vj.RECV_END,media_type:e,start:null===(r=this._currentAudioRecv)||void 0===r?void 0:r.startTime,reason:t,result:!1,stream_user_id:null===(n=this._stream)||void 0===n?void 0:n.userId,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioRecv)||void 0===i?void 0:i.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,wj.rtcFirstFrame(o),this._audioFirstFrameState=2}else if(e===_j.VIDEO){var a,s,c,u;if(1!==this._videoFirstFrameState)return;var d={event_type:vj.RECV_END,media_type:null!==(a=this._stream)&&void 0!==a&&a.isScreen?_j.SCREEN_VIDEO:e,start:null===(s=this._currentVideoRecv)||void 0===s?void 0:s.startTime,reason:t,result:!1,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,event_session_id:this._videoEventSessionId,type:null===(u=this._currentVideoRecv)||void 0===u?void 0:u.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,wj.rtcFirstFrame(d),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,n=mj.LOGIN,i=mj.UNMUTE,a=mj.SUBSCRIBE,s=mj.PUSH_TRACK,t!==_j.AUDIO){e.next=18;break}if(1===this._audioFirstFrameState){e.next=7;break}return e.abrupt("return");case 7:if(this._currentAudioRecv){e.next=9;break}return e.abrupt("return");case 9:u=this._currentAudioRecv,d=u.type,l=u.startTime,[n,i,a,s].indexOf(d)>=0&&(r=0),h={event_type:vj.RECV_END,media_type:t,start:l,result:!0,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,event_session_id:this._audioEventSessionId,type:d,transport_delay:r},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),wj.rtcFirstFrame(h),this._audioFirstFrameState=3,e.next=30;break;case 18:if(t!==_j.VIDEO){e.next=30;break}if(1===this._videoFirstFrameState){e.next=21;break}return e.abrupt("return");case 21:if(this._currentVideoRecv){e.next=23;break}return e.abrupt("return");case 23:v=this._currentVideoRecv,_=v.type,m=v.startTime,[n,i,a,s].indexOf(_)>=0&&(r=0),y={event_type:vj.RECV_END,media_type:null!==(f=this._stream)&&void 0!==f&&f.isScreen?_j.SCREEN_VIDEO:t,start:m,result:!0,stream_user_id:null===(p=this._stream)||void 0===p?void 0:p.userId,event_session_id:this._videoEventSessionId,type:_,transport_delay:r},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),wj.rtcFirstFrame(y),this._videoFirstFrameState=3;case 30:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame(_j.AUDIO,mj.LOGIN),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame(_j.VIDEO,mj.LOGIN),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame(_j.AUDIO,yj.LEAVE_ROOM),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame(_j.VIDEO,yj.LEAVE_ROOM))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&null!==(r=this._stream)&&void 0!==r&&r.audioHasPublish&&(this._unMuteAudio?this.beginRecvFrame(_j.AUDIO,mj.UNMUTE):null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame(_j.AUDIO,yj.MUTE)))}},{key:"setRemoteUnmuteAudio",value:function(e){var t;this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame(_j.AUDIO,mj.REMOTE_UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(_j.AUDIO,yj.REMOTE_MUTE))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame(_j.AUDIO,mj.ENABLE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(_j.AUDIO,yj.DISABLE))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&null!==(r=this._stream)&&void 0!==r&&r.videoHasPublish&&(this._unMuteVideo?this.beginRecvFrame(_j.VIDEO,mj.UNMUTE):null!==(n=this._stream)&&void 0!==n&&n.hasVideo&&this.stopRecvFrame(_j.VIDEO,yj.MUTE)))}},{key:"setRemoteUnmuteVideo",value:function(e){var t;this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame(_j.VIDEO,mj.REMOTE_UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(_j.VIDEO,yj.REMOTE_MUTE))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame(_j.VIDEO,mj.ENABLE):this.stopRecvFrame(_j.VIDEO,yj.DISABLE))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame(_j.AUDIO,mj.PUSH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame(_j.AUDIO,mj.PUSH)}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame(_j.VIDEO,mj.PUSH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame(_j.VIDEO,mj.PUSH)}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame(_j.VIDEO,mj.PUBLISH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(_j.VIDEO,yj.UNPUBLISH)}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame(_j.AUDIO,mj.PUBLISH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(_j.AUDIO,yj.UNPUBLISH)}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame(_j.AUDIO,mj.SUBSCRIBE));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(_j.AUDIO,yj.UNSUBSCRIBE)}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame(_j.VIDEO,mj.SUBSCRIBE));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(_j.VIDEO,yj.UNSUBSCRIBE)}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame(_j.AUDIO,mj.PUSH_TRACK),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(_j.AUDIO,yj.REMOVE_TRACK))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(c(o().mark((function n(){var i,a,s,c,u,d,l,h;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(a=e._stream)||void 0===a||null===(s=a.videoTrack)||void 0===s||!s.getTrack()){n.next=12;break}return n.next=3,LG(null===(c=e._handler)||void 0===c?void 0:c.pc,null===(u=e._stream)||void 0===u||null===(d=u.videoTrack)||void 0===d?void 0:d.getTrack());case 3:if(l=n.sent,!(h=l.find((function(e){return"inbound-rtp"===e.type})))||!(h.framesReceived>t||h.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=h.framesReceived,r=h.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish(_j.VIDEO),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(c(o().mark((function n(){var i,a,s,c,u,d,l,h;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(a=e._stream)||void 0===a||null===(s=a.audioTrack)||void 0===s||!s.getTrack()){n.next=12;break}return n.next=3,LG(null===(c=e._handler)||void 0===c?void 0:c.pc,null===(u=e._stream)||void 0===u||null===(d=u.audioTrack)||void 0===d?void 0:d.getTrack());case 3:if(l=n.sent,!(h=l.find((function(e){return"inbound-rtp"===e.type})))||!(h.totalSamplesReceived>t||h.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=h.totalSamplesReceived,r=h.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish(_j.AUDIO),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=c(o().mark((function e(){var t=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=c(o().mark((function e(){var t,r,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,LG(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=n.find((function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(a=n.find((function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*a.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:mj.LOGIN},this._currentVideoRecv={startTime:0,eventSessionId:0,type:mj.LOGIN},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}}]),e}(),TX=function(){function e(t,r){u(this,e),h(this,"_audioEventSessionId",mM()),h(this,"_videoEventSessionId",mM()),h(this,"_pcSessionId",void 0),h(this,"_handler",void 0),h(this,"_firstAudioFrameTimer",void 0),h(this,"_firstVideoFrameTimer",void 0),h(this,"_stream",void 0),h(this,"_firstVideoFrameInterval",void 0),h(this,"_firstAudioFrameInterval",void 0),h(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:mj.LOGIN}),h(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:mj.LOGIN}),h(this,"_login",!1),h(this,"_publisher",!1),h(this,"_unMuteAudio",!1),h(this,"_enableAudio",!1),h(this,"_unMuteVideo",!1),h(this,"_enableVideo",!1),h(this,"_audioExternal",!1),h(this,"_pushAudio",!1),h(this,"_videoExternal",!1),h(this,"_pushVideo",!1),h(this,"_autoPublish",!1),h(this,"_publish",!1),h(this,"_timeout",1e4),h(this,"_audioFirstFrameState",0),h(this,"_videoFirstFrameState",0),this._stream=t,this._handler=r}var t,r;return l(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if(e===_j.AUDIO){var n;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var i={media_type:e,event_type:vj.BEGIN_SEND,type:t,start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,event_session_id:this._audioEventSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){r.stopSendFrame(_j.AUDIO,yj.TIMEOUT),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),wj.rtcFirstFrame(i),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if(e===_j.VIDEO){var o,a;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var s={media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?_j.SCREEN_VIDEO:e,event_type:vj.BEGIN_SEND,type:t,start:null===(a=this._currentVideoSend)||void 0===a?void 0:a.startTime,event_session_id:this._videoEventSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){r.stopSendFrame(_j.VIDEO,yj.TIMEOUT),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),wj.rtcFirstFrame(s),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if(e===_j.AUDIO){var r,n;if(1!==this._audioFirstFrameState)return;var i={event_type:vj.SENT_END,media_type:e,start:null===(r=this._currentAudioSend)||void 0===r?void 0:r.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(n=this._currentAudioSend)||void 0===n?void 0:n.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,wj.rtcFirstFrame(i),this._audioFirstFrameState=2}else if(e===_j.VIDEO){var o,a,s;if(1!==this._videoFirstFrameState)return;var c={event_type:vj.SENT_END,media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?_j.SCREEN_VIDEO:e,start:null===(a=this._currentVideoSend)||void 0===a?void 0:a.startTime,reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(s=this._currentVideoSend)||void 0===s?void 0:s.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,wj.rtcFirstFrame(c),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if(e===_j.AUDIO){if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var t=this._currentAudioSend,r=t.type,n=t.startTime,i={event_type:vj.SENT_END,media_type:e,start:n,result:!0,event_session_id:this._audioEventSessionId,type:r};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),wj.rtcFirstFrame(i),this._audioFirstFrameState=3}else if(e===_j.VIDEO){var o;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var a=this._currentVideoSend,s=a.type,c=a.startTime,u={event_type:vj.SENT_END,media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?_j.SCREEN_VIDEO:e,start:c,result:!0,event_session_id:this._videoEventSessionId,type:s};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),wj.rtcFirstFrame(u),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame(_j.VIDEO,mj.LOGIN),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame(_j.AUDIO,mj.LOGIN);!e&&this._audioSending&&this.stopSendFrame(_j.AUDIO,yj.LEAVE_ROOM),!e&&this._videoSending&&this.stopSendFrame(_j.VIDEO,yj.LEAVE_ROOM)}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r,n,i;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&(null===(r=this._stream)||void 0===r?void 0:r.pubVideo)&&this.beginSendFrame(_j.VIDEO,mj.PUBLISH),(null===(n=this._stream)||void 0===n?void 0:n.audioTrack)&&(null===(i=this._stream)||void 0===i?void 0:i.pubAudio)&&this.beginSendFrame(_j.AUDIO,mj.PUBLISH);!e&&this._audioSending&&this.stopSendFrame(_j.AUDIO,yj.UNPUBLISH),!e&&this._videoSending&&this.stopSendFrame(_j.VIDEO,yj.UNPUBLISH)}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame(_j.AUDIO,mj.UNMUTE),!e&&this._audioSending&&this.stopSendFrame(_j.AUDIO,yj.MUTE)))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame(_j.AUDIO,mj.ENABLE),!e&&this._audioSending&&this.stopSendFrame(_j.AUDIO,yj.DISABLE))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame(_j.VIDEO,mj.UNMUTE),!e&&this._videoSending&&this.stopSendFrame(_j.VIDEO,yj.MUTE)))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame(_j.VIDEO,mj.ENABLE),!e&&this._videoSending&&this.stopSendFrame(_j.VIDEO,yj.DISABLE))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame(_j.AUDIO,yj.DISABLE),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame(_j.AUDIO,yj.STOP_PUSH),this._pushAudio=!1))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame(_j.AUDIO,mj.PUSH),!e&&this._audioSending&&this.stopSendFrame(_j.AUDIO,yj.STOP_PUSH))}},{key:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame(_j.VIDEO,yj.DISABLE),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame(_j.VIDEO,yj.STOP_PUSH),this._pushVideo=!1))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame(_j.VIDEO,mj.PUSH),!e&&this._videoSending&&this.stopSendFrame(_j.VIDEO,yj.STOP_PUSH))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame(_j.AUDIO,yj.AUDIENCE),!e&&this._videoSending&&this.stopSendFrame(_j.VIDEO,yj.AUDIENCE))}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=c(o().mark((function e(){var t,r,n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,LG(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(a=this._stream)||void 0===a||null===(s=a.videoTrack)||void 0===s?void 0:s.getTrack("preprocessing"));case 3:return c=e.sent,u=c.find((function(e){return"outbound-rtp"===e.type})),e.abrupt("return",u);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=c(o().mark((function e(){var t,r,n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,LG(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(a=this._stream)||void 0===a||null===(s=a.audioTrack)||void 0===s?void 0:s.getTrack("preprocessing"));case 3:return c=e.sent,u=c.find((function(e){return"outbound-rtp"===e.type})),e.abrupt("return",u);case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(c(o().mark((function n(){var i;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(!(i=n.sent)||!(i.framesSent>t||i.packetsSent>r)){n.next=10;break}if(-1!==t||-1!==r){n.next=8;break}return t=i.framesSent,r=i.packetsSent,n.abrupt("return");case 8:e.sendFrameFinish(_j.VIDEO),window.clearInterval(e._firstVideoFrameInterval);case 10:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(c(o().mark((function r(){var n;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish(_j.AUDIO),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:mj.LOGIN},this._currentVideoSend={startTime:0,eventSessionId:0,type:mj.LOGIN},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),IX=(h(bX={},"audio",{delay:1200,stallRadio:.3}),h(bX,"video",{delay:1200,stallRadio:.6}),h(bX,"screen_audio",{delay:1600,stallRadio:.8}),h(bX,"screen_video",{delay:1600,stallRadio:.8}),bX),AX=function(){function e(){u(this,e),h(this,"_preUplinkStats",new Map),h(this,"_preDownlinkStats",new Map),h(this,"_timer",void 0),h(this,"_delayTimer",void 0),h(this,"_connectionState",mX.CONNECTED),h(this,"reportor",void 0)}return l(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i=n?"screen_audio":"audio",o=t.rtt,a=t._fractionLost,s=t._retransmittedRate,c=this._getQosLevel(o,a||0,s||0),u=this._preUplinkStats.get(i)||[c];this._preUplinkStats.set(i,[].concat(k(u),[c]).slice(-2))}if(r.sentKBitrate>0&&r.rtt){var d=n?"screen_video":"video",l=r._fractionLost,h=r.rtt,f=r._sendBandWidth,p=r._retransmittedRate;0===f&&(l=Math.max(.65,l));var v=this._getQosLevel(h,l||0,p||0),_=this._preUplinkStats.get(d)||[v];this._preUplinkStats.set(d,[].concat(k(_),[v]).slice(-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=W.VBAD;else{var l=s.rtt,h=s.audioLossRate,f=s.stallDuration,p=s.statsInterval,v=s.e2eDelay,_=f/p,m=u?"screen_audio":"audio",y=this._getQosLevel(l,h||0,c._retransmittedRate||0),g=this._getDownlinkQoE(m,_,v);r=this._getNetworkQuality(y,g)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=W.VBAD;else{var S=c.rtt,E=c.videoLossRate,b=c.stallDuration,T=c.statsInterval,I=c.e2eDelay,A=c._retransmittedRate,R=b/T,C=u?"screen_video":"video",w=this._getQosLevel(S,E||0,A||0),O=this._getDownlinkQoE(C,R,I);n=this._getNetworkQuality(w,O)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var P="".concat(d).concat(u?"_screen":""),D=this._preDownlinkStats.get(P)||[x];this._preDownlinkStats.set(P,[].concat(k(D),[x]).slice(-2)),this._startNetworkQualityReport()}}}},{key:"setConnectionState",value:function(e){this._connectionState=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r=this;if(this._connectionState!==mX.CONNECTED)e=t=W.VBAD;else{var n=this._getBetterQualityAndRemoveOldest("audio","up"),i=this._getBetterQualityAndRemoveOldest("video","up");e=n&&i?Math.ceil((n+i)/2):n||i||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||W.EXCELLENT;var o=Array.from(this._preDownlinkStats.keys()).map((function(e){return r._getBetterQualityAndRemoveOldest(e,"down")})).filter((function(e){return e}));t=Math.ceil(o.reduce((function(e,t){return t+e}),0)/o.length)||W.UNKNOWN}"function"==typeof this.reportor&&this.reportor(e,t)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=IX[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=W.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=i.filter((function(e){return e}));o.length>0&&(r=Math.min.apply(Math,k(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&kM(t)&&r.localaudio&&r.audiostream,videoActive:n&&TM(t)&&r.localvideo&&r.videostream}}}]),e}(),RX=function(){function e(t){u(this,e),h(this,"_timer",void 0),h(this,"_remoteVideoSizeCache",{}),h(this,"_remoteScreenSizeCache",{}),h(this,"onchange",void 0),this._room=t,this._start()}return l(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,f=a.getSettings(),p=f.width,v=void 0===p?0:p,_=f.height,m=void 0===_?0:_;h===m&&d===v||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,v,m),delete s[i],(n.isScreen?r:t)[i]={width:v,height:m}}}))})),Object.keys(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),Object.keys(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),CX=new FU("Room",1),wX={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1},OX=function(e){f(M,e);var t,r,n,a,s,d,p,v,_,y,S,E,k,T,I,R,C,O,x,P,N=g(M);function M(e,t){var r;return u(this,M),h(m(r=N.call(this)),"_mediaServerClient",void 0),h(m(r),"_localStream",void 0),h(m(r),"_localScreenStream",void 0),h(m(r),"_remoteUsers",new Map),h(m(r),"_remoteStreams",new Map),h(m(r),"_remoteStreamStreamIdUserIdMap",{}),h(m(r),"_virtualStreams",[]),h(m(r),"_joinResolveCallback",void 0),h(m(r),"_joinRejectCallback",void 0),h(m(r),"_getAccessNode",void 0),h(m(r),"_getAccessFeedback",void 0),h(m(r),"_getAccessFeedbackIceNode",void 0),h(m(r),"_reconnectTimer",void 0),h(m(r),"_isReconnecting",void 0),h(m(r),"_context",void 0),h(m(r),"_sessionId",void 0),h(m(r),"_reconnectRecord",void 0),h(m(r),"_connectionLostTimer",void 0),h(m(r),"_liveControlMessage",void 0),h(m(r),"_serverConfig",void 0),h(m(r),"_liveTranscodingOnceSucc",!1),h(m(r),"_roomConfig",void 0),h(m(r),"_roomInfo",void 0),h(m(r),"_waitForNewToken",!1),h(m(r),"_userDuplicateLoginTimerMap",new Map),h(m(r),"_networkQualityManager",void 0),h(m(r),"_videoSizeObserver",void 0),h(m(r),"_hasPublished",!1),h(m(r),"_csrcUserIdMap",void 0),h(m(r),"_publishOnDemandItem",void 0),h(m(r),"_publishOnDemandBusy",!1),r._roomConfig=e,r._mediaServerClient=new gX(t),r._reconnectRecord=new xX,r._addHandlerEventHandler(),r._isReconnecting=!1,r._networkQualityManager=new AX,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(m(r)),r._videoSizeObserver=new RX(m(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(m(r)),r._context=t,r._csrcUserIdMap={},r}return l(M,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A,R,C,w,O,x=this;null===(e=this._mediaServerClient)||void 0===e||e.on(dG.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(dG.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return x._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(dG.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(dG.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return x._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(dG.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(dG.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return x._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(dG.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(dG.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return x._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(dG.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(dG.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(dG.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(dG.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(dG.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(dG.NODE_CHANGE,this._nodeChange.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(dG.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(dG.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(dG.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(dG.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(dG.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(dG.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(dG.ON_SCENE_CONFIG,this._onSceneConfig.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(dG.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(b=this._mediaServerClient)||void 0===b||b.on(lG.RSCP,(function(e){!!e.find((function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:t.includes(null===(r=x._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(x._publishOnDemandItem=e,x._onPublishOnDemand())})),null===(k=this._mediaServerClient)||void 0===k||k.on(lG.RTT,this._onRTT.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(hG.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(I=this._mediaServerClient)||void 0===I||I.on(hG.ABNORMAL_DISCONNECTION,this._handleAbnormalDisconnection.bind(this)),null===(A=this._mediaServerClient)||void 0===A||A.on(dG.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){x._networkQualityManager.updateDownlinkStats(e,x._findRemoteStreamByScreen(e.userId,e.isScreen)),x.emit(sX.ON_REMOTE_STREAM_STATS,IM(e))})),null===(C=this._mediaServerClient)||void 0===C||C.on("onLocalStreamStats",(function(e){x._networkQualityManager.updateUplinkStats(e),x.emit(sX.ON_LOCAL_STREAM_STATS,IM(e))})),null===(w=this._mediaServerClient)||void 0===w||w.on("prevIceNode",(function(e){x._getAccessFeedbackIceNode=e})),null===(O=this._mediaServerClient)||void 0===O||O.on("prevIceNode",(function(e){x._getAccessFeedbackIceNode=e}))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"join",value:(P=c(o().mark((function e(t,r,n,i,a,s,c){var u=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Pj.setStats({rtc_app_id:t,room_id:r,user_id:i.userId}),CX.print("join()"),e.abrupt("return",new Promise((function(e,o){var d,l,h=$N();u._joinResolveCallback=function(t){var r;wj.joinRoom(Sj.END,h,!0,"",{enable_cloud_proxy:null===(r=u._roomInfo)||void 0===r?void 0:r.useCloudProxy}),e(t)},u._joinRejectCallback=function(e){var t;wj.joinRoom(Sj.END,h,!1,e.message,{enable_cloud_proxy:null===(t=u._roomInfo)||void 0===t?void 0:t.useCloudProxy}),o(e)},u._liveControlMessage=a,u._roomInfo={appId:t,roomId:r,token:n,userInfo:i,useCloudProxy:s,roomProfile:u._roomConfig.roomProfileType,expectedIDC:c},u.setSessionId(),wj.joinRoom(Sj.BEGIN,h,!1,"",{enable_cloud_proxy:null===(d=u._roomInfo)||void 0===d?void 0:d.useCloudProxy,expectedIDC:null===(l=u._roomInfo)||void 0===l?void 0:l.expectedIDC}),u._join(u._joinResolveCallback,u._joinRejectCallback,!1)})));case 3:case"end":return e.stop()}}),e)}))),function(e,t,r,n,i,o,a){return P.apply(this,arguments)})},{key:"_join",value:(x=c(o().mark((function e(t,r){var n,i,a,s,c=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>2&&void 0!==c[2]&&c[2],i=$N(),CX.print("_join()"),e.prev=3,e.next=6,this._mediaServerClient.join(this._roomInfo,{node:this._getAccessNode,reason:this._getAccessFeedback,sessionId:this._sessionId,feedbackNode:this._getAccessFeedbackIceNode},n,this._liveControlMessage);case 6:s=e.sent,this._mediaServerClient.roomAttributes=s.roomAttributes,null!==(a=s.roomAttributes)&&void 0!==a&&a.multiChatMode&&this._handleFFAudioTrack(),this._reconnectRecord.clear(),this._joinResolveCallback=void 0,this._joinRejectCallback=void 0,this._getAccessFeedback=void 0,this._getAccessNode=void 0,"function"==typeof t&&t({users:s.clients,streams:s.streams}),this._isReconnecting=!1,wj.rtcJoinRoom(0,"web","web",$N()-i),this._onJoinSucc(s,n),e.next=24;break;case 20:if(e.prev=20,e.t0=e.catch(3),e.t0.code===dD.OPERATION_CANCEL||"function"!=typeof r){e.next=24;break}return e.abrupt("return",r(e.t0));case 24:case"end":return e.stop()}}),e,this,[[3,20]])}))),function(e,t){return x.apply(this,arguments)})},{key:"publishScreen",value:(O=c(o().mark((function e(t,r,n,i,a){var s,c,u,d,l,h,f,p,v,_;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(CX.print("publishScreen()"),this._localScreenStream||(this._localScreenStream=new GK,this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new TX(this._localScreenStream,this._mediaServerClient.handler))),s=!1,c=!1,u=!1,d=!1,!this._localScreenStream.videoTrack&&r?(r instanceof Zz&&(c=!0),s=!0):this._localScreenStream.videoTrack&&!r&&(s=!1),!this._localScreenStream.audioTrack&&n?(n instanceof $z&&(d=!0),u=!0):this._localScreenStream.audioTrack&&!n&&(u=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(kM(i)&&(this._localScreenStream.pubAudio=a===uX.PUB),TM(i)&&(this._localScreenStream.pubVideo=a===uX.PUB),CX.print("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(l=this._localScreenStream)||void 0===l||!l.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(h=this._localScreenStream.observer)||void 0===h||h.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return c?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushVideo(s):null===(p=this._localScreenStream.observer)||void 0===p||p.setEnableVideo(s),d?null===(v=this._localScreenStream.observer)||void 0===v||v.setPushAudio(u):null===(_=this._localScreenStream.observer)||void 0===_||_.setEnableAudio(u),e.next=28,this.updatePubScreenTrack();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return O.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(C=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(CX.print("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return C.apply(this,arguments)})},{key:"unpublishScreen",value:(R=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(CX.print("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=7;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.clean(),this._localScreenStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"liveControlMessage",value:(I=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return CX.print("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),this._liveControlMessage=t,e.next=5,this._mediaServerClient.controlMessage(t);case 5:"stopped"===t.action&&(delete this._liveControlMessage,this._liveTranscodingOnceSucc=!1),this._liveTranscodingOnceSucc=!0;case 7:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(T=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"updateUserAttributes",value:(k=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return CX.print("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"publish",value:(E=c(o().mark((function e(t,r,n,i,a,s){var c,u,d,l,h,f,p,v,_,m,y,g,S=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=S.length>6&&void 0!==S[6]&&S[6],CX.print("publish","Invoke publish"),u=!1,this._localStream||(this._localStream=new GK,this._mediaServerClient.handler&&(this._localStream.observer=new TX(this._localStream,this._mediaServerClient.handler)),u=!0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,a&&(kM(a)&&(this._localStream.pubAudio=s===uX.PUB),TM(a)&&(this._localStream.pubVideo=s===uX.PUB),CX.print("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,c?null===(d=this._localStream.observer)||void 0===d||d.setLogin(!0):u&&(l=!!this._localStream.videoTrack,h=!!this._localStream.audioTrack,f=this._localStream.videoTrack instanceof Zz,p=this._localStream.audioTrack instanceof $z,this._roomConfig.isAutoPublish&&!this._hasPublished?(l&&(f?null===(v=this._localStream.observer)||void 0===v||v.setPushVideo(!0):null===(_=this._localStream.observer)||void 0===_||_.setEnableVideo(!0)),h&&(p?null===(m=this._localStream.observer)||void 0===m||m.setPushAudio(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableAudio(!0))):null===(g=this._localStream.observer)||void 0===g||g.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(sX.ON_PUBLISH_RESULT,{isScreen:!1,state:D.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(sX.ON_PUBLISH_RESULT,{isScreen:!1,state:D.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return E.apply(this,arguments)})},{key:"updatePubTrack",value:(S=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(CX.print("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return S.apply(this,arguments)})},{key:"unpublish",value:(y=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(CX.print("unpublish","Invoke unpublish"),!this._localStream){e.next=6;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.clean(),this._localStream=void 0;case 6:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"subscribe",value:(_=c(o().mark((function e(t,r,n){var i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return CX.print("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"updateSubTrack",value:(v=c(o().mark((function e(t,r,n,i){var a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(CX.print("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(s=this._mediaServerClient)||void 0===s?void 0:s.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return v.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(p=c(o().mark((function e(t,r){var n,i,a,s,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((s=this._findRemoteStreamByScreen(t,!1))&&s.hasSubscribed&&!((null==s||null===(n=s.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return c=this._getSubLayer(r,s),s.originalStreamIndex=c.spatialLayer,e.abrupt("return",null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(s,c));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,f=0;f<(null==d?void 0:d.length);f++){var p,v;if(h>=(null===(p=d[f])||void 0===p?void 0:p.width)*(null===(v=d[f])||void 0===v?void 0:v.height)){l=f;break}}var _=d[0];if(-1===l)_=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,y=(m-h)/(m-d[l].width*d[l].height);_=y<.1?d[l-1]:d[l],l=y<.1?l-1:l}return a=null!==(r=null===(n=_)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=_)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(d=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return CX.print("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"leave",value:(s=c(o().mark((function e(){var t,r,n,i,a,s,c=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=c.length>0&&void 0!==c[0]&&c[0],CX.print("leave","Invoke leave"),r=$N(),e.prev=3,this._mediaServerClient.connectionState!==mX.CONNECTED&&this._joinRejectCallback&&this._joinRejectCallback(new Error(Ej.LEAVE_ROOM)),clearTimeout(this._reconnectTimer),n=A(this._remoteStreams.values());try{for(n.s();!(i=n.n()).done;)a=i.value,Array.isArray(a)&&a.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(o){n.e(o)}finally{n.f()}return this._localStream&&(null===(s=this._localStream.observer)||void 0===s||s.setLogin(!1)),e.next=11,this._mediaServerClient.leave();case 11:this.destroy(),wj.rtcLeaveRoom(0,"",$N()-r),Pj.setStats({room_id:void 0,user_id:void 0,rtc_session_id:void 0}),e.next=24;break;case 16:if(e.prev=16,e.t0=e.catch(3),!t){e.next=22;break}throw e.t0;case 22:this.destroy();case 23:e.t0 instanceof Error&&wj.rtcLeaveRoom(-1,e.t0.message,$N()-r);case 24:case"end":return e.stop()}}),e,this,[[3,16]])}))),function(){return s.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(e){e.streamState!==jK.INIT&&r._mediaServerClient.subscribe(e,e.subMediaType)}))}},{key:"destroy",value:function(){CX.print("destroy","Invoke destroy"),wj.rtcInvokeStatus("".concat((new Error).stack),0,"room_destroy","",0),this._destroyAndInitMediaServerClient(),this._roomInfo=void 0,this._remoteUsers=new Map;var e,t,r,n=A(this._remoteStreams);try{for(n.s();!(e=n.n()).done;){var i=b(e.value,2)[1];Array.isArray(i)&&i.forEach((function(e){e&&e.clean()}))}}catch(o){n.e(o)}finally{n.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new Map,this._localStream)&&(null===(t=this._localStream)||void 0===t||t.clean(),this._localStream=void 0);this._localScreenStream&&(null===(r=this._localScreenStream)||void 0===r||r.clean(),this._localScreenStream=void 0);this._context=void 0,this._reconnectRecord=new xX,this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={}}},{key:"updateToken",value:(a=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return CX.print("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.next=4,this._mediaServerClient.updateToken(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){this._sessionId=xN(),Pj.setStats({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(n=c(o().mark((function e(t){var r,n,i,a,s,c=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=c.length>1&&void 0!==c[1]&&c[1],s={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:a,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!a){e.next=8;break}return e.next=5,rM.ab2b64str(t);case 5:s.message=e.sent,e.next=9;break;case 8:s.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(s));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_destroyAndInitMediaServerClient",value:function(){CX.print("_destroyAndInitMediaServerClient()"),this._mediaServerClient&&(this._mediaServerClient.destroy(),this._removeHandlerEventHandler()),this._mediaServerClient=new gX(this._context),this._addHandlerEventHandler()}},{key:"_onJoinSucc",value:function(e,t){var r,n=this;CX.print("JoinSuccess()"),this._serverConfig=e.config;var i=[],o=[],a=[],s=[],c=[];null===(r=e.clientsDetail)||void 0===r||r.forEach((function(t){if(t.attributes&&(t.attributes.serverMuteVideo&&n.safeEmit(sX.ON_VIDEO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteVideo}),t.attributes.serverMuteAudio&&n.safeEmit(sX.ON_AUDIO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteAudio})),t.clientId!==e.clientId){var r=n._remoteUsers.get(t.clientId);r?r._stillExist=!0:i.push(t)}}));var u,d=A(this._remoteUsers.values());try{for(d.s();!(u=d.n()).done;){var l=u.value;l._stillExist||o.push({clientId:l.userId}),delete l._stillExist}}catch(v){d.e(v)}finally{d.f()}e.streams.forEach((function(e){var t=n._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,c.push(e)):s.push(e)}));var h,f=A(this._remoteStreams.values());try{for(f.s();!(h=f.n()).done;){var p=h.value;Array.isArray(p)&&p.forEach((function(e){e.stillExist?delete e.stillExist:a.push({clientId:e.userId,streamId:e.streamId,message:cG.clientDisconnected})}))}}catch(v){f.e(v)}finally{f.f()}o.forEach((function(e){return n._onUserDisconnection(e)})),i.forEach((function(e){return n._onUserConnection(e)})),a.forEach((function(e){return n._onRemoveStream(e)})),s.forEach((function(e){return n._onAddStream(e,{fromSignal:!1})})),c.forEach((function(e){return n._onUpdateStreamAttributes(e)})),t&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e=this;this._localStream&&(this._localStream.clean(),this._mediaServerClient.publish(this._localStream).catch((function(e){}))),this._localScreenStream&&(this._localScreenStream.clean(),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var t,r=A(this._remoteStreams.values());try{for(r.s();!(t=r.n()).done;){var n=t.value;Array.isArray(n)&&n.forEach(function(){var t=c(o().mark((function t(r){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.hasSubscribed){t.next=15;break}return r.resetHasSubscribed(),t.prev=2,CX.print("start resubscribe ".concat(r.userId," with ").concat(r.subMediaType)),t.next=6,e._mediaServerClient.subscribe(r,r.subMediaType);case 6:CX.print("success resubscribe ".concat(r.userId," with ").concat(r.subMediaType)),e.safeEmit(sX.RESUBSCRIBE,{stream:r}),t.next=15;break;case 10:t.prev=10,t.t0=t.catch(2),CX.print("failed resubscribe ".concat(r.userId," with ").concat(r.subMediaType,", error:").concat(t.t0)),r.clean(),null==r||r.resetHasSubscribed();case 15:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e){return t.apply(this,arguments)}}())}}catch(i){r.e(i)}finally{r.f()}}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=o.find((function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new HK("ff-stream","ff-stream",!1,wX);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=pK(i),this._virtualStreams.push(s),this.safeEmit(sX.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?r.find((function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?r.find((function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var f,p=null===(f=this._remoteStreams.get(e.clientId))||void 0===f?void 0:f.filter((function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,p||[])}var v=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,v)v.attributes=e.attributes;else if((v=new HK(e.clientId,e.streamId,e.screen,e.attributes)).virtual=c,this._initStreamListeners(v),!c){var _=this._remoteStreams.get(e.clientId);_?_.push(v):this._remoteStreams.set(e.clientId,[v])}if(this._mediaServerClient.handler&&(v.observer=new kX(v,this._mediaServerClient.handler)),!v.isScreen&&l){var m,y,g,S,E,b,k,T;if(a&&v.hasVideo)if(v.attributes.extvideo)null===(m=v.observer)||void 0===m||m.setExternalVideoSource(!0),null===(y=v.observer)||void 0===y||y.setPushVideo(!0);else null===(g=v.observer)||void 0===g||g.setExternalVideoSource(!1),null===(S=v.observer)||void 0===S||S.setPublishVideo(!0);if(a&&v.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(v.attributes.extaudio)null===(E=v.observer)||void 0===E||E.setExternalAudioSource(!0),null===(b=v.observer)||void 0===b||b.setPushAudio(!0);else null===(k=v.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=v.observer)||void 0===T||T.setPublishAudio(!0);if(!0===i&&!1===a){var I,A=this._roomConfig,R=A.isAutoSubscribeAudio,C=A.isAutoSubscribeVideo;null===(I=v.observer)||void 0===I||I.setLogin(!0,{audio:!!R,video:!!C})}}return i&&this.safeEmit(dG.ON_ADD_STREAM,{stream:v}),v}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,i({},n)),this.safeEmit(dG.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(sX.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(sX.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===fG.kickedByAdmin?a=dD.KICKED_OUT:i===fG.onUserTokenDidExpire?a=dD.TOKEN_EXPIRED:i===fG.userDuplicateLogin&&(a=dD.DUPLICATE_LOGIN),o===pG.roomDismissByAdmin&&(a=dD.ROOM_DISMISS),a&&this.safeEmit(sX.ON_ROOM_ERROR,{errorCode:a})}else{var s=w.DROPPED;i===fG.userLeave?s=w.QUIT:i===fG.kickedByAdmin?s=w.KICKED_BY_ADMIN:i===fG.roleChanged&&(s=w.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){e.clean(),r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:cG.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(sX.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===fG.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=n.find((function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=t.filter((function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(dG.ON_REMOVE_STREAM,{stream:i,reason:e.message})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(sX.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(sX.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=i(i({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,o=e.clientId,a=e.streamId,s=e.attributes,c=this._findRemoteStream(o,a);if(c){var u,d,l=c.attributes,h=i(i({},l),s),f=!1,p=h.localaudio!==l.localaudio,v=!1,_=!1,m=h.localvideo!==l.localvideo,y=!1,g=TK.NONE,S=TK.NONE;if(h.audiostream!==l.audiostream&&(f=h.localaudio,v=!!h.audiostream,h.audiostream?g|=U.AUDIO:S|=U.AUDIO),h.videostream!==l.videostream&&(_=h.localvideo,y=!!h.videostream,h.videostream?g|=U.VIDEO:S|=U.VIDEO),g&&this.safeEmit(sX.ON_USER_PUBLISH_STATE_CHANGE,{userId:o,mediaType:g,isScreen:c.isScreen,pubState:uX.PUB,remoteStream:c}),S&&this.safeEmit(sX.ON_USER_PUBLISH_STATE_CHANGE,{userId:o,mediaType:S,isScreen:c.isScreen,pubState:uX.UNPUB,remoteStream:c}),c.attributes=h,h.localaudio!==l.localaudio)if(h.localaudio){var E,b,k,T;if(r)if(h.extaudio)null===(E=c.observer)||void 0===E||E.setExternalAudioSource(!0),null===(b=c.observer)||void 0===b||b.setPushAudio(!0);else null===(k=c.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=c.observer)||void 0===T||T.setEnableAudio(!0);this.safeEmit(sX.ON_USER_START_AUDIO_CAPTURE,{userId:o},c)}else{var I,A,R,C;if(h.extaudio)null===(I=c.observer)||void 0===I||I.setExternalAudioSource(!0),null===(A=c.observer)||void 0===A||A.setPushAudio(!1);else null===(R=c.observer)||void 0===R||R.setExternalAudioSource(!1),null===(C=c.observer)||void 0===C||C.setEnableAudio(!1);!c.isScreen&&this.safeEmit(sX.ON_USER_STOP_AUDIO_CAPTURE,{userId:o})}if(h.localvideo!==l.localvideo)if(h.localvideo){var w,O,x,P;if(n)if(h.extvideo)null===(w=c.observer)||void 0===w||w.setExternalVideoSource(!0),null===(O=c.observer)||void 0===O||O.setPushVideo(!0);else null===(x=c.observer)||void 0===x||x.setExternalVideoSource(!1),null===(P=c.observer)||void 0===P||P.setEnableVideo(!0);this.safeEmit(sX.ON_USER_START_VIDEO_CAPTURE,{userId:o})}else{var D,N,M,L;if(h.extvideo)null===(D=c.observer)||void 0===D||D.setExternalVideoSource(!0),null===(N=c.observer)||void 0===N||N.setPushVideo(!1);else null===(M=c.observer)||void 0===M||M.setExternalVideoSource(!1),null===(L=c.observer)||void 0===L||L.setEnableVideo(!1);!c.isScreen&&this.safeEmit(sX.ON_USER_STOP_VIDEO_CAPTURE,{userId:o})}if(f&&!p)null===(u=c.observer)||void 0===u||u.setRemoteUnmuteAudio(v);if(_&&!m)null===(d=c.observer)||void 0===d||d.setRemoteUnmuteVideo(y)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&t.startsWith("audio_mux")){var n=this._onAddStream(i(i({},e),{},{attributes:wX}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(sX.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){CX.print("subscribe","push track failed %o",e)}))}else wj.rtcError("onPushTrack, userId: ".concat(e.clientId,", ").concat(e.streamId),-1001)}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message;CX.print("_onRemoveTrack","remove track: %o",r);var o=this._findRemoteStream(r,n);o&&(null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(o,i))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=b(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&t.sort((function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_nodeChange",value:function(e){var t,r=e.nodes,n=e.reason;Jj.clearAccessNode(null===(t=this._roomInfo)||void 0===t?void 0:t.appId),this._destroyAndInitMediaServerClient(),Array.isArray(r)&&r.length?this._getAccessNode=r[0]:this._getAccessFeedback=n,wj.rtcNodeChange(0,JSON.stringify(e),JSON.stringify(n)),this._joinResolveCallback&&this._joinRejectCallback?this._join(this._joinResolveCallback,this._joinRejectCallback):this._reconnect()}},{key:"_reconnect",value:function(){var e=this;this._isReconnecting=!0;var t,r=A(this._remoteStreams.values());try{for(r.s();!(t=r.n()).done;){var n=t.value;Array.isArray(n)&&n.forEach((function(e){return e.clean()}))}}catch(i){r.e(i)}finally{r.f()}wj.rtcReconnect(1002,YB.PEERCONNECTION_RECONNECTING,this._roomInfo.userInfo.userId,JB.PEERCONNECTION),this._liveTranscodingOnceSucc||delete this._liveControlMessage,this._join((function(){wj.rtcReconnected(QB.PEERCONNECTION_RECONNECTED,ZB.PEERCONNECTION)}),(function(t){e._reconnectRecord.record(t),e._reconnectRecord.shouldReconnect?(CX.print("Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=window.setTimeout(e._reconnect.bind(e),3e3)):(e.safeEmit(sX.RECONNECT_FAILED),e.destroy())}),!0)}},{key:"_handleAbnormalDisconnection",value:function(){CX.print("on ABNORMAL_DISCONNECTION"),this._destroyAndInitMediaServerClient(),navigator.onLine?this._reconnect():this._reconnectTimer=window.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===mX.DISCONNECTED)t=F.CONNECTION_STATE_DISCONNECTED;else if(e.next===mX.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._isReconnecting?F.CONNECTION_STATE_RECONNECTED:F.CONNECTION_STATE_CONNECTED;else{if(e.next!==mX.CONNECTING)return;t=this._isReconnecting?F.CONNECTION_STATE_RECONNECTING:F.CONNECTION_STATE_CONNECTING}e.prev===mX.CONNECTED&&e.next===mX.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(hG.ON_CONNECTION_STATE_CHANGE,{state:F.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setConnectionState(e.next),this.safeEmit(hG.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(sX.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(dG.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(dG.USER_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onUserBinaryMessageReceived",value:function(e){this.safeEmit(dG.USER_BINARY_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onPostProcessingMessage",value:function(e){if(e.body){var t=e.body,r=t.error||0,n=cX.START,i=["success","parameter error","subscription timeout","ffmpeg error","cdn error","publish error"];if("2.0"===t.protocol){switch(t.eventType){case"TranscodeStarted":0!==t.error&&(n=cX.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?cX.START_FAILED:cX.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?cX.STOP_FAILED:cX.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?cX.UPDATE_FAILED:cX.UPDATE_SUCCESS}this.safeEmit(dG.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(dG.POST_PROCESSING_MESSAGE,{code:r,message:i[r],type:e.type})}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(dG.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onSceneConfig",value:function(e){try{var t=e.multiSceneConfig,r=lX[this._roomConfig.roomProfileType][1];if(t){var n,i,o,a,s=t[r];if(null!=s&&s.engine_BAC)null===(n=this._context)||void 0===n||null===(i=n.audioProfileManager)||void 0===i||i.updateEngineBAC(s.engine_BAC);if(null!=s&&s.engine_ANM)null===(o=this._context)||void 0===o||null===(a=o.audioProfileManager)||void 0===a||a.updateEngineANM(s.engine_ANM)}}catch(c){}}},{key:"_onStreamFailed",value:(r=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(c=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?c=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(c=this.localScreenStream),c){e.next=5;break}return e.abrupt("return");case 5:return null===(i=c)||void 0===i||i.clean(),e.next=8,null===(a=this._mediaServerClient)||void 0===a?void 0:a.unpublish(c).catch((function(){}));case 8:null===(s=this._mediaServerClient)||void 0===s||s.publish(c).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(u=this._remoteStreamStreamIdUserIdMap[t.streamId],!(d=this._findRemoteStream(u,t.streamId))){e.next=20;break}return e.next=17,null===(l=this._mediaServerClient)||void 0===l?void 0:l.unsubscribe(d,U.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(h=this._mediaServerClient)||void 0===h?void 0:h.subscribe(d,d.subMediaType,d.subLayer);case 19:this.safeEmit(sX.RESUBSCRIBE,{stream:d});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===uG.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(t=c(o().mark((function e(){var t,r,n,i,a,s,c,u,d,l,h,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(s=this._publishOnDemandItem,this._publishOnDemandItem=void 0,s){e.next=6;break}return e.abrupt("return");case 6:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(a=this._localStream)||void 0===a||!a.videoTransceiver){e.next=15;break}return this._publishOnDemandBusy=!0,d=null===(c=this._localStream)||void 0===c?void 0:c.stream.id,l=null===(u=this._localStream)||void 0===u?void 0:u.videoTransceiver.sender,h=l.getParameters(),Array.isArray(h.encodings)&&Array.isArray(s)&&(f={},CX.print("_onPublishOnDemand exec","usedDescriptions: %o",s),s.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&t.includes(d)){var r=null==e?void 0:e.Metadata.VideoIndex;f[r]=!0}})),h.encodings=h.encodings.map((function(e){return e.rid&&(f[e.rid]?e.active=!0:e.active=!1),e}))),e.next=14,l.setParameters(h);case 14:this._publishOnDemandBusy=!1;case 15:this._onPublishOnDemand();case 16:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(sX.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(sX.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}}]),M}(GU),xX=function(){function e(){u(this,e),h(this,"_all_201_count",void 0),h(this,"_has_4xx",void 0),this._all_201_count=0,this._has_4xx=!1}return l(e,[{key:"shouldReconnect",get:function(){return!(this._all_201_count>=3||this._has_4xx)}},{key:"record",value:function(e){var t=!1,r=!1;if(Array.isArray(e)){var n=0;e.map((function(e){var t,i,o;400<=(null===(t=e.error)||void 0===t?void 0:t.code)&&(null===(i=e.error)||void 0===i?void 0:i.code)<500&&(r=!0),201===(null===(o=e.error)||void 0===o?void 0:o.code)&&n++})),n===e.length&&(t=!0),t&&this._all_201_count++,r&&(this._has_4xx=!0)}}},{key:"clear",value:function(){this._all_201_count=0,this._has_4xx=!1}}]),e}(),PX=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&Object.assign(r.style,t.style),t.attributes&&Object.entries(t.attributes).forEach((function(e){var t=b(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},DX=new FU("Player",0),NX=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],MX={playsinline:"","webkit-playsinline":""},LX={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},UX=function(e){f(n,e);var t,r=g(n);function n(e){var t;u(this,n),h(m(t=r.call(this)),"_containerDom",void 0),h(m(t),"_videoDom",void 0),h(m(t),"__cumulativeTime",void 0),h(m(t),"userId",void 0),h(m(t),"renderMode",void 0),h(m(t),"mirrorType",B.MIRROR_TYPE_NONE),h(m(t),"isScreen",void 0),h(m(t),"isLocal",void 0),h(m(t),"played",!1),h(m(t),"_emitPlayFailed",!1),h(m(t),"_videoContainer",void 0),h(m(t),"emitVideoEvent",(function(e){var r,n,i={type:"video",rawEvent:e,readyState:(null===(r=t._videoDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:e.type,currentTime:(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime)||0,isScreen:t.isScreen};switch(t.emit("playback_event",i),e.type){case"canplay":case"loadeddata":t._internalPlay();break;case"playing":DX.print("VideoPlayerPlaying","[userId-".concat(t.userId,"] video element playing"))}})),h(m(t),"_internalPlay",(function(){var e;if(null!==(e=t._videoDom)&&void 0!==e&&e.paused){var r=t._videoDom.play();null!=r&&r.then&&r.catch((function(e){var r,n;t._emitPlayFailed||("AbortError"!==e.name?(t._emitPlayFailed=!0,wj.rtcError("video autoplay failed, userId: ".concat(t.userId,", ").concat(e.name),-1e3),t.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(r=t._videoDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:"autoplay-error",currentTime:(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime)||0,isScreen:t.isScreen})):wj.rtcError("video autoplay failed, userId: ".concat(t.userId,", ").concat(e.name),-1e3))}))}}));var i=e.renderDom,o=e.userId;t.renderMode=void 0!==e.renderMode?e.renderMode:M.RENDER_MODE_FIT;var a="string"==typeof i?document.getElementById(i):i;if(!a)throw new hD(dD.CANT_FIND_DOM,"can't find dom");return t._videoContainer=document.createElement("div"),t._videoContainer.style.width="100%",t._videoContainer.style.height="100%",t._videoContainer.style.position="relative",t._videoContainer.style.overflow="hidden",t._containerDom=a,t.userId=o,t.isLocal=!!e.isLocal,t.isScreen=!!e.isScreen,t._initVideo(),t}return l(n,[{key:"_initVideo",value:function(){this._videoDom||(this._videoDom=PX("video",{style:{width:"100%",height:"100%"},attributes:LX}),this._videoDom.id="".concat(this.userId,"_").concat(ZN()),this.renderMode===M.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this._videoDom.style.objectFit="cover",this.mirror(this.mirrorType===B.MIRROR_TYPE_RENDER)),this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&NX.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.addEventListener(t,e.emitVideoEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._videoDom&&NX.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.5;if(aM&&tG.VIDEO_STALL){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(!tG.VIDEO_STALL)return;if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=$N();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=$N()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"playVideo",value:(t=c(o().mark((function e(t,r){var n,i,a,s,c=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=this._videoDom,DX.print("playVideo","play video track: ".concat(this.userId)),!(a&&a.srcObject instanceof MediaStream&&a.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{wj.rtcInvokeStatus("play video repeatedly",0,"playVideo",this.userId,0)}catch(EZ){}return e.abrupt("return");case 5:a||(this._initVideo(),a=this._videoDom),DX.print("playVideo","play video by dom: ".concat(null===(i=a)||void 0===i?void 0:i.id)),(s=new MediaStream).addTrack(t.getTrack("preprocessing")),a.srcObject=s,a&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),a&&!this._videoContainer.contains(a)&&this._videoContainer.appendChild(a),setTimeout((function(){return c._internalPlay()})),r&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"manuallyPlay",value:function(){if(DX.print("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new hD(dD.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||hM?this._videoDom.play():Promise.resolve()}},{key:"mirror",value:function(e){DX.print("mirror","".concat(this.userId," set mirror: ").concat(e)),this.mirrorType=e?B.MIRROR_TYPE_RENDER:B.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t=this._containerDom;(DX.print("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(this._videoDom.srcObject=null,null!=t&&t.contains(this._videoContainer)&&t.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){DX.print("destroy","video player: ".concat(this.userId)),this.stop(),E(p(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._videoDom&&(this._videoDom.srcObject=null,delete this._videoDom)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(OU.exports.EventEmitter),VX=function(e){f(i,e);var t,r,n=g(i);function i(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{divId:void 0,muted:!1,isScreen:!1},o=r.divId,a=r.muted,s=r.isScreen;if(u(this,i),h(m(t=n.call(this)),"_containerDom",void 0),h(m(t),"_audioDom",void 0),h(m(t),"_fakeAudioDom",void 0),h(m(t),"userId",void 0),h(m(t),"muted",!1),h(m(t),"_emitPlayFailed",!1),h(m(t),"played",!1),h(m(t),"isScreen",void 0),h(m(t),"_wechatTimer",void 0),h(m(t),"emitAudioEvent",(function(e){var r,n,i={type:"audio",rawEvent:e,readyState:(null===(r=t._audioDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:e.type,currentTime:(null===(n=t._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&DX.print("AudioPlayerPlaying","[userId-".concat(t.userId,"] audio element playing")),"pause"===e.type&&DX.print("AudioPlayerPause","[userId-".concat(t.userId,"] audio element pause")),fM&&hM&&("canplay"===e.type?(clearTimeout(t._wechatTimer),t._wechatTimer=window.setTimeout((function(){t._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(t._wechatTimer)),t.emit("playback_event",i)})),h(m(t),"_internalPlay",(function(){var e,r;if(jj("_internalPlay",{paused:null===(e=t._audioDom)||void 0===e?void 0:e.paused}),null!==(r=t._audioDom)&&void 0!==r&&r.paused)try{var n=t._audioDom.play();null!=n&&n.then&&n.catch((function(e){t._autoPlayError(e),wj.rtcError("audio autoplay failed, userId: ".concat(t.userId,": ").concat(e.message," ").concat(e.name),-1e3)})).then((function(){jj("_internalPlay successfully",{userId:t.userId})}))}catch(i){t._autoPlayError(i),wj.rtcError("audio autoplay failed, userId: ".concat(t.userId,": ").concat(i.message," ").concat(i.name),-1e3)}})),o){var c=document.getElementById(o);if(!c)throw new hD(dD.CANT_FIND_DOM,"can't find dom");t._containerDom=c}else t._containerDom=document.body;return t.userId=e,t.muted=a,t.isScreen=s,t._initAudio(),t}return l(i,[{key:"_initAudio",value:function(){this._audioDom||(this._audioDom=PX("audio",{style:{display:"none"},attributes:MX}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id="".concat(this.userId,"_").concat(ZN()),this._containerDom.appendChild(this._audioDom)),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&NX.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.addEventListener(t,e.emitAudioEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._audioDom&&(NX.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=c(o().mark((function e(t){var r,n,i,a,s,c=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(DX.print("playAudio","play audio track: ".concat(this.userId)),!((a=this._audioDom)&&a.srcObject instanceof MediaStream&&a.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:a||(this._initAudio(),a=this._audioDom),(s=new MediaStream).addTrack(t.getTrack("preprocessing")),a.srcObject=s,null===(n=a)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=a)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return c._internalPlay()})),this.played=!0;case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"pause",value:function(){if(!this._audioDom)throw new hD(dD.INVALID_PARAMS,"Player not found");this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e;if(DX.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new hD(dD.INVALID_PARAMS,"Player not found");if(!this.played)return Promise.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var t=this._audioDom.play();return null!=t&&t.then?t:Promise.resolve(t)}},{key:"setPlaybackDevice",value:(t=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return DX.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,Mz.enumerateAudioPlaybackDevices();case 3:if(e.sent.map((function(e){return e.deviceId})).includes(t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;DX.print("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){DX.print("destroy","audio player: ".concat(this.userId)),this.stop(),E(p(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom)}}]),i}(OU.exports.EventEmitter);function FX(e,t,r,n){var i=function(){var e=c(o().mark((function e(t,i){var a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null==n?void 0:n.get(i),Array.isArray(a)&&(a=null===(s=a)||void 0===s?void 0:s.find((function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:a&&(t instanceof UX&&a.videoTrack&&t.playVideo(a.videoTrack,a),t instanceof VX&&a.audioTrack&&t.playAudio(a.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var a=[];return e.forEach((function(e,t){return a.push(i(e,t))})),Promise.all(a)}var BX=function(){function e(){u(this,e),h(this,"_timer",void 0),h(this,"userMessage",void 0),h(this,"roomMessage",void 0),this.userMessage={},this.roomMessage={},this._setTimer()}return l(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(Object.keys(this.userMessage).length||Object.keys(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e=this;wj.rtcMessageStatistics(Object.keys(this.userMessage).map((function(t){return e.userMessage[t]})),Object.keys(this.roomMessage).map((function(t){return e.roomMessage[t]})),"")}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){this.userMessage["".concat(t,"-").concat(e)]||(this.userMessage["".concat(t,"-").concat(e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:1/0,dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){this._checkInitUserMessage(e,t),this.userMessage["".concat(t,"-").concat(e)].dc_send_total++,r&&this.userMessage["".concat(t,"-").concat(e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){this._checkInitUserMessage(e,t),this.userMessage["".concat(t,"-").concat(e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n=this.userMessage["".concat(t,"-").concat(e)];n&&(n.dc_send_fail++,this._handleUserFail(n,r))}},{key:"_handleUserFail",value:function(e,t){t&&(t.code||t.err)&&(t.code===dD.TIME_OUT?e.dc_fail_timeout++:t.err===mG.NO_RECEIVER?e.dc_fail_no_receiver++:t.err===mG.NO_RELAYPATH?e.dc_fail_no_relay_path++:t.err===mG.TIMEOUT&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o=this.userMessage["".concat(t,"-").concat(e)];o&&(o.dc_send_ack++,o.dc_cost_time+=r,o.dc_cost_s2s+=n||0,o.dc_cost_peer_s2e+=i,o.dc_cost_e2s+=r-(n||0)-i,r<=100?(o.dc_send_ack_100++,o.dc_send_ack_200++,o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=200?(o.dc_send_ack_200++,o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=400?(o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=1e3&&o.dc_send_ack_1s++,r<o.dc_least_time&&(o.dc_least_time=r),r>o.dc_most_time&&(o.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:1/0,dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,bj.P2P,t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,bj.P2P)}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,bj.P2P,t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,bj.P2P,t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,bj.P2P_OUTSIDE_ROOM,t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,bj.P2P_OUTSIDE_ROOM)}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,bj.P2P_OUTSIDE_ROOM,t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,bj.P2P_OUTSIDE_ROOM,t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("",bj.P2SERVER,e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("",bj.P2SERVER,e)}},{key:"sendP2serveAck",value:function(e){this._sendUserAck("",bj.P2SERVER,e,0,0)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?this.sendP2serveAck(Date.now()-r):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),jX="object"==typeof global&&global&&global.Object===Object&&global,GX="object"==typeof self&&self&&self.Object===Object&&self,HX=jX||GX||Function("return this")(),zX=HX.Symbol,KX=Object.prototype,XX=KX.hasOwnProperty,WX=KX.toString,qX=zX?zX.toStringTag:void 0;var YX=Object.prototype.toString;var JX=zX?zX.toStringTag:void 0;function QX(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":JX&&JX in Object(e)?function(e){var t=XX.call(e,qX),r=e[qX];try{e[qX]=void 0;var n=!0}catch(o){}var i=WX.call(e);return n&&(t?e[qX]=r:delete e[qX]),i}(e):function(e){return YX.call(e)}(e)}function ZX(e){return null!=e&&"object"==typeof e}var $X=Array.isArray;function eW(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function tW(e){return e}function rW(e){if(!eW(e))return!1;var t=QX(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var nW,iW=HX["__core-js_shared__"],oW=(nW=/[^.]+$/.exec(iW&&iW.keys&&iW.keys.IE_PROTO||""))?"Symbol(src)_1."+nW:"";var aW=Function.prototype.toString;var sW=/^\[object .+?Constructor\]$/,cW=Function.prototype,uW=Object.prototype,dW=cW.toString,lW=uW.hasOwnProperty,hW=RegExp("^"+dW.call(lW).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fW(e){return!(!eW(e)||(t=e,oW&&oW in t))&&(rW(e)?hW:sW).test(function(e){if(null!=e){try{return aW.call(e)}catch(t){}try{return e+""}catch(t){}}return""}(e));var t}function pW(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var vW=Date.now;var _W,mW,yW,gW=function(){try{var e=fW(t=function(e,t){return null==e?void 0:e[t]}(Object,"defineProperty"))?t:void 0;return e({},"",{}),e}catch(r){}var t}(),SW=gW,EW=SW?function(e,t){return SW(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:tW,bW=(_W=EW,mW=0,yW=0,function(){var e=vW(),t=16-(e-yW);if(yW=e,t>0){if(++mW>=800)return arguments[0]}else mW=0;return _W.apply(void 0,arguments)}),kW=bW,TW=/^(?:0|[1-9]\d*)$/;function IW(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&TW.test(e))&&e>-1&&e%1==0&&e<t}function AW(e,t,r){"__proto__"==t&&SW?SW(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function RW(e,t){return e===t||e!=e&&t!=t}var CW=Object.prototype.hasOwnProperty;function wW(e,t,r){var n=e[t];CW.call(e,t)&&RW(n,r)&&(void 0!==r||t in e)||AW(e,t,r)}var OW=Math.max;function xW(e,t){return kW(function(e,t,r){return t=OW(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=OW(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),pW(e,this,s)}}(e,t,tW),e+"")}function PW(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function DW(e){return null!=e&&PW(e.length)&&!rW(e)}var NW=Object.prototype;function MW(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||NW)}function LW(e){return ZX(e)&&"[object Arguments]"==QX(e)}var UW=Object.prototype,VW=UW.hasOwnProperty,FW=UW.propertyIsEnumerable,BW=LW(function(){return arguments}())?LW:function(e){return ZX(e)&&VW.call(e,"callee")&&!FW.call(e,"callee")},jW=BW;var GW="object"==typeof exports&&exports&&!exports.nodeType&&exports,HW=GW&&"object"==typeof module&&module&&!module.nodeType&&module,zW=HW&&HW.exports===GW?HX.Buffer:void 0,KW=(zW?zW.isBuffer:void 0)||function(){return!1},XW={};XW["[object Float32Array]"]=XW["[object Float64Array]"]=XW["[object Int8Array]"]=XW["[object Int16Array]"]=XW["[object Int32Array]"]=XW["[object Uint8Array]"]=XW["[object Uint8ClampedArray]"]=XW["[object Uint16Array]"]=XW["[object Uint32Array]"]=!0,XW["[object Arguments]"]=XW["[object Array]"]=XW["[object ArrayBuffer]"]=XW["[object Boolean]"]=XW["[object DataView]"]=XW["[object Date]"]=XW["[object Error]"]=XW["[object Function]"]=XW["[object Map]"]=XW["[object Number]"]=XW["[object Object]"]=XW["[object RegExp]"]=XW["[object Set]"]=XW["[object String]"]=XW["[object WeakMap]"]=!1;var WW="object"==typeof exports&&exports&&!exports.nodeType&&exports,qW=WW&&"object"==typeof module&&module&&!module.nodeType&&module,YW=qW&&qW.exports===WW&&jX.process,JW=function(){try{var e=qW&&qW.require&&qW.require("util").types;return e||YW&&YW.binding&&YW.binding("util")}catch(t){}}(),QW=JW&&JW.isTypedArray,ZW=QW?function(e){return function(t){return e(t)}}(QW):function(e){return ZX(e)&&PW(e.length)&&!!XW[QX(e)]},$W=ZW,eq=Object.prototype.hasOwnProperty;function tq(e,t){var r=$X(e),n=!r&&jW(e),i=!r&&!n&&KW(e),o=!r&&!n&&!i&&$W(e),a=r||n||i||o,s=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!eq.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||IW(u,c))||s.push(u);return s}var rq=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),nq=rq,iq=Object.prototype.hasOwnProperty;function oq(e){return DW(e)?tq(e):function(e){if(!MW(e))return nq(e);var t=[];for(var r in Object(e))iq.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var aq=Object.prototype.hasOwnProperty;function sq(e){if(!eW(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=MW(e),r=[];for(var n in e)("constructor"!=n||!t&&aq.call(e,n))&&r.push(n);return r}var cq,uq=(cq=function(e,t){!function(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?AW(r,s,c):wW(r,s,c)}}(t,function(e){return DW(e)?tq(e,!0):sq(e)}(t),e)},xW((function(e,t){var r=-1,n=t.length,i=n>1?t[n-1]:void 0,o=n>2?t[2]:void 0;for(i=cq.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!eW(r))return!1;var n=typeof t;return!!("number"==n?DW(r)&&IW(t,r.length):"string"==n&&t in r)&&RW(r[t],e)}(t[0],t[1],o)&&(i=n<3?void 0:i,n=1),e=Object(e);++r<n;){var a=t[r];a&&cq(e,a,r,i)}return e})));function dq(e,t){return function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}(t,(function(t){return e[t]}))}function lq(e){return null==e?[]:dq(e,oq(e))}var hq=de,fq=sr("iterator"),pq=!hq((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[fq]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),vq=Re,_q=2147483647,mq=/[^\0-\u007E]/,yq=/[.\u3002\uFF0E\uFF61]/g,gq="Overflow: input needs wider integers to process",Sq=RangeError,Eq=vq(yq.exec),bq=Math.floor,kq=String.fromCharCode,Tq=vq("".charCodeAt),Iq=vq([].join),Aq=vq([].push),Rq=vq("".replace),Cq=vq("".split),wq=vq("".toLowerCase),Oq=function(e){return e+22+75*(e<26)},xq=function(e,t,r){var n=0;for(e=r?bq(e/700):e>>1,e+=bq(e/t);e>455;)e=bq(e/35),n+=36;return bq(n+36*e/(e+38))},Pq=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=Tq(e,r++);if(i>=55296&&i<=56319&&r<n){var o=Tq(e,r++);56320==(64512&o)?Aq(t,((1023&i)<<10)+(1023&o)+65536):(Aq(t,i),r--)}else Aq(t,i)}return t}(e);var r,n,i=e.length,o=128,a=0,s=72;for(r=0;r<e.length;r++)(n=e[r])<128&&Aq(t,kq(n));var c=t.length,u=c;for(c&&Aq(t,"-");u<i;){var d=_q;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>bq((_q-a)/l))throw Sq(gq);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>_q)throw Sq(gq);if(n==o){for(var h=a,f=36;;){var p=f<=s?1:f>=s+26?26:f-s;if(h<p)break;var v=h-p,_=36-p;Aq(t,kq(Oq(p+v%_))),h=bq(v/_),f+=36}Aq(t,kq(Oq(h))),s=xq(a,l,u==c),a=0,u++}}a++,o++}return Iq(t,"")},Dq=ro,Nq=ce,Mq=ve,Lq=Re,Uq=le,Vq=pq,Fq=$n,Bq=Sf,jq=Pd,Gq=Fd,Hq=Ln,zq=Xh,Kq=We,Xq=Kt,Wq=ga,qq=So,Yq=Fr,Jq=Je,Qq=As,Zq=cs,$q=be,eY=Ih,tY=yh,rY=rm,nY=NI,iY=sr("iterator"),oY="URLSearchParams",aY="URLSearchParamsIterator",sY=Hq.set,cY=Hq.getterFor(oY),uY=Hq.getterFor(aY),dY=Object.getOwnPropertyDescriptor,lY=function(e){if(!Uq)return Nq[e];var t=dY(Nq,e);return t&&t.value},hY=lY("fetch"),fY=lY("Request"),pY=lY("Headers"),vY=fY&&fY.prototype,_Y=pY&&pY.prototype,mY=Nq.RegExp,yY=Nq.TypeError,gY=Nq.decodeURIComponent,SY=Nq.encodeURIComponent,EY=Lq("".charAt),bY=Lq([].join),kY=Lq([].push),TY=Lq("".replace),IY=Lq([].shift),AY=Lq([].splice),RY=Lq("".split),CY=Lq("".slice),wY=/\+/g,OY=Array(4),xY=function(e){return OY[e-1]||(OY[e-1]=mY("((?:%[\\da-f]{2}){"+e+"})","gi"))},PY=function(e){try{return gY(e)}catch(EZ){return e}},DY=function(e){var t=TY(e,wY," "),r=4;try{return gY(t)}catch(EZ){for(;r;)t=TY(t,xY(r--),PY);return t}},NY=/[!'()~]|%20/g,MY={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},LY=function(e){return MY[e]},UY=function(e){return TY(SY(e),NY,LY)},VY=Gq((function(e,t){sY(this,{type:aY,iterator:eY(cY(e).entries),kind:t})}),"Iterator",(function(){var e=uY(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),FY=function(e){this.entries=[],this.url=null,void 0!==e&&(Jq(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===EY(e,0)?CY(e,1):e:Qq(e)))};FY.prototype={type:oY,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=tY(e);if(c)for(r=(t=eY(e,c)).next;!(n=Mq(r,t)).done;){if(o=(i=eY(Yq(n.value))).next,(a=Mq(o,i)).done||(s=Mq(o,i)).done||!Mq(o,i).done)throw yY("Expected sequence with length 2");kY(this.entries,{key:Qq(a.value),value:Qq(s.value)})}else for(var u in e)Xq(e,u)&&kY(this.entries,{key:u,value:Qq(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=RY(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=RY(t,"="),kY(this.entries,{key:DY(IY(r)),value:DY(bY(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],kY(r,UY(e.key)+"="+UY(e.value));return bY(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var BY=function(){zq(this,jY);var e=arguments.length>0?arguments[0]:void 0;sY(this,new FY(e))},jY=BY.prototype;if(Bq(jY,{append:function(e,t){rY(arguments.length,2);var r=cY(this);kY(r.entries,{key:Qq(e),value:Qq(t)}),r.updateURL()},delete:function(e){rY(arguments.length,1);for(var t=cY(this),r=t.entries,n=Qq(e),i=0;i<r.length;)r[i].key===n?AY(r,i,1):i++;t.updateURL()},get:function(e){rY(arguments.length,1);for(var t=cY(this).entries,r=Qq(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){rY(arguments.length,1);for(var t=cY(this).entries,r=Qq(e),n=[],i=0;i<t.length;i++)t[i].key===r&&kY(n,t[i].value);return n},has:function(e){rY(arguments.length,1);for(var t=cY(this).entries,r=Qq(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){rY(arguments.length,1);for(var r,n=cY(this),i=n.entries,o=!1,a=Qq(e),s=Qq(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?AY(i,c--,1):(o=!0,r.value=s));o||kY(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=cY(this);nY(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=cY(this).entries,n=Wq(e,arguments.length>1?arguments[1]:void 0),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new VY(this,"keys")},values:function(){return new VY(this,"values")},entries:function(){return new VY(this,"entries")}},{enumerable:!0}),Fq(jY,iY,jY.entries,{name:"entries"}),Fq(jY,"toString",(function(){return cY(this).serialize()}),{enumerable:!0}),jq(BY,oY),Dq({global:!0,constructor:!0,forced:!Vq},{URLSearchParams:BY}),!Vq&&Kq(pY)){var GY=Lq(_Y.has),HY=Lq(_Y.set),zY=function(e){if(Jq(e)){var t,r=e.body;if(qq(r)===oY)return t=e.headers?new pY(e.headers):new pY,GY(t,"content-type")||HY(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Zq(e,{body:$q(0,Qq(r)),headers:$q(0,t)})}return e};if(Kq(hY)&&Dq({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return hY(e,arguments.length>1?zY(arguments[1]):{})}}),Kq(fY)){var KY=function(e){return zq(this,vY),new fY(e,arguments.length>1?zY(arguments[1]):{})};vY.constructor=KY,KY.prototype=vY,Dq({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:KY})}}var XY,WY=ro,qY=le,YY=pq,JY=ce,QY=ga,ZY=Re,$Y=$n,eJ=tS,tJ=Xh,rJ=Kt,nJ=vv,iJ=QD,oJ=Nl,aJ=wu.codeAt,sJ=function(e){var t,r,n=[],i=Cq(Rq(wq(e),yq,"."),".");for(t=0;t<i.length;t++)r=i[t],Aq(n,Eq(mq,r)?"xn--"+Pq(r):r);return Iq(n,".")},cJ=As,uJ=Pd,dJ=rm,lJ={URLSearchParams:BY,getState:cY},hJ=Ln,fJ=hJ.set,pJ=hJ.getterFor("URL"),vJ=lJ.URLSearchParams,_J=lJ.getState,mJ=JY.URL,yJ=JY.TypeError,gJ=JY.parseInt,SJ=Math.floor,EJ=Math.pow,bJ=ZY("".charAt),kJ=ZY(/./.exec),TJ=ZY([].join),IJ=ZY(1..toString),AJ=ZY([].pop),RJ=ZY([].push),CJ=ZY("".replace),wJ=ZY([].shift),OJ=ZY("".split),xJ=ZY("".slice),PJ=ZY("".toLowerCase),DJ=ZY([].unshift),NJ="Invalid scheme",MJ="Invalid host",LJ="Invalid port",UJ=/[a-z]/i,VJ=/[\d+-.a-z]/i,FJ=/\d/,BJ=/^0x/i,jJ=/^[0-7]+$/,GJ=/^\d+$/,HJ=/^[\da-f]+$/i,zJ=/[\0\t\n\r #%/:<>?@[\\\]^|]/,KJ=/[\0\t\n\r #/:<>?@[\\\]^|]/,XJ=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,WJ=/[\t\n\r]/g,qJ=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)DJ(t,e%256),e=SJ(e/256);return TJ(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t}(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=IJ(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},YJ={},JJ=nJ({},YJ,{" ":1,'"':1,"<":1,">":1,"`":1}),QJ=nJ({},JJ,{"#":1,"?":1,"{":1,"}":1}),ZJ=nJ({},QJ,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),$J=function(e,t){var r=aJ(e,0);return r>32&&r<127&&!rJ(t,e)?e:encodeURIComponent(e)},eQ={ftp:21,file:null,http:80,https:443,ws:80,wss:443},tQ=function(e,t){var r;return 2==e.length&&kJ(UJ,bJ(e,0))&&(":"==(r=bJ(e,1))||!t&&"|"==r)},rQ=function(e){var t;return e.length>1&&tQ(xJ(e,0,2))&&(2==e.length||"/"===(t=bJ(e,2))||"\\"===t||"?"===t||"#"===t)},nQ=function(e){return"."===e||"%2e"===PJ(e)},iQ={},oQ={},aQ={},sQ={},cQ={},uQ={},dQ={},lQ={},hQ={},fQ={},pQ={},vQ={},_Q={},mQ={},yQ={},gQ={},SQ={},EQ={},bQ={},kQ={},TQ={},IQ=function(e,t,r){var n,i,o,a=cJ(e);if(t){if(i=this.parse(a))throw yJ(i);this.searchParams=null}else{if(void 0!==r&&(n=new IQ(r,!0)),i=this.parse(a,null,n))throw yJ(i);(o=_J(new vJ)).bindURL(this),this.searchParams=o}};IQ.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||iQ,d=0,l="",h=!1,f=!1,p=!1;for(e=cJ(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=CJ(e,XJ,"")),e=CJ(e,WJ,""),n=iJ(e);d<=n.length;){switch(i=n[d],u){case iQ:if(!i||!kJ(UJ,i)){if(t)return NJ;u=aQ;continue}l+=PJ(i),u=oQ;break;case oQ:if(i&&(kJ(VJ,i)||"+"==i||"-"==i||"."==i))l+=PJ(i);else{if(":"!=i){if(t)return NJ;l="",u=aQ,d=0;continue}if(t&&(c.isSpecial()!=rJ(eQ,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&eQ[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=mQ:c.isSpecial()&&r&&r.scheme==c.scheme?u=sQ:c.isSpecial()?u=lQ:"/"==n[d+1]?(u=cQ,d++):(c.cannotBeABaseURL=!0,RJ(c.path,""),u=bQ)}break;case aQ:if(!r||r.cannotBeABaseURL&&"#"!=i)return NJ;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=oJ(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=TQ;break}u="file"==r.scheme?mQ:uQ;continue;case sQ:if("/"!=i||"/"!=n[d+1]){u=uQ;continue}u=hQ,d++;break;case cQ:if("/"==i){u=fQ;break}u=EQ;continue;case uQ:if(c.scheme=r.scheme,i==XY)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=oJ(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=dQ;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=oJ(r.path),c.query="",u=kQ;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=oJ(r.path),c.path.length--,u=EQ;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=oJ(r.path),c.query=r.query,c.fragment="",u=TQ}break;case dQ:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=EQ;continue}u=fQ}else u=hQ;break;case lQ:if(u=hQ,"/"!=i||"/"!=bJ(l,d+1))continue;d++;break;case hQ:if("/"!=i&&"\\"!=i){u=fQ;continue}break;case fQ:if("@"==i){h&&(l="%40"+l),h=!0,o=iJ(l);for(var v=0;v<o.length;v++){var _=o[v];if(":"!=_||p){var m=$J(_,ZJ);p?c.password+=m:c.username+=m}else p=!0}l=""}else if(i==XY||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=iJ(l).length+1,l="",u=pQ}else l+=i;break;case pQ:case vQ:if(t&&"file"==c.scheme){u=gQ;continue}if(":"!=i||f){if(i==XY||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return MJ;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=SQ,t)return;continue}"["==i?f=!0:"]"==i&&(f=!1),l+=i}else{if(""==l)return MJ;if(a=c.parseHost(l))return a;if(l="",u=_Q,t==vQ)return}break;case _Q:if(!kJ(FJ,i)){if(i==XY||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var y=gJ(l,10);if(y>65535)return LJ;c.port=c.isSpecial()&&y===eQ[c.scheme]?null:y,l=""}if(t)return;u=SQ;continue}return LJ}l+=i;break;case mQ:if(c.scheme="file","/"==i||"\\"==i)u=yQ;else{if(!r||"file"!=r.scheme){u=EQ;continue}if(i==XY)c.host=r.host,c.path=oJ(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=oJ(r.path),c.query="",u=kQ;else{if("#"!=i){rQ(TJ(oJ(n,d),""))||(c.host=r.host,c.path=oJ(r.path),c.shortenPath()),u=EQ;continue}c.host=r.host,c.path=oJ(r.path),c.query=r.query,c.fragment="",u=TQ}}break;case yQ:if("/"==i||"\\"==i){u=gQ;break}r&&"file"==r.scheme&&!rQ(TJ(oJ(n,d),""))&&(tQ(r.path[0],!0)?RJ(c.path,r.path[0]):c.host=r.host),u=EQ;continue;case gQ:if(i==XY||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&tQ(l))u=EQ;else if(""==l){if(c.host="",t)return;u=SQ}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=SQ}continue}l+=i;break;case SQ:if(c.isSpecial()){if(u=EQ,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=XY&&(u=EQ,"/"!=i))continue}else c.fragment="",u=TQ;else c.query="",u=kQ;break;case EQ:if(i==XY||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=PJ(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||RJ(c.path,"")):nQ(l)?"/"==i||"\\"==i&&c.isSpecial()||RJ(c.path,""):("file"==c.scheme&&!c.path.length&&tQ(l)&&(c.host&&(c.host=""),l=bJ(l,0)+":"),RJ(c.path,l)),l="","file"==c.scheme&&(i==XY||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)wJ(c.path);"?"==i?(c.query="",u=kQ):"#"==i&&(c.fragment="",u=TQ)}else l+=$J(i,QJ);break;case bQ:"?"==i?(c.query="",u=kQ):"#"==i?(c.fragment="",u=TQ):i!=XY&&(c.path[0]+=$J(i,YJ));break;case kQ:t||"#"!=i?i!=XY&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":$J(i,YJ)):(c.fragment="",u=TQ);break;case TQ:i!=XY&&(c.fragment+=$J(i,JJ))}d++}},parseHost:function(e){var t,r,n;if("["==bJ(e,0)){if("]"!=bJ(e,e.length-1))return MJ;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,d=null,l=0,h=function(){return bJ(e,l)};if(":"==h()){if(":"!=bJ(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&kJ(HJ,h());)t=16*t+gJ(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!kJ(FJ,h()))return;for(;kJ(FJ,h());){if(o=gJ(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;c[u++]=t}else{if(null!==d)return;l++,d=++u}}if(null!==d)for(a=u-d,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[d+a-1],c[d+--a]=s;else if(8!=u)return;return c}(xJ(e,1,-1)),!t)return MJ;this.host=t}else if(this.isSpecial()){if(e=sJ(e),kJ(zJ,e))return MJ;if(t=function(e){var t,r,n,i,o,a,s,c=OJ(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==bJ(i,0)&&(o=kJ(BJ,i)?16:8,i=xJ(i,8==o?1:2)),""===i)a=0;else{if(!kJ(10==o?GJ:8==o?jJ:HJ,i))return e;a=gJ(i,o)}RJ(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=EJ(256,5-t))return null}else if(a>255)return null;for(s=AJ(r),n=0;n<r.length;n++)s+=r[n]*EJ(256,3-n);return s}(e),null===t)return MJ;this.host=t}else{if(kJ(KJ,e))return MJ;for(t="",r=iJ(e),n=0;n<r.length;n++)t+=$J(r[n],YJ);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return rJ(eQ,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&tQ(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=qJ(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+TJ(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw yJ(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new AQ(e.path[0]).origin}catch(EZ){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+qJ(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(cJ(e)+":",iQ)},getUsername:function(){return this.username},setUsername:function(e){var t=iJ(cJ(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=$J(t[r],ZJ)}},getPassword:function(){return this.password},setPassword:function(e){var t=iJ(cJ(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=$J(t[r],ZJ)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?qJ(e):qJ(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,pQ)},getHostname:function(){var e=this.host;return null===e?"":qJ(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,vQ)},getPort:function(){var e=this.port;return null===e?"":cJ(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=cJ(e))?this.port=null:this.parse(e,_Q))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+TJ(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,SQ))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=cJ(e))?this.query=null:("?"==bJ(e,0)&&(e=xJ(e,1)),this.query="",this.parse(e,kQ)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=cJ(e))?("#"==bJ(e,0)&&(e=xJ(e,1)),this.fragment="",this.parse(e,TQ)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var AQ=function(e){var t=tJ(this,RQ),r=dJ(arguments.length,1)>1?arguments[1]:void 0,n=fJ(t,new IQ(e,!1,r));qY||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},RQ=AQ.prototype,CQ=function(e,t){return{get:function(){return pJ(this)[e]()},set:t&&function(e){return pJ(this)[t](e)},configurable:!0,enumerable:!0}};if(qY&&(eJ(RQ,"href",CQ("serialize","setHref")),eJ(RQ,"origin",CQ("getOrigin")),eJ(RQ,"protocol",CQ("getProtocol","setProtocol")),eJ(RQ,"username",CQ("getUsername","setUsername")),eJ(RQ,"password",CQ("getPassword","setPassword")),eJ(RQ,"host",CQ("getHost","setHost")),eJ(RQ,"hostname",CQ("getHostname","setHostname")),eJ(RQ,"port",CQ("getPort","setPort")),eJ(RQ,"pathname",CQ("getPathname","setPathname")),eJ(RQ,"search",CQ("getSearch","setSearch")),eJ(RQ,"searchParams",CQ("getSearchParams")),eJ(RQ,"hash",CQ("getHash","setHash"))),$Y(RQ,"toJSON",(function(){return pJ(this).serialize()}),{enumerable:!0}),$Y(RQ,"toString",(function(){return pJ(this).serialize()}),{enumerable:!0}),mJ){var wQ=mJ.createObjectURL,OQ=mJ.revokeObjectURL;wQ&&$Y(AQ,"createObjectURL",QY(wQ,mJ)),OQ&&$Y(AQ,"revokeObjectURL",QY(OQ,mJ))}uJ(AQ,"URL"),WY({global:!0,constructor:!0,forced:!YY,sham:!qY},{URL:AQ});var xQ=function(){var e=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(URL.createObjectURL(new Blob([t],r))),e.prev=1,n.muted=!0,e.next=5,n.play();case 5:return n.pause(),e.abrupt("return",!0);case 9:return e.prev=9,e.t0=e.catch(1),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r){return e.apply(this,arguments)}}(),PQ=Object.defineProperty,DQ=Object.getOwnPropertyDescriptor,NQ=function(e,t,r,n){for(var i,o=n>1?void 0:n?DQ(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&PQ(t,r,o),o},MQ=function(){function e(t){u(this,e),h(this,"_sharedAudioContext",new AudioContext),h(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),h(this,"_localGainNode",this._sharedAudioContext.createGain()),h(this,"_bufferGainNode",this._sharedAudioContext.createGain()),h(this,"_audioBufferSource",void 0),h(this,"_localSource",void 0),h(this,"_context",void 0),h(this,"_failedAudioList",[]),h(this,"_startingIds",new Map),h(this,"mixingMap",new Map),h(this,"resourcesCache",new Map),h(this,"volumeConfig",new Map),h(this,"cachedBuffer",[]),h(this,"id","AudioMixingManager"),this._context=t,this._localGainNode.gain.value=1}var t,r,n;return l(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v,_,m,y=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),console.log(this._startingIds),i=n.playCount,MM(a=n.type,"mixingType",lq(re)),s=this._context.getLocalAudioTrack()){e.next=10;break}return e.abrupt("return");case 10:if((c=s.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([c])),null!=(u=this.mixingMap.get(t))&&u.audioNode){u.audioNode.pause(),this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_STOPPED,error:lD.AUDIO_MIXING_ERROR_OK});try{u.gainNode.disconnect(this._audioDestination),u.audioSource.disconnect(u.gainNode)}catch(o){}}if(!(l=this.resourcesCache.get(t))||l.filePath!==r){e.next=19;break}d=l.getAudioNode(),e.next=32;break;case 19:return e.next=21,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw y._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FAILED,error:lD.AUDIO_MIXING_ERROR_START_FAILED}),new hD(dD.LOAD_RESOURCES_FAILED,e.statusText)}));case 21:return h=e.sent,r.endsWith("mp3")?f={type:"audio/mpeg"}:r.endsWith("aac")&&(f={type:"audio/aac"}),e.next=25,xQ(h,f);case 25:if(e.sent){e.next=29;break}throw this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FAILED,error:lD.AUDIO_MIXING_ERROR_START_FAILED}),new hD(dD.LOAD_RESOURCES_FAILED,"invalid audio resource");case 29:(d=new Audio).crossOrigin="anonymous",d.src=URL.createObjectURL(new Blob([h],f));case 32:return i<=0?d.loop=!0:i>0&&(p=i,d.onended=function(){--p>0?d.play():(y.mixingMap.delete(t),y._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FINISHED,error:lD.AUDIO_MIXING_ERROR_OK}))}),e.prev=33,e.next=36,d.play();case 36:e.next=43;break;case 38:e.prev=38,e.t0=e.catch(33),console.error(e.t0),this._failedAudioList.push(d),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:L.STREAM_INDEX_MAIN,mediaType:U.AUDIO});case 43:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(d),_=this._sharedAudioContext.createGain(),m=this.volumeConfig.get(t),_.gain.value=m?m/100:1,v.connect(_).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:d,gainNode:_,type:"file"}),a===re.PUBLISH)try{_.disconnect(this._sharedAudioContext.destination)}catch(o){}else _.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_PLAYING,error:lD.AUDIO_MIXING_ERROR_OK});case 53:case"end":return e.stop()}}),e,this,[[33,38]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:ne.AUDIO_MIXING_STATE_STOPPED,error:lD.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:ne.AUDIO_MIXING_STATE_PAUSED,error:lD.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:ne.AUDIO_MIXING_STATE_PLAYING,error:lD.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=c(o().mark((function e(t,r){var n,i,a=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw new hD(dD.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(a._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FAILED,error:lD.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof hD)throw e;throw new hD(dD.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,r.endsWith("mp3")?i={type:"audio/mpeg"}:r.endsWith("aac")&&(i={type:"audio/aac"}),e.next=7,xQ(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_FAILED,error:lD.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new hD(dD.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:this._context.emitMessage({mixId:t,state:ne.AUDIO_MIXING_STATE_PRELOADED,error:lD.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){return new Audio(URL.createObjectURL(new Blob([n],i)))},filePath:r});case 13:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unloadAudioMixing",value:function(e){this.resourcesCache.has(e)&&this.resourcesCache.delete(e)}},{key:"getAudioMixingVolume",value:function(e){var t=this.mixingMap.get(e);return t?100*t.gainNode.gain.value:0}},{key:"setAudioMixingVolume",value:function(e,t){t<0?t=0:t>400&&(t=400),this.volumeConfig.set(e,t);var r=this.mixingMap.get(e);r&&(r.gainNode.gain.value=Number(t)/100)}},{key:"getAudioMixingDuration",value:function(e){var t=this.mixingMap.get(e),r=this.mixingMap.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.audioNode.duration:0:0}},{key:"getAudioMixingCurrentPosition",value:function(e){var t=this.mixingMap.get(e);return t?1e3*t.audioNode.currentTime:0}},{key:"setAudioMixingPosition",value:function(e,t){var r=this.mixingMap.get(e);r&&(r.audioNode.currentTime=t/1e3,r.audioNode.play())}},{key:"enableAudioMixingBuffer",value:function(e){MM(e,"type",lq(re));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===re.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(n){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:ne.AUDIO_MIXING_STATE_PCM_ENABLED,error:lD.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:ne.AUDIO_MIXING_STATE_PCM_DISABLED,error:lD.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(r){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(t){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=c(o().mark((function e(){var t,r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=A(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:L.STREAM_INDEX_MAIN,mediaType:U.AUDIO}),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new Map}}]),e}();NQ([Fj("default","id","filePath","options")],MQ.prototype,"startAudioMixing",1),NQ([Fj("default","id")],MQ.prototype,"stopAudioMixing",1),NQ([Fj("default","id")],MQ.prototype,"pauseAudioMixing",1),NQ([Fj("default","id")],MQ.prototype,"resumeAudioMixing",1),NQ([Fj("default","id")],MQ.prototype,"preloadAudioMixing",1),NQ([Fj("default","id")],MQ.prototype,"unloadAudioMixing",1),NQ([Fj("default","id")],MQ.prototype,"getAudioMixingVolume",1),NQ([Fj("default","id","volume")],MQ.prototype,"setAudioMixingVolume",1),NQ([Fj("default","id")],MQ.prototype,"getAudioMixingDuration",1),NQ([Fj("default","id")],MQ.prototype,"getAudioMixingCurrentPosition",1),NQ([Fj("default","id","position")],MQ.prototype,"setAudioMixingPosition",1),NQ([Fj("default","type")],MQ.prototype,"enableAudioMixingBuffer",1),NQ([Fj()],MQ.prototype,"disableAudioMixingBuffer",1),NQ([Fj("default","buffer")],MQ.prototype,"pushAudioMixingBuffer",1);var LQ=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(LQ||{}),UQ=new FU("RTMClient",1),VQ=function(e){f(_,e);var t,r,n,i,a,s,d,v=g(_);function _(e){var t;return u(this,_),h(m(t=v.call(this)),"_dataChannelSignal",null),h(m(t),"_handler",null),h(m(t),"_dataChannelSignalState",mX.DISCONNECTED),h(m(t),"_loginSessionId",null),h(m(t),"_userId",null),h(m(t),"_token",null),h(m(t),"_isReconnecting",!1),h(m(t),"_reconnectTimer",null),h(m(t),"_loginResolveCallback",null),h(m(t),"_loginRejectCallback",null),h(m(t),"_iceConfigNode",null),h(m(t),"_wait_login_token",!1),h(m(t),"_serverParamsCache",void 0),t._appId=e,t}return l(_,[{key:"login",value:function(e,t){var r=this;return new Promise((function(n,i){if(UQ.print("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new hD(dD.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new hD(dD.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,Dj.setStats({rtc_app_id:r._appId,user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():(UQ.print("login","init dataChannelSingling"),r._dataChannelSignalState=mX.CONNECTING,r._createDataChannelSignaling(t).then((function(e){r._dataChannelSignal=e,r._login()})).catch((function(){r._onDisconnect()})))}))}},{key:"logout",value:(d=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new hD(dD.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId},{functionType:bG.C2RTM}).catch((function(){}));case 4:this._closeDataChannelSignaling(),this._clearState();case 6:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"updateLoginToken",value:(s=c(o().mark((function e(t){var r=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Promise((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(a=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new hD(dD.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,peerUserId:t},{functionType:bG.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(i=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new hD(dD.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setServerParams",value:(n=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,NM(t,"signature"),NM(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new hD(dD.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,signature:t,url:r},{functionType:bG.C2RTM}).catch((function(e){throw new hD(dD.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return n.apply(this,arguments)})},{key:"sendServerMessage",value:(r=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new hD(dD.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:"",room:"",type:_G.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){this._clearState(),this._closeDataChannelSignaling(),E(p(_.prototype),"removeAllListeners",this).call(this),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=ZN();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:rM.token2auth(this._appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:tG.VERSION,deviceId:Jj.getDeviceId(),appId:this._appId,userId:this._userId},accessParams:JSON.stringify({requireICEUfragV2:!0})},{functionType:bG.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=dD.INVALID_PARAMS,n="Invalid userId"):(r=dD.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=dD.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new hD(r,a||n))})).finally((function(){e._loginResolveCallback=null,e._loginRejectCallback=null}))}}},{key:"_createDataChannelSignaling",value:(t=c(o().mark((function e(t){var r,n,i,a,s,c,u,d=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new RG,i=this._iceConfigNode){e.next=16;break}return e.prev=3,e.next=6,null==n?void 0:n.getAccessNode(this._appId,"",t,Jj.getDeviceId(),"");case 6:if(a=e.sent,i=a[0]){e.next=10;break}throw new Error;case 10:e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(3),jj("rtm.login.getNodeFailed","",0,!0),new hD(dD.ICE_SERVER_WRONG,"get ICE config failed");case 16:return jj("rtm.login.getNodeSuccess",i,0,!0),UQ.print("_createDataChannelSignaling()","get node success",i),this._handler=nX(Oj),null===(r=this._handler)||void 0===r||r.once("disconnect",(function(){UQ.print("_createDataChannelSignaling()","recv BasicHandler event: disconnect"),d._onDisconnect()})),e.prev=20,e.next=23,null===(c=this._handler)||void 0===c?void 0:c.connect(i);case 23:s=e.sent,UQ.print("_createDataChannelSignaling()","establish peerConnection success"),this._dataChannelSignalState=mX.CONNECTED,e.next=33;break;case 28:throw e.prev=28,e.t1=e.catch(20),this._iceConfigNode=null,this._dataChannelSignalState=mX.DISCONNECTED,new hD(dD.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t1);case 33:return u=new TG(s),UQ.print("_createDataChannelSignaling()","send ping"),u.sendPingSignaling(),u.once("close",(function(){UQ.print("_createDataChannelSignaling()","recv DataChannelSignaling event: close"),d._onDisconnect()})),u.on(dG.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){d.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),u.on(dG.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){d.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),u.on(dG.USER_DISCONNECTION,(function(){d.emit("onUserDisconnection"),d._clearState()})),u.on(dG.NODE_CHANGE,(function(e){jj("rtm.nodeChange",JSON.stringify(e),0,!0),Array.isArray(e.nodes)&&e.nodes.length&&(d._iceConfigNode=e.nodes[0]),d._loginResolveCallback&&d._loginRejectCallback?d._login():d._reconnect()})),e.abrupt("return",u);case 42:case"end":return e.stop()}}),e,this,[[3,12],[20,28]])}))),function(e){return t.apply(this,arguments)})},{key:"_closeDataChannelSignaling",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),this._dataChannelSignal=null,null===(t=this._handler)||void 0===t||t.destroy(),this._handler=null}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==mX.CONNECTED)throw new hD(dD.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_onDisconnect",value:function(){this._dataChannelSignalState=mX.DISCONNECTED,this._closeDataChannelSignaling(),navigator.onLine?this._reconnect():this._reconnectTimer=self.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_reconnect",value:function(){var e=this;!this._isReconnecting&&this._userId&&(UQ.print("_reconnect()","start reconnect..."),this._isReconnecting=!0,this._createDataChannelSignaling(this._userId).then((function(t){UQ.print("_reconnect()","reconnect success!"),e._dataChannelSignal=t,e._login(),e._reconnectTimer=null})).catch((function(t){UQ.print("_reconnect()","Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=self.setTimeout(e._reconnect.bind(e),3e3)})).finally((function(){e._isReconnecting=!1})))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,null!==this._reconnectTimer&&(self.clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}}]),_}(OU.exports.EventEmitter),FQ=function(e){f(a,e);var t,r,n,i=g(a);function a(e){var t;return u(this,a),h(m(t=i.call(this)),"_mediaServerClient",void 0),h(m(t),"_appId",void 0),h(m(t),"_reconnectTimer",void 0),h(m(t),"remoteStreams",void 0),t._appId=e,t.remoteStreams=new Map,t}return l(a,[{key:"connect",value:(n=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new gX({avSync:!0,enableFallbackHandler:oZ(this._appId)}),this._bindEvents(),e.next=4,this._mediaServerClient.connect(this._appId);case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new hD(dD.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new HK(t,t,!1,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=AM(e),i=0;i<t.seiCount;i++)n.emit(sX.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){this.remoteStreams=new Map,this._mediaServerClient&&this._mediaServerClient.destroy()}},{key:"_handleReconnected",value:(t=c(o().mark((function e(){var t,r,n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:clearTimeout(this._reconnectTimer),t=A(this.remoteStreams);try{for(n=function(){var e=b(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(sX.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_reconnect",value:function(){var e=this;this._mediaServerClient.removeAllListeners(),this._mediaServerClient.destroy(),navigator.onLine?this.connect().then(this._handleReconnected.bind(this)):this._reconnectTimer=window.setTimeout((function(){return e.connect().then(e._handleReconnected.bind(e))}),3e3)}},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on(hG.ABNORMAL_DISCONNECTION,this._reconnect.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),a}(GU),BQ=new FU("AudioDeviceManager",1),jQ=function(e){f(a,e);var t,r,n,i=g(a);function a(e){var t;return u(this,a),h(m(t=i.call(this)),"_audioLevelFetcher",void 0),h(m(t),"_playbackDeviceTestTimer",void 0),h(m(t),"_audioElement",void 0),h(m(t),"_audioTrack",void 0),h(m(t),"_mediaRecorder",void 0),h(m(t),"_recoderTimer",void 0),h(m(t),"_isAudioPlaybackDeviceTesting",!1),h(m(t),"_isAudioDeviceRecordTesting",!1),h(m(t),"_audioCaptureAndRecoderResolve",void 0),h(m(t),"_onAutoplayFailed",void 0),t._extensionManager=e,t}return l(a,[{key:"startAudioPlaybackDeviceTest",value:(n=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new hD(dD.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,BQ.print("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),BQ.print("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return n.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(BQ.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(r=c(o().mark((function e(t,r){var n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(window.MediaRecorder){e.next=2;break}throw new hD(dD.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 2:if(!this._isAudioDeviceRecordTesting){e.next=4;break}throw new hD(dD.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 4:return this._isAudioDeviceRecordTesting=!0,BQ.print("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){BQ.print("startAudioDeviceRecordTest()","".concat(3e4,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),n._stopAudioCaptureAndRecoder()}),3e4),e.prev=7,this._onAutoplayFailed=r,e.next=11,this._startAudioCaptureAndRecoder(t);case 11:e.next=18;break;case 13:throw e.prev=13,e.t0=e.catch(7),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 18:delete this._audioCaptureAndRecoderResolve;case 19:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e,t){return r.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){BQ.print("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(BQ.print("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"destroy",value:function(){BQ.print("destroy()","Invoke"),E(p(a.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:function(e,t){var r=this;return BQ.print("_playAudioFile()","Invoke url=".concat(e,"; loop=").concat(t.loop)),new Promise((function(n,i){var a,s,u=PX("audio",{attributes:{src:e,crossOrigin:"anonymous"}});r._audioElement=u,u.loop=t.loop,r._audioLevelFetcher=new Uz(u),u.onplaying=function(){u.onplaying=null,BQ.print("_playAudioFile()","onplaying"),n()},u.onerror=function(){var e=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:BQ.print("_playAudioFile()","onerror",t),n=t.message||(null==u||null===(r=u.error)||void 0===r?void 0:r.message),i(new hD(dD.LOAD_RESOURCES_FAILED,"Failed to play recorded audio"+(n?", reason: ".concat(n):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),null===(a=u.play())||void 0===a||null===(s=a.catch)||void 0===s||s.call(a,(function(e){BQ.print("_playAudioFile()","autoplay error",e);var t="Failed to play recorded audio, ".concat(e.name,": ").concat(e.message);"NotAllowedError"===e.name&&r._onAutoplayFailed?r._onAutoplayFailed((function(){var e;return Promise.all([null===(e=r._audioLevelFetcher)||void 0===e?void 0:e.resume(),u.play()])})):i(new hD(dD.LOAD_RESOURCES_FAILED,t))}))}))}},{key:"_destroyAudioElement",value:function(){this._audioElement&&(BQ.print("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(BQ.print("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(BQ.print("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(t=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,dK({},this._extensionManager);case 2:return this._audioTrack=e.sent,i=this._audioTrack.getTrack("preprocessing"),r=Gz.get(i),BQ.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Promise((function(e,i){var a;"function"==typeof MediaRecorder.isTypeSupported&&(a=["audio/webm","audio/mp4"].find((function(e){return MediaRecorder.isTypeSupported(e)})),BQ.print("startAudioDeviceRecordTest()","use mimeType: ".concat(a))),n._mediaRecorder=new MediaRecorder(r,a?{mimeType:a}:void 0);var s=n._mediaRecorder.mimeType;n._mediaRecorder.ondataavailable=function(){var r=c(o().mark((function r(a){var c,u;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!n._isAudioDeviceRecordTesting){r.next=16;break}return BQ.print("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),u=new Blob([a.data],{type:s}),r.prev=3,r.next=6,n._playAudioFile(URL.createObjectURL(u),{loop:!1});case 6:r.next=11;break;case 8:return r.prev=8,r.t0=r.catch(3),r.abrupt("return",i(r.t0));case 11:n._startEmitAudioPlaybackDeviceTestVolume(t),null===(c=n._audioElement)||void 0===c||c.addEventListener("ended",(function(){n.stopAudioDevicePlayTest(),e()})),n._audioCaptureAndRecoderResolve=e,r.next=17;break;case 16:e();case 17:case"end":return r.stop()}}),r,null,[[3,8]])})));return function(e){return r.apply(this,arguments)}}(),n._mediaRecorder.onerror=function(e){i(new hD(dD.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},n._mediaRecorder.start()})));case 6:case"end":return e.stop()}var i}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}}]),a}(OU.exports.EventEmitter),GQ=function(){function e(){u(this,e),h(this,"engineBAC",{adm:{},agc:{},ans:{}}),h(this,"engineANM",{}),h(this,"bitrate",void 0),h(this,"sampleRate",void 0),h(this,"channel",void 0),h(this,"aec",void 0),h(this,"agc",void 0),h(this,"ans",void 0),this._init()}var t;return l(e,[{key:"_init",value:(t=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new CG,e.next=3,t.getAudioProfile();case 3:this.engineBAC=e.sent;case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateEngineBAC",value:function(e){e&&(this.engineBAC={codec:i(i({},this.engineBAC.codec),e.codec),adm:i(i({},this.engineBAC.adm),e.adm)},this.setAEC(!!e.aec),this.setAGC(!!e.agc),this.setANS(!!e.ans))}},{key:"updateEngineANM",value:function(e){e&&(this.engineANM=e)}},{key:"setAudioProfile",value:function(e){var t,r,n;switch(e){case J.fluent:r=16e3,t=24e3;break;case J.standard:r=48e3,t=48e3;break;case J.hd:r=48e3,t=128e3,n=2;break;case J.standardStereo:r=48e3,t=8e4,n=2;break;case J.hdMono:r=48e3,t=128e3}t&&(this.bitrate=t),n&&(this.channel=n),r&&(this.sampleRate=r)}},{key:"setBitrate",value:function(e){e>128e3&&(e=128e3),this.bitrate=e}},{key:"setAEC",value:function(e){this.aec=e}},{key:"setAGC",value:function(e){this.agc=e}},{key:"setANS",value:function(e){this.ans=e}},{key:"getOpusConfigStr",value:function(){var e=";",t=this.config;return console.log("config",t),t.bitrate&&(e+="maxaveragebitrate=".concat(t.bitrate,";")),t.encSampleRate&&(e+="sprop-maxcapturerate=".concat(t.encSampleRate,";")),t.playbackRate&&(e+="maxplaybackrate=".concat(t.playbackRate,";")),t.encChannel&&t.encChannel>1&&(e+="sprop-stereo=1;"),t.channel&&t.channel>1&&(e+="stereo=1;"),console.log("configStr",e),e.slice(0,-1)}},{key:"config",get:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,f,p,v,_;return{bitrate:this.bitrate||(null===(e=this.engineANM.enc_param)||void 0===e?void 0:e.bitrate)||0,playChannel:(null===(t=this.engineBAC.adm)||void 0===t||null===(r=t.play)||void 0===r?void 0:r.chn)||1,encChannel:this.channel||(null===(n=this.engineANM)||void 0===n||null===(i=n.enc_param)||void 0===i?void 0:i.chn)||(null===(o=this.engineBAC.adm)||void 0===o||null===(a=o.record)||void 0===a?void 0:a.chn),channel:this.channel||(null===(s=this.engineBAC.adm)||void 0===s||null===(c=s.record)||void 0===c?void 0:c.chn),aec:this.aec,agc:this.agc,ans:this.ans,encSampleRate:this.sampleRate||(null===(u=this.engineBAC.codec)||void 0===u?void 0:u.enc_fs)||(null===(d=this.engineANM.enc_param)||void 0===d?void 0:d.sr)||(null===(l=this.engineBAC.adm)||void 0===l||null===(h=l.record)||void 0===h?void 0:h.sr),sampleRate:this.sampleRate||(null===(f=this.engineBAC.adm)||void 0===f||null===(p=f.record)||void 0===p?void 0:p.sr),playbackRate:null===(v=this.engineBAC.adm)||void 0===v||null===(_=v.play)||void 0===_?void 0:_.sr}}}]),e}(),HQ=new FU("VideoSnapshot",1),zQ=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},KQ=function(){var e=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),a=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(s=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?a.setTransform(-1,0,0,1,t,0):a.setTransform(1,0,0,1,0,0),a.drawImage(e,0,0,t,n),a.getImageData(0,0,t,n)},c=Date.now(),!(u=zQ(n))){e.next=16;break}return HQ.print("takeSnapshot","VideoPlayer already set."),e.next=11,s(u,u.videoWidth,u.videoHeight);case 11:return d=e.sent,HQ.print("takeSnapshot","success, cost ".concat(Date.now()-c,"ms")),e.abrupt("return",d);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(l=new window.ImageCapture(t)).track.readyState||!l.track.enabled||l.track.muted){e.next=29;break}return HQ.print("takeSnapshot","use ImageCapture"),e.t0=s,e.next=23,l.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return h=e.sent,HQ.print("takeSnapshot","success, cost ".concat(Date.now()-c,"ms")),e.abrupt("return",h);case 29:return HQ.print("takeSnapshot","use temp video"),e.abrupt("return",new Promise((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=s(i,i.videoWidth,i.videoHeight);HQ.print("takeSnapshot","success, cost ".concat(Date.now()-c,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),XQ=function(){return{url:"",video:{codec:$.H264,width:640,height:360,fps:15,gop:2,kBitRate:WQ(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Z.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function WQ(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function qQ(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new hD(dD.INVALID_PARAMS,"Invalid rtmp address")}function YQ(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new hD(dD.INVALID_PARAMS,"regions should not be empty.");var t,r=A(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new hD(dD.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new hD(dD.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function JQ(e,t){var r,n,i,o=function(e,r){var n=e.reduce((function(e,t){return null==e?void 0:e[t]}),t),i=e.reduce((function(e,t){return null==e?void 0:e[t]}),XQ());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),u=o(["video","fps"],(function(e){return e>=1&&e<=60})),d=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,l=o(["audio","sampleRate"],(function(e){return!![32e3,44100,48e3].find((function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:l<100?1e3*l:l,channels:o(["audio","channels"],(function(e){return[1,2].includes(e)})),profile:o(["audio","AACProfile"],(function(e){return[Z.LC,Z.HEv1,Z.HEv2].includes(e)}))},video:{codec:o(["video","codec"],(function(e){return["H264","H265"].includes(e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(d>=16&&d<=1e4?d:WQ(s,c,u)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:i.map((function(e){return{alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,uid:e.userId,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,renderMode:e.renderMode&&[1,2,3].includes(e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&[0,1,2].includes(e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}var QQ,ZQ={getDefaultValue:XQ,checkStartParams:function(e){var t;qQ(e.url),YQ(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&qQ(e.url),YQ(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return JQ("started",e)},getUpdateParams:function(e){return JQ("layoutChanged",e)}},$Q=Object.defineProperty,eZ=Object.getOwnPropertyDescriptor,tZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?eZ(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&$Q(t,r,o),o},rZ=new FU("Engine",0),nZ=function(e){f(Ge,e);var t,r,n,a,s,d,v,_,y,S,k,T,I,w,O,x,N,M,j,G,H,z,W,q,J,Z,$,ee,te,ne,ie,ae,se,ce,ue,de,le,he,fe,pe,ve,_e,me,ye,ge,Se,Ee,be,ke,Te,Ie,Ae,Re,Ce,we,Oe,xe,Pe,De,Ne,Me,Le,Ue,Ve,Fe,Be,je=g(Ge);function Ge(e,t){var r;return u(this,Ge),h(m(r=je.call(this)),"_room",void 0),h(m(r),"_outsideRoom",void 0),h(m(r),"_appId",void 0),h(m(r),"_businessId",void 0),h(m(r),"_visibility",!0),h(m(r),"_localVideoTrack",void 0),h(m(r),"_localAudioTrack",void 0),h(m(r),"_localImgVideoTrack",void 0),h(m(r),"_localImgScreenTrack",void 0),h(m(r),"_localScreenVideoTrack",void 0),h(m(r),"_localScreenAudioTrack",void 0),h(m(r),"_tempMixingAudioTrack",void 0),h(m(r),"_audioPlaybackDeviceId",void 0),h(m(r),"_videoPlayer",void 0),h(m(r),"_screenPlayer",void 0),h(m(r),"_remoteVideoPlayer",new Map),h(m(r),"_remoteScreenPlayer",new Map),h(m(r),"_remoteAudioPlayer",new Map),h(m(r),"_remoteScreenAudioPlayer",new Map),h(m(r),"_publicStreamAudioPlayer",new Map),h(m(r),"_publicStreamVideoPlayer",new Map),h(m(r),"_publicStreamIds",new Map),h(m(r),"_roomConfig",void 0),h(m(r),"_videoStreamConstraints",{width:640,height:360,frameRate:15}),h(m(r),"_audioStreamConstraints",{}),h(m(r),"_enableSimulcast",!1),h(m(r),"_videoStreamEncodeConfig",[aG]),h(m(r),"_screenStreamEncodeConfig",[sG]),h(m(r),"_dummyMainImage",void 0),h(m(r),"_dummyScreenImage",void 0),h(m(r),"_trackSourceType",void 0),h(m(r),"_liveTranscodeConfig",void 0),h(m(r),"_useCloudProxy",void 0),h(m(r),"_startCloudProxyTimestamp",void 0),h(m(r),"_localVideoDeviceId",void 0),h(m(r),"_localAudioDeviceId",void 0),h(m(r),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),h(m(r),"_audioVolumeIndicationTimer",void 0),h(m(r),"_dummyMainTimer",void 0),h(m(r),"_dummyScreenTimer",void 0),h(m(r),"_audioPropertiesReportTimer",null),h(m(r),"_mirrorType",B.MIRROR_TYPE_RENDER),h(m(r),"_audioMixingManager",void 0),h(m(r),"_pubLock",void 0),h(m(r),"_rtmClient",void 0),h(m(r),"_messageStatisticsObserver",void 0),h(m(r),"_tempRoomInfo",void 0),h(m(r),"_originIceConfigRequestUrls",void 0),h(m(r),"_originConfigServerUrls",void 0),h(m(r),"_originLogServerUrl",void 0),h(m(r),"_extensionManager",new Bz),h(m(r),"_audioDeviceManager",new jQ(r._extensionManager)),h(m(r),"_audioProfileManager",new GQ),h(m(r),"_remoteVideoConfig",new Map),h(m(r),"_userPriorityMap",new Map),h(m(r),"_subscribeFallbackOption",void 0),h(m(r),"_cameraCapturing",!1),h(m(r),"_interruptCameraCapture",!1),h(m(r),"_micCapturing",!1),h(m(r),"_interruptMicCapture",!1),h(m(r),"_avSync",!0),h(m(r),"_config",void 0),h(m(r),"_needClosePreTrack",!1),h(m(r),"_updateMixAudioTrack",function(){var e=c(o().mark((function e(t){var n,i,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>1&&void 0!==a[1]?a[1]:re.PLAYOUT_AND_PUBLISH,rZ.print("_updateMixAudioTrack()"),r._localAudioTrack){e.next=5;break}return t&&(r._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(r._localAudioTrack.mixType=i,r._localAudioTrack.mixedAudioTrack=t):(delete r._localAudioTrack.mixType,delete r._localAudioTrack.mixedAudioTrack),null===(n=r._room)||void 0===n||!n.hasPublished){e.next=9;break}return e.next=9,r._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),h(m(r),"_onAudioMixingMessage",(function(e){r.safeEmit(oe.onAudioMixingStateChanged,e)})),h(m(r),"_onAudioMixingAutoplayFailed",(function(e){r.safeEmit(oe.onAutoplayFailed,e)})),r._appId=e,r._pubLock=new aX("pubLock"),r._addDeviceEventHandler(),r._audioMixingManager=new MQ({getLocalAudioTrack:function(){return r._localAudioTrack},updateLocalAudioTrack:r._updateMixAudioTrack,emitMessage:r._onAudioMixingMessage,onAutoPlayFailed:r._onAudioMixingAutoplayFailed}),window.__rtc_engine__=m(r),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=m(r),r._trackSourceType={video:R.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:R.VIDEO_SOURCE_TYPE_INTERNAL,audio:C.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:C.AUDIO_SOURCE_TYPE_INTERNAL},r._config=t,r._rtmClient=new VQ(e),r._handleRTMClient(r._rtmClient),r._useCloudProxy=!1,r._handleAudioDeviceManager(),r._messageStatisticsObserver=new BX,r._extensionManager.setMinotor(wj),(new CG).getWebRtcConfig({appId:r.appId,deviceId:Jj.getDeviceId()}),r}return l(Ge,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(Be=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("updateToken()","token: %s",t),NM(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,a=n.userInfo,s=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,s,a,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new hD(dD.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return Be.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Fe=c(o().mark((function e(t){var r,n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("setVideoCaptureDevice()","deviceId: %s",t),NM(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=uq({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),rZ.print("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=11,cK(r,this._extensionManager).catch((function(e){if(i._localVideoTrack&&!i._localVideoTrack.dummy)return rZ.print("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),i._removeLocalTrackEvents(i._localVideoTrack),i._localVideoTrack.close(),delete i._localVideoTrack,cK(r,i._extensionManager).then((function(e){return i._needClosePreTrack=!0,e})).catch(c(o().mark((function t(){var r;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return rZ.print("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,cK(i._videoStreamConstraints,i._extensionManager);case 3:throw r=t.sent,i._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 11:return n=e.sent,rZ.print("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=17,this._switchTrack(n);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return Fe.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(Ve=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("setAudioCaptureDevice()","deviceId: %s",t),NM(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return(r=this._audioStreamConstraints).deviceId={exact:t},this._audioStreamConstraints=r,this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.next=12,dK(r,this._extensionManager,this._audioProfileManager);case 12:if(n=e.sent,this._initLocalTrackEvents(n),this._localAudioTrack=n,this._room){e.next=17;break}return e.abrupt("return");case 17:if(!this._room.hasPublished){e.next=20;break}return e.next=20,this._updatePublish();case 20:case"end":return e.stop()}}),e,this)}))),function(e){return Ve.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){Mz.on(oe.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),Mz.on(oe.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T,I,A,R,C,w=this;null===(e=this._room)||void 0===e||e.on(dG.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(dG.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(dG.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(sX.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(sX.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(sX.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(dG.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(dG.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(dG.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(dG.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(dG.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?w._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?w._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&w._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(hG.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(sX.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(f=this._room)||void 0===f||f.on(sX.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(p=this._room)||void 0===p||p.on(sX.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(v=this._room)||void 0===v||v.on(sX.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=w._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&w.safeEmit(oe.onAutoPublishResult,e)})),null===(_=this._room)||void 0===_||_.on(sX.ON_REMOTE_STREAM_STATS,(function(e){w.safeEmit(oe.onRemoteStreamStats,e)})),null===(m=this._room)||void 0===m||m.on(sX.ON_LOCAL_STREAM_STATS,(function(e){w.safeEmit(oe.onLocalStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(sX.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(g=this._room)||void 0===g||g.on(sX.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;w._updateAudioPlayerState(t),w.safeEmit(oe.onUserStartAudioCapture,{userId:r})})),null===(S=this._room)||void 0===S||S.on(sX.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;w.safeEmit(oe.onUserStopAudioCapture,{userId:t})})),null===(E=this._room)||void 0===E||E.on(sX.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;w.safeEmit(oe.onUserStartVideoCapture,{userId:t})})),null===(b=this._room)||void 0===b||b.on(sX.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;w.safeEmit(oe.onUserStopVideoCapture,{userId:t})})),null===(k=this._room)||void 0===k||k.on(sX.ON_SEI_MESSAGED_RECEIVED,(function(e){w.safeEmit(oe.onSEIMessageReceived,e)})),null===(T=this._room)||void 0===T||T.on(sX.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){w.safeEmit(oe.onRemoteVideoSizeChanged,e,t)})),null===(I=this._room)||void 0===I||I.on(sX.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return w.safeEmit(oe.onSimulcastSubscribeFallback,e)})),null===(A=this._room)||void 0===A||A.on(sX.RECONNECT_FAILED,(function(){w.safeEmit(oe.onError,{errorCode:dD.RECONNECT_FAILED})})),null===(R=this._room)||void 0===R||R.on(sX.ON_VIDEO_STREAM_BANNED,(function(e){w.safeEmit(oe.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(C=this._room)||void 0===C||C.on(sX.ON_AUDIO_STREAM_BANNED,(function(e){w.safeEmit(oe.onAudioStreamBanned,{uid:e.uid,banned:e.banned})}))}},{key:"safeEmit",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return YM(e)&&Bj(e,gM(n)),(t=E(p(Ge.prototype),"safeEmit",this)).call.apply(t,[this,e].concat(n))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"joinRoom",value:(Ue=c(o().mark((function e(t,r,n){var a,s,c,u,d,l,h,f=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=f.length>3&&void 0!==f[3]?f[3]:{},rZ.print("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,a),jM(t)||NM(t,"token"),GM(r),KM(n),XM(a=uq({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Y.communication},a)),!this._room||this._room.connectionState===mX.DISCONNECTED){e.next=11;break}throw new hD(dD.REPEAT_JOIN,"Already joined");case 11:return this._room=new OX(a,{audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync,enableFallbackHandler:oZ(this.appId)}),this._addHandlerEventHandler(),s=this._liveTranscodeConfig&&ZQ.getStartParams(this._liveTranscodeConfig),c=i(i({},n),{},{businessId:this._businessId,role:this._visibility?LQ.NORMAL_USER:LQ.SILENT_USER}),e.prev=15,this._useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),e.next=19,this._room.join(this._appId,r,t,c,s,this._useCloudProxy,null===(u=this._config)||void 0===u?void 0:u.expectedIDC);case 19:return l=e.sent,this._roomConfig=a,this._tempRoomInfo&&delete this._tempRoomInfo,null!==(d=a)&&void 0!==d&&d.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:U.AUDIO_AND_VIDEO}):this.safeEmit(oe.onAutoPublishResult,{isScreen:!1,state:D.PUBLISH_FAIL})),e.abrupt("return",l);case 26:throw e.prev=26,e.t0=e.catch(15),e.t0.code===dD.INVALID_TOKEN&&(this._tempRoomInfo={config:a,roomId:r,userInfo:c}),null===(h=this._room)||void 0===h||h.destroy(),e.t0;case 31:case"end":return e.stop()}}),e,this,[[15,26]])}))),function(e,t,r){return Ue.apply(this,arguments)})},{key:"leaveRoom",value:(Le=c(o().mark((function e(){var t,r,n,i=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],rZ.print("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new Map,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new Map,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new Map,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new Map,this._roomConfig=void 0,this._publicStreamIds=new Map;case 21:case"end":return e.stop()}}),e,this)}))),function(){return Le.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;rZ.print("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._audioStreamConstraints={},this._videoStreamEncodeConfig=[aG],this._screenStreamEncodeConfig=[sG],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new Map,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new Map,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new Map,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new Map,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new Map,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new Map,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._outsideRoom)||void 0===r||r.destroy(),this._publicStreamIds=new Map,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new Map,this._userPriorityMap.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._avSync=!0}},{key:"publishStream",value:(Me=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!TM(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,iK(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Me.apply(this,arguments)})},{key:"unpublishStream",value:(Ne=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:uX.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return Ne.apply(this,arguments)})},{key:"publishScreen",value:(De=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!TM(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,aK(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:uX.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof hD)){e.next=18;break}throw e.t0;case 18:throw new hD(dD.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return De.apply(this,arguments)})},{key:"unpublishScreen",value:(Pe=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:uX.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return Pe.apply(this,arguments)})},{key:"subscribeStream",value:(xe=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return xe.apply(this,arguments)})},{key:"_subscribe",value:(Oe=c(o().mark((function e(t,r,n){var i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==U.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return rZ.print("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(d=this._room.remoteStreams.get(r),l=null==d?void 0:d.find((function(e){return e.isScreen===t}))){e.next=9;break}throw new hD(dD.STREAM_NOT_EXIST,"stream not exist");case 9:return h=this._pauseAllSubscribeState.audio,f=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&U.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&U.VIDEO),rZ.print("subscribeStream()","due to pauseAll mediaType: %o",n),p=l.hasSubscribed,v=this._remoteVideoConfig.get(r)||(null===(a=this._roomConfig)||void 0===a?void 0:a.remoteVideoConfig),l.originalMediaType=n,e.next=19,this._room.subscribe(l,n,v);case 19:kM(n)&&this._updateAudioPlayerState(l),TM(n)&&this._updateVideoPlayerState(l),_=0,m=0,h!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?_|=U.AUDIO:m|=U.AUDIO),f!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?_|=U.VIDEO:m|=U.VIDEO),_&&this.pauseAllSubscribedStream(_),m&&this.resumeAllSubscribedStream(m),this._pauseAllSubscribeState.resumeStreamIds[l.streamId]=l.streamId,!t&&(null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeAudio||null!==(c=this._roomConfig)&&void 0!==c&&c.isAutoSubscribeVideo)&&(l.audioTrack||l.videoTrack)&&(y={userId:r,isScreen:!1,state:P.SUBSCRIBE_SUCC},this.safeEmit(oe.onAutoSubscribeResult,y)),null!==(u=this._room)&&void 0!==u&&u.multiChatMode||p||!kM(n)||!l.hasAudio||null===(g=l.observer)||void 0===g||g.setSubscribeAudio(!0),!p&&TM(n)&&l.hasVideo&&(null===(S=l.observer)||void 0===S||S.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return Oe.apply(this,arguments)})},{key:"unsubscribeStream",value:(we=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:rZ.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return we.apply(this,arguments)})},{key:"subscribeScreen",value:(Ce=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return Ce.apply(this,arguments)})},{key:"unsubscribeScreen",value:(Re=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:rZ.print("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return Re.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==U.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a=this._room.remoteStreams.get(t),s=null==a?void 0:a.find((function(t){return t.isScreen===e}));if(null==s||!s.hasSubscribed)throw new hD(dD.STREAM_NOT_EXIST,"stream not exist");return this._room.unsubscribe(s,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[s.streamId]}))}rZ.print("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(Ae=c(o().mark((function e(t,r){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),HM(t),JM(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return Ae.apply(this,arguments)})},{key:"startVideoCapture",value:(Ie=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("startVideoCapture()","deviceId: %s",t),jM(t)||NM(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new hD(dD.REPEAT_CAPTURE,"Has already capture");case 8:return i=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?i.facingMode=t:i.deviceId={exact:t},this._videoStreamConstraints=i),a={},e.prev=11,this._cameraCapturing=!0,e.next=15,cK(i,this._extensionManager);case 15:if(c=e.sent,!this._interruptCameraCapture){e.next=21;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(c),c.close(),new hD(dD.INTERRUPT,"interrupt by stopVideoCapture");case 21:if(this._initLocalTrackEvents(c),this._localVideoTrack=c,null===(s=this._videoPlayer)||void 0===s||s.playVideo(c),(u=null==c?void 0:c.getTrack())&&(a=u.getSettings(),d={width:a.width,height:a.height},this._localVideoTrack.resolution=d,setTimeout((function(){return h.safeEmit(oe.onLocalVideoSizeChanged,{streamIndex:L.STREAM_INDEX_MAIN,info:d})}))),this._room){e.next=28;break}return e.abrupt("return",a);case 28:return e.prev=28,this._cameraCapturing=!1,e.finish(28);case 31:return l=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||l)&&(this._visibility?this._updatePublish():this.safeEmit(oe.onAutoPublishResult,{isScreen:!1,state:D.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableVideo(!0),e.abrupt("return",a);case 35:case"end":return e.stop()}}),e,this,[[11,,28,31]])}))),function(e){return Ie.apply(this,arguments)})},{key:"stopVideoCapture",value:(Te=c(o().mark((function e(){var t,r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,rZ.print("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(s=this._localVideoTrack)||void 0===s||s.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||!r.hasPublished){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||null===(a=i.observer)||void 0===a||a.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return Te.apply(this,arguments)})},{key:"startAudioCapture",value:(ke=c(o().mark((function e(t){var r,n,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("startAudioCapture()","deviceId: $o",t),jM(t)||NM(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new hD(dD.REPEAT_CAPTURE,"Has already capture");case 8:return i=this._audioStreamConstraints,t&&(i.deviceId={exact:t},this._audioStreamConstraints=i),e.prev=10,this._micCapturing=!0,e.next=14,dK(i,this._extensionManager,this._audioProfileManager);case 14:if(a=e.sent,!this._interruptMicCapture){e.next=20;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(a),a.close(),new hD(dD.INTERRUPT,"interrupt by stopAudioCapture");case 20:if(this._initLocalTrackEvents(a),this._localAudioTrack=a,this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),this._room){e.next=25;break}return e.abrupt("return");case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:s=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||s)&&(this._visibility?this._updatePublish():this.safeEmit(oe.onAutoPublishResult,{isScreen:!1,state:D.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!0);case 31:case"end":return e.stop()}}),e,this,[[10,,25,28]])}))),function(e){return ke.apply(this,arguments)})},{key:"stopAudioCapture",value:(be=c(o().mark((function e(){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,rZ.print("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=12;break}return e.abrupt("return");case 12:if(!this._room.hasPublished){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(t=this._room.localStream)||void 0===t||null===(r=t.observer)||void 0===r||r.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return be.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return rZ.print("getAudioMixingManager()"),this._audioMixingManager}},{key:"startScreenCapture",value:(Ee=c(o().mark((function e(){var t,r,n,i,a,s,c,u,d,l,h,f,p,v=this,_=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=_.length>0&&void 0!==_[0]?_[0]:{},rZ.print("startScreenCapture()","config: %o",a),s=a.enableAudio,c=void 0!==s&&s,this._trackSourceType.screenVideo!==R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,hK(c,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(u=e.sent,d=b(u,2),l=d[0],h=d[1],this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=l,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&l.setContentHint(null===(f=this._screenStreamEncodeConfig[0])||void 0===f?void 0:f.contentHint),(p=null==l?void 0:l.getTrack())&&setTimeout((function(){var e=p.getSettings(),t={width:e.width,height:e.height};l.resolution=t,v.safeEmit(oe.onLocalVideoSizeChanged,{streamIndex:L.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),h&&(this._localScreenAudioTrack=h,this._initLocalTrackEvents(h)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(i=this._room)||void 0===i||!i.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(){return Ee.apply(this,arguments)})},{key:"stopScreenCapture",value:(Se=c(o().mark((function e(){var t,r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(n=this._localScreenVideoTrack)||void 0===n||n.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,null===(r=this._room)||void 0===r||!r.hasScreenPublished){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return Se.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(rZ.print("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),MM(e,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,o=i(i({userId:this._getUserId()},t),{},{isLocal:!0});if(WM(o),e===L.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new UX(o),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==Q.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),this._videoPlayer.domElement;if(e===L.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new UX(i(i({},o),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Q.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),this._screenPlayer.domElement}else{var a,s;e===L.STREAM_INDEX_MAIN?(null===(a=this._videoPlayer)||void 0===a||a.destroy(),delete this._videoPlayer):(null===(s=this._screenPlayer)||void 0===s||s.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(ge=c(o().mark((function e(t){var r,n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("startLiveTranscoding()","transcode: %o",t),ZQ.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new hD(dD.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(oe.onStreamMixingEvent,{event:cX.START,error:0,message:""}),!this._room||this._room.connectionState!==mX.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(ZQ.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof hD)){e.next=19;break}throw e.t0;case 19:throw new hD(dD.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return ge.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(ye=c(o().mark((function e(t){var r,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=uq({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,ZQ.checckUpdateParams(i),this._liveTranscodeConfig=uq(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(oe.onStreamMixingEvent,{event:cX.UPDATE,error:0,message:""}),e.next=13,null===(a=this._room)||void 0===a?void 0:a.liveControlMessage(ZQ.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof hD)){e.next=21;break}throw e.t0;case 21:throw new hD(dD.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return ye.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(me=c(o().mark((function e(){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(oe.onStreamMixingEvent,{event:cX.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof hD)){e.next=16;break}throw e.t0;case 16:throw new hD(dD.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return me.apply(this,arguments)})},{key:"setBusinessId",value:function(e){return rZ.print("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(Pj.setStats({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(_e=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?LQ.NORMAL_USER:LQ.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:U.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return _e.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:L.STREAM_INDEX_MAIN,i=n===L.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o=e.userId.replace("_screen","");r?t.safeEmit(oe.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:o}):(t.safeEmit(oe.onAudioFirstFrameDecoded,{userId:o,isScreen:i}),t.safeEmit(oe.onRemoteAudioFirstFrame,{userId:o,isScreen:i})),wj.firstRemoteAudioRender("",o||"",{isScreen:i})}else{var a,s,c={userId:e.userId,height:(null===(a=e.domElement)||void 0===a?void 0:a.videoHeight)||0,width:(null===(s=e.domElement)||void 0===s?void 0:s.videoWidth)||0,isScreen:i};r?(c.publicStreamId=c.userId,delete c.userId,delete c.isScreen,t.safeEmit(oe.onFirstPublicStreamVideoFrameRendered,c),t.safeEmit(oe.onFirstPublicStreamVideoFrameDecoded,c)):e.isLocal||(t.safeEmit(oe.onVideoFirstFrameRendered,c),t.safeEmit(oe.onVideoFirstFrameDecoded,c),t.safeEmit(oe.onRemoteVideoFirstFrame,c)),wj.firstRemoteVideoRender("",n.userId||"",{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),wj.rtcInvokeStatus(e instanceof UX?"video":"audio",0,"autoplay-error",n.userId||"",0),void t.safeEmit(oe.onAutoplayFailed,{userId:n.userId,kind:e instanceof UX?"video":"audio",mediaType:e instanceof UX?U.VIDEO:U.AUDIO,streamIndex:e.isScreen?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN})}t.safeEmit(oe.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.on("track-ended",(function(e){var r=!1;e!==t._localScreenAudioTrack&&e!==t._localScreenVideoTrack||(r=!0),t.safeEmit(oe.onTrackEnded,{kind:e.getTrack().kind,isScreen:r})})),e.on("resolution-change",(function(e){t.safeEmit(oe.onLocalVideoSizeChanged,{streamIndex:r?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){rZ.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),MM(e,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),WM(t);var r,n,o,a=t.userId;if(e===L.STREAM_INDEX_MAIN){var s,c,u;if(null===(s=this._remoteVideoPlayer.get(a))||void 0===s||s.destroy(),!t.renderDom)return;var d=new UX(t);this._initPlayerEvents(d,!1,e),this._remoteVideoPlayer.set(a,d);var l=null===(c=this._room)||void 0===c||null===(u=c.remoteStreams.get(a))||void 0===u?void 0:u.find((function(e){return!e.isScreen}));return l&&this._updateVideoPlayerState(l),d.domElement}if(null===(r=this._remoteScreenPlayer.get(a))||void 0===r||r.destroy(),t.renderDom){var h=new UX(i(i({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(a,h),this._initPlayerEvents(h,!1,e);var f=null===(n=this._room)||void 0===n||null===(o=n.remoteStreams.get(a))||void 0===o?void 0:o.find((function(e){return e.isScreen}));return f&&this._updateVideoPlayerState(f),h.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){rZ.print("setLocalVideoMirrorType()","mirrorType: %o",e),MM(e,"mirrorType",[B.MIRROR_TYPE_NONE,B.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(ve=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("setAudioPlaybackDevice()","deviceId: %s",t),NM(t,"deviceId"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=5;break}return rZ.print("setAudioPlaybackDevice failed","setSinkId not supported by current browser"),e.abrupt("return");case 5:return e.next=7,Mz.getDeviceById(t);case 7:if(r=e.sent){e.next=10;break}throw new hD(dD.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 10:this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._audioPlaybackDeviceId=t,r&&this.safeEmit(oe.onAudioPlaybackDeviceChanged,r),wj.rtcAudioDevice(pj.PLAYOUT_DEVICE_SWITCH,t,0);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return ve.apply(this,arguments)})},{key:"play",value:(pe=c(o().mark((function e(t){var r,n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=g.length>1&&void 0!==g[1]?g[1]:U.AUDIO_AND_VIDEO,s=g.length>2?g[2]:void 0,rZ.print("play()","userId: %s, mediaType: %s, streamIndex: %s",t,a,s),c=!t||t===this._getUserId()||"local_user",u=void 0===s||s===L.STREAM_INDEX_MAIN,d=void 0===s||s===L.STREAM_INDEX_SCREEN,l=a!==U.VIDEO,h=a!==U.AUDIO,f=[],c&&h&&(u&&this._localVideoTrack&&(null===(p=this._videoPlayer)||void 0===p||p.mirror(!!this._mirrorType),f.push(null===(v=this._videoPlayer)||void 0===v?void 0:v.playVideo(this._localVideoTrack))),d&&this._localScreenVideoTrack&&f.push(null===(_=this._screenPlayer)||void 0===_?void 0:_.playVideo(this._localScreenVideoTrack))),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&f.push(this._audioMixingManager.resumeLocalPlay()),m=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,h&&u&&f.push(FX(this._remoteVideoPlayer,t,!1,m)),h&&d&&f.push(FX(this._remoteScreenPlayer,t,!0,m)),l&&u&&f.push(FX(this._remoteAudioPlayer,t,!1,m)),h&&d&&f.push(FX(this._remoteScreenAudioPlayer,t,!0,m)),y=null===(i=this._outsideRoom)||void 0===i?void 0:i.remoteStreams,l&&f.push(FX(this._publicStreamVideoPlayer,t,!1,y)),h&&f.push(FX(this._publicStreamAudioPlayer,t,!1,y)),e.abrupt("return",Promise.all(f).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return pe.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(fe=c(o().mark((function e(t){var r,n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),kM(t)&&(s._pauseAllSubscribeState.audio=!0),TM(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Promise.resolve());case 6:r=[],n=A(this._room.remoteStreams.values());try{for(n.s();!(i=n.n()).done;)a=i.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var n=s._unsubscribe(e.isScreen,e.userId,t,!0);n&&r.push(n)}}))}catch(o){n.e(o)}finally{n.f()}return e.abrupt("return",Promise.all(r).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return fe.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(he=c(o().mark((function e(t){var r,n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),kM(t)&&(s._pauseAllSubscribeState.audio=!1),TM(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Promise.resolve());case 6:r=[],n=A(this._room.remoteStreams.values());try{for(n.s();!(i=n.n()).done;)a=i.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var n=s._subscribe(e.isScreen,e.userId,t);n&&r.push(n)}}))}catch(o){n.e(o)}finally{n.f()}return e.abrupt("return",Promise.all(r).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"sendUserMessage",value:(le=c(o().mark((function e(t,r){var n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HM(t),qM(r),this._assertNotInRoom(),a=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return s._messageStatisticsObserver.countP2PMessage(!0,t,!1,a,e),e.id})).catch((function(e){throw s._messageStatisticsObserver.countP2PMessage(!1,t,!1,a,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return le.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(de=c(o().mark((function e(t,r){var n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HM(t),VM(r,"message"),qM(r),this._assertNotInRoom(),a=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return s._messageStatisticsObserver.countP2PMessage(!0,t,!0,a,e),e.id})).catch((function(e){throw s._messageStatisticsObserver.countP2PMessage(!1,t,!0,a,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return de.apply(this,arguments)})},{key:"sendRoomMessage",value:(ue=c(o().mark((function e(t){var r,n,i,a=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qM(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return a._messageStatisticsObserver.countRoomMessage(!0,null===(t=a._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw a._messageStatisticsObserver.countRoomMessage(!1,null===(t=a._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ue.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(ce=c(o().mark((function e(t){var r,n,i,a=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qM(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return a._messageStatisticsObserver.countRoomMessage(!0,null===(t=a._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw a._messageStatisticsObserver.countRoomMessage(!1,null===(t=a._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ce.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(se=c(o().mark((function e(){var t,r,n,i=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},rZ.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,FM(t),r=this._audioStreamConstraints.deviceId,this._audioStreamConstraints=t,r&&(this._audioStreamConstraints.deviceId=r),!this._localAudioTrack){e.next=11;break}return this._localAudioTrack.audioCaptureConfig=this._audioStreamConstraints,e.next=11,null===(n=this._localAudioTrack)||void 0===n?void 0:n.updateAudioCaptureConfig();case 11:case"end":return e.stop()}}),e,this)}))),function(){return se.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(ae=c(o().mark((function e(){var t,r,n,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.length>0&&void 0!==a[0]?a[0]:{},rZ.print("setVideoCaptureConfig()","config: %o",r),delete r.deviceId,FM(r),n=i(i({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=9;break}return e.next=8,this._localVideoTrack.updateVideoCaptureConfig(n);case 8:this._updatePublish();case 9:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 11:case"end":return e.stop()}}),e,this)}))),function(){return ae.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){return rZ.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,!0}},{key:"setVideoEncoderConfig",value:(ie=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:rZ.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),t.length>3&&(t=t.slice(0,3)),t.sort((function(e,t){return t.maxKbps-e.maxKbps})),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(L.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 7:case"end":return e.stop()}}),e,this)}))),function(e){return ie.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(ne=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:rZ.print("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(L.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return ne.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(rZ.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!zG())throw new hD(dD.NOT_SUPPORTED,"Browser does not support sending SEI");MM(e,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),DM(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(rM.str2ab(t)):t;if(t.length){var i;if(e===L.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,d;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)rZ.print("sei size must not bigger than 4KB");else{var l=ZN();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){if(i){var e=i.seiList.findIndex((function(e){return e.uuid===l}));e&&i.seiList.splice(e,1)}}),2e3)}}else rZ.print("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;rZ.print("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=e.find((function(e){return!1===e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(oe.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=t.reduce((function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(oe.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};rZ.print("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:L.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:bM(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:L.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:bM(o)}})}if(e.safeEmit(oe.onLocalAudioPropertiesReport,t),e._room){var a,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:L.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:bM(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.push({streamKey:{userId:r,streamIndex:t.isScreen?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:bM(o)}})}}))}));e.safeEmit(oe.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,s.filter((function(e){return e.streamKey.streamIndex!==L.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(te=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b,k,T;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),MM(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),MM(r,"VideoSourceType",[R.VIDEO_SOURCE_TYPE_EXTERNAL,R.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===L.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,rZ.print("setVideoSourceType","set ".concat(n," source type to ").concat(r)),!this._localVideoTrack||t!==L.STREAM_INDEX_MAIN){e.next=17;break}if(c=!1,r===R.VIDEO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(i=this._videoPlayer)||void 0===i||i.stop(),this._localVideoTrack=void 0,u=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableVideo(!1):null===(f=this._room)||void 0===f||null===(p=f.localStream)||void 0===p||null===(v=p.observer)||void 0===v||v.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&s.hasPublished||u)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==L.STREAM_INDEX_SCREEN){e.next=26;break}if(y=!1,r===R.VIDEO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(_=this._screenPlayer)||void 0===_||_.stop(),this._localScreenVideoTrack=void 0,y?null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||null===(E=S.observer)||void 0===E||E.setEnableVideo(!1):null===(b=this._room)||void 0===b||null===(k=b.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushVideo(!1),null===(m=this._room)||void 0===m||!m.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return te.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(ee=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("setExternalVideoTrack()","index: %o, track: %o",t,r),MM(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),LM(r),t!==L.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,vK(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||s)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==L.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===R.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,gK(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(c=this._screenPlayer)||void 0===c||c.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||!h.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return ee.apply(this,arguments)})},{key:"setAudioSourceType",value:($=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f,p,v,_,m,y,g,S,E,b;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),MM(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),MM(r,"audioSourceType",[C.AUDIO_SOURCE_TYPE_EXTERNAL,C.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===L.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,rZ.print("setVideoSourceType","set ".concat(n," source type to ").concat(r)),!this._localAudioTrack||t!==L.STREAM_INDEX_MAIN){e.next=16;break}if(s=!1,this._trackSourceType.audio===C.AUDIO_SOURCE_TYPE_EXTERNAL&&(s=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,c=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,s?null===(u=this._room)||void 0===u||null===(d=u.localStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setEnableAudio(!1):null===(h=this._room)||void 0===h||null===(f=h.localStream)||void 0===f||null===(p=f.observer)||void 0===p||p.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||c)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==L.STREAM_INDEX_SCREEN){e.next=24;break}if(_=!1,this._trackSourceType.audio===C.AUDIO_SOURCE_TYPE_EXTERNAL&&(_=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,_?null===(m=this._room)||void 0===m||null===(y=m.localScreenStream)||void 0===y||null===(g=y.observer)||void 0===g||g.setEnableAudio(!1):null===(S=this._room)||void 0===S||null===(E=S.localScreenStream)||void 0===E||null===(b=E.observer)||void 0===b||b.setPushAudio(!1),null===(v=this._room)||void 0===v||!v.hasScreenPublished){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return $.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(Z=c(o().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("setExternalAudioTrack()","index: %o, track: %o",t,r),MM(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),LM(r),t!==L.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.audio===C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,mK(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(a=i.localStream)||void 0===a||null===(s=a.observer)||void 0===s||s.setPushAudio(!0),!(null!==(c=this._room)&&void 0!==c&&c.hasPublished||u)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==L.STREAM_INDEX_SCREEN){e.next=26;break}if(this._trackSourceType.screenAudio===C.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new hD(dD.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 18:return e.next=20,EK(r,this._extensionManager);case 20:if(this._localScreenAudioTrack=e.sent,this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(f=this._room)||void 0===f||!f.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return Z.apply(this,arguments)})},{key:"login",value:(J=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("login()","token: %o, userInfo: %o",t,r),jM(t)||NM(t,"token"),HM(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return J.apply(this,arguments)})},{key:"logout",value:(q=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return q.apply(this,arguments)})},{key:"updateLoginToken",value:(W=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("updateLoginToken()","token: %o",t),jM(t)||NM(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(z=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("getPeerOnlineStatus()","userId: %o",t),HM(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return z.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(H=c(o().mark((function e(t,r){var n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HM(t),qM(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return H.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(G=c(o().mark((function e(t,r){var n,i=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HM(t),VM(r,"message"),qM(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return G.apply(this,arguments)})},{key:"setServerParams",value:(j=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return j.apply(this,arguments)})},{key:"sendServerMessage",value:(M=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return NM(t,"message"),qM(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(){n._messageStatisticsObserver.countServerMessage(!0,!1,r)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(N=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return VM(t,"message"),qM(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(){n._messageStatisticsObserver.countServerMessage(!0,!0,r)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return N.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new hD(dD.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");rZ.print("startCloudProxy()",e),NM(e.logProxy,"logProxy"),NM(e.accessProxy,"accessProxy"),NM(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=nG("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=nG("LOG_SERVER_URL"),this._originConfigServerUrls=nG("CONFIG_REQUEST_DOMAINS"),rG("ICE_CONFIG_REQUEST_URLS",e.accessProxy),rG("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),rG("CONFIG_REQUEST_DOMAINS",[e.configProxy]),this._useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){if(this._room)throw new hD(dD.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");rZ.print("stopCloudProxy()"),rG("ICE_CONFIG_REQUEST_URLS",[]),rG("LOG_SERVER_URL",this._originLogServerUrl),rG("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),this._useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(x=c(o().mark((function e(t,r){var n,i,a,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),zM(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new hD(dD.REPEAT_PUSH,"repeat push public media stream");case 5:return a=iG(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(a))||void 0===i?void 0:i.then((function(){s._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return x.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(O=c(o().mark((function e(t,r){var n,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),zM(t),this._assertNotInRoom(),i=iG(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"stopPushPublicStream",value:(w=c(o().mark((function e(t){var r,n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("startPushPublicStream()","publicStreamId: %o",t),zM(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"startPlayPublicStream",value:(I=c(o().mark((function e(t){var r,n,i,a,s,c,u=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(zM(t),this._outsideRoom){e.next=8;break}return this._outsideRoom=new FQ(this._appId),this._outsideRoom.on(sX.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=u._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=u._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._outsideRoom)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,u.safeEmit(oe.onPublicStreamStats,e)})),null===(n=this._outsideRoom)||void 0===n||n.on(sX.ON_SEI_MESSAGED_RECEIVED,(function(e){u.safeEmit(oe.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._outsideRoom.connect();case 8:return e.next=10,this._outsideRoom.startPlayPublicStream(t);case 10:i=e.sent,(a=this._publicStreamVideoPlayer.get(t))&&null!=i&&i.videoTrack&&a.playVideo(i.videoTrack,i),!(s=this._publicStreamAudioPlayer.get(t))&&null!=i&&i.audioTrack&&(s=new VX(t,{muted:(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)===Q.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(s,!0),s.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,s));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(T=c(o().mark((function e(t){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._outsideRoom){e.next=2;break}return e.abrupt("return");case 2:this._outsideRoom.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"setAudioProfile",value:(k=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._audioProfileManager.setAudioProfile(t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,o,a;rZ.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var s=this._publicStreamVideoPlayer.get(e);if(null===(r=s)||void 0===r||r.destroy(),null!=t&&t.renderDom){s=new UX(i(i({},t),{},{userId:e})),this._initPlayerEvents(s,!0),this._publicStreamVideoPlayer.set(e,s);var c=null===(n=this._outsideRoom)||void 0===n||null===(o=n.remoteStreams)||void 0===o?void 0:o.get(e);null!=c&&c.videoTrack&&(null===(a=this._config)||void 0===a?void 0:a.autoPlayPolicy)!==Q.PLAY_MANUALLY&&s.playVideo(c.videoTrack,c)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(S=c(o().mark((function e(t,r){var n=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,i){NM(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===L.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new hD(dD.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new hD(dD.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return S.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===L.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d");if(!a)throw new hD(dD.UNEXPECTED_ERROR,"Not support canvas");!r||t.width<=r.width&&t.height<=r.height?(n=t.width,i=t.height):(n=Math.min(r.width,t.width*r.height/t.height),i=Math.min(r.height,t.height*r.width/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var s=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===L.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=s):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=s);var c,u,d,l,h=o.captureStream(5).getVideoTracks()[0];if(e===L.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=h,null!==(c=this._localVideoTrack)&&void 0!==c&&c.dummy)null===(u=this._localVideoTrack)||void 0===u||u.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=h,null!==(d=this._localScreenVideoTrack)&&void 0!==d&&d.dummy)null===(l=this._localScreenVideoTrack)||void 0===l||l.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))}))}},{key:"registerExtension",value:(y=c(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor=wj,t.isSupported()){e.next=3;break}throw new Error("This extension is not supported.");case 3:return e.next=5,t.init();case 5:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(JSON.stringify(ZQ.getDefaultValue()))}},{key:"_updatePublish",value:(_=c(o().mark((function e(){var t,r,n,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.length>0&&void 0!==a[0]?a[0]:{},rZ.print("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:uX.PUB},t=i(i({},r),t),this._visibility){e.next=6;break}throw new hD(dD.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===mX.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:e.next=24;break;case 17:if(e.prev=17,e.t0=e.catch(12),!(e.t0 instanceof hD)){e.next=23;break}throw e.t0;case 23:throw new hD(dD.UNEXPECTED_ERROR,"unexpected error",e.t0);case 24:return e.prev=24,n(),e.finish(24);case 27:case"end":return e.stop()}}),e,this,[[12,17,24,27]])}))),function(){return _.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(v=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),NM(t,"filePath"),DM(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){rZ.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(d=c(o().mark((function e(t,r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rZ.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),DM(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){rZ.print("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){rZ.print("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;rZ.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{HM(e),MM(t,"priority",[X.HIGH,X.MEDIUM,X.LOW])}catch(n){return console.warn(n),!1}return this._userPriorityMap.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(s=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("takeLocalSnapshot()","streamIndex: %o",t),MM(t,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),r=t===L.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new hD(dD.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===L.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",KQ(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===B.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(a=c(o().mark((function e(t,r){var n,i,a,s,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rZ.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),NM(t,"id"),MM(r,"streamIndex",[L.STREAM_INDEX_MAIN,L.STREAM_INDEX_SCREEN]),u=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(a=i.find((function(e){return e.isScreen===(r===L.STREAM_INDEX_SCREEN)})))||void 0===a?void 0:a.videoTrack)||(null===(s=this._outsideRoom)||void 0===s||null===(c=s.remoteStreams.get(t))||void 0===c?void 0:c.videoTrack)){e.next=6;break}throw new hD(dD.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",KQ(u.getTrack(),!1,r===L.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){rZ.print("setSubscribeFallbackOption()","option: %o",e);try{MM(e,"option",[K.DISABLE,K.VIDEO_STREAM_LOW,K.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===L.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof kK&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===L.STREAM_INDEX_MAIN)a=o.find((function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=o.find((function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._outsideRoom&&this._outsideRoom.remoteStreams){var r=this._outsideRoom.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._avSync=!!e,!0)}},{key:"_reportMsTrackEvent",value:function(e,t){if(!e.hookStop){e.hookStop=!0;var r=e.stop;e.stop=function(){wj.rtcInvokeStatus(t,0,"stop",t||"",0),r.call(e)}}}},{key:"_updateScreenPublish",value:(n=c(o().mark((function e(){var t,r,n,a=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:{},rZ.print("_updateScreenPublish()"),r={mediaType:void 0,pubState:uX.PUB},t=i(i({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===mX.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(10),!(e.t0 instanceof hD)){e.next=21;break}throw e.t0;case 21:throw new hD(dD.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:return e.prev=22,n(),e.finish(22);case 25:case"end":return e.stop()}}),e,this,[[10,15,22,25]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){rZ.print("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&(e.attributes.audiostream&&e.subAudio||this.multiChatMode)){var a,s;if(!o)o=new VX(r,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===Q.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?L.STREAM_INDEX_SCREEN:L.STREAM_INDEX_MAIN),i.set(r,o),this._audioPlaybackDeviceId&&o.setPlaybackDevice(this._audioPlaybackDeviceId);(null===(a=this._config)||void 0===a?void 0:a.autoPlayPolicy)!==Q.PLAY_MANUALLY&&o.playAudio(e.audioTrack),aM&&lM&&(t=this._remoteAudioPlayer,QQ&&clearTimeout(QQ),QQ=setTimeout((function(){var e,r=A(t);try{for(r.s();!(e=r.n()).done;){var n=b(e.value,2),i=n[0],o=n[1];null!=i&&i.startsWith("mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=A(t);try{for(s.s();!(a=s.n()).done;){var c=b(a.value,2),u=c[0],d=c[1];null!=u&&u.startsWith("mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var c;null===(c=o)||void 0===c||c.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;rZ.print("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Q.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=c(o().mark((function e(t){var r,n,i,a,s,c,u,d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.stream,n=null==r?void 0:r.attributes,i=n.localaudio,a=n.audiostream,s=n.localvideo,c=n.videostream,u=TK.NONE,a&&(u|=U.AUDIO),c&&(u|=U.VIDEO),!u){e.next=11;break}return e.next=8,new Promise((function(e){return setTimeout(e)}));case 8:null!=r&&r.isScreen?this.safeEmit(oe.onUserPublishScreen,{userId:r.userId,mediaType:u}):(this.safeEmit(oe.onUserPublishStream,{userId:r.userId,mediaType:u,videoStreamDescriptions:null==r||null===(d=r.attributes)||void 0===d?void 0:d.videoDescriptions}),this._handleAutoSubscribe(r,!0)),this.safeEmit("onAddStream",{userId:r.userId,mediaType:u,isScreen:!(null==r||!r.isScreen)}),null!=r&&r.isScreen||(i&&this.safeEmit(oe.onUserStartAudioCapture,{userId:r.userId}),s&&this.safeEmit(oe.onUserStartVideoCapture,{userId:r.userId}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=TK.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=U.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=U.VIDEO),i){var o,a;if(t&&kM(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&TM(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=iZ[e.reason])&&void 0!==t?t:V.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?oe.onUserUnpublishScreen:oe.onUserUnpublishStream,a=TK.NONE;n.attributes.audiostream&&(a|=U.AUDIO),n.attributes.videostream&&(a|=U.VIDEO),a!==TK.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){var t=n.isScreen?"".concat(n.userId,"_screen"):n.userId;r._remoteAudioPlayer.delete(t),n.isScreen?r._remoteScreenPlayer.delete(n.userId):r._remoteVideoPlayer.delete(n.userId),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(oe.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){this.safeEmit(oe.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(oe.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.safeEmit.apply(this,[oe.onNetworkQuality].concat(t))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._useCloudProxy&&e.state===F.CONNECTION_STATE_CONNECTED&&this.safeEmit(oe.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(oe.onConnectionStateChanged,e),e.state===F.CONNECTION_STATE_RECONNECTING){var t,r=A(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=b(t.value,2),i=n[0],o=n[1];null!=i&&i.startsWith("mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){return[(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e)]}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(oe.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(oe.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=this,n=e.userId,o=e.isScreen,a=e.mediaType,s=e.pubState,c=e.remoteStream,u={userId:n,mediaType:a};(a&U.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(c)})),o)?s===uX.PUB?this.safeEmit(oe.onUserPublishScreen,u):this.safeEmit(oe.onUserUnpublishScreen,i(i({},u),{},{reason:V.STREAM_REMOVE_REASON_UNPUBLISH})):s===uX.PUB?(u.videoStreamDescriptions=null==c||null===(t=c.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(oe.onUserPublishStream,u),this._handleAutoSubscribe(c,!0)):this.safeEmit(oe.onUserUnpublishStream,i(i({},u),{},{reason:V.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(oe.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(oe.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(oe.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(oe.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(oe.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(oe.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(oe.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(oe.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(oe.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(oe.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(oe.onError,{errorCode:dD.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(oe.onError,{errorCode:dD.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(oe.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&(null===(t=this._room)||void 0===t||t.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){r.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})));return r}},{key:"iceState",get:function(){var e,t,r,n;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||null===(r=t.handler)||void 0===r||null===(n=r._peerConnection)||void 0===n?void 0:n.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&(null===(t=this._room)||void 0===t||t.remoteUsers.forEach((function(e){r.push({userId:e.userId})})));return r}},{key:"multiChatMode",get:function(){var e,t;return!(null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||!t.roomAttributes.multiChatMode)}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(oe.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==mX.CONNECTED)throw new hD(dD.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){MM(e,"mediaType",[U.AUDIO,U.VIDEO,U.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=c(o().mark((function e(t){var r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||!n.hasPublished){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),Ge}(GU);tZ([Fj()],nZ.prototype,"updateToken",1),tZ([Fj()],nZ.prototype,"setVideoCaptureDevice",1),tZ([Fj()],nZ.prototype,"setAudioCaptureDevice",1),tZ([Fj()],nZ.prototype,"joinRoom",1),tZ([Fj()],nZ.prototype,"leaveRoom",1),tZ([Fj()],nZ.prototype,"destroy",1),tZ([Fj()],nZ.prototype,"publishStream",1),tZ([Fj()],nZ.prototype,"unpublishStream",1),tZ([Fj()],nZ.prototype,"publishScreen",1),tZ([Fj()],nZ.prototype,"unpublishScreen",1),tZ([Fj()],nZ.prototype,"subscribeStream",1),tZ([Fj()],nZ.prototype,"unsubscribeStream",1),tZ([Fj()],nZ.prototype,"subscribeScreen",1),tZ([Fj()],nZ.prototype,"unsubscribeScreen",1),tZ([Fj()],nZ.prototype,"setRemoteVideoConfig",1),tZ([Fj()],nZ.prototype,"startVideoCapture",1),tZ([Fj()],nZ.prototype,"stopVideoCapture",1),tZ([Fj()],nZ.prototype,"startAudioCapture",1),tZ([Fj()],nZ.prototype,"stopAudioCapture",1),tZ([Fj()],nZ.prototype,"getAudioMixingManager",1),tZ([Fj()],nZ.prototype,"startScreenCapture",1),tZ([Fj()],nZ.prototype,"stopScreenCapture",1),tZ([Fj()],nZ.prototype,"setLocalVideoPlayer",1),tZ([Fj()],nZ.prototype,"startLiveTranscoding",1),tZ([Fj()],nZ.prototype,"updateLiveTranscoding",1),tZ([Fj()],nZ.prototype,"stopLiveTranscoding",1),tZ([Fj()],nZ.prototype,"setBusinessId",1),tZ([Fj()],nZ.prototype,"setUserVisibility",1),tZ([Fj()],nZ.prototype,"setRemoteVideoPlayer",1),tZ([Fj()],nZ.prototype,"setLocalVideoMirrorType",1),tZ([Fj()],nZ.prototype,"setAudioPlaybackDevice",1),tZ([Fj()],nZ.prototype,"play",1),tZ([Fj()],nZ.prototype,"pauseAllSubscribedStream",1),tZ([Fj()],nZ.prototype,"resumeAllSubscribedStream",1),tZ([Fj()],nZ.prototype,"sendUserMessage",1),tZ([Fj()],nZ.prototype,"sendUserBinaryMessage",1),tZ([Fj()],nZ.prototype,"sendRoomMessage",1),tZ([Fj()],nZ.prototype,"sendRoomBinaryMessage",1),tZ([Fj()],nZ.prototype,"setAudioCaptureConfig",1),tZ([Fj()],nZ.prototype,"setVideoCaptureConfig",1),tZ([Fj()],nZ.prototype,"enableSimulcastMode",1),tZ([Fj()],nZ.prototype,"setVideoEncoderConfig",1),tZ([Fj()],nZ.prototype,"setScreenEncoderConfig",1),tZ([Fj()],nZ.prototype,"sendSEIMessage",1),tZ([Fj()],nZ.prototype,"setAudioVolumeIndicationInterval",1),tZ([Fj()],nZ.prototype,"enableAudioPropertiesReport",1),tZ([Fj()],nZ.prototype,"setVideoSourceType",1),tZ([Fj()],nZ.prototype,"setExternalVideoTrack",1),tZ([Fj()],nZ.prototype,"setAudioSourceType",1),tZ([Fj()],nZ.prototype,"setExternalAudioTrack",1),tZ([Fj("rtm")],nZ.prototype,"login",1),tZ([Fj("rtm")],nZ.prototype,"logout",1),tZ([Fj("rtm")],nZ.prototype,"updateLoginToken",1),tZ([Fj("rtm")],nZ.prototype,"getPeerOnlineStatus",1),tZ([Fj("rtm")],nZ.prototype,"sendUserMessageOutsideRoom",1),tZ([Fj("rtm")],nZ.prototype,"sendUserBinaryMessageOutsideRoom",1),tZ([Fj("rtm")],nZ.prototype,"setServerParams",1),tZ([Fj("rtm")],nZ.prototype,"sendServerMessage",1),tZ([Fj("rtm")],nZ.prototype,"sendServerBinaryMessage",1),tZ([Fj()],nZ.prototype,"startCloudProxy",1),tZ([Fj()],nZ.prototype,"stopCloudProxy",1),tZ([Fj()],nZ.prototype,"startPushPublicStream",1),tZ([Fj()],nZ.prototype,"updatePublicStreamParam",1),tZ([Fj()],nZ.prototype,"stopPushPublicStream",1),tZ([Fj("outsideRoom","streamId")],nZ.prototype,"startPlayPublicStream",1),tZ([Fj("outsideRoom","streamId")],nZ.prototype,"stopPlayPublicStream",1),tZ([Fj()],nZ.prototype,"setAudioProfile",1),tZ([Fj("outsideRoom")],nZ.prototype,"setPublicStreamVideoPlayer",1),tZ([Fj()],nZ.prototype,"setDummyCaptureImagePath",1),tZ([Fj()],nZ.prototype,"registerExtension",1),tZ([Fj()],nZ.prototype,"startAudioPlaybackDeviceTest",1),tZ([Fj()],nZ.prototype,"stopAudioPlaybackDeviceTest",1),tZ([Fj()],nZ.prototype,"startAudioDeviceRecordTest",1),tZ([Fj()],nZ.prototype,"stopAudioDeviceRecordAndPlayTest",1),tZ([Fj()],nZ.prototype,"stopAudioDevicePlayTest",1),tZ([Fj()],nZ.prototype,"setRemoteUserPriority",1),tZ([Fj()],nZ.prototype,"takeLocalSnapshot",1),tZ([Fj()],nZ.prototype,"takeRemoteSnapshot",1),tZ([Fj()],nZ.prototype,"setSubscribeFallbackOption",1),tZ([Fj()],nZ.prototype,"getLocalStreamTrack",1),tZ([Fj()],nZ.prototype,"getRemoteStreamTrack",1),tZ([Fj()],nZ.prototype,"getPublicStreamTrack",1),tZ([Fj()],nZ.prototype,"setRemoteStreamRenderSync",1);var iZ={"client unpublished":V.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":V.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":V.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":V.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":V.STREAM_REMOVE_REASON_REPUBLISH};function oZ(e){var t=Jj.getServerConfig(e).web_rtc_config;return!(null==t||!t.fallback)||!!nG("ENABLE_FALLBACK_HANDLER")}var aZ=new FU("VERTC",0);MU.storeKey="".concat(Date.now(),"-").concat(Jj.getDeviceId()),[Pj,Dj,Nj].forEach((function(e){var t;return e.setStats({rtc_sdk_version:tG.VERSION,product_line:KB.RTC,report_version:XB.W_5,os:WB.WEB,device_id:Jj.getDeviceId(),log_cache_key:MU.storeKey,user_agent:tM()?"":null===(t=navigator)||void 0===t?void 0:t.userAgent})}));var sZ=function(e,t){return aZ.print("createEngine","Invoke VERTC.createEngine"),NM(e,"appId"),[Pj,Dj,Nj].forEach((function(r){return r.setStats({rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy})})),wj.sdkInitEngine(Date.now(),gj.BEGIN),new nZ(e,t)},cZ=function(e){if(aZ.print("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof nZ))throw new hD(dD.INVALID_ENGINE,"Invalid engine object");e.destroy(),wj.sdkInitEngine(Date.now(),gj.END)},uZ=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Mz.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),dZ=function(){var e=c(o().mark((function e(){var t,r,n,i,a,s,c=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=13;break}return e.prev=4,e.next=7,Mz.getPermissions({video:!0,force:!0});case 7:a=e.sent,i.video=a.video,e.next=13;break;case 11:e.prev=11,e.t0=e.catch(4);case 13:if(!n){e.next=23;break}return e.prev=14,e.next=17,Mz.getPermissions({audio:!0,force:!0});case 17:s=e.sent,i.audio=s.audio,e.next=23;break;case 21:e.prev=21,e.t1=e.catch(14);case 23:return e.abrupt("return",i);case 24:case"end":return e.stop()}}),e,null,[[4,11],[14,21]])})));return function(){return e.apply(this,arguments)}}(),lZ=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Mz.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),hZ=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Mz.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),fZ=function(){var e=c(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Mz.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),pZ=function(){return tG.VERSION},vZ=function(){return wj.rtcSdkApiCall("isSupported",0,""),jG()},_Z=function(){return wj.rtcSdkApiCall("getSupportedCodecs",0,""),HG()},mZ=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(MU.logLevel=t),r&&(MU.LogfileSize=r)},yZ=function(e){MU.download(e)};function gZ(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return JSON.stringify(t.map((function(e){return e instanceof nZ?"[ENGINE]":e})))}function SZ(e,t){return function(){Uj(t,0,gZ.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return Vj(t,0,gZ(e)),e})).catch((function(e){throw Vj(t,e.code,e.message),e})):(Vj(t,0,gZ(r)),r)}}return!tM()&&location.search.includes("_rtc_autotest_"),i(i(i(i({},new(l((function e(){u(this,e),h(this,"getSdkVersion",SZ(pZ,"getSdkVersion")),h(this,"createEngine",SZ(sZ,"createEngine")),h(this,"destroyEngine",SZ(cZ,"destroyEngine")),h(this,"enumerateDevices",SZ(uZ,"enumerateDevices")),h(this,"enableDevices",SZ(dZ,"enableDevices")),h(this,"enumerateAudioCaptureDevices",SZ(lZ,"enumerateAudioCaptureDevices")),h(this,"enumerateVideoCaptureDevices",SZ(hZ,"enumerateVideoCaptureDevices")),h(this,"enumerateAudioPlaybackDevices",SZ(fZ,"enumerateAudioPlaybackDevices")),h(this,"getParameter",nG),h(this,"setParameter",rG),h(this,"isSupported",SZ(vZ,"isSupported")),h(this,"getSupportedCodecs",SZ(_Z,"getSupportedCodecs")),h(this,"events",oe),h(this,"ErrorCode",dD),h(this,"platform","".concat({}.PRODUCT_PLATFORM)),h(this,"_monitor",wj),h(this,"downloadLog",SZ(yZ,"downloadLog")),h(this,"setLogConfig",SZ(mZ,"setLogConfig"))})))),ee),ie),{},{events:oe})}));