trtc-sdk-v5 5.10.1-beta.3 → 5.10.1-beta.5

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.
Files changed (60) hide show
  1. package/README-zh_CN.md +1 -2
  2. package/README.md +1 -2
  3. package/index.d.ts +1796 -1824
  4. package/package.json +1 -1
  5. package/{assets → plugins/ai-denoiser}/denoiser-wasm.js +1 -1
  6. package/plugins/cdn-streaming/cdn-streaming.esm.js +1 -1
  7. package/plugins/cdn-streaming/cdn-streaming.iife.js +1 -0
  8. package/plugins/cdn-streaming/package.json +2 -1
  9. package/plugins/cross-room/cross-room.esm.js +1 -1
  10. package/plugins/cross-room/cross-room.iife.js +1 -0
  11. package/plugins/cross-room/package.json +2 -1
  12. package/plugins/device-detector/device-detector.esm.js +1234 -93
  13. package/plugins/device-detector/device-detector.iife.js +1472 -0
  14. package/plugins/device-detector/package.json +2 -1
  15. package/plugins/video-decoder/package.json +1 -1
  16. package/plugins/video-decoder/video-decoder.esm.d.ts +20 -20
  17. package/plugins/video-decoder/video-decoder.esm.js +43 -1
  18. package/plugins/video-decoder/video-decoder.iife.js +43 -0
  19. package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +2 -1
  20. package/plugins/video-effect/basic-beauty/basic-beauty.iife.js +2 -0
  21. package/plugins/video-effect/basic-beauty/package.json +2 -1
  22. package/plugins/video-effect/beauty/beauty.esm.js +2954 -1
  23. package/plugins/video-effect/beauty/beauty.iife.js +2954 -0
  24. package/plugins/video-effect/beauty/package.json +2 -1
  25. package/plugins/video-effect/virtual-background/package.json +2 -1
  26. package/plugins/video-effect/virtual-background/virtual-background.esm.js +60 -1
  27. package/plugins/video-effect/virtual-background/virtual-background.iife.js +60 -0
  28. package/plugins/video-effect/watermark/package.json +2 -1
  29. package/plugins/video-effect/watermark/watermark.esm.d.ts +2 -10
  30. package/plugins/video-effect/watermark/watermark.esm.js +1 -1
  31. package/plugins/video-effect/watermark/watermark.iife.js +1 -0
  32. package/trtc.esm.js +30 -30
  33. package/trtc.js +1 -1
  34. package/assets/debug-dialog.js +0 -1
  35. package/assets/selfie_segmentation/package.json +0 -27
  36. package/assets/selfie_segmentation/selfie_segmentation.binarypb +0 -0
  37. package/assets/selfie_segmentation/selfie_segmentation.tflite +0 -0
  38. package/assets/selfie_segmentation/selfie_segmentation_landscape.tflite +0 -0
  39. package/assets/selfie_segmentation/selfie_segmentation_solution_simd_wasm_bin.data +0 -0
  40. package/assets/selfie_segmentation/selfie_segmentation_solution_simd_wasm_bin.wasm +0 -0
  41. package/assets/selfie_segmentation/selfie_segmentation_solution_wasm_bin.wasm +0 -0
  42. package/assets/videodec.wasm +0 -0
  43. package/assets/videodec_simd.wasm +0 -0
  44. package/plugins/cdn-streaming/cdn-streaming.umd.js +0 -1
  45. package/plugins/cross-room/cross-room.umd.js +0 -1
  46. package/plugins/custom-encryption/custom-encryption.esm.d.ts +0 -31
  47. package/plugins/custom-encryption/custom-encryption.esm.js +0 -1
  48. package/plugins/custom-encryption/custom-encryption.umd.js +0 -1
  49. package/plugins/custom-encryption/package.json +0 -7
  50. package/plugins/device-detector/device-detector.umd.js +0 -39
  51. package/plugins/video-decoder/video-decoder.umd.js +0 -1
  52. package/plugins/video-effect/basic-beauty/basic-beauty.umd.js +0 -1
  53. package/plugins/video-effect/beauty/beauty.umd.js +0 -1
  54. package/plugins/video-effect/virtual-background/virtual-background.umd.js +0 -1
  55. package/plugins/video-effect/watermark/watermark.umd.js +0 -1
  56. package/plugins/voice-changer/package.json +0 -9
  57. package/plugins/voice-changer/voice-changer.esm.d.ts +0 -20
  58. package/plugins/voice-changer/voice-changer.esm.js +0 -1
  59. package/plugins/voice-changer/voice-changer.umd.js +0 -1
  60. package/trtc.es5.js +0 -1
package/trtc.es5.js DELETED
@@ -1 +0,0 @@
1
- var factory;factory=function(){function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function n(e,n,r){return n=l(n),function(e,n){if(n&&("object"==typeof n||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return t(e)}(e,h()?Reflect.construct(n,r||[],l(e).constructor):n.apply(e,r))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){if(h())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&m(i,n.prototype),i}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,T(r.key),r)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=S(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function c(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=_(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},u.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(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&&m(e,t)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}function f(){f=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=t&&t.prototype instanceof g?t:g,o=Object.create(a.prototype),s=new x(r||[]);return i(o,"_invoke",{value:R(e,n,s)}),o}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",p="suspendedYield",m="executing",v="completed",_={};function g(){}function y(){}function E(){}var T={};u(T,o,(function(){return this}));var k=Object.getPrototypeOf,S=k&&k(k(O([])));S&&S!==n&&r.call(S,o)&&(T=S);var b=E.prototype=g.prototype=Object.create(T);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function n(i,a,o,s){var c=d(e[i],e,a);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,o,s)}),(function(e){n("throw",e,o,s)})):t.resolve(l).then((function(e){u.value=e,o(u)}),(function(e){return n("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function R(t,n,r){var i=h;return function(a,o){if(i===m)throw Error("Generator is already running");if(i===v){if("throw"===a)throw o;return{value:e,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var c=C(s,r);if(c){if(c===_)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var u=d(t,n,r);if("normal"===u.type){if(i=r.done?v:p,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=v,r.method="throw",r.arg=u.arg)}}}function C(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,C(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var a=d(i,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,_;var o=a.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,_):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function w(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 D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw new TypeError(typeof t+" is not iterable")}return y.prototype=E,i(b,"constructor",{value:E,configurable:!0}),i(E,"constructor",{value:y,configurable:!0}),y.displayName=u(E,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,u(e,c,"GeneratorFunction")),e.prototype=Object.create(b),e},t.awrap=function(e){return{__await:e}},I(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,n,r,i,a){void 0===a&&(a=Promise);var o=new A(l(e,n,r,i),a);return t.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=O,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(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 a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(o)},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),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;D(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),_}},t}function p(e,t,n,r){return p="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(e,t,n,r){var i,a=_(e,t);if(a){if((i=Object.getOwnPropertyDescriptor(a,t)).set)return i.set.call(r,n),!0;if(!i.writable)return!1}if(i=Object.getOwnPropertyDescriptor(r,t)){if(!i.writable)return!1;i.value=n,Object.defineProperty(r,t,i)}else c(r,t,n);return!0},p(e,t,n,r)}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],c=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||S(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 _(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}function g(e,t,n,r){var i=u(l(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function y(e,t,n,r,i,a){return function(e,t,n,r,i){if(!p(e,t,n,r||e)&&i)throw new TypeError("failed to set property");return n}(l(a?e.prototype:e),t,n,r,i)}function E(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||S(t)||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){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function k(e){return k="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},k(e)}function S(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}function b(e){var t="function"==typeof Map?new Map:void 0;return b=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return i(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,e)},b(e)}function I(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(t,n))}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var A=require("../internals/global-this"),R=require("../internals/object-get-own-property-descriptor").f,C=require("../internals/create-non-enumerable-property"),w=require("../internals/define-built-in"),D=require("../internals/define-global-property"),x=require("../internals/copy-constructor-properties"),O=require("../internals/is-forced");module.exports=function(e,t){var n,r,i,a,o,s=e.target,c=e.global,u=e.stat;if(n=c?A:u?A[s]||D(s,{}):A[s]&&A[s].prototype)for(r in t){if(a=t[r],i=e.dontCallGetSet?(o=R(n,r))&&o.value:n[r],!O(c?r:s+(u?".":"#")+r,e.forced)&&void 0!==i){if(k(a)==k(i))continue;x(a,i)}(e.sham||i&&i.sham)&&C(a,"sham",!0),w(n,r,a,e)}};var N=I(Object.freeze({__proto__:null})),P=L;N({global:!0,forced:P.globalThis!==P},{globalThis:P});var M=function(e){return e&&e.Math===Math&&e};module.exports=M("object"==("undefined"==typeof globalThis?"undefined":k(globalThis))&&globalThis)||M("object"==("undefined"==typeof window?"undefined":k(window))&&window)||M("object"==("undefined"==typeof self?"undefined":k(self))&&self)||M("object"==("undefined"==typeof global?"undefined":k(global))&&global)||M("object"==k(void 0)&&void 0)||function(){return this}()||Function("return this")();var L=I(Object.freeze({__proto__:null})),U={},V={get exports(){return U},set exports(e){U=e}},F=require("../internals/export"),B=require("../internals/descriptors"),q=require("../internals/object-define-property").f;F({target:"Object",stat:!0,forced:Object.defineProperty!==q,sham:!B},{defineProperty:q});var j=require("../internals/global-this"),H=Object.defineProperty;module.exports=function(e,t){try{H(j,e,{value:t,configurable:!0,writable:!0})}catch(n){j[e]=t}return t};var G=L,W=I(Object.freeze({__proto__:null})),z="__core-js_shared__",J=V.exports=G[z]||W(z,{});(J.versions||(J.versions=[])).push({version:"3.38.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"});var K=U,Y=function(e,t){return K[e]||(K[e]=t||{})},X=require("../internals/export"),Q=require("../internals/function-bind");X({target:"Function",proto:!0,forced:Function.bind!==Q},{bind:Q});var $=require("../internals/function-bind-native"),Z=Function.prototype,ee=Z.call,te=$&&Z.bind.bind(ee,ee);module.exports=$?te:function(e){return function(){return ee.apply(e,arguments)}};var ne=I(Object.freeze({__proto__:null})),re=function(e){return null==e},ie=re,ae=TypeError,oe=function(e){if(ie(e))throw new ae("Can't call method on "+e);return e},se=oe,ce=Object,ue=function(e){return ce(se(e))},le=ue,de=ne({}.hasOwnProperty),he=Object.hasOwn||function(e,t){return de(le(e),t)},fe=require("../internals/export"),pe=require("../internals/regexp-exec");fe({target:"RegExp",proto:!0,forced:/./.exec!==pe},{exec:pe});var me=require("../internals/descriptors"),ve=require("../internals/function-name").EXISTS,_e=require("../internals/function-uncurry-this"),ge=require("../internals/define-built-in-accessor"),ye=Function.prototype,Ee=_e(ye.toString),Te=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,ke=_e(Te.exec);me&&!ve&&ge(ye,"name",{configurable:!0,get:function(){try{return ke(Te,Ee(this))[1]}catch(e){return""}}});var Se=require("../internals/export"),be=require("../internals/fails"),Ie=require("../internals/is-array"),Ae=require("../internals/is-object"),Re=require("../internals/to-object"),Ce=require("../internals/length-of-array-like"),we=require("../internals/does-not-exceed-safe-integer"),De=require("../internals/create-property"),xe=require("../internals/array-species-create"),Oe=require("../internals/array-method-has-species-support"),Ne=require("../internals/well-known-symbol"),Pe=require("../internals/environment-v8-version"),Me=Ne("isConcatSpreadable"),Le=Pe>=51||!be((function(){var e=[];return e[Me]=!1,e.concat()[0]!==e})),Ue=function(e){if(!Ae(e))return!1;var t=e[Me];return void 0!==t?!!t:Ie(e)};Se({target:"Array",proto:!0,arity:1,forced:!Le||!Oe("concat")},{concat:function(e){var t,n,r,i,a,o=Re(this),s=xe(o,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(Ue(a=-1===t?o:arguments[t]))for(i=Ce(a),we(c+i),n=0;n<i;n++,c++)n in a&&De(s,c,a[n]);else we(c+1),De(s,c++,a);return s.length=c,s}});var Ve=require("../internals/function-apply"),Fe=require("../internals/function-call"),Be=require("../internals/function-uncurry-this"),qe=require("../internals/fix-regexp-well-known-symbol-logic"),je=require("../internals/fails"),He=require("../internals/an-object"),Ge=require("../internals/is-callable"),We=require("../internals/is-null-or-undefined"),ze=require("../internals/to-integer-or-infinity"),Je=require("../internals/to-length"),Ke=require("../internals/to-string"),Ye=require("../internals/require-object-coercible"),Xe=require("../internals/advance-string-index"),Qe=require("../internals/get-method"),$e=require("../internals/get-substitution"),Ze=require("../internals/regexp-exec-abstract"),et=require("../internals/well-known-symbol")("replace"),tt=Math.max,nt=Math.min,rt=Be([].concat),it=Be([].push),at=Be("".indexOf),ot=Be("".slice),st="$0"==="a".replace(/./,"$0"),ct=!!/./[et]&&""===/./[et]("a","$0");qe("replace",(function(e,t,n){var r=ct?"$":"$0";return[function(e,n){var r=Ye(this),i=We(e)?void 0:Qe(e,et);return i?Fe(i,e,r,n):Fe(t,Ke(r),e,n)},function(e,i){var a=He(this),o=Ke(e);if("string"==typeof i&&-1===at(i,r)&&-1===at(i,"$<")){var s=n(t,a,o,i);if(s.done)return s.value}var c=Ge(i);c||(i=Ke(i));var u,l=a.global;l&&(u=a.unicode,a.lastIndex=0);for(var d,h=[];null!==(d=Ze(a,o))&&(it(h,d),l);)""===Ke(d[0])&&(a.lastIndex=Xe(o,Je(a.lastIndex),u));for(var f,p="",m=0,v=0;v<h.length;v++){for(var _,g=Ke((d=h[v])[0]),y=tt(nt(ze(d.index),o.length),0),E=[],T=1;T<d.length;T++)it(E,void 0===(f=d[T])?f:String(f));var k=d.groups;if(c){var S=rt([g],E,y,o);void 0!==k&&it(S,k),_=Ke(Ve(i,void 0,S))}else _=$e(g,o,y,E,k,i);y>=m&&(p+=ot(o,m,y)+_,m=y+g.length)}return p+ot(o,m)}]}),!!je((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!st||ct);var ut=require("../internals/descriptors"),lt=require("../internals/global-this"),dt=require("../internals/function-uncurry-this"),ht=require("../internals/is-forced"),ft=require("../internals/inherit-if-required"),pt=require("../internals/create-non-enumerable-property"),mt=require("../internals/object-create"),vt=require("../internals/object-get-own-property-names").f,_t=require("../internals/object-is-prototype-of"),gt=require("../internals/is-regexp"),yt=require("../internals/to-string"),Et=require("../internals/regexp-get-flags"),Tt=require("../internals/regexp-sticky-helpers"),kt=require("../internals/proxy-accessor"),St=require("../internals/define-built-in"),bt=require("../internals/fails"),It=require("../internals/has-own-property"),At=require("../internals/internal-state").enforce,Rt=require("../internals/set-species"),Ct=require("../internals/well-known-symbol"),wt=require("../internals/regexp-unsupported-dot-all"),Dt=require("../internals/regexp-unsupported-ncg"),xt=Ct("match"),Ot=lt.RegExp,Nt=Ot.prototype,Pt=lt.SyntaxError,Mt=dt(Nt.exec),Lt=dt("".charAt),Ut=dt("".replace),Vt=dt("".indexOf),Ft=dt("".slice),Bt=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,qt=/a/g,jt=/a/g,Ht=new Ot(qt)!==qt,Gt=Tt.MISSED_STICKY,Wt=Tt.UNSUPPORTED_Y,zt=ut&&(!Ht||Gt||wt||Dt||bt((function(){return jt[xt]=!1,Ot(qt)!==qt||Ot(jt)===jt||"/a/i"!==String(Ot(qt,"i"))})));if(ht("RegExp",zt)){for(var Jt=function(e,t){var n,r,i,a,o,s,c=_t(Nt,this),u=gt(e),l=void 0===t,d=[],h=e;if(!c&&u&&l&&e.constructor===Jt)return e;if((u||_t(Nt,e))&&(e=e.source,l&&(t=Et(h))),e=void 0===e?"":yt(e),t=void 0===t?"":yt(t),h=e,wt&&"dotAll"in qt&&(r=!!t&&Vt(t,"s")>-1)&&(t=Ut(t,/s/g,"")),n=t,Gt&&"sticky"in qt&&(i=!!t&&Vt(t,"y")>-1)&&Wt&&(t=Ut(t,/y/g,"")),Dt&&(a=function(e){for(var t,n=e.length,r=0,i="",a=[],o=mt(null),s=!1,c=!1,u=0,l="";r<=n;r++){if("\\"===(t=Lt(e,r)))t+=Lt(e,++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(i+=t,"?:"===Ft(e,r+1,r+3))continue;Mt(Bt,Ft(e,r+1))&&(r+=2,c=!0),u++;continue;case">"===t&&c:if(""===l||It(o,l))throw new Pt("Invalid capture group name");o[l]=!0,a[a.length]=[l,u],c=!1,l="";continue}c?l+=t:i+=t}return[i,a]}(e),e=a[0],d=a[1]),o=ft(Ot(e,t),c?this:Nt,Jt),(r||i||d.length)&&(s=At(o),r&&(s.dotAll=!0,s.raw=Jt(function(e){for(var t,n=e.length,r=0,i="",a=!1;r<=n;r++)"\\"!==(t=Lt(e,r))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),i+=t):i+="[\\s\\S]":i+=t+Lt(e,++r);return i}(e),n)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{pt(o,"source",""===h?"(?:)":h)}catch(f){}return o},Kt=vt(Ot),Yt=0;Kt.length>Yt;)kt(Jt,Ot,Kt[Yt++]);Nt.constructor=Jt,Jt.prototype=Nt,St(lt,"RegExp",Jt,{constructor:!0})}Rt("RegExp");var Xt=require("../internals/function-name").PROPER,Qt=require("../internals/define-built-in"),$t=require("../internals/an-object"),Zt=require("../internals/to-string"),en=require("../internals/fails"),tn=require("../internals/regexp-get-flags"),nn="toString",rn=RegExp.prototype,an=rn[nn],on=en((function(){return"/a/b"!==an.call({source:"a",flags:"b"})})),sn=Xt&&an.name!==nn;(on||sn)&&Qt(rn,nn,(function(){var e=$t(this);return"/"+Zt(e.source)+"/"+Zt(tn(e))}),{unsafe:!0});var cn=require("../internals/function-uncurry-this"),un=0,ln=Math.random(),dn=cn(1..toString);module.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+dn(++un+ln,36)};var hn=I(Object.freeze({__proto__:null})),fn=require("../internals/environment-v8-version"),pn=require("../internals/fails"),mn=require("../internals/global-this").String;module.exports=!!Object.getOwnPropertySymbols&&!pn((function(){var e=Symbol("symbol detection");return!mn(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&fn&&fn<41}));var vn=I(Object.freeze({__proto__:null})),_n=L,gn={},yn=Wa;gn.f=yn;var En=function(e){try{return!!e()}catch(t){return!0}},Tn=require("../internals/function-call"),kn=require("../internals/function-uncurry-this"),Sn=require("../internals/fix-regexp-well-known-symbol-logic"),bn=require("../internals/an-object"),In=require("../internals/is-null-or-undefined"),An=require("../internals/require-object-coercible"),Rn=require("../internals/species-constructor"),Cn=require("../internals/advance-string-index"),wn=require("../internals/to-length"),Dn=require("../internals/to-string"),xn=require("../internals/get-method"),On=require("../internals/regexp-exec-abstract"),Nn=require("../internals/regexp-sticky-helpers"),Pn=require("../internals/fails"),Mn=Nn.UNSUPPORTED_Y,Ln=Math.min,Un=kn([].push),Vn=kn("".slice),Fn=!Pn((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),Bn="c"==="abbc".split(/(b)*/)[1]||4!=="test".split(/(?:)/,-1).length||2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length;Sn("split",(function(e,t,n){var r="0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:Tn(t,this,e,n)}:t;return[function(t,n){var i=An(this),a=In(t)?void 0:xn(t,e);return a?Tn(a,t,i,n):Tn(r,Dn(i),t,n)},function(e,i){var a=bn(this),o=Dn(e);if(!Bn){var s=n(r,a,o,i,r!==t);if(s.done)return s.value}var c=Rn(a,RegExp),u=a.unicode,l=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(Mn?"g":"y"),d=new c(Mn?"^(?:"+a.source+")":a,l),h=void 0===i?4294967295:i>>>0;if(0===h)return[];if(0===o.length)return null===On(d,o)?[o]:[];for(var f=0,p=0,m=[];p<o.length;){d.lastIndex=Mn?0:p;var v,_=On(d,Mn?Vn(o,p):o);if(null===_||(v=Ln(wn(d.lastIndex+(Mn?p:0)),o.length))===f)p=Cn(o,p,u);else{if(Un(m,Vn(o,f,p)),m.length===h)return m;for(var g=1;g<=_.length-1;g++)if(Un(m,_[g]),m.length===h)return m;p=f=v}}return Un(m,Vn(o,f)),m}]}),Bn||!Fn,Mn);var qn=require("../internals/function-uncurry-this"),jn=require("../internals/fails"),Hn=require("../internals/classof-raw"),Gn=Object,Wn=qn("".split);module.exports=jn((function(){return!Gn("z").propertyIsEnumerable(0)}))?function(e){return"String"===Hn(e)?Wn(e,""):Gn(e)}:Gn;var zn=I(Object.freeze({__proto__:null})),Jn=zn,Kn=oe,Yn=function(e){return Jn(Kn(e))},Xn=require("../internals/descriptors"),Qn=require("../internals/function-call"),$n=require("../internals/object-property-is-enumerable"),Zn=require("../internals/create-property-descriptor"),er=require("../internals/to-indexed-object"),tr=require("../internals/to-property-key"),nr=require("../internals/has-own-property"),rr=require("../internals/ie8-dom-define"),ir=Object.getOwnPropertyDescriptor;exports.f=Xn?ir:function(e,t){if(e=er(e),t=tr(t),rr)try{return ir(e,t)}catch(n){}if(nr(e,t))return Zn(!Qn($n.f,e,t),e[t])};var ar=I(Object.freeze({__proto__:null})),or=require("../internals/fails");module.exports=!or((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}));var sr=I(Object.freeze({__proto__:null})),cr=N,ur=En,lr=Yn,dr=ar.f,hr=sr;cr({target:"Object",stat:!0,forced:!hr||ur((function(){dr(1)})),sham:!hr},{getOwnPropertyDescriptor:function(e,t){return dr(lr(e),t)}});var fr=require("../internals/descriptors"),pr=require("../internals/ie8-dom-define"),mr=require("../internals/v8-prototype-define-bug"),vr=require("../internals/an-object"),_r=require("../internals/to-property-key"),gr=TypeError,yr=Object.defineProperty,Er=Object.getOwnPropertyDescriptor,Tr="enumerable",kr="configurable",Sr="writable";exports.f=fr?mr?function(e,t,n){if(vr(e),t=_r(t),vr(n),"function"==typeof e&&"prototype"===t&&"value"in n&&Sr in n&&!n[Sr]){var r=Er(e,t);r&&r[Sr]&&(e[t]=n.value,n={configurable:kr in n?n[kr]:r[kr],enumerable:Tr in n?n[Tr]:r[Tr],writable:!1})}return yr(e,t,n)}:yr:function(e,t,n){if(vr(e),t=_r(t),vr(n),pr)try{return yr(e,t,n)}catch(r){}if("get"in n||"set"in n)throw new gr("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var br=I(Object.freeze({__proto__:null})),Ir=_n,Ar=he,Rr=gn,Cr=br.f,wr=function(e){var t=Ir.Symbol||(Ir.Symbol={});Ar(t,e)||Cr(t,e,{value:Rr.f(e)})};wr("iterator");var Dr=require("../internals/to-indexed-object"),xr=require("../internals/add-to-unscopables"),Or=require("../internals/iterators"),Nr=require("../internals/internal-state"),Pr=require("../internals/object-define-property").f,Mr=require("../internals/iterator-define"),Lr=require("../internals/create-iter-result-object"),Ur=require("../internals/is-pure"),Vr=require("../internals/descriptors"),Fr="Array Iterator",Br=Nr.set,qr=Nr.getterFor(Fr);module.exports=Mr(Array,"Array",(function(e,t){Br(this,{type:Fr,target:Dr(e),index:0,kind:t})}),(function(){var e=qr(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,Lr(void 0,!0);switch(e.kind){case"keys":return Lr(n,!1);case"values":return Lr(t[n],!1)}return Lr([n,t[n]],!1)}),"values");var jr=Or.Arguments=Or.Array;if(xr("keys"),xr("values"),xr("entries"),!Ur&&Vr&&"values"!==jr.name)try{Pr(jr,"name",{value:"values"})}catch(LN){}N({target:"Math",stat:!0},{trunc:Wr});var Hr=Math.ceil,Gr=Math.floor;module.exports=Math.trunc||function(e){var t=+e;return(t>0?Gr:Hr)(t)};var Wr=I(Object.freeze({__proto__:null})),zr=Wr,Jr=function(e){var t=+e;return t!=t||0===t?0:zr(t)},Kr="object"==("undefined"==typeof document?"undefined":k(document))&&document.all;module.exports=void 0===Kr&&void 0!==Kr?function(e){return"function"==typeof e||e===Kr}:function(e){return"function"==typeof e};var Yr=I(Object.freeze({__proto__:null})),Xr=require("../internals/function-uncurry-this"),Qr=Xr({}.toString),$r=Xr("".slice);module.exports=function(e){return $r(Qr(e),8,-1)};var Zr=I(Object.freeze({__proto__:null})),ei=Ja,ti=Yr,ni=Zr,ri=Wa("toStringTag"),ii=Object,ai="Arguments"===ni(function(){return arguments}()),oi=ei?ni:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(LN){}}(t=ii(e),ri))?n:ai?ni(t):"Object"===(r=ni(t))&&ti(t.callee)?"Arguments":r},si=oi,ci=String,ui=function(e){if("Symbol"===si(e))throw new TypeError("Cannot convert a Symbol value to a string");return ci(e)},li=ne,di=Jr,hi=ui,fi=oe,pi=li("".charAt),mi=li("".charCodeAt),vi=li("".slice),_i=function(e){return function(t,n){var r,i,a=hi(fi(t)),o=di(n),s=a.length;return o<0||o>=s?e?"":void 0:(r=mi(a,o))<55296||r>56319||o+1===s||(i=mi(a,o+1))<56320||i>57343?e?pi(a,o):r:e?vi(a,o,o+2):i-56320+(r-55296<<10)+65536}},gi={codeAt:_i(!1),charAt:_i(!0)},yi=require("../internals/global-this"),Ei=require("../internals/is-callable"),Ti=yi.WeakMap;module.exports=Ei(Ti)&&/native code/.test(String(Ti));var ki=I(Object.freeze({__proto__:null})),Si=require("../internals/is-callable");module.exports=function(e){return"object"==k(e)?null!==e:Si(e)};var bi,Ii,Ai,Ri=I(Object.freeze({__proto__:null})),Ci=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},wi=br,Di=Ci,xi=sr?function(e,t,n){return wi.f(e,t,Di(1,n))}:function(e,t,n){return e[t]=n,e},Oi=hn,Ni=Y("keys"),Pi=ki,Mi=L,Li=Ri,Ui=xi,Vi=he,Fi=U,Bi=function(e){return Ni[e]||(Ni[e]=Oi(e))},qi="Object already initialized",ji=Mi.TypeError,Hi=Mi.WeakMap;if(Pi||Fi.state){var Gi=Fi.state||(Fi.state=new Hi);Gi.get=Gi.get,Gi.has=Gi.has,Gi.set=Gi.set,bi=function(e,t){if(Gi.has(e))throw new ji(qi);return t.facade=e,Gi.set(e,t),t},Ii=function(e){return Gi.get(e)||{}},Ai=function(e){return Gi.has(e)}}else{var Wi=Bi("state");bi=function(e,t){if(Vi(e,Wi))throw new ji(qi);return t.facade=e,Ui(e,Wi,t),t},Ii=function(e){return Vi(e,Wi)?e[Wi]:{}},Ai=function(e){return Vi(e,Wi)}}var zi={set:bi,get:Ii,has:Ai,enforce:function(e){return Ai(e)?Ii(e):bi(e,{})},getterFor:function(e){return function(t){var n;if(!Li(t)||(n=Ii(t)).type!==e)throw new ji("Incompatible receiver, "+e+" required");return n}}},Ji=require("../internals/global-this"),Ki=require("../internals/dom-iterables"),Yi=require("../internals/dom-token-list-prototype"),Xi=require("../modules/es.array.iterator"),Qi=require("../internals/create-non-enumerable-property"),$i=require("../internals/set-to-string-tag"),Zi=require("../internals/well-known-symbol")("iterator"),ea=Xi.values,ta=function(e,t){if(e){if(e[Zi]!==ea)try{Qi(e,Zi,ea)}catch(LN){e[Zi]=ea}if($i(e,t,!0),Ki[t])for(var n in Xi)if(e[n]!==Xi[n])try{Qi(e,n,Xi[n])}catch(LN){e[n]=Xi[n]}}};for(var na in Ki)ta(Ji[na]&&Ji[na].prototype,na);ta(Yi,"DOMTokenList");var ra=require("../internals/export"),ia=require("../internals/function-call"),aa=require("../internals/is-pure"),oa=require("../internals/function-name"),sa=require("../internals/is-callable"),ca=require("../internals/iterator-create-constructor"),ua=require("../internals/object-get-prototype-of"),la=require("../internals/object-set-prototype-of"),da=require("../internals/set-to-string-tag"),ha=require("../internals/create-non-enumerable-property"),fa=require("../internals/define-built-in"),pa=require("../internals/well-known-symbol"),ma=require("../internals/iterators"),va=require("../internals/iterators-core"),_a=oa.PROPER,ga=oa.CONFIGURABLE,ya=va.IteratorPrototype,Ea=va.BUGGY_SAFARI_ITERATORS,Ta=pa("iterator"),ka="keys",Sa="values",ba="entries",Ia=function(){return this};module.exports=function(e,t,n,r,i,a,o){ca(n,t,r);var s,c,u,l=function(e){if(e===i&&m)return m;if(!Ea&&e&&e in f)return f[e];switch(e){case ka:case Sa:case ba:return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,f=e.prototype,p=f[Ta]||f["@@iterator"]||i&&f[i],m=!Ea&&p||l(i),v="Array"===t&&f.entries||p;if(v&&(s=ua(v.call(new e)))!==Object.prototype&&s.next&&(aa||ua(s)===ya||(la?la(s,ya):sa(s[Ta])||fa(s,Ta,Ia)),da(s,d,!0,!0),aa&&(ma[d]=Ia)),_a&&i===Sa&&p&&p.name!==Sa&&(!aa&&ga?ha(f,"name",Sa):(h=!0,m=function(){return ia(p,this)})),i)if(c={values:l(Sa),keys:a?m:l(ka),entries:l(ba)},o)for(u in c)(Ea||h||!(u in f))&&fa(f,u,c[u]);else ra({target:t,proto:!0,forced:Ea||h},c);return aa&&!o||f[Ta]===m||fa(f,Ta,m,{name:i}),ma[t]=m,c};var Aa=I(Object.freeze({__proto__:null})),Ra=function(e,t){return{value:e,done:t}},Ca=gi.charAt,wa=ui,Da=zi,xa=Aa,Oa=Ra,Na="String Iterator",Pa=Da.set,Ma=Da.getterFor(Na);xa(String,"String",(function(e){Pa(this,{type:Na,string:wa(e),index:0})}),(function(){var e,t=Ma(this),n=t.string,r=t.index;return r>=n.length?Oa(void 0,!0):(e=Ca(n,r),t.index+=e.length,Oa(e,!1))}));var La=require("../internals/symbol-constructor-detection");module.exports=La&&!Symbol.sham&&"symbol"==k(Symbol.iterator);var Ua=Y,Va=he,Fa=hn,Ba=vn,qa=I(Object.freeze({__proto__:null})),ja=L.Symbol,Ha=Ua("wks"),Ga=qa?ja.for||ja:ja&&ja.withoutSetter||Fa,Wa=function(e){return Va(Ha,e)||(Ha[e]=Ba&&Va(ja,e)?ja[e]:Ga("Symbol."+e)),Ha[e]},za={};za[Wa("toStringTag")]="z";var Ja="[object z]"===String(za),Ka=require("../internals/is-callable"),Ya=require("../internals/object-define-property"),Xa=require("../internals/make-built-in"),Qa=require("../internals/define-global-property");module.exports=function(e,t,n,r){r||(r={});var i=r.enumerable,a=void 0!==r.name?r.name:t;if(Ka(n)&&Xa(n,a,r),r.global)i?e[t]=n:Qa(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(LN){}i?e[t]=n:Ya.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e};var $a=I(Object.freeze({__proto__:null})),Za=require("../internals/to-string-tag-support"),eo=require("../internals/classof");module.exports=Za?{}.toString:function(){return"[object "+eo(this)+"]"};var to=I(Object.freeze({__proto__:null}));Ja||$a(Object.prototype,"toString",to,{unsafe:!0});var no=require("../internals/function-uncurry-this"),ro=require("../internals/define-built-in"),io=Date.prototype,ao="Invalid Date",oo="toString",so=no(io[oo]),co=no(io.getTime);String(new Date(NaN))!==ao&&ro(io,oo,(function(){var e=co(this);return e==e?so(this):ao}));var uo=require("../internals/export"),lo=require("../internals/descriptors"),ho=require("../internals/global-this"),fo=require("../internals/function-uncurry-this"),po=require("../internals/has-own-property"),mo=require("../internals/is-callable"),vo=require("../internals/object-is-prototype-of"),_o=require("../internals/to-string"),go=require("../internals/define-built-in-accessor"),yo=require("../internals/copy-constructor-properties"),Eo=ho.Symbol,To=Eo&&Eo.prototype;if(lo&&mo(Eo)&&(!("description"in To)||void 0!==Eo().description)){var ko={},So=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:_o(arguments[0]),t=vo(To,this)?new Eo(e):void 0===e?Eo():Eo(e);return""===e&&(ko[t]=!0),t};yo(So,Eo),So.prototype=To,To.constructor=So;var bo="Symbol(description detection)"===String(Eo("description detection")),Io=fo(To.valueOf),Ao=fo(To.toString),Ro=/^Symbol\((.*)\)[^)]+$/,Co=fo("".replace),wo=fo("".slice);go(To,"description",{configurable:!0,get:function(){var e=Io(this);if(po(ko,e))return"";var t=Ao(e),n=bo?wo(t,7,-1):Co(t,Ro,"$1");return""===n?void 0:n}}),uo({global:!0,constructor:!0,forced:!0},{Symbol:So})}var Do=require("../internals/export"),xo=require("../internals/array-for-each");Do({target:"Array",proto:!0,forced:[].forEach!==xo},{forEach:xo});var Oo=require("../internals/global-this"),No=require("../internals/dom-iterables"),Po=require("../internals/dom-token-list-prototype"),Mo=require("../internals/array-for-each"),Lo=require("../internals/create-non-enumerable-property"),Uo=function(e){if(e&&e.forEach!==Mo)try{Lo(e,"forEach",Mo)}catch(LN){e.forEach=Mo}};for(var Vo in No)No[Vo]&&Uo(Oo[Vo]&&Oo[Vo].prototype);Uo(Po);var Fo=require("../internals/export"),Bo=require("../internals/global-this"),qo=require("../internals/function-call"),jo=require("../internals/function-uncurry-this"),Ho=require("../internals/is-pure"),Go=require("../internals/descriptors"),Wo=require("../internals/symbol-constructor-detection"),zo=require("../internals/fails"),Jo=require("../internals/has-own-property"),Ko=require("../internals/object-is-prototype-of"),Yo=require("../internals/an-object"),Xo=require("../internals/to-indexed-object"),Qo=require("../internals/to-property-key"),$o=require("../internals/to-string"),Zo=require("../internals/create-property-descriptor"),es=require("../internals/object-create"),ts=require("../internals/object-keys"),ns=require("../internals/object-get-own-property-names"),rs=require("../internals/object-get-own-property-names-external"),is=require("../internals/object-get-own-property-symbols"),as=require("../internals/object-get-own-property-descriptor"),os=require("../internals/object-define-property"),ss=require("../internals/object-define-properties"),cs=require("../internals/object-property-is-enumerable"),us=require("../internals/define-built-in"),ls=require("../internals/define-built-in-accessor"),ds=require("../internals/shared"),hs=require("../internals/shared-key"),fs=require("../internals/hidden-keys"),ps=require("../internals/uid"),ms=require("../internals/well-known-symbol"),vs=require("../internals/well-known-symbol-wrapped"),_s=require("../internals/well-known-symbol-define"),gs=require("../internals/symbol-define-to-primitive"),ys=require("../internals/set-to-string-tag"),Es=require("../internals/internal-state"),Ts=require("../internals/array-iteration").forEach,ks=hs("hidden"),Ss="Symbol",bs="prototype",Is=Es.set,As=Es.getterFor(Ss),Rs=Object[bs],Cs=Bo.Symbol,ws=Cs&&Cs[bs],Ds=Bo.RangeError,xs=Bo.TypeError,Os=Bo.QObject,Ns=as.f,Ps=os.f,Ms=rs.f,Ls=cs.f,Us=jo([].push),Vs=ds("symbols"),Fs=ds("op-symbols"),Bs=ds("wks"),qs=!Os||!Os[bs]||!Os[bs].findChild,js=function(e,t,n){var r=Ns(Rs,t);r&&delete Rs[t],Ps(e,t,n),r&&e!==Rs&&Ps(Rs,t,r)},Hs=Go&&zo((function(){return 7!==es(Ps({},"a",{get:function(){return Ps(this,"a",{value:7}).a}})).a}))?js:Ps,Gs=function(e,t){var n=Vs[e]=es(ws);return Is(n,{type:Ss,tag:e,description:t}),Go||(n.description=t),n},Ws=function(e,t,n){e===Rs&&Ws(Fs,t,n),Yo(e);var r=Qo(t);return Yo(n),Jo(Vs,r)?(n.enumerable?(Jo(e,ks)&&e[ks][r]&&(e[ks][r]=!1),n=es(n,{enumerable:Zo(0,!1)})):(Jo(e,ks)||Ps(e,ks,Zo(1,es(null))),e[ks][r]=!0),Hs(e,r,n)):Ps(e,r,n)},zs=function(e,t){Yo(e);var n=Xo(t),r=ts(n).concat(Xs(n));return Ts(r,(function(t){Go&&!qo(Js,n,t)||Ws(e,t,n[t])})),e},Js=function(e){var t=Qo(e),n=qo(Ls,this,t);return!(this===Rs&&Jo(Vs,t)&&!Jo(Fs,t))&&(!(n||!Jo(this,t)||!Jo(Vs,t)||Jo(this,ks)&&this[ks][t])||n)},Ks=function(e,t){var n=Xo(e),r=Qo(t);if(n!==Rs||!Jo(Vs,r)||Jo(Fs,r)){var i=Ns(n,r);return!i||!Jo(Vs,r)||Jo(n,ks)&&n[ks][r]||(i.enumerable=!0),i}},Ys=function(e){var t=Ms(Xo(e)),n=[];return Ts(t,(function(e){Jo(Vs,e)||Jo(fs,e)||Us(n,e)})),n},Xs=function(e){var t=e===Rs,n=Ms(t?Fs:Xo(e)),r=[];return Ts(n,(function(e){!Jo(Vs,e)||t&&!Jo(Rs,e)||Us(r,Vs[e])})),r};Wo||(Cs=function(){if(Ko(ws,this))throw new xs("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?$o(arguments[0]):void 0,t=ps(e),n=function(e){var r=void 0===this?Bo:this;r===Rs&&qo(n,Fs,e),Jo(r,ks)&&Jo(r[ks],t)&&(r[ks][t]=!1);var i=Zo(1,e);try{Hs(r,t,i)}catch(LN){if(!(LN instanceof Ds))throw LN;js(r,t,i)}};return Go&&qs&&Hs(Rs,t,{configurable:!0,set:n}),Gs(t,e)},us(ws=Cs[bs],"toString",(function(){return As(this).tag})),us(Cs,"withoutSetter",(function(e){return Gs(ps(e),e)})),cs.f=Js,os.f=Ws,ss.f=zs,as.f=Ks,ns.f=rs.f=Ys,is.f=Xs,vs.f=function(e){return Gs(ms(e),e)},Go&&(ls(ws,"description",{configurable:!0,get:function(){return As(this).description}}),Ho||us(Rs,"propertyIsEnumerable",Js,{unsafe:!0}))),Fo({global:!0,constructor:!0,wrap:!0,forced:!Wo,sham:!Wo},{Symbol:Cs}),Ts(ts(Bs),(function(e){_s(e)})),Fo({target:Ss,stat:!0,forced:!Wo},{useSetter:function(){qs=!0},useSimple:function(){qs=!1}}),Fo({target:"Object",stat:!0,forced:!Wo,sham:!Go},{create:function(e,t){return void 0===t?es(e):zs(es(e),t)},defineProperty:Ws,defineProperties:zs,getOwnPropertyDescriptor:Ks}),Fo({target:"Object",stat:!0,forced:!Wo},{getOwnPropertyNames:Ys}),gs(),ys(Cs,Ss),fs[ks]=!0;var Qs=L,$s=Yr,Zs=function(e,t){return arguments.length<2?(n=Qs[e],$s(n)?n:void 0):Qs[e]&&Qs[e][t];var n},ec=vn&&!!Symbol.for&&!!Symbol.keyFor,tc=N,nc=Zs,rc=he,ic=ui,ac=Y,oc=ec,sc=ac("string-to-symbol-registry"),cc=ac("symbol-to-string-registry");tc({target:"Symbol",stat:!0,forced:!oc},{for:function(e){var t=ic(e);if(rc(sc,t))return sc[t];var n=nc("Symbol")(t);return sc[t]=n,cc[n]=t,n}});var uc=require("../internals/get-built-in"),lc=require("../internals/is-callable"),dc=require("../internals/object-is-prototype-of"),hc=require("../internals/use-symbol-as-uid"),fc=Object;module.exports=hc?function(e){return"symbol"==k(e)}:function(e){var t=uc("Symbol");return lc(t)&&dc(t.prototype,fc(e))};var pc=I(Object.freeze({__proto__:null})),mc=String,vc=function(e){try{return mc(e)}catch(LN){return"Object"}},_c=N,gc=he,yc=pc,Ec=vc,Tc=ec,kc=Y("symbol-to-string-registry");_c({target:"Symbol",stat:!0,forced:!Tc},{keyFor:function(e){if(!yc(e))throw new TypeError(Ec(e)+" is not a symbol");if(gc(kc,e))return kc[e]}});var Sc=require("../internals/export"),bc=require("../internals/get-built-in"),Ic=require("../internals/function-apply"),Ac=require("../internals/function-call"),Rc=require("../internals/function-uncurry-this"),Cc=require("../internals/fails"),wc=require("../internals/is-callable"),Dc=require("../internals/is-symbol"),xc=require("../internals/array-slice"),Oc=require("../internals/get-json-replacer-function"),Nc=require("../internals/symbol-constructor-detection"),Pc=String,Mc=bc("JSON","stringify"),Lc=Rc(/./.exec),Uc=Rc("".charAt),Vc=Rc("".charCodeAt),Fc=Rc("".replace),Bc=Rc(1..toString),qc=/[\uD800-\uDFFF]/g,jc=/^[\uD800-\uDBFF]$/,Hc=/^[\uDC00-\uDFFF]$/,Gc=!Nc||Cc((function(){var e=bc("Symbol")("stringify detection");return"[null]"!==Mc([e])||"{}"!==Mc({a:e})||"{}"!==Mc(Object(e))})),Wc=Cc((function(){return'"\\udf06\\ud834"'!==Mc("\udf06\ud834")||'"\\udead"'!==Mc("\udead")})),zc=function(e,t){var n=xc(arguments),r=Oc(t);if(wc(r)||void 0!==e&&!Dc(e))return n[1]=function(e,t){if(wc(r)&&(t=Ac(r,this,Pc(e),t)),!Dc(t))return t},Ic(Mc,null,n)},Jc=function(e,t,n){var r=Uc(n,t-1),i=Uc(n,t+1);return Lc(jc,e)&&!Lc(Hc,i)||Lc(Hc,e)&&!Lc(jc,r)?"\\u"+Bc(Vc(e,0),16):e};Mc&&Sc({target:"JSON",stat:!0,arity:3,forced:Gc||Wc},{stringify:function(e,t,n){var r=xc(arguments),i=Ic(Gc?zc:Mc,null,r);return Wc&&"string"==typeof i?Fc(i,qc,Jc):i}}),exports.f=Object.getOwnPropertySymbols;var Kc=I(Object.freeze({__proto__:null})),Yc=ue;N({target:"Object",stat:!0,forced:!vn||En((function(){Kc.f(1)}))},{getOwnPropertySymbols:function(e){var t=Kc.f;return t?t(Yc(e)):[]}});var Xc=require("../internals/export"),Qc=require("../internals/array-iteration").every;Xc({target:"Array",proto:!0,forced:!require("../internals/array-method-is-strict")("every")},{every:function(e){return Qc(this,e,arguments.length>1?arguments[1]:void 0)}});var $c=Jr,Zc=Math.max,eu=Math.min,tu=function(e,t){var n=$c(e);return n<0?Zc(n+t,0):eu(n,t)},nu=Jr,ru=Math.min,iu=function(e){var t=nu(e);return t>0?ru(t,9007199254740991):0},au=iu,ou=function(e){return au(e.length)},su=ue,cu=tu,uu=ou;N({target:"Object",stat:!0,sham:!sr},{create:Iu});var lu,du=require("../internals/an-object"),hu=require("../internals/object-define-properties"),fu=require("../internals/enum-bug-keys"),pu=require("../internals/hidden-keys"),mu=require("../internals/html"),vu=require("../internals/document-create-element"),_u=require("../internals/shared-key"),gu="prototype",yu="script",Eu=_u("IE_PROTO"),Tu=function(){},ku=function(e){return"<"+yu+">"+e+"</"+yu+">"},Su=function(e){e.write(ku("")),e.close();var t=e.parentWindow.Object;return e=null,t},bu=function(){try{lu=new ActiveXObject("htmlfile")}catch(LN){}var e,t,n;bu="undefined"!=typeof document?document.domain&&lu?Su(lu):(t=vu("iframe"),n="java"+yu+":",t.style.display="none",mu.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(ku("document.F=Object")),e.close(),e.F):Su(lu);for(var r=fu.length;r--;)delete bu[gu][fu[r]];return bu()};pu[Eu]=!0,module.exports=Object.create||function(e,t){var n;return null!==e?(Tu[gu]=du(e),n=new Tu,Tu[gu]=null,n[Eu]=e):n=bu(),void 0===t?n:hu.f(n,t)};var Iu=I(Object.freeze({__proto__:null})),Au=Wa,Ru=Iu,Cu=br.f,wu=Au("unscopables"),Du=Array.prototype;void 0===Du[wu]&&Cu(Du,wu,{configurable:!0,value:Ru(null)});var xu=function(e){Du[wu][e]=!0},Ou=function(e){for(var t=su(this),n=uu(t),r=arguments.length,i=cu(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,o=void 0===a?n:cu(a,n);o>i;)t[i++]=e;return t},Nu=xu;N({target:"Array",proto:!0},{fill:Ou}),Nu("fill");var Pu=require("../internals/export"),Mu=require("../internals/array-iteration").filter;Pu({target:"Array",proto:!0,forced:!require("../internals/array-method-has-species-support")("filter")},{filter:function(e){return Mu(this,e,arguments.length>1?arguments[1]:void 0)}});var Lu=require("../internals/export"),Uu=require("../internals/array-iteration").find,Vu=require("../internals/add-to-unscopables"),Fu="find",Bu=!0;Fu in[]&&Array(1)[Fu]((function(){Bu=!1})),Lu({target:"Array",proto:!0,forced:Bu},{find:function(e){return Uu(this,e,arguments.length>1?arguments[1]:void 0)}}),Vu(Fu);var qu=require("../internals/export"),ju=require("../internals/array-iteration").findIndex,Hu=require("../internals/add-to-unscopables"),Gu="findIndex",Wu=!0;Gu in[]&&Array(1)[Gu]((function(){Wu=!1})),qu({target:"Array",proto:!0,forced:Wu},{findIndex:function(e){return ju(this,e,arguments.length>1?arguments[1]:void 0)}}),Hu(Gu);var zu=require("../internals/export"),Ju=require("../internals/array-from");zu({target:"Array",stat:!0,forced:!require("../internals/check-correctness-of-iteration")((function(e){Array.from(e)}))},{from:Ju});var Ku=Ri,Yu=Zr,Xu=Wa("match"),Qu=function(e){var t;return Ku(e)&&(void 0!==(t=e[Xu])?!!t:"RegExp"===Yu(e))},$u=TypeError,Zu=function(e){if(Qu(e))throw new $u("The method doesn't accept regular expressions");return e},el=Wa("match"),tl=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[el]=!1,"/./"[e](t)}catch(r){}}return!1},nl=N,rl=Zu,il=oe,al=ui,ol=tl,sl=ne("".indexOf);nl({target:"String",proto:!0,forced:!ol("includes")},{includes:function(e){return!!~sl(al(il(this)),al(rl(e)),arguments.length>1?arguments[1]:void 0)}});var cl=require("../internals/export"),ul=require("../internals/array-includes").includes,ll=require("../internals/fails"),dl=require("../internals/add-to-unscopables");cl({target:"Array",proto:!0,forced:ll((function(){return!Array(1).includes()}))},{includes:function(e){return ul(this,e,arguments.length>1?arguments[1]:void 0)}}),dl("includes");var hl=require("../internals/export"),fl=require("../internals/function-uncurry-this-clause"),pl=require("../internals/array-includes").indexOf,ml=require("../internals/array-method-is-strict"),vl=fl([].indexOf),_l=!!vl&&1/vl([1],1,-0)<0;hl({target:"Array",proto:!0,forced:_l||!ml("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return _l?vl(this,e,t)||0:pl(this,e,t)}});var gl=require("../internals/classof-raw");module.exports=Array.isArray||function(e){return"Array"===gl(e)};var yl=I(Object.freeze({__proto__:null}));N({target:"Array",stat:!0},{isArray:yl});var El=require("../internals/export"),Tl=require("../internals/function-uncurry-this"),kl=require("../internals/indexed-object"),Sl=require("../internals/to-indexed-object"),bl=require("../internals/array-method-is-strict"),Il=Tl([].join);El({target:"Array",proto:!0,forced:kl!==Object||!bl("join",",")},{join:function(e){return Il(Sl(this),void 0===e?",":e)}});var Al=require("../internals/export"),Rl=require("../internals/array-last-index-of");Al({target:"Array",proto:!0,forced:Rl!==[].lastIndexOf},{lastIndexOf:Rl});var Cl=require("../internals/export"),wl=require("../internals/array-iteration").map;Cl({target:"Array",proto:!0,forced:!require("../internals/array-method-has-species-support")("map")},{map:function(e){return wl(this,e,arguments.length>1?arguments[1]:void 0)}});var Dl=Yr,xl=vc,Ol=TypeError,Nl=function(e){if(Dl(e))return e;throw new Ol(xl(e)+" is not a function")},Pl=Nl,Ml=ue,Ll=zn,Ul=ou,Vl=TypeError,Fl="Reduce of empty array with no initial value",Bl=function(e){return function(t,n,r,i){var a=Ml(t),o=Ll(a),s=Ul(a);if(Pl(n),0===s&&r<2)throw new Vl(Fl);var c=e?s-1:0,u=e?-1:1;if(r<2)for(;;){if(c in o){i=o[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw new Vl(Fl)}for(;e?c>=0:s>c;c+=u)c in o&&(i=n(i,o[c],c,a));return i}},ql={left:Bl(!1),right:Bl(!0)},jl=En,Hl=function(e,t){var n=[][e];return!!n&&jl((function(){n.call(null,t||function(){return 1},1)}))},Gl=require("../internals/function-call"),Wl=require("../internals/fix-regexp-well-known-symbol-logic"),zl=require("../internals/an-object"),Jl=require("../internals/is-null-or-undefined"),Kl=require("../internals/to-length"),Yl=require("../internals/to-string"),Xl=require("../internals/require-object-coercible"),Ql=require("../internals/get-method"),$l=require("../internals/advance-string-index"),Zl=require("../internals/regexp-exec-abstract");Wl("match",(function(e,t,n){return[function(t){var n=Xl(this),r=Jl(t)?void 0:Ql(t,e);return r?Gl(r,t,n):new RegExp(t)[e](Yl(n))},function(e){var r=zl(this),i=Yl(e),a=n(t,r,i);if(a.done)return a.value;if(!r.global)return Zl(r,i);var o=r.unicode;r.lastIndex=0;for(var s,c=[],u=0;null!==(s=Zl(r,i));){var l=Yl(s[0]);c[u]=l,""===l&&(r.lastIndex=$l(i,Kl(r.lastIndex),o)),u++}return 0===u?null:c}]}));var ed,td,nd=require("../internals/global-this"),rd=require("../internals/environment-user-agent"),id=nd.process,ad=nd.Deno,od=id&&id.versions||ad&&ad.version,sd=od&&od.v8;sd&&(td=(ed=sd.split("."))[0]>0&&ed[0]<4?1:+(ed[0]+ed[1])),!td&&rd&&(!(ed=rd.match(/Edge\/(\d+)/))||ed[1]>=74)&&(ed=rd.match(/Chrome\/(\d+)/))&&(td=+ed[1]),module.exports=td;var cd=I(Object.freeze({__proto__:null})),ud=require("../internals/function-uncurry-this"),ld=require("../internals/fails"),dd=require("../internals/is-callable"),hd=require("../internals/classof"),fd=require("../internals/get-built-in"),pd=require("../internals/inspect-source"),md=function(){},vd=fd("Reflect","construct"),_d=/^\s*(?:class|function)\b/,gd=ud(_d.exec),yd=!_d.test(md),Ed=function(e){if(!dd(e))return!1;try{return vd(md,[],e),!0}catch(LN){return!1}},Td=function(e){if(!dd(e))return!1;switch(hd(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return yd||!!gd(_d,pd(e))}catch(LN){return!0}};Td.sham=!0,module.exports=!vd||ld((function(){var e;return Ed(Ed.call)||!Ed(Object)||!Ed((function(){e=!0}))||e}))?Td:Ed;var kd=I(Object.freeze({__proto__:null})),Sd=sr,bd=br,Id=Ci,Ad=function(e,t,n){Sd?bd.f(e,t,Id(0,n)):e[t]=n},Rd=En,Cd=cd,wd=Wa("species"),Dd=function(e){return Cd>=51||!Rd((function(){var t=[];return(t.constructor={})[wd]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},xd=require("../internals/function-uncurry-this");module.exports=xd([].slice);var Od=I(Object.freeze({__proto__:null})),Nd=N,Pd=yl,Md=kd,Ld=Ri,Ud=tu,Vd=ou,Fd=Yn,Bd=Ad,qd=Wa,jd=Od,Hd=Dd("slice"),Gd=qd("species"),Wd=Array,zd=Math.max;Nd({target:"Array",proto:!0,forced:!Hd},{slice:function(e,t){var n,r,i,a=Fd(this),o=Vd(a),s=Ud(e,o),c=Ud(void 0===t?o:t,o);if(Pd(a)&&(n=a.constructor,(Md(n)&&(n===Wd||Pd(n.prototype))||Ld(n)&&null===(n=n[Gd]))&&(n=void 0),n===Wd||void 0===n))return jd(a,s,c);for(r=new(void 0===n?Wd:n)(zd(c-s,0)),i=0;s<c;s++,i++)s in a&&Bd(r,i,a[s]);return r.length=i,r}});var Jd=require("../internals/global-this"),Kd=require("../internals/environment-user-agent"),Yd=require("../internals/classof-raw"),Xd=function(e){return Kd.slice(0,e.length)===e};module.exports=Xd("Bun/")?"BUN":Xd("Cloudflare-Workers")?"CLOUDFLARE":Xd("Deno/")?"DENO":Xd("Node.js/")?"NODE":Jd.Bun&&"string"==typeof Bun.version?"BUN":Jd.Deno&&"object"==k(Deno.version)?"DENO":"process"===Yd(Jd.process)?"NODE":Jd.window&&Jd.document?"BROWSER":"REST";var Qd="NODE"===I(Object.freeze({__proto__:null})),$d=ql.left;N({target:"Array",proto:!0,forced:!Qd&&cd>79&&cd<83||!Hl("reduce")},{reduce:function(e){var t=arguments.length;return $d(this,e,t,t>1?arguments[1]:void 0)}});var Zd=ql.right;N({target:"Array",proto:!0,forced:!Qd&&cd>79&&cd<83||!Hl("reduceRight")},{reduceRight:function(e){return Zd(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var eh=require("../internals/export"),th=require("../internals/function-uncurry-this"),nh=require("../internals/is-array"),rh=th([].reverse),ih=[1,2];eh({target:"Array",proto:!0,forced:String(ih)===String(ih.reverse())},{reverse:function(){return nh(this)&&(this.length=this.length),rh(this)}});var ah=require("../internals/export"),oh=require("../internals/array-iteration").some;ah({target:"Array",proto:!0,forced:!require("../internals/array-method-is-strict")("some")},{some:function(e){return oh(this,e,arguments.length>1?arguments[1]:void 0)}});var sh=require("../internals/export"),ch=require("../internals/function-uncurry-this"),uh=require("../internals/a-callable"),lh=require("../internals/to-object"),dh=require("../internals/length-of-array-like"),hh=require("../internals/delete-property-or-throw"),fh=require("../internals/to-string"),ph=require("../internals/fails"),mh=require("../internals/array-sort"),vh=require("../internals/array-method-is-strict"),_h=require("../internals/environment-ff-version"),gh=require("../internals/environment-is-ie-or-edge"),yh=require("../internals/environment-v8-version"),Eh=require("../internals/environment-webkit-version"),Th=[],kh=ch(Th.sort),Sh=ch(Th.push),bh=ph((function(){Th.sort(void 0)})),Ih=ph((function(){Th.sort(null)})),Ah=vh("sort"),Rh=!ph((function(){if(yh)return yh<70;if(!(_h&&_h>3)){if(gh)return!0;if(Eh)return Eh<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)Th.push({k:t+r,v:n})}for(Th.sort((function(e,t){return t.v-e.v})),r=0;r<Th.length;r++)t=Th[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));sh({target:"Array",proto:!0,forced:bh||!Ih||!Ah||!Rh},{sort:function(e){void 0!==e&&uh(e);var t=lh(this);if(Rh)return void 0===e?kh(t):kh(t,e);var n,r,i=[],a=dh(t);for(r=0;r<a;r++)r in t&&Sh(i,t[r]);for(mh(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:fh(t)>fh(n)?1:-1}}(e)),n=dh(i),r=0;r<n;)t[r]=i[r++];for(;r<a;)hh(t,r++);return t}});var Ch=require("../internals/descriptors"),wh=require("../internals/is-array"),Dh=TypeError,xh=Object.getOwnPropertyDescriptor,Oh=Ch&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(LN){return LN instanceof TypeError}}();module.exports=Oh?function(e,t){if(wh(e)&&!xh(e,"length").writable)throw new Dh("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t};var Nh=I(Object.freeze({__proto__:null})),Ph=TypeError,Mh=yl,Lh=kd,Uh=Ri,Vh=Wa("species"),Fh=Array,Bh=function(e){var t;return Mh(e)&&(t=e.constructor,(Lh(t)&&(t===Fh||Mh(t.prototype))||Uh(t)&&null===(t=t[Vh]))&&(t=void 0)),void 0===t?Fh:t},qh=vc,jh=TypeError,Hh=N,Gh=ue,Wh=tu,zh=Jr,Jh=ou,Kh=Nh,Yh=function(e){if(e>9007199254740991)throw Ph("Maximum allowed index exceeded");return e},Xh=function(e,t){return new(Bh(e))(0===t?0:t)},Qh=Ad,$h=function(e,t){if(!delete e[t])throw new jh("Cannot delete property "+qh(t)+" of "+qh(e))},Zh=Dd("splice"),ef=Math.max,tf=Math.min;Hh({target:"Array",proto:!0,forced:!Zh},{splice:function(e,t){var n,r,i,a,o,s,c=Gh(this),u=Jh(c),l=Wh(e,u),d=arguments.length;for(0===d?n=r=0:1===d?(n=0,r=u-l):(n=d-2,r=tf(ef(zh(t),0),u-l)),Yh(u+n-r),i=Xh(c,r),a=0;a<r;a++)(o=l+a)in c&&Qh(i,a,c[o]);if(i.length=r,n<r){for(a=l;a<u-r;a++)s=a+n,(o=a+r)in c?c[s]=c[o]:$h(c,s);for(a=u;a>u-r+n;a--)$h(c,a-1)}else if(n>r)for(a=u-r;a>l;a--)s=a+n-1,(o=a+r-1)in c?c[s]=c[o]:$h(c,s);for(a=0;a<n;a++)c[a+l]=arguments[a+2];return Kh(c,u-r+n),i}});var nf=require("../internals/global-this"),rf=require("../internals/function-uncurry-this"),af=require("../internals/descriptors"),of=require("../internals/array-buffer-basic-detection"),sf=require("../internals/function-name"),cf=require("../internals/create-non-enumerable-property"),uf=require("../internals/define-built-in-accessor"),lf=require("../internals/define-built-ins"),df=require("../internals/fails"),hf=require("../internals/an-instance"),ff=require("../internals/to-integer-or-infinity"),pf=require("../internals/to-length"),mf=require("../internals/to-index"),vf=require("../internals/math-fround"),_f=require("../internals/ieee754"),gf=require("../internals/object-get-prototype-of"),yf=require("../internals/object-set-prototype-of"),Ef=require("../internals/array-fill"),Tf=require("../internals/array-slice"),kf=require("../internals/inherit-if-required"),Sf=require("../internals/copy-constructor-properties"),bf=require("../internals/set-to-string-tag"),If=require("../internals/internal-state"),Af=sf.PROPER,Rf=sf.CONFIGURABLE,Cf="ArrayBuffer",wf="DataView",Df="prototype",xf="Wrong index",Of=If.getterFor(Cf),Nf=If.getterFor(wf),Pf=If.set,Mf=nf[Cf],Lf=Mf,Uf=Lf&&Lf[Df],Vf=nf[wf],Ff=Vf&&Vf[Df],Bf=Object.prototype,qf=nf.Array,jf=nf.RangeError,Hf=rf(Ef),Gf=rf([].reverse),Wf=_f.pack,zf=_f.unpack,Jf=function(e){return[255&e]},Kf=function(e){return[255&e,e>>8&255]},Yf=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Xf=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Qf=function(e){return Wf(vf(e),23,4)},$f=function(e){return Wf(e,52,8)},Zf=function(e,t,n){uf(e[Df],t,{configurable:!0,get:function(){return n(this)[t]}})},ep=function(e,t,n,r){var i=Nf(e),a=mf(n),o=!!r;if(a+t>i.byteLength)throw new jf(xf);var s=i.bytes,c=a+i.byteOffset,u=Tf(s,c,c+t);return o?u:Gf(u)},tp=function(e,t,n,r,i,a){var o=Nf(e),s=mf(n),c=r(+i),u=!!a;if(s+t>o.byteLength)throw new jf(xf);for(var l=o.bytes,d=s+o.byteOffset,h=0;h<t;h++)l[d+h]=c[u?h:t-h-1]};if(of){var np=Af&&Mf.name!==Cf;df((function(){Mf(1)}))&&df((function(){new Mf(-1)}))&&!df((function(){return new Mf,new Mf(1.5),new Mf(NaN),1!==Mf.length||np&&!Rf}))?np&&Rf&&cf(Mf,"name",Cf):((Lf=function(e){return hf(this,Uf),kf(new Mf(mf(e)),this,Lf)})[Df]=Uf,Uf.constructor=Lf,Sf(Lf,Mf)),yf&&gf(Ff)!==Bf&&yf(Ff,Bf);var rp=new Vf(new Lf(2)),ip=rf(Ff.setInt8);rp.setInt8(0,2147483648),rp.setInt8(1,2147483649),!rp.getInt8(0)&&rp.getInt8(1)||lf(Ff,{setInt8:function(e,t){ip(this,e,t<<24>>24)},setUint8:function(e,t){ip(this,e,t<<24>>24)}},{unsafe:!0})}else Uf=(Lf=function(e){hf(this,Uf);var t=mf(e);Pf(this,{type:Cf,bytes:Hf(qf(t),0),byteLength:t}),af||(this.byteLength=t,this.detached=!1)})[Df],Ff=(Vf=function(e,t,n){hf(this,Ff),hf(e,Uf);var r=Of(e),i=r.byteLength,a=ff(t);if(a<0||a>i)throw new jf("Wrong offset");if(a+(n=void 0===n?i-a:pf(n))>i)throw new jf("Wrong length");Pf(this,{type:wf,buffer:e,byteLength:n,byteOffset:a,bytes:r.bytes}),af||(this.buffer=e,this.byteLength=n,this.byteOffset=a)})[Df],af&&(Zf(Lf,"byteLength",Of),Zf(Vf,"buffer",Nf),Zf(Vf,"byteLength",Nf),Zf(Vf,"byteOffset",Nf)),lf(Ff,{getInt8:function(e){return ep(this,1,e)[0]<<24>>24},getUint8:function(e){return ep(this,1,e)[0]},getInt16:function(e){var t=ep(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ep(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return Xf(ep(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return Xf(ep(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return zf(ep(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return zf(ep(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){tp(this,1,e,Jf,t)},setUint8:function(e,t){tp(this,1,e,Jf,t)},setInt16:function(e,t){tp(this,2,e,Kf,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){tp(this,2,e,Kf,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){tp(this,4,e,Yf,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){tp(this,4,e,Yf,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){tp(this,4,e,Qf,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){tp(this,8,e,$f,t,arguments.length>2&&arguments[2])}});bf(Lf,Cf),bf(Vf,wf),module.exports={ArrayBuffer:Lf,DataView:Vf};var ap=I(Object.freeze({__proto__:null})),op=require("../internals/function-uncurry-this"),sp=require("../internals/fails"),cp=require("../internals/is-callable"),up=require("../internals/has-own-property"),lp=require("../internals/descriptors"),dp=require("../internals/function-name").CONFIGURABLE,hp=require("../internals/inspect-source"),fp=require("../internals/internal-state"),pp=fp.enforce,mp=fp.get,vp=String,_p=Object.defineProperty,gp=op("".slice),yp=op("".replace),Ep=op([].join),Tp=lp&&!sp((function(){return 8!==_p((function(){}),"length",{value:8}).length})),kp=String(String).split("String"),Sp=module.exports=function(e,t,n){"Symbol("===gp(vp(t),0,7)&&(t="["+yp(vp(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!up(e,"name")||dp&&e.name!==t)&&(lp?_p(e,"name",{value:t,configurable:!0}):e.name=t),Tp&&n&&up(n,"arity")&&e.length!==n.arity&&_p(e,"length",{value:n.arity});try{n&&up(n,"constructor")&&n.constructor?lp&&_p(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(LN){}var r=pp(e);return up(r,"source")||(r.source=Ep(kp,"string"==typeof t?t:"")),e};Function.prototype.toString=Sp((function(){return cp(this)&&mp(this).source||hp(this)}),"toString");var bp=I(Object.freeze({__proto__:null})),Ip=br,Ap=function(e,t,n){return n.get&&bp(n.get,t,{getter:!0}),n.set&&bp(n.set,t,{setter:!0}),Ip.f(e,t,n)},Rp=Zs,Cp=Ap,wp=sr,Dp=Wa("species"),xp=function(e){var t=Rp(e);wp&&t&&!t[Dp]&&Cp(t,Dp,{configurable:!0,get:function(){return this}})},Op=N,Np=L,Pp=xp,Mp="ArrayBuffer",Lp=ap[Mp];Op({global:!0,constructor:!0,forced:Np[Mp]!==Lp},{ArrayBuffer:Lp}),Pp(Mp);var Up=require("../internals/export"),Vp=require("../internals/function-uncurry-this-clause"),Fp=require("../internals/fails"),Bp=require("../internals/array-buffer"),qp=require("../internals/an-object"),jp=require("../internals/to-absolute-index"),Hp=require("../internals/to-length"),Gp=require("../internals/species-constructor"),Wp=Bp.ArrayBuffer,zp=Bp.DataView,Jp=zp.prototype,Kp=Vp(Wp.prototype.slice),Yp=Vp(Jp.getUint8),Xp=Vp(Jp.setUint8);Up({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:Fp((function(){return!new Wp(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(Kp&&void 0===t)return Kp(qp(this),e);for(var n=qp(this).byteLength,r=jp(e,n),i=jp(void 0===t?n:t,n),a=new(Gp(this,Wp))(Hp(i-r)),o=new zp(this),s=new zp(a),c=0;r<i;)Xp(s,c++,Yp(o,r++));return a}}),module.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView;var Qp=I(Object.freeze({__proto__:null}));N({global:!0,constructor:!0,forced:!Qp},{DataView:ap.DataView});var $p=require("../internals/export"),Zp=require("../internals/function-uncurry-this"),em=Date,tm=Zp(em.prototype.getTime);$p({target:"Date",stat:!0},{now:function(){return tm(new em)}});var nm=require("../internals/export"),rm=require("../internals/date-to-iso-string");nm({target:"Date",proto:!0,forced:Date.prototype.toISOString!==rm},{toISOString:rm});var im=require("../internals/export"),am=require("../internals/fails"),om=require("../internals/to-object"),sm=require("../internals/to-primitive");im({target:"Date",proto:!0,arity:1,forced:am((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}))},{toJSON:function(e){var t=om(this),n=sm(t,"number");return"number"!=typeof n||isFinite(n)?t.toISOString():null}});var cm=require("../internals/export"),um=require("../internals/global-this"),lm=require("../internals/function-uncurry-this"),dm=require("../internals/is-forced"),hm=require("../internals/define-built-in"),fm=require("../internals/internal-metadata"),pm=require("../internals/iterate"),mm=require("../internals/an-instance"),vm=require("../internals/is-callable"),_m=require("../internals/is-null-or-undefined"),gm=require("../internals/is-object"),ym=require("../internals/fails"),Em=require("../internals/check-correctness-of-iteration"),Tm=require("../internals/set-to-string-tag"),km=require("../internals/inherit-if-required");module.exports=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),a=r?"set":"add",o=um[e],s=o&&o.prototype,c=o,u={},l=function(e){var t=lm(s[e]);hm(s,e,"add"===e?function(e){return t(this,0===e?0:e),this}:"delete"===e?function(e){return!(i&&!gm(e))&&t(this,0===e?0:e)}:"get"===e?function(e){return i&&!gm(e)?void 0:t(this,0===e?0:e)}:"has"===e?function(e){return!(i&&!gm(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(dm(e,!vm(o)||!(i||s.forEach&&!ym((function(){(new o).entries().next()})))))c=n.getConstructor(t,e,r,a),fm.enable();else if(dm(e,!0)){var d=new c,h=d[a](i?{}:-0,1)!==d,f=ym((function(){d.has(1)})),p=Em((function(e){new o(e)})),m=!i&&ym((function(){for(var e=new o,t=5;t--;)e[a](t,t);return!e.has(-0)}));p||((c=t((function(e,t){mm(e,s);var n=km(new o,e,c);return _m(t)||pm(t,n[a],{that:n,AS_ENTRIES:r}),n}))).prototype=s,s.constructor=c),(f||m)&&(l("delete"),l("has"),r&&l("get")),(m||h)&&l(a),i&&s.clear&&delete s.clear}return u[e]=c,cm({global:!0,constructor:!0,forced:c!==o},u),Tm(c,e),i||n.setStrong(c,e,r),c};var Sm=I(Object.freeze({__proto__:null})),bm=$a,Im=require("../internals/function-uncurry-this-clause"),Am=require("../internals/a-callable"),Rm=require("../internals/function-bind-native"),Cm=Im(Im.bind);module.exports=function(e,t){return Am(e),void 0===t?e:Rm?Cm(e,t):function(){return e.apply(t,arguments)}};var wm=I(Object.freeze({__proto__:null})),Dm=ne({}.isPrototypeOf),xm=Dm,Om=TypeError,Nm=function(e,t){if(xm(t,e))return e;throw new Om("Incorrect invocation")},Pm=require("../internals/function-bind-context"),Mm=require("../internals/function-call"),Lm=require("../internals/an-object"),Um=require("../internals/try-to-string"),Vm=require("../internals/is-array-iterator-method"),Fm=require("../internals/length-of-array-like"),Bm=require("../internals/object-is-prototype-of"),qm=require("../internals/get-iterator"),jm=require("../internals/get-iterator-method"),Hm=require("../internals/iterator-close"),Gm=TypeError,Wm=function(e,t){this.stopped=e,this.result=t},zm=Wm.prototype;module.exports=function(e,t,n){var r,i,a,o,s,c,u,l=n&&n.that,d=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_RECORD),f=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),m=Pm(t,l),v=function(e){return r&&Hm(r,"normal",e),new Wm(!0,e)},_=function(e){return d?(Lm(e),p?m(e[0],e[1],v):m(e[0],e[1])):p?m(e,v):m(e)};if(h)r=e.iterator;else if(f)r=e;else{if(!(i=jm(e)))throw new Gm(Um(e)+" is not iterable");if(Vm(i)){for(a=0,o=Fm(e);o>a;a++)if((s=_(e[a]))&&Bm(zm,s))return s;return new Wm(!1)}r=qm(e,i)}for(c=h?e.next:r.next;!(u=Mm(c,r)).done;){try{s=_(u.value)}catch(LN){Hm(r,"throw",LN)}if("object"==k(s)&&s&&Bm(zm,s))return s}return new Wm(!1)};var Jm=I(Object.freeze({__proto__:null})),Km=require("../internals/export"),Ym=require("../internals/function-uncurry-this"),Xm=require("../internals/hidden-keys"),Qm=require("../internals/is-object"),$m=require("../internals/has-own-property"),Zm=require("../internals/object-define-property").f,ev=require("../internals/object-get-own-property-names"),tv=require("../internals/object-get-own-property-names-external"),nv=require("../internals/object-is-extensible"),rv=require("../internals/uid"),iv=require("../internals/freezing"),av=!1,ov=rv("meta"),sv=0,cv=function(e){Zm(e,ov,{value:{objectID:"O"+sv++,weakData:{}}})},uv=module.exports={enable:function(){uv.enable=function(){},av=!0;var e=ev.f,t=Ym([].splice),n={};n[ov]=1,e(n).length&&(ev.f=function(n){for(var r=e(n),i=0,a=r.length;i<a;i++)if(r[i]===ov){t(r,i,1);break}return r},Km({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:tv.f}))},fastKey:function(e,t){if(!Qm(e))return"symbol"==k(e)?e:("string"==typeof e?"S":"P")+e;if(!$m(e,ov)){if(!nv(e))return"F";if(!t)return"E";cv(e)}return e[ov].objectID},getWeakData:function(e,t){if(!$m(e,ov)){if(!nv(e))return!0;if(!t)return!1;cv(e)}return e[ov].weakData},onFreeze:function(e){return iv&&av&&nv(e)&&!$m(e,ov)&&cv(e),e}};Xm[ov]=!0;var lv=Iu,dv=Ap,hv=function(e,t,n){for(var r in t)bm(e,r,t[r],n);return e},fv=wm,pv=Nm,mv=re,vv=Jm,_v=Aa,gv=Ra,yv=xp,Ev=sr,Tv=I(Object.freeze({__proto__:null})).fastKey,kv=zi.set,Sv=zi.getterFor,bv={getConstructor:function(e,t,n,r){var i=e((function(e,i){pv(e,a),kv(e,{type:t,index:lv(null),first:null,last:null,size:0}),Ev||(e.size=0),mv(i)||vv(i,e[r],{that:e,AS_ENTRIES:n})})),a=i.prototype,o=Sv(t),s=function(e,t,n){var r,i,a=o(e),s=c(e,t);return s?s.value=n:(a.last=s={index:i=Tv(t,!0),key:t,value:n,previous:r=a.last,next:null,removed:!1},a.first||(a.first=s),r&&(r.next=s),Ev?a.size++:e.size++,"F"!==i&&(a.index[i]=s)),e},c=function(e,t){var n,r=o(e),i=Tv(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key===t)return n};return hv(a,{clear:function(){for(var e=o(this),t=e.first;t;)t.removed=!0,t.previous&&(t.previous=t.previous.next=null),t=t.next;e.first=e.last=null,e.index=lv(null),Ev?e.size=0:this.size=0},delete:function(e){var t=this,n=o(t),r=c(t,e);if(r){var i=r.next,a=r.previous;delete n.index[r.index],r.removed=!0,a&&(a.next=i),i&&(i.previous=a),n.first===r&&(n.first=i),n.last===r&&(n.last=a),Ev?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=o(this),r=fv(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),hv(a,n?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),Ev&&dv(a,"size",{configurable:!0,get:function(){return o(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=Sv(t),a=Sv(r);_v(e,t,(function(e,t){kv(this,{type:r,target:e,state:i(e),kind:t,last:null})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?gv("keys"===t?n.key:"values"===t?n.value:[n.key,n.value],!1):(e.target=null,gv(void 0,!0))}),n?"entries":"values",!n,!0),yv(t)}};Sm("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),bv);var Iv=require("../internals/math-float-round");module.exports=Math.fround||function(e){return Iv(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},N({target:"Math",stat:!0},{fround:I(Object.freeze({__proto__:null}))});var Av=Math.log,Rv=Math.LOG10E;module.exports=Math.log10||function(e){return Av(e)*Rv},N({target:"Math",stat:!0},{log10:I(Object.freeze({__proto__:null}))}),module.exports=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},N({target:"Math",stat:!0},{sign:I(Object.freeze({__proto__:null}))});var Cv=require("../internals/export"),wv=require("../internals/number-parse-int");Cv({global:!0,forced:parseInt!==wv},{parseInt:wv});var Dv=require("../internals/export"),xv=require("../internals/string-trim").trim;Dv({target:"String",proto:!0,forced:require("../internals/string-trim-forced")("trim")},{trim:function(){return xv(this)}});var Ov=require("../internals/export"),Nv=require("../internals/is-pure"),Pv=require("../internals/descriptors"),Mv=require("../internals/global-this"),Lv=require("../internals/path"),Uv=require("../internals/function-uncurry-this"),Vv=require("../internals/is-forced"),Fv=require("../internals/has-own-property"),Bv=require("../internals/inherit-if-required"),qv=require("../internals/object-is-prototype-of"),jv=require("../internals/is-symbol"),Hv=require("../internals/to-primitive"),Gv=require("../internals/fails"),Wv=require("../internals/object-get-own-property-names").f,zv=require("../internals/object-get-own-property-descriptor").f,Jv=require("../internals/object-define-property").f,Kv=require("../internals/this-number-value"),Yv=require("../internals/string-trim").trim,Xv="Number",Qv=Mv[Xv],$v=Lv[Xv],Zv=Qv.prototype,e_=Mv.TypeError,t_=Uv("".slice),n_=Uv("".charCodeAt),r_=function(e){var t,n,r,i,a,o,s,c,u=Hv(e,"number");if(jv(u))throw new e_("Cannot convert a Symbol value to a number");if("string"==typeof u&&u.length>2)if(u=Yv(u),43===(t=n_(u,0))||45===t){if(88===(n=n_(u,2))||120===n)return NaN}else if(48===t){switch(n_(u,1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+u}for(o=(a=t_(u,2)).length,s=0;s<o;s++)if((c=n_(a,s))<48||c>i)return NaN;return parseInt(a,r)}return+u},i_=Vv(Xv,!Qv(" 0o1")||!Qv("0b1")||Qv("+0x1")),a_=function(e){var t,n=arguments.length<1?0:Qv(function(e){var t=Hv(e,"number");return"bigint"==typeof t?t:r_(t)}(e));return qv(Zv,t=this)&&Gv((function(){Kv(t)}))?Bv(Object(n),this,a_):n};a_.prototype=Zv,i_&&!Nv&&(Zv.constructor=a_),Ov({global:!0,constructor:!0,wrap:!0,forced:i_},{Number:a_});var o_=function(e,t){for(var n,r=Pv?Wv(t):"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(","),i=0;r.length>i;i++)Fv(t,n=r[i])&&!Fv(e,n)&&Jv(e,n,zv(t,n))};Nv&&$v&&o_(Lv[Xv],$v),(i_||Nv)&&o_(Lv[Xv],Qv);var s_=require("../internals/is-object"),c_=Math.floor;module.exports=Number.isInteger||function(e){return!s_(e)&&isFinite(e)&&c_(e)===e},N({target:"Number",stat:!0},{isInteger:I(Object.freeze({__proto__:null}))}),N({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var u_=require("../internals/export"),l_=require("../internals/function-uncurry-this"),d_=require("../internals/to-integer-or-infinity"),h_=require("../internals/this-number-value"),f_=require("../internals/string-repeat"),p_=require("../internals/fails"),m_=RangeError,v_=String,__=Math.floor,g_=l_(f_),y_=l_("".slice),E_=l_(1..toFixed),T_=function(e,t,n){return 0===t?n:t%2==1?T_(e,t-1,n*e):T_(e*e,t/2,n)},k_=function(e,t,n){for(var r=-1,i=n;++r<6;)i+=t*e[r],e[r]=i%1e7,i=__(i/1e7)},S_=function(e,t){for(var n=6,r=0;--n>=0;)r+=e[n],e[n]=__(r/t),r=r%t*1e7},b_=function(e){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==e[t]){var r=v_(e[t]);n=""===n?r:n+g_("0",7-r.length)+r}return n};u_({target:"Number",proto:!0,forced:p_((function(){return"0.000"!==E_(8e-5,3)||"1"!==E_(.9,0)||"1.25"!==E_(1.255,2)||"1000000000000000128"!==E_(0xde0b6b3a7640080,0)}))||!p_((function(){E_({})}))},{toFixed:function(e){var t,n,r,i,a=h_(this),o=d_(e),s=[0,0,0,0,0,0],c="",u="0";if(o<0||o>20)throw new m_("Incorrect fraction digits");if(a!=a)return"NaN";if(a<=-1e21||a>=1e21)return v_(a);if(a<0&&(c="-",a=-a),a>1e-21)if(n=(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(a*T_(2,69,1))-69)<0?a*T_(2,-t,1):a/T_(2,t,1),n*=4503599627370496,(t=52-t)>0){for(k_(s,0,n),r=o;r>=7;)k_(s,1e7,0),r-=7;for(k_(s,T_(10,r,1),0),r=t-1;r>=23;)S_(s,1<<23),r-=23;S_(s,1<<r),k_(s,1,1),S_(s,2),u=b_(s)}else k_(s,0,n),k_(s,1<<-t,0),u=b_(s)+g_("0",o);return u=o>0?c+((i=u.length)<=o?"0."+g_("0",o-i)+u:y_(u,0,i-o)+"."+y_(u,i-o)):c+u}});var I_=require("../internals/export"),A_=require("../internals/object-assign");I_({target:"Object",stat:!0,arity:2,forced:Object.assign!==A_},{assign:A_});var R_=require("../internals/export"),C_=require("../internals/descriptors"),w_=require("../internals/object-define-properties").f;R_({target:"Object",stat:!0,forced:Object.defineProperties!==w_,sham:!C_},{defineProperties:w_});var D_=require("../internals/export"),x_=require("../internals/freezing"),O_=require("../internals/fails"),N_=require("../internals/is-object"),P_=require("../internals/internal-metadata").onFreeze,M_=Object.freeze;D_({target:"Object",stat:!0,forced:O_((function(){M_(1)})),sham:!x_},{freeze:function(e){return M_&&N_(e)?M_(P_(e)):e}});var L_=require("../internals/get-built-in"),U_=require("../internals/function-uncurry-this"),V_=require("../internals/object-get-own-property-names"),F_=require("../internals/object-get-own-property-symbols"),B_=require("../internals/an-object"),q_=U_([].concat);module.exports=L_("Reflect","ownKeys")||function(e){var t=V_.f(B_(e)),n=F_.f;return n?q_(t,n(e)):t};var j_=I(Object.freeze({__proto__:null})),H_=j_,G_=Yn,W_=ar,z_=Ad;N({target:"Object",stat:!0,sham:!sr},{getOwnPropertyDescriptors:function(e){for(var t,n,r=G_(e),i=W_.f,a=H_(r),o={},s=0;a.length>s;)void 0!==(n=i(r,t=a[s++]))&&z_(o,t,n);return o}});var J_=require("../internals/export"),K_=require("../internals/fails"),Y_=require("../internals/object-get-own-property-names-external").f;J_({target:"Object",stat:!0,forced:K_((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:Y_});var X_=require("../internals/has-own-property"),Q_=require("../internals/is-callable"),$_=require("../internals/to-object"),Z_=require("../internals/shared-key"),eg=require("../internals/correct-prototype-getter"),tg=Z_("IE_PROTO"),ng=Object,rg=ng.prototype;module.exports=eg?ng.getPrototypeOf:function(e){var t=$_(e);if(X_(t,tg))return t[tg];var n=t.constructor;return Q_(n)&&t instanceof n?n.prototype:t instanceof ng?rg:null};var ig=I(Object.freeze({__proto__:null})),ag=require("../internals/fails");module.exports=!ag((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}));var og=ue,sg=ig,cg=I(Object.freeze({__proto__:null}));N({target:"Object",stat:!0,forced:En((function(){sg(1)})),sham:!cg},{getPrototypeOf:function(e){return sg(og(e))}});var ug=require("../internals/object-keys-internal"),lg=require("../internals/enum-bug-keys");module.exports=Object.keys||function(e){return ug(e,lg)};var dg=ue,hg=I(Object.freeze({__proto__:null}));N({target:"Object",stat:!0,forced:En((function(){hg(1)}))},{keys:function(e){return hg(dg(e))}});var fg=require("../internals/function-uncurry-this-accessor"),pg=require("../internals/is-object"),mg=require("../internals/require-object-coercible"),vg=require("../internals/a-possible-prototype");module.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=fg(Object.prototype,"__proto__","set"))(n,[]),t=n instanceof Array}catch(LN){}return function(n,r){return mg(n),vg(r),pg(n)?(t?e(n,r):n.__proto__=r,n):n}}():void 0);var _g=I(Object.freeze({__proto__:null}));N({target:"Object",stat:!0},{setPrototypeOf:_g});var gg=require("../internals/export"),yg=require("../internals/object-to-array").values;gg({target:"Object",stat:!0},{values:function(e){return yg(e)}});var Eg=require("../internals/export"),Tg=require("../internals/number-parse-float");Eg({global:!0,forced:parseFloat!==Tg},{parseFloat:Tg});var kg=require("../internals/function-bind-native"),Sg=Function.prototype.call;module.exports=kg?Sg.bind(Sg):function(){return Sg.apply(Sg,arguments)};var bg=I(Object.freeze({__proto__:null})),Ig=br.f,Ag=he,Rg=Wa("toStringTag"),Cg=Ri,wg=String,Dg=TypeError,xg=function(e){if(Cg(e))return e;throw new Dg(wg(e)+" is not an object")},Og=kd,Ng=vc,Pg=TypeError,Mg=function(e){if(Og(e))return e;throw new Pg(Ng(e)+" is not a constructor")},Lg=xg,Ug=Mg,Vg=re,Fg=Wa("species"),Bg=function(e,t){var n,r=Lg(e).constructor;return void 0===r||Vg(n=Lg(r)[Fg])?t:Ug(n)},qg=require("../internals/global-this"),jg=require("../internals/function-apply"),Hg=require("../internals/is-callable"),Gg=require("../internals/environment"),Wg=require("../internals/environment-user-agent"),zg=require("../internals/array-slice"),Jg=require("../internals/validate-arguments-length"),Kg=qg.Function,Yg=/MSIE .\./.test(Wg)||"BUN"===Gg&&function(){var e=qg.Bun.version.split(".");return e.length<3||"0"===e[0]&&(e[1]<3||"3"===e[1]&&"0"===e[2])}();module.exports=function(e,t){var n=t?2:1;return Yg?function(r,i){var a=Jg(arguments.length,1)>n,o=Hg(r)?r:Kg(r),s=a?zg(arguments,n):[],c=a?function(){jg(o,this,s)}:o;return t?e(c,i):e(c)}:e};var Xg=I(Object.freeze({__proto__:null})),Qg=N,$g=L,Zg=Xg($g.setInterval,!0);Qg({global:!0,bind:!0,forced:$g.setInterval!==Zg},{setInterval:Zg});var ey=N,ty=L,ny=Xg(ty.setTimeout,!0);ey({global:!0,bind:!0,forced:ty.setTimeout!==ny},{setTimeout:ny});var ry,iy,ay,oy,sy=require("../internals/global-this"),cy=require("../internals/function-apply"),uy=require("../internals/function-bind-context"),ly=require("../internals/is-callable"),dy=require("../internals/has-own-property"),hy=require("../internals/fails"),fy=require("../internals/html"),py=require("../internals/array-slice"),my=require("../internals/document-create-element"),vy=require("../internals/validate-arguments-length"),_y=require("../internals/environment-is-ios"),gy=require("../internals/environment-is-node"),yy=sy.setImmediate,Ey=sy.clearImmediate,Ty=sy.process,ky=sy.Dispatch,Sy=sy.Function,by=sy.MessageChannel,Iy=sy.String,Ay=0,Ry={},Cy="onreadystatechange";hy((function(){ry=sy.location}));var wy=function(e){if(dy(Ry,e)){var t=Ry[e];delete Ry[e],t()}},Dy=function(e){return function(){wy(e)}},xy=function(e){wy(e.data)},Oy=function(e){sy.postMessage(Iy(e),ry.protocol+"//"+ry.host)};yy&&Ey||(yy=function(e){vy(arguments.length,1);var t=ly(e)?e:Sy(e),n=py(arguments,1);return Ry[++Ay]=function(){cy(t,void 0,n)},iy(Ay),Ay},Ey=function(e){delete Ry[e]},gy?iy=function(e){Ty.nextTick(Dy(e))}:ky&&ky.now?iy=function(e){ky.now(Dy(e))}:by&&!_y?(oy=(ay=new by).port2,ay.port1.onmessage=xy,iy=uy(oy.postMessage,oy)):sy.addEventListener&&ly(sy.postMessage)&&!sy.importScripts&&ry&&"file:"!==ry.protocol&&!hy(Oy)?(iy=Oy,sy.addEventListener("message",xy,!1)):iy=Cy in my("script")?function(e){fy.appendChild(my("script"))[Cy]=function(){fy.removeChild(this),wy(e)}}:function(e){setTimeout(Dy(e),0)}),module.exports={set:yy,clear:Ey};var Ny=I(Object.freeze({__proto__:null})),Py=require("../internals/global-this"),My=require("../internals/descriptors"),Ly=Object.getOwnPropertyDescriptor;module.exports=function(e){if(!My)return Py[e];var t=Ly(Py,e);return t&&t.value};var Uy=I(Object.freeze({__proto__:null})),Vy=function(){this.head=null,this.tail=null};Vy.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var Fy=Vy,By=require("../internals/environment-user-agent");module.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(By);var qy=I(Object.freeze({__proto__:null})),jy=require("../internals/environment-user-agent");module.exports=/ipad|iphone|ipod/i.test(jy)&&"undefined"!=typeof Pebble;var Hy=I(Object.freeze({__proto__:null})),Gy=require("../internals/environment-user-agent");module.exports=/web0s(?!.*chrome)/i.test(Gy);var Wy,zy,Jy,Ky,Yy,Xy=I(Object.freeze({__proto__:null})),Qy=L,$y=Uy,Zy=wm,eE=Ny.set,tE=Fy,nE=qy,rE=Hy,iE=Xy,aE=Qd,oE=Qy.MutationObserver||Qy.WebKitMutationObserver,sE=Qy.document,cE=Qy.process,uE=Qy.Promise,lE=$y("queueMicrotask");if(!lE){var dE=new tE,hE=function(){var e,t;for(aE&&(e=cE.domain)&&e.exit();t=dE.get();)try{t()}catch(LN){throw dE.head&&Wy(),LN}e&&e.enter()};nE||aE||iE||!oE||!sE?!rE&&uE&&uE.resolve?((Ky=uE.resolve(void 0)).constructor=uE,Yy=Zy(Ky.then,Ky),Wy=function(){Yy(hE)}):aE?Wy=function(){cE.nextTick(hE)}:(eE=Zy(eE,Qy),Wy=function(){eE(hE)}):(zy=!0,Jy=sE.createTextNode(""),new oE(hE).observe(Jy,{characterData:!0}),Wy=function(){Jy.data=zy=!zy}),lE=function(e){dE.head||Wy(),dE.add(e)}}var fE=lE,pE=function(e){try{return{error:!1,value:e()}}catch(LN){return{error:!0,value:LN}}},mE=L.Promise,vE=require("../internals/export"),_E=require("../internals/is-pure"),gE=require("../internals/promise-native-constructor"),yE=require("../internals/fails"),EE=require("../internals/get-built-in"),TE=require("../internals/is-callable"),kE=require("../internals/species-constructor"),SE=require("../internals/promise-resolve"),bE=require("../internals/define-built-in"),IE=gE&&gE.prototype;if(vE({target:"Promise",proto:!0,real:!0,forced:!!gE&&yE((function(){IE.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=kE(this,EE("Promise")),n=TE(e);return this.then(n?function(n){return SE(t,e()).then((function(){return n}))}:e,n?function(n){return SE(t,e()).then((function(){throw n}))}:e)}}),!_E&&TE(gE)){var AE=EE("Promise").prototype.finally;IE.finally!==AE&&bE(IE,"finally",AE,{unsafe:!0})}var RE=require("../internals/global-this"),CE=require("../internals/promise-native-constructor"),wE=require("../internals/is-callable"),DE=require("../internals/is-forced"),xE=require("../internals/inspect-source"),OE=require("../internals/well-known-symbol"),NE=require("../internals/environment"),PE=require("../internals/is-pure"),ME=require("../internals/environment-v8-version"),LE=CE&&CE.prototype,UE=OE("species"),VE=!1,FE=wE(RE.PromiseRejectionEvent),BE=DE("Promise",(function(){var e=xE(CE),t=e!==String(CE);if(!t&&66===ME)return!0;if(PE&&(!LE.catch||!LE.finally))return!0;if(!ME||ME<51||!/native code/.test(e)){var n=new CE((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[UE]=r,!(VE=n.then((function(){}))instanceof r))return!0}return!(t||"BROWSER"!==NE&&"DENO"!==NE||FE)}));module.exports={CONSTRUCTOR:BE,REJECTION_EVENT:FE,SUBCLASSING:VE};var qE=I(Object.freeze({__proto__:null})),jE={},HE=Nl,GE=TypeError,WE=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw new GE("Bad Promise constructor");t=e,n=r})),this.resolve=HE(t),this.reject=HE(n)};jE.f=function(e){return new WE(e)};var zE,JE,KE,YE=N,XE=Qd,QE=L,$E=bg,ZE=$a,eT=_g,tT=function(e,t,n){e&&!n&&(e=e.prototype),e&&!Ag(e,Rg)&&Ig(e,Rg,{configurable:!0,value:t})},nT=xp,rT=Nl,iT=Yr,aT=Ri,oT=Nm,sT=Bg,cT=Ny.set,uT=fE,lT=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(LN){}},dT=pE,hT=Fy,fT=zi,pT=mE,mT=qE,vT=jE,_T="Promise",gT=mT.CONSTRUCTOR,yT=mT.REJECTION_EVENT,ET=mT.SUBCLASSING,TT=fT.getterFor(_T),kT=fT.set,ST=pT&&pT.prototype,bT=pT,IT=ST,AT=QE.TypeError,RT=QE.document,CT=QE.process,wT=vT.f,DT=wT,xT=!!(RT&&RT.createEvent&&QE.dispatchEvent),OT="unhandledrejection",NT=function(e){var t;return!(!aT(e)||!iT(t=e.then))&&t},PT=function(e,t){var n,r,i,a=t.value,o=1===t.state,s=o?e.ok:e.fail,c=e.resolve,u=e.reject,l=e.domain;try{s?(o||(2===t.rejection&&FT(t),t.rejection=1),!0===s?n=a:(l&&l.enter(),n=s(a),l&&(l.exit(),i=!0)),n===e.promise?u(new AT("Promise-chain cycle")):(r=NT(n))?$E(r,n,c,u):c(n)):u(a)}catch(LN){l&&!i&&l.exit(),u(LN)}},MT=function(e,t){e.notified||(e.notified=!0,uT((function(){for(var n,r=e.reactions;n=r.get();)PT(n,e);e.notified=!1,t&&!e.rejection&&UT(e)})))},LT=function(e,t,n){var r,i;xT?((r=RT.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),QE.dispatchEvent(r)):r={promise:t,reason:n},!yT&&(i=QE["on"+e])?i(r):e===OT&&lT("Unhandled promise rejection",n)},UT=function(e){$E(cT,QE,(function(){var t,n=e.facade,r=e.value;if(VT(e)&&(t=dT((function(){XE?CT.emit("unhandledRejection",r,n):LT(OT,n,r)})),e.rejection=XE||VT(e)?2:1,t.error))throw t.value}))},VT=function(e){return 1!==e.rejection&&!e.parent},FT=function(e){$E(cT,QE,(function(){var t=e.facade;XE?CT.emit("rejectionHandled",t):LT("rejectionhandled",t,e.value)}))},BT=function(e,t,n){return function(r){e(t,r,n)}},qT=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,MT(e,!0))},jT=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new AT("Promise can't be resolved itself");var r=NT(t);r?uT((function(){var n={done:!1};try{$E(r,t,BT(jT,n,e),BT(qT,n,e))}catch(LN){qT(n,LN,e)}})):(e.value=t,e.state=1,MT(e,!1))}catch(LN){qT({done:!1},LN,e)}}};if(gT&&(IT=(bT=function(e){oT(this,IT),rT(e),$E(zE,this);var t=TT(this);try{e(BT(jT,t),BT(qT,t))}catch(LN){qT(t,LN)}}).prototype,(zE=function(e){kT(this,{type:_T,done:!1,notified:!1,parent:!1,reactions:new hT,rejection:!1,state:0,value:null})}).prototype=ZE(IT,"then",(function(e,t){var n=TT(this),r=wT(sT(this,bT));return n.parent=!0,r.ok=!iT(e)||e,r.fail=iT(t)&&t,r.domain=XE?CT.domain:void 0,0===n.state?n.reactions.add(r):uT((function(){PT(r,n)})),r.promise})),JE=function(){var e=new zE,t=TT(e);this.promise=e,this.resolve=BT(jT,t),this.reject=BT(qT,t)},vT.f=wT=function(e){return e===bT||void 0===e?new JE(e):DT(e)},iT(pT)&&ST!==Object.prototype)){KE=ST.then,ET||ZE(ST,"then",(function(e,t){var n=this;return new bT((function(e,t){$E(KE,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete ST.constructor}catch(LN){}eT&&eT(ST,IT)}YE({global:!0,constructor:!0,wrap:!0,forced:gT},{Promise:bT}),tT(bT,_T,!1),nT(_T);var HT=require("../internals/well-known-symbol")("iterator"),GT=!1;try{var WT=0,zT={next:function(){return{done:!!WT++}},return:function(){GT=!0}};zT[HT]=function(){return this},Array.from(zT,(function(){throw 2}))}catch(LN){}module.exports=function(e,t){try{if(!t&&!GT)return!1}catch(LN){return!1}var n=!1;try{var r={};r[HT]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(LN){}return n};var JT=I(Object.freeze({__proto__:null})),KT=mE,YT=JT,XT=qE.CONSTRUCTOR||!YT((function(e){KT.all(e).then(void 0,(function(){}))})),QT=bg,$T=Nl,ZT=jE,ek=pE,tk=Jm;N({target:"Promise",stat:!0,forced:XT},{all:function(e){var t=this,n=ZT.f(t),r=n.resolve,i=n.reject,a=ek((function(){var n=$T(t.resolve),a=[],o=0,s=1;tk(e,(function(e){var c=o++,u=!1;s++,QT(n,t,e).then((function(e){u||(u=!0,a[c]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise}});var nk=N,rk=qE.CONSTRUCTOR,ik=mE,ak=Zs,ok=Yr,sk=$a,ck=ik&&ik.prototype;if(nk({target:"Promise",proto:!0,forced:rk,real:!0},{catch:function(e){return this.then(void 0,e)}}),ok(ik)){var uk=ak("Promise").prototype.catch;ck.catch!==uk&&sk(ck,"catch",uk,{unsafe:!0})}var lk=bg,dk=Nl,hk=jE,fk=pE,pk=Jm;N({target:"Promise",stat:!0,forced:XT},{race:function(e){var t=this,n=hk.f(t),r=n.reject,i=fk((function(){var i=dk(t.resolve);pk(e,(function(e){lk(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var mk=jE;N({target:"Promise",stat:!0,forced:qE.CONSTRUCTOR},{reject:function(e){var t=mk.f(this);return(0,t.reject)(e),t.promise}});var vk=xg,_k=Ri,gk=jE,yk=N,Ek=Zs,Tk=qE.CONSTRUCTOR,kk=function(e,t){if(vk(e),_k(t)&&t.constructor===e)return t;var n=gk.f(e);return(0,n.resolve)(t),n.promise};Ek("Promise"),yk({target:"Promise",stat:!0,forced:Tk},{resolve:function(e){return kk(this,e)}});var Sk=require("../internals/export"),bk=require("../internals/function-apply"),Ik=require("../internals/a-callable"),Ak=require("../internals/an-object");Sk({target:"Reflect",stat:!0,forced:!require("../internals/fails")((function(){Reflect.apply((function(){}))}))},{apply:function(e,t,n){return bk(Ik(e),t,Ak(n))}});var Rk=he,Ck=bg,wk=Ri,Dk=xg,xk=function(e){return void 0!==e&&(Rk(e,"value")||Rk(e,"writable"))},Ok=ar,Nk=ig;N({target:"Reflect",stat:!0},{get:function e(t,n){var r,i,a=arguments.length<3?t:arguments[2];return Dk(t)===a?t[n]:(r=Ok.f(t,n))?xk(r)?r.value:void 0===r.get?void 0:Ck(r.get,a):wk(i=Nk(t))?e(i,n,a):void 0}}),N({target:"Reflect",stat:!0},{ownKeys:j_});var Pk=require("../internals/global-this"),Mk=require("../internals/descriptors"),Lk=require("../internals/define-built-in-accessor"),Uk=require("../internals/regexp-flags"),Vk=require("../internals/fails"),Fk=Pk.RegExp,Bk=Fk.prototype,qk=Mk&&Vk((function(){var e=!0;try{Fk(".","d")}catch(LN){e=!1}var t={},n="",r=e?"dgimsy":"gimsy",i=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},a={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var o in e&&(a.hasIndices="d"),a)i(o,a[o]);return Object.getOwnPropertyDescriptor(Bk,"flags").get.call(t)!==r||n!==r}));qk&&Lk(Bk,"flags",{configurable:!0,get:Uk}),Sm("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),bv);var jk,Hk=Zr,Gk=ne,Wk=function(e){if("Function"===Hk(e))return Gk(e)},zk=N,Jk=Wk,Kk=ar.f,Yk=iu,Xk=ui,Qk=Zu,$k=oe,Zk=tl,eS=Jk("".slice),tS=Math.min,nS=Zk("endsWith");zk({target:"String",proto:!0,forced:!(!nS&&(jk=Kk(String.prototype,"endsWith"),jk&&!jk.writable)||nS)},{endsWith:function(e){var t=Xk($k(this));Qk(e);var n=arguments.length>1?arguments[1]:void 0,r=t.length,i=void 0===n?r:tS(Yk(n),r),a=Xk(e);return eS(t,i-a.length,i)===a}});var rS=require("../internals/export"),iS=require("../internals/function-uncurry-this"),aS=require("../internals/to-absolute-index"),oS=RangeError,sS=String.fromCharCode,cS=String.fromCodePoint,uS=iS([].join);rS({target:"String",stat:!0,arity:1,forced:!!cS&&1!==cS.length},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,i=0;r>i;){if(t=+arguments[i++],aS(t,1114111)!==t)throw new oS(t+" is not a valid code point");n[i]=t<65536?sS(t):sS(55296+((t-=65536)>>10),t%1024+56320)}return uS(n,"")}});var lS=Jr,dS=ui,hS=oe,fS=RangeError,pS=ne,mS=iu,vS=ui,_S=oe,gS=pS((function(e){var t=dS(hS(this)),n="",r=lS(e);if(r<0||Infinity===r)throw new fS("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n})),yS=pS("".slice),ES=Math.ceil,TS=function(e){return function(t,n,r){var i,a,o=vS(_S(t)),s=mS(n),c=o.length,u=void 0===r?" ":vS(r);return s<=c||""===u?o:((a=gS(u,ES((i=s-c)/u.length))).length>i&&(a=yS(a,0,i)),e?o+a:a+o)}},kS={start:TS(!1),end:TS(!0)},SS=require("../internals/environment-user-agent");module.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(SS);var bS=kS.start;N({target:"String",proto:!0,forced:I(Object.freeze({__proto__:null}))},{padStart:function(e){return bS(this,e,arguments.length>1?arguments[1]:void 0)}});var IS=require("../internals/function-call"),AS=require("../internals/fix-regexp-well-known-symbol-logic"),RS=require("../internals/an-object"),CS=require("../internals/is-null-or-undefined"),wS=require("../internals/require-object-coercible"),DS=require("../internals/same-value"),xS=require("../internals/to-string"),OS=require("../internals/get-method"),NS=require("../internals/regexp-exec-abstract");AS("search",(function(e,t,n){return[function(t){var n=wS(this),r=CS(t)?void 0:OS(t,e);return r?IS(r,t,n):new RegExp(t)[e](xS(n))},function(e){var r=RS(this),i=xS(e),a=n(t,r,i);if(a.done)return a.value;var o=r.lastIndex;DS(o,0)||(r.lastIndex=0);var s=NS(r,i);return DS(r.lastIndex,o)||(r.lastIndex=o),null===s?-1:s.index}]}));var PS=N,MS=Wk,LS=ar.f,US=iu,VS=ui,FS=Zu,BS=oe,qS=tl,jS=MS("".slice),HS=Math.min,GS=qS("startsWith"),WS=!GS&&!!function(){var e=LS(String.prototype,"startsWith");return e&&!e.writable}();PS({target:"String",proto:!0,forced:!WS&&!GS},{startsWith:function(e){var t=VS(BS(this));FS(e);var n=US(HS(arguments.length>1?arguments[1]:void 0,t.length)),r=VS(e);return jS(t,n,n+r.length)===r}});var zS=require("../internals/function-uncurry-this"),JS=require("../internals/require-object-coercible"),KS=require("../internals/to-string"),YS=/"/g,XS=zS("".replace);module.exports=function(e,t,n,r){var i=KS(JS(e)),a="<"+t;return""!==n&&(a+=" "+n+'="'+XS(KS(r),YS,"&quot;")+'"'),a+">"+i+"</"+t+">"};var QS=I(Object.freeze({__proto__:null})),$S=En,ZS=function(e){return $S((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))},eb=QS;N({target:"String",proto:!0,forced:ZS("link")},{link:function(e){return eb(this,"a","href",e)}});var tb=QS;N({target:"String",proto:!0,forced:ZS("small")},{small:function(){return tb(this,"small","","")}});var nb=require("../internals/export"),rb=require("../internals/global-this"),ib=require("../internals/function-call"),ab=require("../internals/descriptors"),ob=require("../internals/typed-array-constructors-require-wrappers"),sb=require("../internals/array-buffer-view-core"),cb=require("../internals/array-buffer"),ub=require("../internals/an-instance"),lb=require("../internals/create-property-descriptor"),db=require("../internals/create-non-enumerable-property"),hb=require("../internals/is-integral-number"),fb=require("../internals/to-length"),pb=require("../internals/to-index"),mb=require("../internals/to-offset"),vb=require("../internals/to-uint8-clamped"),_b=require("../internals/to-property-key"),gb=require("../internals/has-own-property"),yb=require("../internals/classof"),Eb=require("../internals/is-object"),Tb=require("../internals/is-symbol"),kb=require("../internals/object-create"),Sb=require("../internals/object-is-prototype-of"),bb=require("../internals/object-set-prototype-of"),Ib=require("../internals/object-get-own-property-names").f,Ab=require("../internals/typed-array-from"),Rb=require("../internals/array-iteration").forEach,Cb=require("../internals/set-species"),wb=require("../internals/define-built-in-accessor"),Db=require("../internals/object-define-property"),xb=require("../internals/object-get-own-property-descriptor"),Ob=require("../internals/array-from-constructor-and-list"),Nb=require("../internals/internal-state"),Pb=require("../internals/inherit-if-required"),Mb=Nb.get,Lb=Nb.set,Ub=Nb.enforce,Vb=Db.f,Fb=xb.f,Bb=rb.RangeError,qb=cb.ArrayBuffer,jb=qb.prototype,Hb=cb.DataView,Gb=sb.NATIVE_ARRAY_BUFFER_VIEWS,Wb=sb.TYPED_ARRAY_TAG,zb=sb.TypedArray,Jb=sb.TypedArrayPrototype,Kb=sb.isTypedArray,Yb="BYTES_PER_ELEMENT",Xb="Wrong length",Qb=function(e,t){wb(e,t,{configurable:!0,get:function(){return Mb(this)[t]}})},$b=function(e){var t;return Sb(jb,e)||"ArrayBuffer"===(t=yb(e))||"SharedArrayBuffer"===t},Zb=function(e,t){return Kb(e)&&!Tb(t)&&t in e&&hb(+t)&&t>=0},eI=function(e,t){return t=_b(t),Zb(e,t)?lb(2,e[t]):Fb(e,t)},tI=function(e,t,n){return t=_b(t),!(Zb(e,t)&&Eb(n)&&gb(n,"value"))||gb(n,"get")||gb(n,"set")||n.configurable||gb(n,"writable")&&!n.writable||gb(n,"enumerable")&&!n.enumerable?Vb(e,t,n):(e[t]=n.value,e)};ab?(Gb||(xb.f=eI,Db.f=tI,Qb(Jb,"buffer"),Qb(Jb,"byteOffset"),Qb(Jb,"byteLength"),Qb(Jb,"length")),nb({target:"Object",stat:!0,forced:!Gb},{getOwnPropertyDescriptor:eI,defineProperty:tI}),module.exports=function(e,t,n){var r=e.match(/\d+/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=rb[i],c=s,u=c&&c.prototype,l={},d=function(e,t){Vb(e,t,{get:function(){return function(e,t){var n=Mb(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=Mb(e);a.view[o](t*r+a.byteOffset,n?vb(i):i,!0)}(this,t,e)},enumerable:!0})};Gb?ob&&(c=t((function(e,t,n,i){return ub(e,u),Pb(Eb(t)?$b(t)?void 0!==i?new s(t,mb(n,r),i):void 0!==n?new s(t,mb(n,r)):new s(t):Kb(t)?Ob(c,t):ib(Ab,c,t):new s(pb(t)),e,c)})),bb&&bb(c,zb),Rb(Ib(s),(function(e){e in c||db(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,n,i){ub(e,u);var a,o,s,l=0,h=0;if(Eb(t)){if(!$b(t))return Kb(t)?Ob(c,t):ib(Ab,c,t);a=t,h=mb(n,r);var f=t.byteLength;if(void 0===i){if(f%r)throw new Bb(Xb);if((o=f-h)<0)throw new Bb(Xb)}else if((o=fb(i)*r)+h>f)throw new Bb(Xb);s=o/r}else s=pb(t),a=new qb(o=s*r);for(Lb(e,{buffer:a,byteOffset:h,byteLength:o,length:s,view:new Hb(a)});l<s;)d(e,l++)})),bb&&bb(c,zb),u=c.prototype=kb(Jb)),u.constructor!==c&&db(u,"constructor",c),Ub(u).TypedArrayConstructor=c,Wb&&db(u,Wb,i);var h=c!==s;l[i]=c,nb({global:!0,constructor:!0,forced:h,sham:!Gb},l),Yb in c||db(c,Yb,r),Yb in u||db(u,Yb,r),Cb(i)}):module.exports=function(){};var nI=I(Object.freeze({__proto__:null}));nI("Float32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),nI("Int8",(function(e){return function(t,n,r){return e(this,t,n,r)}})),nI("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}})),nI("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}),!0);var rI,iI,aI,oI=Qp,sI=sr,cI=L,uI=Yr,lI=Ri,dI=he,hI=oi,fI=vc,pI=xi,mI=$a,vI=Ap,_I=Dm,gI=ig,yI=_g,EI=Wa,TI=hn,kI=zi.enforce,SI=zi.get,bI=cI.Int8Array,II=bI&&bI.prototype,AI=cI.Uint8ClampedArray,RI=AI&&AI.prototype,CI=bI&&gI(bI),wI=II&&gI(II),DI=Object.prototype,xI=cI.TypeError,OI=EI("toStringTag"),NI=TI("TYPED_ARRAY_TAG"),PI="TypedArrayConstructor",MI=oI&&!!yI&&"Opera"!==hI(cI.opera),LI=!1,UI={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},VI={BigInt64Array:8,BigUint64Array:8},FI=function(e){var t=gI(e);if(lI(t)){var n=SI(t);return n&&dI(n,PI)?n[PI]:FI(t)}},BI=function(e){if(!lI(e))return!1;var t=hI(e);return dI(UI,t)||dI(VI,t)};for(rI in UI)(aI=(iI=cI[rI])&&iI.prototype)?kI(aI)[PI]=iI:MI=!1;for(rI in VI)(aI=(iI=cI[rI])&&iI.prototype)&&(kI(aI)[PI]=iI);if((!MI||!uI(CI)||CI===Function.prototype)&&(CI=function(){throw new xI("Incorrect invocation")},MI))for(rI in UI)cI[rI]&&yI(cI[rI],CI);if((!MI||!wI||wI===DI)&&(wI=CI.prototype,MI))for(rI in UI)cI[rI]&&yI(cI[rI].prototype,wI);if(MI&&gI(RI)!==wI&&yI(RI,wI),sI&&!dI(wI,OI))for(rI in LI=!0,vI(wI,OI,{configurable:!0,get:function(){return lI(this)?this[NI]:void 0}}),UI)cI[rI]&&pI(cI[rI],NI,rI);var qI={NATIVE_ARRAY_BUFFER_VIEWS:MI,TYPED_ARRAY_TAG:LI&&NI,aTypedArray:function(e){if(BI(e))return e;throw new xI("Target is not a typed array")},aTypedArrayConstructor:function(e){if(uI(e)&&(!yI||_I(CI,e)))return e;throw new xI(fI(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(sI){if(n)for(var i in UI){var a=cI[i];if(a&&dI(a.prototype,e))try{delete a.prototype[e]}catch(LN){try{a.prototype[e]=t}catch(o){}}}wI[e]&&!n||mI(wI,e,n?t:MI&&II[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(sI){if(yI){if(n)for(r in UI)if((i=cI[r])&&dI(i,e))try{delete i[e]}catch(LN){}if(CI[e]&&!n)return;try{return mI(CI,e,n?t:MI&&CI[e]||t)}catch(LN){}}for(r in UI)!(i=cI[r])||i[e]&&!n||mI(i,e,t)}},getTypedArrayConstructor:FI,isView:function(e){if(!lI(e))return!1;var t=hI(e);return"DataView"===t||dI(UI,t)||dI(VI,t)},isTypedArray:BI,TypedArray:CI,TypedArrayPrototype:wI},jI=xu;N({target:"Array",proto:!0},{copyWithin:KI}),jI("copyWithin");var HI=require("../internals/to-object"),GI=require("../internals/to-absolute-index"),WI=require("../internals/length-of-array-like"),zI=require("../internals/delete-property-or-throw"),JI=Math.min;module.exports=[].copyWithin||function(e,t){var n=HI(this),r=WI(n),i=GI(e,r),a=GI(t,r),o=arguments.length>2?arguments[2]:void 0,s=JI((void 0===o?r:GI(o,r))-a,r-i),c=1;for(a<i&&i<a+s&&(c=-1,a+=s-1,i+=s-1);s-- >0;)a in n?n[i]=n[a]:zI(n,i),i+=c,a+=c;return n};var KI=I(Object.freeze({__proto__:null})),YI=qI,XI=ne(KI),QI=YI.aTypedArray;(0,YI.exportTypedArrayMethod)("copyWithin",(function(e,t){return XI(QI(this),e,t,arguments.length>2?arguments[2]:void 0)}));var $I=require("../internals/array-buffer-view-core"),ZI=require("../internals/array-iteration").every,eA=$I.aTypedArray;(0,$I.exportTypedArrayMethod)("every",(function(e){return ZI(eA(this),e,arguments.length>1?arguments[1]:void 0)}));var tA=require("../internals/array-buffer-view-core"),nA=require("../internals/array-iteration").filter,rA=require("../internals/typed-array-from-species-and-list"),iA=tA.aTypedArray;(0,tA.exportTypedArrayMethod)("filter",(function(e){var t=nA(iA(this),e,arguments.length>1?arguments[1]:void 0);return rA(this,t)}));var aA=require("../internals/array-buffer-view-core"),oA=require("../internals/array-iteration").find,sA=aA.aTypedArray;(0,aA.exportTypedArrayMethod)("find",(function(e){return oA(sA(this),e,arguments.length>1?arguments[1]:void 0)}));var cA=require("../internals/array-buffer-view-core"),uA=require("../internals/array-iteration").findIndex,lA=cA.aTypedArray;(0,cA.exportTypedArrayMethod)("findIndex",(function(e){return uA(lA(this),e,arguments.length>1?arguments[1]:void 0)}));var dA=require("../internals/array-buffer-view-core"),hA=require("../internals/array-iteration").forEach,fA=dA.aTypedArray;(0,dA.exportTypedArrayMethod)("forEach",(function(e){hA(fA(this),e,arguments.length>1?arguments[1]:void 0)}));var pA=require("../internals/array-buffer-view-core"),mA=require("../internals/array-includes").includes,vA=pA.aTypedArray;(0,pA.exportTypedArrayMethod)("includes",(function(e){return mA(vA(this),e,arguments.length>1?arguments[1]:void 0)}));var _A=require("../internals/array-buffer-view-core"),gA=require("../internals/array-includes").indexOf,yA=_A.aTypedArray;(0,_A.exportTypedArrayMethod)("indexOf",(function(e){return gA(yA(this),e,arguments.length>1?arguments[1]:void 0)}));var EA=require("../internals/global-this"),TA=require("../internals/fails"),kA=require("../internals/function-uncurry-this"),SA=require("../internals/array-buffer-view-core"),bA=require("../modules/es.array.iterator"),IA=require("../internals/well-known-symbol")("iterator"),AA=EA.Uint8Array,RA=kA(bA.values),CA=kA(bA.keys),wA=kA(bA.entries),DA=SA.aTypedArray,xA=SA.exportTypedArrayMethod,OA=AA&&AA.prototype,NA=!TA((function(){OA[IA].call([1])})),PA=!!OA&&OA.values&&OA[IA]===OA.values&&"values"===OA.values.name,MA=function(){return RA(DA(this))};xA("entries",(function(){return wA(DA(this))}),NA),xA("keys",(function(){return CA(DA(this))}),NA),xA("values",MA,NA||!PA,{name:"values"}),xA(IA,MA,NA||!PA,{name:"values"});var LA=require("../internals/array-buffer-view-core"),UA=require("../internals/function-uncurry-this"),VA=LA.aTypedArray,FA=LA.exportTypedArrayMethod,BA=UA([].join);FA("join",(function(e){return BA(VA(this),e)}));var qA=require("../internals/function-bind-native"),jA=Function.prototype,HA=jA.apply,GA=jA.call;module.exports="object"==("undefined"==typeof Reflect?"undefined":k(Reflect))&&Reflect.apply||(qA?GA.bind(HA):function(){return GA.apply(HA,arguments)});var WA=I(Object.freeze({__proto__:null})),zA=require("../internals/function-apply"),JA=require("../internals/to-indexed-object"),KA=require("../internals/to-integer-or-infinity"),YA=require("../internals/length-of-array-like"),XA=require("../internals/array-method-is-strict"),QA=Math.min,$A=[].lastIndexOf,ZA=!!$A&&1/[1].lastIndexOf(1,-0)<0,eR=XA("lastIndexOf"),tR=ZA||!eR;module.exports=tR?function(e){if(ZA)return zA($A,this,arguments)||0;var t=JA(this),n=YA(t);if(0===n)return-1;var r=n-1;for(arguments.length>1&&(r=QA(r,KA(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:$A;var nR=WA,rR=I(Object.freeze({__proto__:null})),iR=qI.aTypedArray;(0,qI.exportTypedArrayMethod)("lastIndexOf",(function(e){var t=arguments.length;return nR(rR,iR(this),t>1?[e,arguments[1]]:[e])}));var aR=require("../internals/array-buffer-view-core"),oR=require("../internals/array-iteration").map,sR=require("../internals/typed-array-species-constructor"),cR=aR.aTypedArray;(0,aR.exportTypedArrayMethod)("map",(function(e){return oR(cR(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(sR(e))(t)}))}));var uR=ql.left,lR=qI.aTypedArray;(0,qI.exportTypedArrayMethod)("reduce",(function(e){var t=arguments.length;return uR(lR(this),e,t,t>1?arguments[1]:void 0)}));var dR=ql.right,hR=qI.aTypedArray;(0,qI.exportTypedArrayMethod)("reduceRight",(function(e){var t=arguments.length;return dR(hR(this),e,t,t>1?arguments[1]:void 0)}));var fR=qI.aTypedArray,pR=qI.exportTypedArrayMethod,mR=Math.floor;pR("reverse",(function(){for(var e,t=this,n=fR(t).length,r=mR(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var vR=require("../internals/array-buffer-view-core"),_R=require("../internals/array-iteration").some,gR=vR.aTypedArray;(0,vR.exportTypedArrayMethod)("some",(function(e){return _R(gR(this),e,arguments.length>1?arguments[1]:void 0)}));var yR=require("../internals/global-this"),ER=require("../internals/function-uncurry-this-clause"),TR=require("../internals/fails"),kR=require("../internals/a-callable"),SR=require("../internals/array-sort"),bR=require("../internals/array-buffer-view-core"),IR=require("../internals/environment-ff-version"),AR=require("../internals/environment-is-ie-or-edge"),RR=require("../internals/environment-v8-version"),CR=require("../internals/environment-webkit-version"),wR=bR.aTypedArray,DR=bR.exportTypedArrayMethod,xR=yR.Uint16Array,OR=xR&&ER(xR.prototype.sort),NR=!(!OR||TR((function(){OR(new xR(2),null)}))&&TR((function(){OR(new xR(2),{})}))),PR=!!OR&&!TR((function(){if(RR)return RR<74;if(IR)return IR<67;if(AR)return!0;if(CR)return CR<602;var e,t,n=new xR(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(OR(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));DR("sort",(function(e){return void 0!==e&&kR(e),PR?OR(this,e):SR(wR(this),function(e){return function(t,n){return void 0!==e?+e(t,n)||0:n!=n?-1:t!=t?1:0===t&&0===n?1/t>0&&1/n<0?1:-1:t>n}}(e))}),!PR||NR);var MR=Bg,LR=qI.aTypedArrayConstructor,UR=qI.getTypedArrayConstructor,VR=iu,FR=tu,BR=function(e){return LR(MR(e,UR(e)))},qR=qI.aTypedArray;(0,qI.exportTypedArrayMethod)("subarray",(function(e,t){var n=qR(this),r=n.length,i=FR(e,r);return new(BR(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,VR((void 0===t?r:FR(t,r))-i))}));var jR=WA,HR=qI,GR=En,WR=Od,zR=L.Int8Array,JR=HR.aTypedArray,KR=HR.exportTypedArrayMethod,YR=[].toLocaleString,XR=!!zR&&GR((function(){YR.call(new zR(1))}));KR("toLocaleString",(function(){return jR(YR,XR?WR(JR(this)):JR(this),WR(arguments))}),GR((function(){return[1,2].toLocaleString()!==new zR([1,2]).toLocaleString()}))||!GR((function(){zR.prototype.toLocaleString.call([1,2])})));var QR=require("../internals/array-buffer-view-core").exportTypedArrayMethod,$R=require("../internals/fails"),ZR=require("../internals/global-this"),eC=require("../internals/function-uncurry-this"),tC=ZR.Uint8Array,nC=tC&&tC.prototype||{},rC=[].toString,iC=eC([].join);$R((function(){rC.call({})}))&&(rC=function(){return iC(this)});var aC=nC.toString!==rC;QR("toString",rC,aC);var oC=require("../internals/array-buffer-view-core"),sC=require("../internals/typed-array-species-constructor"),cC=require("../internals/fails"),uC=require("../internals/array-slice"),lC=oC.aTypedArray;(0,oC.exportTypedArrayMethod)("slice",(function(e,t){for(var n=uC(lC(this),e,t),r=sC(this),i=0,a=n.length,o=new r(a);a>i;)o[i]=n[i++];return o}),cC((function(){new Int8Array(1).slice()})));var dC=require("../internals/global-this"),hC=require("../internals/function-call"),fC=require("../internals/array-buffer-view-core"),pC=require("../internals/length-of-array-like"),mC=require("../internals/to-offset"),vC=require("../internals/to-object"),_C=require("../internals/fails"),gC=dC.RangeError,yC=dC.Int8Array,EC=yC&&yC.prototype,TC=EC&&EC.set,kC=fC.aTypedArray,SC=fC.exportTypedArrayMethod,bC=!_C((function(){var e=new Uint8ClampedArray(2);return hC(TC,e,{length:1,0:3},1),3!==e[1]})),IC=bC&&fC.NATIVE_ARRAY_BUFFER_VIEWS&&_C((function(){var e=new yC(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));SC("set",(function(e){kC(this);var t=mC(arguments.length>1?arguments[1]:void 0,1),n=vC(e);if(bC)return hC(TC,this,n,t);var r=this.length,i=pC(n),a=0;if(i+t>r)throw new gC("Wrong length");for(;a<i;)this[t+a]=n[a++]}),!bC||IC);var AC=require("../internals/array-buffer-view-core"),RC=require("../internals/array-fill"),CC=require("../internals/to-big-int"),wC=require("../internals/classof"),DC=require("../internals/function-call"),xC=require("../internals/function-uncurry-this"),OC=require("../internals/fails"),NC=AC.aTypedArray,PC=AC.exportTypedArrayMethod,MC=xC("".slice);PC("fill",(function(e){var t=arguments.length;NC(this);var n="Big"===MC(wC(this),0,3)?CC(e):+e;return DC(RC,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),OC((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var LC=L,UC=En,VC=JT,FC=qI.NATIVE_ARRAY_BUFFER_VIEWS,BC=LC.ArrayBuffer,qC=LC.Int8Array,jC=!FC||!UC((function(){qC(1)}))||!UC((function(){new qC(-1)}))||!VC((function(e){new qC,new qC(null),new qC(1.5),new qC(e)}),!0)||UC((function(){return 1!==new qC(new BC(2),1,void 0).length})),HC=Nl,GC=re,WC=function(e,t){var n=e[t];return GC(n)?void 0:HC(n)},zC={},JC=oi,KC=WC,YC=re,XC=zC,QC=Wa("iterator"),$C=function(e){if(!YC(e))return KC(e,QC)||KC(e,"@@iterator")||XC[JC(e)]},ZC=bg,ew=Nl,tw=xg,nw=vc,rw=$C,iw=TypeError,aw=zC,ow=Wa("iterator"),sw=Array.prototype,cw=oi,uw=require("../internals/function-call"),lw=require("../internals/is-callable"),dw=require("../internals/is-object"),hw=TypeError;module.exports=function(e,t){var n,r;if("string"===t&&lw(n=e.toString)&&!dw(r=uw(n,e)))return r;if(lw(n=e.valueOf)&&!dw(r=uw(n,e)))return r;if("string"!==t&&lw(n=e.toString)&&!dw(r=uw(n,e)))return r;throw new hw("Can't convert object to primitive value")};var fw=bg,pw=Ri,mw=pc,vw=WC,_w=I(Object.freeze({__proto__:null})),gw=TypeError,yw=Wa("toPrimitive"),Ew=function(e,t){if(!pw(e)||mw(e))return e;var n,r=vw(e,yw);if(r){if(void 0===t&&(t="default"),n=fw(r,e,t),!pw(n)||mw(n))return n;throw new gw("Can't convert object to primitive value")}return void 0===t&&(t="number"),_w(e,t)},Tw=TypeError,kw=wm,Sw=bg,bw=Mg,Iw=ue,Aw=ou,Rw=function(e,t){var n=arguments.length<2?rw(e):t;if(ew(n))return tw(ZC(n,e));throw new iw(nw(e)+" is not iterable")},Cw=$C,ww=function(e){return void 0!==e&&(aw.Array===e||sw[ow]===e)},Dw=function(e){var t=cw(e);return"BigInt64Array"===t||"BigUint64Array"===t},xw=qI.aTypedArrayConstructor,Ow=function(e){var t=Ew(e,"number");if("number"==typeof t)throw new Tw("Can't convert number to bigint");return BigInt(t)},Nw=function(e){var t,n,r,i,a,o,s,c,u=bw(this),l=Iw(e),d=arguments.length,h=d>1?arguments[1]:void 0,f=void 0!==h,p=Cw(l);if(p&&!ww(p))for(c=(s=Rw(l,p)).next,l=[];!(o=Sw(c,s)).done;)l.push(o.value);for(f&&d>2&&(h=kw(h,arguments[2])),n=Aw(l),r=new(xw(u))(n),i=Dw(r),t=0;n>t;t++)a=f?h(l[t],t):l[t],r[t]=i?Ow(a):+a;return r};(0,qI.exportTypedArrayStaticMethod)("from",Nw,jC);var Pw=require("../internals/export"),Mw=require("../internals/object-is-extensible");Pw({target:"Object",stat:!0,forced:Object.isExtensible!==Mw},{isExtensible:Mw});var Lw=require("../internals/export"),Uw=require("../internals/fails"),Vw=require("../internals/is-object"),Fw=require("../internals/classof-raw"),Bw=require("../internals/array-buffer-non-extensible"),qw=Object.isFrozen;Lw({target:"Object",stat:!0,forced:Bw||Uw((function(){}))},{isFrozen:function(e){return!Vw(e)||!(!Bw||"ArrayBuffer"!==Fw(e))||!!qw&&qw(e)}});var jw=require("../internals/export"),Hw=require("../internals/fails"),Gw=require("../internals/is-object"),Ww=require("../internals/classof-raw"),zw=require("../internals/array-buffer-non-extensible"),Jw=Object.isSealed;jw({target:"Object",stat:!0,forced:zw||Hw((function(){}))},{isSealed:function(e){return!Gw(e)||!(!zw||"ArrayBuffer"!==Ww(e))||!!Jw&&Jw(e)}});var Kw=require("../internals/export"),Yw=require("../internals/is-object"),Xw=require("../internals/internal-metadata").onFreeze,Qw=require("../internals/freezing"),$w=require("../internals/fails"),Zw=Object.seal;Kw({target:"Object",stat:!0,forced:$w((function(){Zw(1)})),sham:!Qw},{seal:function(e){return Zw&&Yw(e)?Zw(Xw(e)):e}});var eD,tD=require("../internals/freezing"),nD=require("../internals/global-this"),rD=require("../internals/function-uncurry-this"),iD=require("../internals/define-built-ins"),aD=require("../internals/internal-metadata"),oD=require("../internals/collection"),sD=require("../internals/collection-weak"),cD=require("../internals/is-object"),uD=require("../internals/internal-state").enforce,lD=require("../internals/fails"),dD=require("../internals/weak-map-basic-detection"),hD=Object,fD=Array.isArray,pD=hD.isExtensible,mD=hD.isFrozen,vD=hD.isSealed,_D=hD.freeze,gD=hD.seal,yD=!nD.ActiveXObject&&"ActiveXObject"in nD,ED=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},TD=oD("WeakMap",ED,sD),kD=TD.prototype,SD=rD(kD.set);if(dD)if(yD){eD=sD.getConstructor(ED,"WeakMap",!0),aD.enable();var bD=rD(kD.delete),ID=rD(kD.has),AD=rD(kD.get);iD(kD,{delete:function(e){if(cD(e)&&!pD(e)){var t=uD(this);return t.frozen||(t.frozen=new eD),bD(this,e)||t.frozen.delete(e)}return bD(this,e)},has:function(e){if(cD(e)&&!pD(e)){var t=uD(this);return t.frozen||(t.frozen=new eD),ID(this,e)||t.frozen.has(e)}return ID(this,e)},get:function(e){if(cD(e)&&!pD(e)){var t=uD(this);return t.frozen||(t.frozen=new eD),ID(this,e)?AD(this,e):t.frozen.get(e)}return AD(this,e)},set:function(e,t){if(cD(e)&&!pD(e)){var n=uD(this);n.frozen||(n.frozen=new eD),ID(this,e)?SD(this,e,t):n.frozen.set(e,t)}else SD(this,e,t);return this}})}else tD&&lD((function(){var e=_D([]);return SD(new TD,e,1),!mD(e)}))&&iD(kD,{set:function(e,t){var n;return fD(e)&&(mD(e)?n=_D:vD(e)&&(n=gD)),SD(this,e,t),n&&n(e),this}});require("../modules/es.string.iterator");var RD,CD=require("../internals/export"),wD=require("../internals/descriptors"),DD=require("../internals/url-constructor-detection"),xD=require("../internals/global-this"),OD=require("../internals/function-bind-context"),ND=require("../internals/function-uncurry-this"),PD=require("../internals/define-built-in"),MD=require("../internals/define-built-in-accessor"),LD=require("../internals/an-instance"),UD=require("../internals/has-own-property"),VD=require("../internals/object-assign"),FD=require("../internals/array-from"),BD=require("../internals/array-slice"),qD=require("../internals/string-multibyte").codeAt,jD=require("../internals/string-punycode-to-ascii"),HD=require("../internals/to-string"),GD=require("../internals/set-to-string-tag"),WD=require("../internals/validate-arguments-length"),zD=require("../modules/web.url-search-params.constructor"),JD=require("../internals/internal-state"),KD=JD.set,YD=JD.getterFor("URL"),XD=zD.URLSearchParams,QD=zD.getState,$D=xD.URL,ZD=xD.TypeError,ex=xD.parseInt,tx=Math.floor,nx=Math.pow,rx=ND("".charAt),ix=ND(/./.exec),ax=ND([].join),ox=ND(1..toString),sx=ND([].pop),cx=ND([].push),ux=ND("".replace),lx=ND([].shift),dx=ND("".split),hx=ND("".slice),fx=ND("".toLowerCase),px=ND([].unshift),mx="Invalid scheme",vx="Invalid host",_x="Invalid port",gx=/[a-z]/i,yx=/[\d+-.a-z]/i,Ex=/\d/,Tx=/^0x/i,kx=/^[0-7]+$/,Sx=/^\d+$/,bx=/^[\da-f]+$/i,Ix=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Ax=/[\0\t\n\r #/:<>?@[\\\]^|]/,Rx=/^[\u0000-\u0020]+/,Cx=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,wx=/[\t\n\r]/g,Dx=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)px(t,e%256),e=tx(e/256);return ax(t,".")}if("object"==k(e)){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++i);return i>n?r:t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=ox(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},xx={},Ox=VD({},xx,{" ":1,'"':1,"<":1,">":1,"`":1}),Nx=VD({},Ox,{"#":1,"?":1,"{":1,"}":1}),Px=VD({},Nx,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Mx=function(e,t){var n=qD(e,0);return n>32&&n<127&&!UD(t,e)?e:encodeURIComponent(e)},Lx={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Ux=function(e,t){var n;return 2===e.length&&ix(gx,rx(e,0))&&(":"===(n=rx(e,1))||!t&&"|"===n)},Vx=function(e){var t;return e.length>1&&Ux(hx(e,0,2))&&(2===e.length||"/"===(t=rx(e,2))||"\\"===t||"?"===t||"#"===t)},Fx=function(e){return"."===e||"%2e"===fx(e)},Bx={},qx={},jx={},Hx={},Gx={},Wx={},zx={},Jx={},Kx={},Yx={},Xx={},Qx={},$x={},Zx={},eO={},tO={},nO={},rO={},iO={},aO={},oO={},sO=function(e,t,n){var r,i,a,o=HD(e);if(t){if(i=this.parse(o))throw new ZD(i);this.searchParams=null}else{if(void 0!==n&&(r=new sO(n,!0)),i=this.parse(o,null,r))throw new ZD(i);(a=QD(new XD)).bindURL(this),this.searchParams=a}};sO.prototype={type:"URL",parse:function(e,t,n){var r,i,a,o,s,c=this,u=t||Bx,l=0,d="",h=!1,f=!1,p=!1;for(e=HD(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=ux(e,Rx,""),e=ux(e,Cx,"$1")),e=ux(e,wx,""),r=FD(e);l<=r.length;){switch(i=r[l],u){case Bx:if(!i||!ix(gx,i)){if(t)return mx;u=jx;continue}d+=fx(i),u=qx;break;case qx:if(i&&(ix(yx,i)||"+"===i||"-"===i||"."===i))d+=fx(i);else{if(":"!==i){if(t)return mx;d="",u=jx,l=0;continue}if(t&&(c.isSpecial()!==UD(Lx,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&Lx[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?u=Zx:c.isSpecial()&&n&&n.scheme===c.scheme?u=Hx:c.isSpecial()?u=Jx:"/"===r[l+1]?(u=Gx,l++):(c.cannotBeABaseURL=!0,cx(c.path,""),u=iO)}break;case jx:if(!n||n.cannotBeABaseURL&&"#"!==i)return mx;if(n.cannotBeABaseURL&&"#"===i){c.scheme=n.scheme,c.path=BD(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=oO;break}u="file"===n.scheme?Zx:Wx;continue;case Hx:if("/"!==i||"/"!==r[l+1]){u=Wx;continue}u=Kx,l++;break;case Gx:if("/"===i){u=Yx;break}u=rO;continue;case Wx:if(c.scheme=n.scheme,i===RD)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=BD(n.path),c.query=n.query;else if("/"===i||"\\"===i&&c.isSpecial())u=zx;else if("?"===i)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=BD(n.path),c.query="",u=aO;else{if("#"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=BD(n.path),c.path.length--,u=rO;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=BD(n.path),c.query=n.query,c.fragment="",u=oO}break;case zx:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=rO;continue}u=Yx}else u=Kx;break;case Jx:if(u=Kx,"/"!==i||"/"!==rx(d,l+1))continue;l++;break;case Kx:if("/"!==i&&"\\"!==i){u=Yx;continue}break;case Yx:if("@"===i){h&&(d="%40"+d),h=!0,a=FD(d);for(var m=0;m<a.length;m++){var v=a[m];if(":"!==v||p){var _=Mx(v,Px);p?c.password+=_:c.username+=_}else p=!0}d=""}else if(i===RD||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===d)return"Invalid authority";l-=FD(d).length+1,d="",u=Xx}else d+=i;break;case Xx:case Qx:if(t&&"file"===c.scheme){u=tO;continue}if(":"!==i||f){if(i===RD||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===d)return vx;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(o=c.parseHost(d))return o;if(d="",u=nO,t)return;continue}"["===i?f=!0:"]"===i&&(f=!1),d+=i}else{if(""===d)return vx;if(o=c.parseHost(d))return o;if(d="",u=$x,t===Qx)return}break;case $x:if(!ix(Ex,i)){if(i===RD||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==d){var g=ex(d,10);if(g>65535)return _x;c.port=c.isSpecial()&&g===Lx[c.scheme]?null:g,d=""}if(t)return;u=nO;continue}return _x}d+=i;break;case Zx:if(c.scheme="file","/"===i||"\\"===i)u=eO;else{if(!n||"file"!==n.scheme){u=rO;continue}switch(i){case RD:c.host=n.host,c.path=BD(n.path),c.query=n.query;break;case"?":c.host=n.host,c.path=BD(n.path),c.query="",u=aO;break;case"#":c.host=n.host,c.path=BD(n.path),c.query=n.query,c.fragment="",u=oO;break;default:Vx(ax(BD(r,l),""))||(c.host=n.host,c.path=BD(n.path),c.shortenPath()),u=rO;continue}}break;case eO:if("/"===i||"\\"===i){u=tO;break}n&&"file"===n.scheme&&!Vx(ax(BD(r,l),""))&&(Ux(n.path[0],!0)?cx(c.path,n.path[0]):c.host=n.host),u=rO;continue;case tO:if(i===RD||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&Ux(d))u=rO;else if(""===d){if(c.host="",t)return;u=nO}else{if(o=c.parseHost(d))return o;if("localhost"===c.host&&(c.host=""),t)return;d="",u=nO}continue}d+=i;break;case nO:if(c.isSpecial()){if(u=rO,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==RD&&(u=rO,"/"!==i))continue}else c.fragment="",u=oO;else c.query="",u=aO;break;case rO:if(i===RD||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=fx(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||cx(c.path,"")):Fx(d)?"/"===i||"\\"===i&&c.isSpecial()||cx(c.path,""):("file"===c.scheme&&!c.path.length&&Ux(d)&&(c.host&&(c.host=""),d=rx(d,0)+":"),cx(c.path,d)),d="","file"===c.scheme&&(i===RD||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)lx(c.path);"?"===i?(c.query="",u=aO):"#"===i&&(c.fragment="",u=oO)}else d+=Mx(i,Nx);break;case iO:"?"===i?(c.query="",u=aO):"#"===i?(c.fragment="",u=oO):i!==RD&&(c.path[0]+=Mx(i,xx));break;case aO:t||"#"!==i?i!==RD&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":Mx(i,xx)):(c.fragment="",u=oO);break;case oO:i!==RD&&(c.fragment+=Mx(i,Ox))}l++}},parseHost:function(e){var t,n,r;if("["===rx(e,0)){if("]"!==rx(e,e.length-1))return vx;if(t=function(e){var t,n,r,i,a,o,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,h=function(){return rx(e,d)};if(":"===h()){if(":"!==rx(e,1))return;d+=2,l=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=n=0;n<4&&ix(bx,h());)t=16*t+ex(h(),16),d++,n++;if("."===h()){if(0===n)return;if(d-=n,u>6)return;for(r=0;h();){if(i=null,r>0){if(!("."===h()&&r<4))return;d++}if(!ix(Ex,h()))return;for(;ix(Ex,h());){if(a=ex(h(),10),null===i)i=a;else{if(0===i)return;i=10*i+a}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++r&&4!==r||u++}if(4!==r)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(o=u-l,u=7;0!==u&&o>0;)s=c[u],c[u--]=c[l+o-1],c[l+--o]=s;else if(8!==u)return;return c}(hx(e,1,-1)),!t)return vx;this.host=t}else if(this.isSpecial()){if(e=jD(e),ix(Ix,e))return vx;if(t=function(e){var t,n,r,i,a,o,s,c=dx(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(n=[],r=0;r<t;r++){if(""===(i=c[r]))return e;if(a=10,i.length>1&&"0"===rx(i,0)&&(a=ix(Tx,i)?16:8,i=hx(i,8===a?1:2)),""===i)o=0;else{if(!ix(10===a?Sx:8===a?kx:bx,i))return e;o=ex(i,a)}cx(n,o)}for(r=0;r<t;r++)if(o=n[r],r===t-1){if(o>=nx(256,5-t))return null}else if(o>255)return null;for(s=sx(n),r=0;r<n.length;r++)s+=n[r]*nx(256,3-r);return s}(e),null===t)return vx;this.host=t}else{if(ix(Ax,e))return vx;for(t="",n=FD(e),r=0;r<n.length;r++)t+=Mx(n[r],xx);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return UD(Lx,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&Ux(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,o=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=n+(r?":"+r:"")+"@"),u+=Dx(i),null!==a&&(u+=":"+a)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?o[0]:o.length?"/"+ax(o,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw new ZD(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new cO(e.path[0]).origin}catch(LN){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+Dx(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(HD(e)+":",Bx)},getUsername:function(){return this.username},setUsername:function(e){var t=FD(HD(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=Mx(t[n],Px)}},getPassword:function(){return this.password},setPassword:function(e){var t=FD(HD(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=Mx(t[n],Px)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?Dx(e):Dx(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Xx)},getHostname:function(){var e=this.host;return null===e?"":Dx(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Qx)},getPort:function(){var e=this.port;return null===e?"":HD(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=HD(e))?this.port=null:this.parse(e,$x))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+ax(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,nO))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=HD(e))?this.query=null:("?"===rx(e,0)&&(e=hx(e,1)),this.query="",this.parse(e,aO)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=HD(e))?("#"===rx(e,0)&&(e=hx(e,1)),this.fragment="",this.parse(e,oO)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var cO=function(e){var t=LD(this,uO),n=WD(arguments.length,1)>1?arguments[1]:void 0,r=KD(t,new sO(e,!1,n));wD||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},uO=cO.prototype,lO=function(e,t){return{get:function(){return YD(this)[e]()},set:t&&function(e){return YD(this)[t](e)},configurable:!0,enumerable:!0}};if(wD&&(MD(uO,"href",lO("serialize","setHref")),MD(uO,"origin",lO("getOrigin")),MD(uO,"protocol",lO("getProtocol","setProtocol")),MD(uO,"username",lO("getUsername","setUsername")),MD(uO,"password",lO("getPassword","setPassword")),MD(uO,"host",lO("getHost","setHost")),MD(uO,"hostname",lO("getHostname","setHostname")),MD(uO,"port",lO("getPort","setPort")),MD(uO,"pathname",lO("getPathname","setPathname")),MD(uO,"search",lO("getSearch","setSearch")),MD(uO,"searchParams",lO("getSearchParams")),MD(uO,"hash",lO("getHash","setHash"))),PD(uO,"toJSON",(function(){return YD(this).serialize()}),{enumerable:!0}),PD(uO,"toString",(function(){return YD(this).serialize()}),{enumerable:!0}),$D){var dO=$D.createObjectURL,hO=$D.revokeObjectURL;dO&&PD(cO,"createObjectURL",OD(dO,$D)),hO&&PD(cO,"revokeObjectURL",OD(hO,$D))}GD(cO,"URL"),CD({global:!0,constructor:!0,forced:!DD,sham:!wD},{URL:cO}),require("../modules/es.array.iterator"),require("../modules/es.string.from-code-point");var fO=require("../internals/export"),pO=require("../internals/global-this"),mO=require("../internals/safe-get-built-in"),vO=require("../internals/get-built-in"),_O=require("../internals/function-call"),gO=require("../internals/function-uncurry-this"),yO=require("../internals/descriptors"),EO=require("../internals/url-constructor-detection"),TO=require("../internals/define-built-in"),kO=require("../internals/define-built-in-accessor"),SO=require("../internals/define-built-ins"),bO=require("../internals/set-to-string-tag"),IO=require("../internals/iterator-create-constructor"),AO=require("../internals/internal-state"),RO=require("../internals/an-instance"),CO=require("../internals/is-callable"),wO=require("../internals/has-own-property"),DO=require("../internals/function-bind-context"),xO=require("../internals/classof"),OO=require("../internals/an-object"),NO=require("../internals/is-object"),PO=require("../internals/to-string"),MO=require("../internals/object-create"),LO=require("../internals/create-property-descriptor"),UO=require("../internals/get-iterator"),VO=require("../internals/get-iterator-method"),FO=require("../internals/create-iter-result-object"),BO=require("../internals/validate-arguments-length"),qO=require("../internals/well-known-symbol"),jO=require("../internals/array-sort"),HO=qO("iterator"),GO="URLSearchParams",WO=GO+"Iterator",zO=AO.set,JO=AO.getterFor(GO),KO=AO.getterFor(WO),YO=mO("fetch"),XO=mO("Request"),QO=mO("Headers"),$O=XO&&XO.prototype,ZO=QO&&QO.prototype,eN=pO.TypeError,tN=pO.encodeURIComponent,nN=String.fromCharCode,rN=vO("String","fromCodePoint"),iN=parseInt,aN=gO("".charAt),oN=gO([].join),sN=gO([].push),cN=gO("".replace),uN=gO([].shift),lN=gO([].splice),dN=gO("".split),hN=gO("".slice),fN=gO(/./.exec),pN=/\+/g,mN=/^[0-9a-f]+$/i,vN=function(e,t){var n=hN(e,t,t+2);return fN(mN,n)?iN(n,16):NaN},_N=function(e){for(var t=0,n=128;n>0&&e&n;n>>=1)t++;return t},gN=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},yN=function(e){for(var t=(e=cN(e,pN," ")).length,n="",r=0;r<t;){var i=aN(e,r);if("%"===i){if("%"===aN(e,r+1)||r+3>t){n+="%",r++;continue}var a=vN(e,r+1);if(a!=a){n+=i,r++;continue}r+=2;var o=_N(a);if(0===o)i=nN(a);else{if(1===o||o>4){n+="�",r++;continue}for(var s=[a],c=1;c<o&&!(3+ ++r>t||"%"!==aN(e,r));){var u=vN(e,r+1);if(u!=u){r+=3;break}if(u>191||u<128)break;sN(s,u),r+=2,c++}if(s.length!==o){n+="�";continue}var l=gN(s);null===l?n+="�":i=rN(l)}}n+=i,r++}return n},EN=/[!'()~]|%20/g,TN={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},kN=function(e){return TN[e]},SN=function(e){return cN(tN(e),EN,kN)},bN=IO((function(e,t){zO(this,{type:WO,target:JO(e).entries,index:0,kind:t})}),GO,(function(){var e=KO(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,FO(void 0,!0);var r=t[n];switch(e.kind){case"keys":return FO(r.key,!1);case"values":return FO(r.value,!1)}return FO([r.key,r.value],!1)}),!0),IN=function(e){this.entries=[],this.url=null,void 0!==e&&(NO(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===aN(e,0)?hN(e,1):e:PO(e)))};IN.prototype={type:GO,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,a,o,s,c=this.entries,u=VO(e);if(u)for(n=(t=UO(e,u)).next;!(r=_O(n,t)).done;){if(a=(i=UO(OO(r.value))).next,(o=_O(a,i)).done||(s=_O(a,i)).done||!_O(a,i).done)throw new eN("Expected sequence with length 2");sN(c,{key:PO(o.value),value:PO(s.value)})}else for(var l in e)wO(e,l)&&sN(c,{key:l,value:PO(e[l])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=dN(e,"&"),a=0;a<i.length;)(t=i[a++]).length&&(n=dN(t,"="),sN(r,{key:yN(uN(n)),value:yN(oN(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],sN(n,SN(e.key)+"="+SN(e.value));return oN(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var AN=function(){RO(this,RN);var e=zO(this,new IN(arguments.length>0?arguments[0]:void 0));yO||(this.size=e.entries.length)},RN=AN.prototype;if(SO(RN,{append:function(e,t){var n=JO(this);BO(arguments.length,2),sN(n.entries,{key:PO(e),value:PO(t)}),yO||this.length++,n.updateURL()},delete:function(e){for(var t=JO(this),n=BO(arguments.length,1),r=t.entries,i=PO(e),a=n<2?void 0:arguments[1],o=void 0===a?a:PO(a),s=0;s<r.length;){var c=r[s];if(c.key!==i||void 0!==o&&c.value!==o)s++;else if(lN(r,s,1),void 0!==o)break}yO||(this.size=r.length),t.updateURL()},get:function(e){var t=JO(this).entries;BO(arguments.length,1);for(var n=PO(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){var t=JO(this).entries;BO(arguments.length,1);for(var n=PO(e),r=[],i=0;i<t.length;i++)t[i].key===n&&sN(r,t[i].value);return r},has:function(e){for(var t=JO(this).entries,n=BO(arguments.length,1),r=PO(e),i=n<2?void 0:arguments[1],a=void 0===i?i:PO(i),o=0;o<t.length;){var s=t[o++];if(s.key===r&&(void 0===a||s.value===a))return!0}return!1},set:function(e,t){var n=JO(this);BO(arguments.length,1);for(var r,i=n.entries,a=!1,o=PO(e),s=PO(t),c=0;c<i.length;c++)(r=i[c]).key===o&&(a?lN(i,c--,1):(a=!0,r.value=s));a||sN(i,{key:o,value:s}),yO||(this.size=i.length),n.updateURL()},sort:function(){var e=JO(this);jO(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=JO(this).entries,r=DO(e,arguments.length>1?arguments[1]:void 0),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new bN(this,"keys")},values:function(){return new bN(this,"values")},entries:function(){return new bN(this,"entries")}},{enumerable:!0}),TO(RN,HO,RN.entries,{name:"entries"}),TO(RN,"toString",(function(){return JO(this).serialize()}),{enumerable:!0}),yO&&kO(RN,"size",{get:function(){return JO(this).entries.length},configurable:!0,enumerable:!0}),bO(AN,GO),fO({global:!0,constructor:!0,forced:!EO},{URLSearchParams:AN}),!EO&&CO(QO)){var CN=gO(ZO.has),wN=gO(ZO.set),DN=function(e){if(NO(e)){var t,n=e.body;if(xO(n)===GO)return t=e.headers?new QO(e.headers):new QO,CN(t,"content-type")||wN(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),MO(e,{body:LO(0,PO(n)),headers:LO(0,t)})}return e};if(CO(YO)&&fO({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return YO(e,arguments.length>1?DN(arguments[1]):{})}}),CO(XO)){var xN=function(e){return RO(this,$O),new XO(e,arguments.length>1?DN(arguments[1]):{})};$O.constructor=xN,xN.prototype=$O,fO({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:xN})}}module.exports={URLSearchParams:AN,getState:JO};var ON,NN,PN=require("../internals/export"),MN=require("../internals/function-call");PN({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return MN(URL.prototype.toString,this)}}),ON=void 0,NN=function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a=function(e){return e&&e.Math===Math&&e},u=a("object"==("undefined"==typeof globalThis?"undefined":k(globalThis))&&globalThis)||a("object"==("undefined"==typeof window?"undefined":k(window))&&window)||a("object"==("undefined"==typeof self?"undefined":k(self))&&self)||a("object"==k(e)&&e)||a("object"==k(e)&&e)||function(){return this}()||Function("return this")(),l={},h=function(t){try{return!!t()}catch(e){return!0}},p=!h((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),m=!h((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),_=m,T=Function.prototype.call,S=_?T.bind(T):function(){return T.apply(T,arguments)},I={},A={}.propertyIsEnumerable,R=Object.getOwnPropertyDescriptor,C=R&&!A.call({1:2},1);I.f=C?function(e){var t=R(this,e);return!!t&&t.enumerable}:A;var w,D,x=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},O=m,N=Function.prototype,P=N.call,M=O&&N.bind.bind(P,P),L=O?M:function(e){return function(){return P.apply(e,arguments)}},U=L,V=U({}.toString),F=U("".slice),B=function(e){return F(V(e),8,-1)},q=h,j=B,H=Object,G=L("".split),W=q((function(){return!H("z").propertyIsEnumerable(0)}))?function(e){return"String"===j(e)?G(e,""):H(e)}:H,z=function(e){return null==e},J=z,K=TypeError,Y=function(e){if(J(e))throw new K("Can't call method on "+e);return e},X=W,Q=Y,$=function(e){return X(Q(e))},Z="object"==("undefined"==typeof document?"undefined":k(document))&&document.all,ee=void 0===Z&&void 0!==Z?function(e){return"function"==typeof e||e===Z}:function(e){return"function"==typeof e},te=ee,ne=function(e){return"object"==k(e)?null!==e:te(e)},re=u,ie=ee,ae=function(e,t){return arguments.length<2?(n=re[e],ie(n)?n:void 0):re[e]&&re[e][t];var n},oe=L({}.isPrototypeOf),se=u.navigator,ce=se&&se.userAgent,ue=ce?String(ce):"",le=u,de=ue,he=le.process,fe=le.Deno,pe=he&&he.versions||fe&&fe.version,me=pe&&pe.v8;me&&(D=(w=me.split("."))[0]>0&&w[0]<4?1:+(w[0]+w[1])),!D&&de&&(!(w=de.match(/Edge\/(\d+)/))||w[1]>=74)&&(w=de.match(/Chrome\/(\d+)/))&&(D=+w[1]);var ve=D,_e=ve,ge=h,ye=u.String,Ee=!!Object.getOwnPropertySymbols&&!ge((function(){var e=Symbol("symbol detection");return!ye(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&_e&&_e<41})),Te=Ee&&!Symbol.sham&&"symbol"==k(Symbol.iterator),ke=ae,Se=ee,be=oe,Ie=Object,Ae=Te?function(e){return"symbol"==k(e)}:function(e){var t=ke("Symbol");return Se(t)&&be(t.prototype,Ie(e))},Re=String,Ce=function(t){try{return Re(t)}catch(e){return"Object"}},we=ee,De=Ce,xe=TypeError,Oe=function(e){if(we(e))return e;throw new xe(De(e)+" is not a function")},Ne=Oe,Pe=z,Me=function(e,t){var n=e[t];return Pe(n)?void 0:Ne(n)},Le=S,Ue=ee,Ve=ne,Fe=TypeError,Be={},qe={get exports(){return Be},set exports(e){Be=e}},je=u,He=Object.defineProperty,Ge=function(e,t){try{He(je,e,{value:t,configurable:!0,writable:!0})}catch(a){je[e]=t}return t},We=u,ze=Ge,Je="__core-js_shared__",Ke=qe.exports=We[Je]||ze(Je,{});(Ke.versions||(Ke.versions=[])).push({version:"3.38.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Ye=Be,Xe=function(e,t){return Ye[e]||(Ye[e]=t||{})},Qe=Y,$e=Object,Ze=function(e){return $e(Qe(e))},et=Ze,tt=L({}.hasOwnProperty),nt=Object.hasOwn||function(e,t){return tt(et(e),t)},rt=L,it=0,at=Math.random(),ot=rt(1..toString),st=function(e){return"Symbol("+(void 0===e?"":e)+")_"+ot(++it+at,36)},ct=Xe,ut=nt,lt=st,dt=Ee,ht=Te,ft=u.Symbol,pt=ct("wks"),mt=ht?ft.for||ft:ft&&ft.withoutSetter||lt,vt=function(e){return ut(pt,e)||(pt[e]=dt&&ut(ft,e)?ft[e]:mt("Symbol."+e)),pt[e]},_t=S,gt=ne,yt=Ae,Et=Me,Tt=TypeError,kt=vt("toPrimitive"),St=function(e,t){if(!gt(e)||yt(e))return e;var n,r=Et(e,kt);if(r){if(void 0===t&&(t="default"),n=_t(r,e,t),!gt(n)||yt(n))return n;throw new Tt("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,r;if("string"===t&&Ue(n=e.toString)&&!Ve(r=Le(n,e)))return r;if(Ue(n=e.valueOf)&&!Ve(r=Le(n,e)))return r;if("string"!==t&&Ue(n=e.toString)&&!Ve(r=Le(n,e)))return r;throw new Fe("Can't convert object to primitive value")}(e,t)},bt=St,It=Ae,At=function(e){var t=bt(e,"string");return It(t)?t:t+""},Rt=ne,Ct=u.document,wt=Rt(Ct)&&Rt(Ct.createElement),Dt=function(e){return wt?Ct.createElement(e):{}},xt=Dt,Ot=!p&&!h((function(){return 7!==Object.defineProperty(xt("div"),"a",{get:function(){return 7}}).a})),Nt=p,Pt=S,Mt=I,Lt=x,Ut=$,Vt=At,Ft=nt,Bt=Ot,qt=Object.getOwnPropertyDescriptor;l.f=Nt?qt:function(e,t){if(e=Ut(e),t=Vt(t),Bt)try{return qt(e,t)}catch(a){}if(Ft(e,t))return Lt(!Pt(Mt.f,e,t),e[t])};var jt={},Ht=p&&h((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Gt=ne,Wt=String,zt=TypeError,Jt=function(e){if(Gt(e))return e;throw new zt(Wt(e)+" is not an object")},Kt=p,Yt=Ot,Xt=Ht,Qt=Jt,$t=At,Zt=TypeError,en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn="enumerable",rn="configurable",an="writable";jt.f=Kt?Xt?function(e,t,n){if(Qt(e),t=$t(t),Qt(n),"function"==typeof e&&"prototype"===t&&"value"in n&&an in n&&!n[an]){var r=tn(e,t);r&&r[an]&&(e[t]=n.value,n={configurable:rn in n?n[rn]:r[rn],enumerable:nn in n?n[nn]:r[nn],writable:!1})}return en(e,t,n)}:en:function(e,t,n){if(Qt(e),t=$t(t),Qt(n),Yt)try{return en(e,t,n)}catch(u){}if("get"in n||"set"in n)throw new Zt("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var on=jt,sn=x,cn=p?function(e,t,n){return on.f(e,t,sn(1,n))}:function(e,t,n){return e[t]=n,e},un={},ln={get exports(){return un},set exports(e){un=e}},dn=p,hn=nt,fn=Function.prototype,pn=dn&&Object.getOwnPropertyDescriptor,mn=hn(fn,"name"),vn={EXISTS:mn,PROPER:mn&&"something"===function(){}.name,CONFIGURABLE:mn&&(!dn||dn&&pn(fn,"name").configurable)},_n=ee,gn=Be,yn=L(Function.toString);_n(gn.inspectSource)||(gn.inspectSource=function(e){return yn(e)});var En,Tn,kn,Sn=gn.inspectSource,bn=ee,In=u.WeakMap,An=bn(In)&&/native code/.test(String(In)),Rn=st,Cn=Xe("keys"),wn=function(e){return Cn[e]||(Cn[e]=Rn(e))},Dn={},xn=An,On=u,Nn=ne,Pn=cn,Mn=nt,Ln=Be,Un=wn,Vn=Dn,Fn="Object already initialized",Bn=On.TypeError,qn=On.WeakMap;if(xn||Ln.state){var jn=Ln.state||(Ln.state=new qn);jn.get=jn.get,jn.has=jn.has,jn.set=jn.set,En=function(e,t){if(jn.has(e))throw new Bn(Fn);return t.facade=e,jn.set(e,t),t},Tn=function(e){return jn.get(e)||{}},kn=function(e){return jn.has(e)}}else{var Hn=Un("state");Vn[Hn]=!0,En=function(e,t){if(Mn(e,Hn))throw new Bn(Fn);return t.facade=e,Pn(e,Hn,t),t},Tn=function(e){return Mn(e,Hn)?e[Hn]:{}},kn=function(e){return Mn(e,Hn)}}var Gn={set:En,get:Tn,has:kn,enforce:function(e){return kn(e)?Tn(e):En(e,{})},getterFor:function(e){return function(t){var n;if(!Nn(t)||(n=Tn(t)).type!==e)throw new Bn("Incompatible receiver, "+e+" required");return n}}},Wn=L,zn=h,Jn=ee,Kn=nt,Yn=p,Xn=vn.CONFIGURABLE,Qn=Sn,$n=Gn.enforce,Zn=Gn.get,er=String,tr=Object.defineProperty,nr=Wn("".slice),rr=Wn("".replace),ir=Wn([].join),ar=Yn&&!zn((function(){return 8!==tr((function(){}),"length",{value:8}).length})),or=String(String).split("String"),sr=ln.exports=function(e,t,n){"Symbol("===nr(er(t),0,7)&&(t="["+rr(er(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Kn(e,"name")||Xn&&e.name!==t)&&(Yn?tr(e,"name",{value:t,configurable:!0}):e.name=t),ar&&n&&Kn(n,"arity")&&e.length!==n.arity&&tr(e,"length",{value:n.arity});try{n&&Kn(n,"constructor")&&n.constructor?Yn&&tr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(l){}var r=$n(e);return Kn(r,"source")||(r.source=ir(or,"string"==typeof t?t:"")),e};Function.prototype.toString=sr((function(){return Jn(this)&&Zn(this).source||Qn(this)}),"toString");var cr=ee,ur=jt,lr=un,dr=Ge,hr=function(e,t,n,r){r||(r={});var i=r.enumerable,a=void 0!==r.name?r.name:t;if(cr(n)&&lr(n,a,r),r.global)i?e[t]=n:dr(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(p){}i?e[t]=n:ur.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},fr={},pr=Math.ceil,mr=Math.floor,vr=Math.trunc||function(e){var t=+e;return(t>0?mr:pr)(t)},_r=vr,gr=function(e){var t=+e;return t!=t||0===t?0:_r(t)},yr=gr,Er=Math.max,Tr=Math.min,kr=function(e,t){var n=yr(e);return n<0?Er(n+t,0):Tr(n,t)},Sr=gr,br=Math.min,Ir=function(e){var t=Sr(e);return t>0?br(t,9007199254740991):0},Ar=Ir,Rr=function(e){return Ar(e.length)},Cr=$,wr=kr,Dr=Rr,xr=function(e){return function(t,n,r){var i=Cr(t),a=Dr(i);if(0===a)return!e&&-1;var o,s=wr(r,a);if(e&&n!=n){for(;a>s;)if((o=i[s++])!=o)return!0}else for(;a>s;s++)if((e||s in i)&&i[s]===n)return e||s||0;return!e&&-1}},Or={includes:xr(!0),indexOf:xr(!1)},Nr=nt,Pr=$,Mr=Or.indexOf,Lr=Dn,Ur=L([].push),Vr=function(e,t){var n,r=Pr(e),i=0,a=[];for(n in r)!Nr(Lr,n)&&Nr(r,n)&&Ur(a,n);for(;t.length>i;)Nr(r,n=t[i++])&&(~Mr(a,n)||Ur(a,n));return a},Fr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Br=Vr,qr=Fr.concat("length","prototype");fr.f=Object.getOwnPropertyNames||function(e){return Br(e,qr)};var jr={};jr.f=Object.getOwnPropertySymbols;var Hr=ae,Gr=fr,Wr=jr,zr=Jt,Jr=L([].concat),Kr=Hr("Reflect","ownKeys")||function(e){var t=Gr.f(zr(e)),n=Wr.f;return n?Jr(t,n(e)):t},Yr=nt,Xr=Kr,Qr=l,$r=jt,Zr=function(e,t,n){for(var r=Xr(t),i=$r.f,a=Qr.f,o=0;o<r.length;o++){var s=r[o];Yr(e,s)||n&&Yr(n,s)||i(e,s,a(t,s))}},ei=h,ti=ee,ni=/#|\.prototype\./,ri=function(e,t){var n=ai[ii(e)];return n===si||n!==oi&&(ti(t)?ei(t):!!t)},ii=ri.normalize=function(e){return String(e).replace(ni,".").toLowerCase()},ai=ri.data={},oi=ri.NATIVE="N",si=ri.POLYFILL="P",ci=ri,ui=u,li=l.f,di=cn,hi=hr,fi=Ge,pi=Zr,mi=ci,vi=function(e,t){var n,r,i,a,o,s=e.target,c=e.global,u=e.stat;if(n=c?ui:u?ui[s]||fi(s,{}):ui[s]&&ui[s].prototype)for(r in t){if(a=t[r],i=e.dontCallGetSet?(o=li(n,r))&&o.value:n[r],!mi(c?r:s+(u?".":"#")+r,e.forced)&&void 0!==i){if(k(a)==k(i))continue;pi(a,i)}(e.sham||i&&i.sham)&&di(a,"sham",!0),hi(n,r,a,e)}},_i={};_i[vt("toStringTag")]="z";var gi="[object z]"===String(_i),yi=ee,Ei=B,Ti=vt("toStringTag"),ki=Object,Si="Arguments"===Ei(function(){return arguments}()),bi=gi?Ei:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(n){}}(t=ki(e),Ti))?n:Si?Ei(t):"Object"===(r=Ei(t))&&yi(t.callee)?"Arguments":r},Ii=bi,Ai=String,Ri=function(e){if("Symbol"===Ii(e))throw new TypeError("Cannot convert a Symbol value to a string");return Ai(e)},Ci=un,wi=jt,Di=function(e,t,n){return n.get&&Ci(n.get,t,{getter:!0}),n.set&&Ci(n.set,t,{setter:!0}),wi.f(e,t,n)},xi=vi,Oi=p,Ni=L,Pi=nt,Mi=ee,Li=oe,Ui=Ri,Vi=Di,Fi=Zr,Bi=u.Symbol,qi=Bi&&Bi.prototype;if(Oi&&Mi(Bi)&&(!("description"in qi)||void 0!==Bi().description)){var ji={},Hi=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Ui(arguments[0]),t=Li(qi,this)?new Bi(e):void 0===e?Bi():Bi(e);return""===e&&(ji[t]=!0),t};Fi(Hi,Bi),Hi.prototype=qi,qi.constructor=Hi;var Gi="Symbol(description detection)"===String(Bi("description detection")),Wi=Ni(qi.valueOf),zi=Ni(qi.toString),Ji=/^Symbol\((.*)\)[^)]+$/,Ki=Ni("".replace),Yi=Ni("".slice);Vi(qi,"description",{configurable:!0,get:function(){var e=Wi(this);if(Pi(ji,e))return"";var t=zi(e),n=Gi?Yi(t,7,-1):Ki(t,Ji,"$1");return""===n?void 0:n}}),xi({global:!0,constructor:!0,forced:!0},{Symbol:Hi})}var Xi={},Qi=Vr,$i=Fr,Zi=Object.keys||function(e){return Qi(e,$i)},ea=p,ta=Ht,na=jt,ra=Jt,ia=$,aa=Zi;Xi.f=ea&&!ta?Object.defineProperties:function(e,t){ra(e);for(var n,r=ia(t),i=aa(t),a=i.length,o=0;a>o;)na.f(e,n=i[o++],r[n]);return e};var oa,sa=ae("document","documentElement"),ca=Jt,ua=Xi,la=Fr,da=Dn,ha=sa,fa=Dt,pa="prototype",ma="script",va=wn("IE_PROTO"),_a=function(){},ga=function(e){return"<"+ma+">"+e+"</"+ma+">"},ya=function(e){e.write(ga("")),e.close();var t=e.parentWindow.Object;return e=null,t},Ea=function(){try{oa=new ActiveXObject("htmlfile")}catch(l){}var e,t,n;Ea="undefined"!=typeof document?document.domain&&oa?ya(oa):(t=fa("iframe"),n="java"+ma+":",t.style.display="none",ha.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(ga("document.F=Object")),e.close(),e.F):ya(oa);for(var r=la.length;r--;)delete Ea[pa][la[r]];return Ea()};da[va]=!0;var Ta=Object.create||function(e,t){var n;return null!==e?(_a[pa]=ca(e),n=new _a,_a[pa]=null,n[va]=e):n=Ea(),void 0===t?n:ua.f(n,t)},ka=vt,Sa=Ta,ba=jt.f,Ia=ka("unscopables"),Aa=Array.prototype;void 0===Aa[Ia]&&ba(Aa,Ia,{configurable:!0,value:Sa(null)});var Ra=function(e){Aa[Ia][e]=!0},Ca=Or.includes,wa=Ra;vi({target:"Array",proto:!0,forced:h((function(){return!Array(1).includes()}))},{includes:function(e){return Ca(this,e,arguments.length>1?arguments[1]:void 0)}}),wa("includes");var Da,xa,Oa,Na={},Pa=!h((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Ma=nt,La=ee,Ua=Ze,Va=Pa,Fa=wn("IE_PROTO"),Ba=Object,qa=Ba.prototype,ja=Va?Ba.getPrototypeOf:function(e){var t=Ua(e);if(Ma(t,Fa))return t[Fa];var n=t.constructor;return La(n)&&t instanceof n?n.prototype:t instanceof Ba?qa:null},Ha=h,Ga=ee,Wa=ne,za=ja,Ja=hr,Ka=vt("iterator"),Ya=!1;[].keys&&("next"in(Oa=[].keys())?(xa=za(za(Oa)))!==Object.prototype&&(Da=xa):Ya=!0);var Xa=!Wa(Da)||Ha((function(){var e={};return Da[Ka].call(e)!==e}));Xa&&(Da={}),Ga(Da[Ka])||Ja(Da,Ka,(function(){return this}));var Qa={IteratorPrototype:Da,BUGGY_SAFARI_ITERATORS:Ya},$a=jt.f,Za=nt,eo=vt("toStringTag"),to=function(e,t,n){e&&!n&&(e=e.prototype),e&&!Za(e,eo)&&$a(e,eo,{configurable:!0,value:t})},no=Qa.IteratorPrototype,ro=Ta,io=x,ao=to,oo=Na,so=function(){return this},co=function(e,t,n,r){var i=t+" Iterator";return e.prototype=ro(no,{next:io(+!r,n)}),ao(e,i,!1),oo[i]=so,e},uo=L,lo=Oe,ho=ne,fo=String,po=TypeError,mo=ne,vo=Y,_o=function(e){if(function(e){return ho(e)||null===e}(e))return e;throw new po("Can't set "+fo(e)+" as a prototype")},go=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=function(e,t,n){try{return uo(lo(Object.getOwnPropertyDescriptor(e,t)[n]))}catch(u){}}(Object.prototype,"__proto__","set"))(n,[]),t=n instanceof Array}catch(u){}return function(n,r){return vo(n),_o(r),mo(n)?(t?e(n,r):n.__proto__=r,n):n}}():void 0),yo=vi,Eo=S,To=ee,ko=co,So=ja,bo=go,Io=to,Ao=cn,Ro=hr,Co=Na,wo=vn.PROPER,Do=vn.CONFIGURABLE,xo=Qa.IteratorPrototype,Oo=Qa.BUGGY_SAFARI_ITERATORS,No=vt("iterator"),Po="keys",Mo="values",Lo="entries",Uo=function(){return this},Vo=function(e,t,n,r,i,a,o){ko(n,t,r);var s,c,u,l=function(e){if(e===i&&m)return m;if(!Oo&&e&&e in f)return f[e];switch(e){case Po:case Mo:case Lo:return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,f=e.prototype,p=f[No]||f["@@iterator"]||i&&f[i],m=!Oo&&p||l(i),v="Array"===t&&f.entries||p;if(v&&(s=So(v.call(new e)))!==Object.prototype&&s.next&&(So(s)!==xo&&(bo?bo(s,xo):To(s[No])||Ro(s,No,Uo)),Io(s,d,!0)),wo&&i===Mo&&p&&p.name!==Mo&&(Do?Ao(f,"name",Mo):(h=!0,m=function(){return Eo(p,this)})),i)if(c={values:l(Mo),keys:a?m:l(Po),entries:l(Lo)},o)for(u in c)(Oo||h||!(u in f))&&Ro(f,u,c[u]);else yo({target:t,proto:!0,forced:Oo||h},c);return f[No]!==m&&Ro(f,No,m,{name:i}),Co[t]=m,c},Fo=function(e,t){return{value:e,done:t}},Bo=$,qo=Ra,jo=Na,Ho=Gn,Go=jt.f,Wo=Vo,zo=Fo,Jo=p,Ko="Array Iterator",Yo=Ho.set,Xo=Ho.getterFor(Ko),Qo=Wo(Array,"Array",(function(e,t){Yo(this,{type:Ko,target:Bo(e),index:0,kind:t})}),(function(){var e=Xo(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,zo(void 0,!0);switch(e.kind){case"keys":return zo(n,!1);case"values":return zo(t[n],!1)}return zo([n,t[n]],!1)}),"values"),$o=jo.Arguments=jo.Array;if(qo("keys"),qo("values"),qo("entries"),Jo&&"values"!==$o.name)try{Go($o,"name",{value:"values"})}catch(jj){}var Zo=Oe,es=Ze,ts=W,ns=Rr,rs=TypeError,is="Reduce of empty array with no initial value",as=function(e){return function(t,n,r,i){var a=es(t),o=ts(a),s=ns(a);if(Zo(n),0===s&&r<2)throw new rs(is);var c=e?s-1:0,u=e?-1:1;if(r<2)for(;;){if(c in o){i=o[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw new rs(is)}for(;e?c>=0:s>c;c+=u)c in o&&(i=n(i,o[c],c,a));return i}},os={left:as(!1),right:as(!0)},ss=h,cs=function(e,t){var n=[][e];return!!n&&ss((function(){n.call(null,t||function(){return 1},1)}))},us=u,ls=ue,ds=B,hs=function(e){return ls.slice(0,e.length)===e},fs=hs("Bun/")?"BUN":hs("Cloudflare-Workers")?"CLOUDFLARE":hs("Deno/")?"DENO":hs("Node.js/")?"NODE":us.Bun&&"string"==typeof Bun.version?"BUN":us.Deno&&"object"==k(Deno.version)?"DENO":"process"===ds(us.process)?"NODE":us.window&&us.document?"BROWSER":"REST",ps="NODE"===fs,ms=os.left;vi({target:"Array",proto:!0,forced:!ps&&ve>79&&ve<83||!cs("reduce")},{reduce:function(e){var t=arguments.length;return ms(this,e,t,t>1?arguments[1]:void 0)}});var vs=os.right;vi({target:"Array",proto:!0,forced:!ps&&ve>79&&ve<83||!cs("reduceRight")},{reduceRight:function(e){return vs(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var _s=B,gs=Array.isArray||function(e){return"Array"===_s(e)},ys=vi,Es=gs,Ts=L([].reverse),ks=[1,2];ys({target:"Array",proto:!0,forced:String(ks)===String(ks.reverse())},{reverse:function(){return Es(this)&&(this.length=this.length),Ts(this)}});var Ss=Ce,bs=TypeError,Is=L([].slice),As=Is,Rs=Math.floor,Cs=function(e,t){var n=e.length;if(n<8)for(var r,i,a=1;a<n;){for(i=a,r=e[a];i&&t(e[i-1],r)>0;)e[i]=e[--i];i!==a++&&(e[i]=r)}else for(var o=Rs(n/2),s=Cs(As(e,0,o),t),c=Cs(As(e,o),t),u=s.length,l=c.length,d=0,h=0;d<u||h<l;)e[d+h]=d<u&&h<l?t(s[d],c[h])<=0?s[d++]:c[h++]:d<u?s[d++]:c[h++];return e},ws=Cs,Ds=ue.match(/firefox\/(\d+)/i),xs=!!Ds&&+Ds[1],Os=/MSIE|Trident/.test(ue),Ns=ue.match(/AppleWebKit\/(\d+)\./),Ps=!!Ns&&+Ns[1],Ms=vi,Ls=L,Us=Oe,Vs=Ze,Fs=Rr,Bs=function(e,t){if(!delete e[t])throw new bs("Cannot delete property "+Ss(t)+" of "+Ss(e))},qs=Ri,js=h,Hs=ws,Gs=cs,Ws=xs,zs=Os,Js=ve,Ks=Ps,Ys=[],Xs=Ls(Ys.sort),Qs=Ls(Ys.push),$s=js((function(){Ys.sort(void 0)})),Zs=js((function(){Ys.sort(null)})),ec=Gs("sort"),tc=!js((function(){if(Js)return Js<70;if(!(Ws&&Ws>3)){if(zs)return!0;if(Ks)return Ks<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)Ys.push({k:t+r,v:n})}for(Ys.sort((function(e,t){return t.v-e.v})),r=0;r<Ys.length;r++)t=Ys[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));Ms({target:"Array",proto:!0,forced:$s||!Zs||!ec||!tc},{sort:function(e){void 0!==e&&Us(e);var t=Vs(this);if(tc)return void 0===e?Xs(t):Xs(t,e);var n,r,i=[],a=Fs(t);for(r=0;r<a;r++)r in t&&Qs(i,t[r]);for(Hs(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:qs(t)>qs(n)?1:-1}}(e)),n=Fs(i),r=0;r<n;)t[r]=i[r++];for(;r<a;)Bs(t,r++);return t}});var nc="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,rc=hr,ic=function(e,t,n){for(var r in t)rc(e,r,t[r],n);return e},ac=oe,oc=TypeError,sc=function(e,t){if(ac(t,e))return e;throw new oc("Incorrect invocation")},cc=gr,uc=Ir,lc=RangeError,dc=function(e){if(void 0===e)return 0;var t=cc(e),n=uc(t);if(t!==n)throw new lc("Wrong length or index");return n},hc=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},fc=hc,pc=Math.abs,mc=2220446049250313e-31,vc=1/mc,_c=Math.fround||function(e){return function(e,t,n,r){var i=+e,a=pc(i),o=fc(i);if(a<r)return o*function(e){return e+vc-vc}(a/r/t)*r*t;var s=(1+t/mc)*a,c=s-(s-a);return c>n||c!=c?Infinity*o:o*c}(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},gc=Array,yc=Math.abs,Ec=Math.pow,Tc=Math.floor,kc=Math.log,Sc=Math.LN2,bc={pack:function(e,t,n){var r,i,a,o=gc(n),s=8*n-t-1,c=(1<<s)-1,u=c>>1,l=23===t?Ec(2,-24)-Ec(2,-77):0,d=e<0||0===e&&1/e<0?1:0,h=0;for((e=yc(e))!=e||Infinity===e?(i=e!=e?1:0,r=c):(r=Tc(kc(e)/Sc),e*(a=Ec(2,-r))<1&&(r--,a*=2),(e+=r+u>=1?l/a:l*Ec(2,1-u))*a>=2&&(r++,a/=2),r+u>=c?(i=0,r=c):r+u>=1?(i=(e*a-1)*Ec(2,t),r+=u):(i=e*Ec(2,u-1)*Ec(2,t),r=0));t>=8;)o[h++]=255&i,i/=256,t-=8;for(r=r<<t|i,s+=t;s>0;)o[h++]=255&r,r/=256,s-=8;return o[h-1]|=128*d,o},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,a=(1<<i)-1,o=a>>1,s=i-7,c=r-1,u=e[c--],l=127&u;for(u>>=7;s>0;)l=256*l+e[c--],s-=8;for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)n=256*n+e[c--],s-=8;if(0===l)l=1-o;else{if(l===a)return n?NaN:u?-Infinity:Infinity;n+=Ec(2,t),l-=o}return(u?-1:1)*n*Ec(2,l-t)}},Ic=Ze,Ac=kr,Rc=Rr,Cc=function(e){for(var t=Ic(this),n=Rc(t),r=arguments.length,i=Ac(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,o=void 0===a?n:Ac(a,n);o>i;)t[i++]=e;return t},wc=ee,Dc=ne,xc=go,Oc=function(e,t,n){var r,i;return xc&&wc(r=t.constructor)&&r!==n&&Dc(i=r.prototype)&&i!==n.prototype&&xc(e,i),e},Nc=u,Pc=L,Mc=p,Lc=nc,Uc=cn,Vc=Di,Fc=ic,Bc=h,qc=sc,jc=gr,Hc=Ir,Gc=dc,Wc=_c,zc=bc,Jc=ja,Kc=go,Yc=Cc,Xc=Is,Qc=Oc,$c=Zr,Zc=to,eu=Gn,tu=vn.PROPER,nu=vn.CONFIGURABLE,ru="ArrayBuffer",iu="DataView",au="prototype",ou="Wrong index",su=eu.getterFor(ru),cu=eu.getterFor(iu),uu=eu.set,lu=Nc[ru],du=lu,hu=du&&du[au],fu=Nc[iu],pu=fu&&fu[au],mu=Object.prototype,vu=Nc.Array,_u=Nc.RangeError,gu=Pc(Yc),yu=Pc([].reverse),Eu=zc.pack,Tu=zc.unpack,ku=function(e){return[255&e]},Su=function(e){return[255&e,e>>8&255]},bu=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Iu=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Au=function(e){return Eu(Wc(e),23,4)},Ru=function(e){return Eu(e,52,8)},Cu=function(e,t,n){Vc(e[au],t,{configurable:!0,get:function(){return n(this)[t]}})},wu=function(e,t,n,r){var i=cu(e),a=Gc(n),o=!!r;if(a+t>i.byteLength)throw new _u(ou);var s=i.bytes,c=a+i.byteOffset,u=Xc(s,c,c+t);return o?u:yu(u)},Du=function(e,t,n,r,i,a){var o=cu(e),s=Gc(n),c=r(+i),u=!!a;if(s+t>o.byteLength)throw new _u(ou);for(var l=o.bytes,d=s+o.byteOffset,h=0;h<t;h++)l[d+h]=c[u?h:t-h-1]};if(Lc){var xu=tu&&lu.name!==ru;Bc((function(){lu(1)}))&&Bc((function(){new lu(-1)}))&&!Bc((function(){return new lu,new lu(1.5),new lu(NaN),1!==lu.length||xu&&!nu}))?xu&&nu&&Uc(lu,"name",ru):((du=function(e){return qc(this,hu),Qc(new lu(Gc(e)),this,du)})[au]=hu,hu.constructor=du,$c(du,lu)),Kc&&Jc(pu)!==mu&&Kc(pu,mu);var Ou=new fu(new du(2)),Nu=Pc(pu.setInt8);Ou.setInt8(0,2147483648),Ou.setInt8(1,2147483649),!Ou.getInt8(0)&&Ou.getInt8(1)||Fc(pu,{setInt8:function(e,t){Nu(this,e,t<<24>>24)},setUint8:function(e,t){Nu(this,e,t<<24>>24)}},{unsafe:!0})}else hu=(du=function(e){qc(this,hu);var t=Gc(e);uu(this,{type:ru,bytes:gu(vu(t),0),byteLength:t}),Mc||(this.byteLength=t,this.detached=!1)})[au],pu=(fu=function(e,t,n){qc(this,pu),qc(e,hu);var r=su(e),i=r.byteLength,a=jc(t);if(a<0||a>i)throw new _u("Wrong offset");if(a+(n=void 0===n?i-a:Hc(n))>i)throw new _u("Wrong length");uu(this,{type:iu,buffer:e,byteLength:n,byteOffset:a,bytes:r.bytes}),Mc||(this.buffer=e,this.byteLength=n,this.byteOffset=a)})[au],Mc&&(Cu(du,"byteLength",su),Cu(fu,"buffer",cu),Cu(fu,"byteLength",cu),Cu(fu,"byteOffset",cu)),Fc(pu,{getInt8:function(e){return wu(this,1,e)[0]<<24>>24},getUint8:function(e){return wu(this,1,e)[0]},getInt16:function(e){var t=wu(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=wu(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return Iu(wu(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return Iu(wu(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return Tu(wu(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return Tu(wu(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){Du(this,1,e,ku,t)},setUint8:function(e,t){Du(this,1,e,ku,t)},setInt16:function(e,t){Du(this,2,e,Su,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){Du(this,2,e,Su,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){Du(this,4,e,bu,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){Du(this,4,e,bu,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){Du(this,4,e,Au,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){Du(this,8,e,Ru,t,arguments.length>2&&arguments[2])}});Zc(du,ru),Zc(fu,iu);var Pu={ArrayBuffer:du,DataView:fu},Mu=ae,Lu=Di,Uu=p,Vu=vt("species"),Fu=function(e){var t=Mu(e);Uu&&t&&!t[Vu]&&Lu(t,Vu,{configurable:!0,get:function(){return this}})},Bu=Fu,qu="ArrayBuffer",ju=Pu[qu];vi({global:!0,constructor:!0,forced:u[qu]!==ju},{ArrayBuffer:ju}),Bu(qu);var Hu=B,Gu=L,Wu=function(e){if("Function"===Hu(e))return Gu(e)},zu=L,Ju=h,Ku=ee,Yu=bi,Xu=Sn,Qu=function(){},$u=ae("Reflect","construct"),Zu=/^\s*(?:class|function)\b/,el=zu(Zu.exec),tl=!Zu.test(Qu),nl=function(e){if(!Ku(e))return!1;try{return $u(Qu,[],e),!0}catch(jj){return!1}},rl=function(e){if(!Ku(e))return!1;switch(Yu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return tl||!!el(Zu,Xu(e))}catch(jj){return!0}};rl.sham=!0;var il=!$u||Ju((function(){var e;return nl(nl.call)||!nl(Object)||!nl((function(){e=!0}))||e}))?rl:nl,al=il,ol=Ce,sl=TypeError,cl=function(e){if(al(e))return e;throw new sl(ol(e)+" is not a constructor")},ul=Jt,ll=cl,dl=z,hl=vt("species"),fl=function(e,t){var n,r=ul(e).constructor;return void 0===r||dl(n=ul(r)[hl])?t:ll(n)},pl=vi,ml=Wu,vl=h,_l=Jt,gl=kr,yl=Ir,El=fl,Tl=Pu.ArrayBuffer,kl=Pu.DataView,Sl=kl.prototype,bl=ml(Tl.prototype.slice),Il=ml(Sl.getUint8),Al=ml(Sl.setUint8);pl({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:vl((function(){return!new Tl(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(bl&&void 0===t)return bl(_l(this),e);for(var n=_l(this).byteLength,r=gl(e,n),i=gl(void 0===t?n:t,n),a=new(El(this,Tl))(yl(i-r)),o=new kl(this),s=new kl(a),c=0;r<i;)Al(s,c++,Il(o,r++));return a}});var Rl,Cl,wl,Dl,xl=m,Ol=Function.prototype,Nl=Ol.apply,Pl=Ol.call,Ml="object"==("undefined"==typeof Reflect?"undefined":k(Reflect))&&Reflect.apply||(xl?Pl.bind(Nl):function(){return Pl.apply(Nl,arguments)}),Ll=Oe,Ul=m,Vl=Wu(Wu.bind),Fl=function(e,t){return Ll(e),void 0===t?e:Ul?Vl(e,t):function(){return e.apply(t,arguments)}},Bl=TypeError,ql=function(e,t){if(e<t)throw new Bl("Not enough arguments");return e},jl=/(?:ipad|iphone|ipod).*applewebkit/i.test(ue),Hl=u,Gl=Ml,Wl=Fl,zl=ee,Jl=nt,Kl=h,Yl=sa,Xl=Is,Ql=Dt,$l=ql,Zl=jl,ed=ps,td=Hl.setImmediate,nd=Hl.clearImmediate,rd=Hl.process,id=Hl.Dispatch,ad=Hl.Function,od=Hl.MessageChannel,sd=Hl.String,cd=0,ud={},ld="onreadystatechange";Kl((function(){Rl=Hl.location}));var dd=function(e){if(Jl(ud,e)){var t=ud[e];delete ud[e],t()}},hd=function(e){return function(){dd(e)}},fd=function(e){dd(e.data)},pd=function(e){Hl.postMessage(sd(e),Rl.protocol+"//"+Rl.host)};td&&nd||(td=function(e){$l(arguments.length,1);var t=zl(e)?e:ad(e),n=Xl(arguments,1);return ud[++cd]=function(){Gl(t,void 0,n)},Cl(cd),cd},nd=function(e){delete ud[e]},ed?Cl=function(e){rd.nextTick(hd(e))}:id&&id.now?Cl=function(e){id.now(hd(e))}:od&&!Zl?(Dl=(wl=new od).port2,wl.port1.onmessage=fd,Cl=Wl(Dl.postMessage,Dl)):Hl.addEventListener&&zl(Hl.postMessage)&&!Hl.importScripts&&Rl&&"file:"!==Rl.protocol&&!Kl(pd)?(Cl=pd,Hl.addEventListener("message",fd,!1)):Cl=ld in Ql("script")?function(e){Yl.appendChild(Ql("script"))[ld]=function(){Yl.removeChild(this),dd(e)}}:function(e){setTimeout(hd(e),0)});var md={set:td,clear:nd},vd=u,_d=p,gd=Object.getOwnPropertyDescriptor,yd=function(e){if(!_d)return vd[e];var t=gd(vd,e);return t&&t.value},Ed=function(){this.head=null,this.tail=null};Ed.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var Td,kd,Sd,bd,Id,Ad=Ed,Rd=/ipad|iphone|ipod/i.test(ue)&&"undefined"!=typeof Pebble,Cd=/web0s(?!.*chrome)/i.test(ue),wd=u,Dd=yd,xd=Fl,Od=md.set,Nd=Ad,Pd=jl,Md=Rd,Ld=Cd,Ud=ps,Vd=wd.MutationObserver||wd.WebKitMutationObserver,Fd=wd.document,Bd=wd.process,qd=wd.Promise,jd=Dd("queueMicrotask");if(!jd){var Hd=new Nd,Gd=function(){var e,t;for(Ud&&(e=Bd.domain)&&e.exit();t=Hd.get();)try{t()}catch(jj){throw Hd.head&&Td(),jj}e&&e.enter()};Pd||Ud||Ld||!Vd||!Fd?!Md&&qd&&qd.resolve?((bd=qd.resolve(void 0)).constructor=qd,Id=xd(bd.then,bd),Td=function(){Id(Gd)}):Ud?Td=function(){Bd.nextTick(Gd)}:(Od=xd(Od,wd),Td=function(){Od(Gd)}):(kd=!0,Sd=Fd.createTextNode(""),new Vd(Gd).observe(Sd,{characterData:!0}),Td=function(){Sd.data=kd=!kd}),jd=function(e){Hd.head||Td(),Hd.add(e)}}var Wd=jd,zd=function(e){try{return{error:!1,value:e()}}catch(jj){return{error:!0,value:jj}}},Jd=u.Promise,Kd=u,Yd=Jd,Xd=ee,Qd=ci,$d=Sn,Zd=vt,eh=fs,th=ve;Yd&&Yd.prototype;var nh=Zd("species"),rh=!1,ih=Xd(Kd.PromiseRejectionEvent),ah=Qd("Promise",(function(){var e=$d(Yd),t=e!==String(Yd);if(!t&&66===th)return!0;if(!th||th<51||!/native code/.test(e)){var n=new Yd((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[nh]=r,!(rh=n.then((function(){}))instanceof r))return!0}return!(t||"BROWSER"!==eh&&"DENO"!==eh||ih)})),oh={CONSTRUCTOR:ah,REJECTION_EVENT:ih,SUBCLASSING:rh},sh={},ch=Oe,uh=TypeError,lh=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw new uh("Bad Promise constructor");t=e,n=r})),this.resolve=ch(t),this.reject=ch(n)};sh.f=function(e){return new lh(e)};var dh,hh,fh,ph=vi,mh=ps,vh=u,_h=S,gh=hr,yh=go,Eh=to,Th=Fu,kh=Oe,Sh=ee,bh=ne,Ih=sc,Ah=fl,Rh=md.set,Ch=Wd,wh=zd,Dh=Ad,xh=Gn,Oh=Jd,Nh=sh,Ph="Promise",Mh=oh.CONSTRUCTOR,Lh=oh.REJECTION_EVENT,Uh=oh.SUBCLASSING,Vh=xh.getterFor(Ph),Fh=xh.set,Bh=Oh&&Oh.prototype,qh=Oh,jh=Bh,Hh=vh.TypeError,Gh=vh.document,Wh=vh.process,zh=Nh.f,Jh=zh,Kh=!!(Gh&&Gh.createEvent&&vh.dispatchEvent),Yh="unhandledrejection",Xh=function(e){var t;return!(!bh(e)||!Sh(t=e.then))&&t},Qh=function(e,t){var n,r,i,a=t.value,o=1===t.state,s=o?e.ok:e.fail,c=e.resolve,u=e.reject,l=e.domain;try{s?(o||(2===t.rejection&&nf(t),t.rejection=1),!0===s?n=a:(l&&l.enter(),n=s(a),l&&(l.exit(),i=!0)),n===e.promise?u(new Hh("Promise-chain cycle")):(r=Xh(n))?_h(r,n,c,u):c(n)):u(a)}catch(jj){l&&!i&&l.exit(),u(jj)}},$h=function(e,t){e.notified||(e.notified=!0,Ch((function(){for(var n,r=e.reactions;n=r.get();)Qh(n,e);e.notified=!1,t&&!e.rejection&&ef(e)})))},Zh=function(e,t,n){var r,i;Kh?((r=Gh.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),vh.dispatchEvent(r)):r={promise:t,reason:n},!Lh&&(i=vh["on"+e])?i(r):e===Yh&&function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(jj){}}("Unhandled promise rejection",n)},ef=function(e){_h(Rh,vh,(function(){var t,n=e.facade,r=e.value;if(tf(e)&&(t=wh((function(){mh?Wh.emit("unhandledRejection",r,n):Zh(Yh,n,r)})),e.rejection=mh||tf(e)?2:1,t.error))throw t.value}))},tf=function(e){return 1!==e.rejection&&!e.parent},nf=function(e){_h(Rh,vh,(function(){var t=e.facade;mh?Wh.emit("rejectionHandled",t):Zh("rejectionhandled",t,e.value)}))},rf=function(e,t,n){return function(r){e(t,r,n)}},af=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,$h(e,!0))},of=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new Hh("Promise can't be resolved itself");var r=Xh(t);r?Ch((function(){var n={done:!1};try{_h(r,t,rf(of,n,e),rf(af,n,e))}catch(jj){af(n,jj,e)}})):(e.value=t,e.state=1,$h(e,!1))}catch(jj){af({done:!1},jj,e)}}};if(Mh&&(jh=(qh=function(e){Ih(this,jh),kh(e),_h(dh,this);var t=Vh(this);try{e(rf(of,t),rf(af,t))}catch(jj){af(t,jj)}}).prototype,(dh=function(e){Fh(this,{type:Ph,done:!1,notified:!1,parent:!1,reactions:new Dh,rejection:!1,state:0,value:null})}).prototype=gh(jh,"then",(function(e,t){var n=Vh(this),r=zh(Ah(this,qh));return n.parent=!0,r.ok=!Sh(e)||e,r.fail=Sh(t)&&t,r.domain=mh?Wh.domain:void 0,0===n.state?n.reactions.add(r):Ch((function(){Qh(r,n)})),r.promise})),hh=function(){var e=new dh,t=Vh(e);this.promise=e,this.resolve=rf(of,t),this.reject=rf(af,t)},Nh.f=zh=function(e){return e===qh||void 0===e?new hh(e):Jh(e)},Sh(Oh)&&Bh!==Object.prototype)){fh=Bh.then,Uh||gh(Bh,"then",(function(e,t){var n=this;return new qh((function(e,t){_h(fh,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete Bh.constructor}catch(jj){}yh&&yh(Bh,jh)}ph({global:!0,constructor:!0,wrap:!0,forced:Mh},{Promise:qh}),Eh(qh,Ph,!1),Th(Ph);var sf=Na,cf=vt("iterator"),uf=Array.prototype,lf=function(e){return void 0!==e&&(sf.Array===e||uf[cf]===e)},df=bi,hf=Me,ff=z,pf=Na,mf=vt("iterator"),vf=function(e){if(!ff(e))return hf(e,mf)||hf(e,"@@iterator")||pf[df(e)]},_f=S,gf=Oe,yf=Jt,Ef=Ce,Tf=vf,kf=TypeError,Sf=function(e,t){var n=arguments.length<2?Tf(e):t;if(gf(n))return yf(_f(n,e));throw new kf(Ef(e)+" is not iterable")},bf=S,If=Jt,Af=Me,Rf=function(e,t,n){var r,i;If(e);try{if(!(r=Af(e,"return"))){if("throw"===t)throw n;return n}r=bf(r,e)}catch(jj){i=!0,r=jj}if("throw"===t)throw n;if(i)throw r;return If(r),n},Cf=Fl,wf=S,Df=Jt,xf=Ce,Of=lf,Nf=Rr,Pf=oe,Mf=Sf,Lf=vf,Uf=Rf,Vf=TypeError,Ff=function(e,t){this.stopped=e,this.result=t},Bf=Ff.prototype,qf=function(e,t,n){var r,i,a,o,s,c,u,l=n&&n.that,d=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_RECORD),f=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),m=Cf(t,l),v=function(e){return r&&Uf(r,"normal",e),new Ff(!0,e)},_=function(e){return d?(Df(e),p?m(e[0],e[1],v):m(e[0],e[1])):p?m(e,v):m(e)};if(h)r=e.iterator;else if(f)r=e;else{if(!(i=Lf(e)))throw new Vf(xf(e)+" is not iterable");if(Of(i)){for(a=0,o=Nf(e);o>a;a++)if((s=_(e[a]))&&Pf(Bf,s))return s;return new Ff(!1)}r=Mf(e,i)}for(c=h?e.next:r.next;!(u=wf(c,r)).done;){try{s=_(u.value)}catch(jj){Uf(r,"throw",jj)}if("object"==k(s)&&s&&Pf(Bf,s))return s}return new Ff(!1)},jf=vt("iterator"),Hf=!1;try{var Gf=0,Wf={next:function(){return{done:!!Gf++}},return:function(){Hf=!0}};Wf[jf]=function(){return this},Array.from(Wf,(function(){throw 2}))}catch(jj){}var zf=function(e,t){try{if(!t&&!Hf)return!1}catch(jj){return!1}var n=!1;try{var r={};r[jf]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(jj){}return n},Jf=Jd,Kf=oh.CONSTRUCTOR||!zf((function(e){Jf.all(e).then(void 0,(function(){}))})),Yf=S,Xf=Oe,Qf=sh,$f=zd,Zf=qf;vi({target:"Promise",stat:!0,forced:Kf},{all:function(e){var t=this,n=Qf.f(t),r=n.resolve,i=n.reject,a=$f((function(){var n=Xf(t.resolve),a=[],o=0,s=1;Zf(e,(function(e){var c=o++,u=!1;s++,Yf(n,t,e).then((function(e){u||(u=!0,a[c]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise}});var ep=vi,tp=oh.CONSTRUCTOR,np=Jd,rp=ae,ip=ee,ap=hr,op=np&&np.prototype;if(ep({target:"Promise",proto:!0,forced:tp,real:!0},{catch:function(e){return this.then(void 0,e)}}),ip(np)){var sp=rp("Promise").prototype.catch;op.catch!==sp&&ap(op,"catch",sp,{unsafe:!0})}var cp=S,up=Oe,lp=sh,dp=zd,hp=qf;vi({target:"Promise",stat:!0,forced:Kf},{race:function(e){var t=this,n=lp.f(t),r=n.reject,i=dp((function(){var i=up(t.resolve);hp(e,(function(e){cp(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var fp=sh;vi({target:"Promise",stat:!0,forced:oh.CONSTRUCTOR},{reject:function(e){var t=fp.f(this);return(0,t.reject)(e),t.promise}});var pp=Jt,mp=ne,vp=sh,_p=function(e,t){if(pp(e),mp(t)&&t.constructor===e)return t;var n=vp.f(e);return(0,n.resolve)(t),n.promise},gp=vi,yp=oh.CONSTRUCTOR,Ep=_p;ae("Promise"),gp({target:"Promise",stat:!0,forced:yp},{resolve:function(e){return Ep(this,e)}});var Tp=vi,kp=Jd,Sp=h,bp=ae,Ip=ee,Ap=fl,Rp=_p,Cp=hr,wp=kp&&kp.prototype;if(Tp({target:"Promise",proto:!0,real:!0,forced:!!kp&&Sp((function(){wp.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Ap(this,bp("Promise")),n=Ip(e);return this.then(n?function(n){return Rp(t,e()).then((function(){return n}))}:e,n?function(n){return Rp(t,e()).then((function(){throw n}))}:e)}}),Ip(kp)){var Dp=bp("Promise").prototype.finally;wp.finally!==Dp&&Cp(wp,"finally",Dp,{unsafe:!0})}var xp=ne,Op=B,Np=vt("match"),Pp=Jt,Mp=function(){var e=Pp(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},Lp=S,Up=nt,Vp=oe,Fp=Mp,Bp=RegExp.prototype,qp=h,jp=u.RegExp,Hp=qp((function(){var e=jp("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),Gp=Hp||qp((function(){return!jp("a","y").sticky})),Wp=Hp||qp((function(){var e=jp("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),zp={BROKEN_CARET:Wp,MISSED_STICKY:Gp,UNSUPPORTED_Y:Hp},Jp=jt.f,Kp=h,Yp=u.RegExp,Xp=Kp((function(){var e=Yp(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),Qp=h,$p=u.RegExp,Zp=Qp((function(){var e=$p("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),em=p,tm=u,nm=L,rm=ci,im=Oc,am=cn,om=Ta,sm=fr.f,cm=oe,um=Ri,lm=zp,dm=function(e,t,n){n in e||Jp(e,n,{configurable:!0,get:function(){return t[n]},set:function(e){t[n]=e}})},hm=hr,fm=h,pm=nt,mm=Gn.enforce,vm=Fu,_m=Xp,gm=Zp,ym=vt("match"),Em=tm.RegExp,Tm=Em.prototype,km=tm.SyntaxError,Sm=nm(Tm.exec),bm=nm("".charAt),Im=nm("".replace),Am=nm("".indexOf),Rm=nm("".slice),Cm=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,wm=/a/g,Dm=/a/g,xm=new Em(wm)!==wm,Om=lm.MISSED_STICKY,Nm=lm.UNSUPPORTED_Y;if(rm("RegExp",em&&(!xm||Om||_m||gm||fm((function(){return Dm[ym]=!1,Em(wm)!==wm||Em(Dm)===Dm||"/a/i"!==String(Em(wm,"i"))}))))){for(var Pm=function(e,t){var n,r,i,a,o,s,c=cm(Tm,this),u=function(e){var t;return xp(e)&&(void 0!==(t=e[Np])?!!t:"RegExp"===Op(e))}(e),l=void 0===t,d=[],h=e;if(!c&&u&&l&&e.constructor===Pm)return e;if((u||cm(Tm,e))&&(e=e.source,l&&(t=function(e){var t=e.flags;return void 0!==t||"flags"in Bp||Up(e,"flags")||!Vp(Bp,e)?t:Lp(Fp,e)}(h))),e=void 0===e?"":um(e),t=void 0===t?"":um(t),h=e,_m&&"dotAll"in wm&&(r=!!t&&Am(t,"s")>-1)&&(t=Im(t,/s/g,"")),n=t,Om&&"sticky"in wm&&(i=!!t&&Am(t,"y")>-1)&&Nm&&(t=Im(t,/y/g,"")),gm&&(a=function(e){for(var t,n=e.length,r=0,i="",a=[],o=om(null),s=!1,c=!1,u=0,l="";r<=n;r++){if("\\"===(t=bm(e,r)))t+=bm(e,++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(i+=t,"?:"===Rm(e,r+1,r+3))continue;Sm(Cm,Rm(e,r+1))&&(r+=2,c=!0),u++;continue;case">"===t&&c:if(""===l||pm(o,l))throw new km("Invalid capture group name");o[l]=!0,a[a.length]=[l,u],c=!1,l="";continue}c?l+=t:i+=t}return[i,a]}(e),e=a[0],d=a[1]),o=im(Em(e,t),c?this:Tm,Pm),(r||i||d.length)&&(s=mm(o),r&&(s.dotAll=!0,s.raw=Pm(function(e){for(var t,n=e.length,r=0,i="",a=!1;r<=n;r++)"\\"!==(t=bm(e,r))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),i+=t):i+="[\\s\\S]":i+=t+bm(e,++r);return i}(e),n)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{am(o,"source",""===h?"(?:)":h)}catch(jj){}return o},Mm=sm(Em),Lm=0;Mm.length>Lm;)dm(Pm,Em,Mm[Lm++]);Tm.constructor=Pm,Pm.prototype=Tm,hm(tm,"RegExp",Pm,{constructor:!0})}vm("RegExp");var Um=S,Vm=L,Fm=Ri,Bm=Mp,qm=zp,jm=Ta,Hm=Gn.get,Gm=Xp,Wm=Zp,zm=Xe("native-string-replace",String.prototype.replace),Jm=RegExp.prototype.exec,Km=Jm,Ym=Vm("".charAt),Xm=Vm("".indexOf),Qm=Vm("".replace),$m=Vm("".slice),Zm=function(){var e=/a/,t=/b*/g;return Um(Jm,e,"a"),Um(Jm,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),ev=qm.BROKEN_CARET,tv=void 0!==/()??/.exec("")[1];(Zm||tv||ev||Gm||Wm)&&(Km=function(e){var t,n,r,i,a,o,s,c=this,u=Hm(c),l=Fm(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=Um(Km,d,l),c.lastIndex=d.lastIndex,t;var h=u.groups,f=ev&&c.sticky,p=Um(Bm,c),m=c.source,v=0,_=l;if(f&&(p=Qm(p,"y",""),-1===Xm(p,"g")&&(p+="g"),_=$m(l,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==Ym(l,c.lastIndex-1))&&(m="(?: "+m+")",_=" "+_,v++),n=new RegExp("^(?:"+m+")",p)),tv&&(n=new RegExp("^"+m+"$(?!\\s)",p)),Zm&&(r=c.lastIndex),i=Um(Jm,f?n:c,_),f?i?(i.input=$m(i.input,v),i[0]=$m(i[0],v),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:Zm&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),tv&&i&&i.length>1&&Um(zm,i[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(i[a]=void 0)})),i&&h)for(i.groups=o=jm(null),a=0;a<h.length;a++)o[(s=h[a])[0]]=i[s[1]];return i});var nv=Km;vi({target:"RegExp",proto:!0,forced:/./.exec!==nv},{exec:nv});var rv=gr,iv=Ri,av=Y,ov=RangeError,sv=L,cv=Ir,uv=Ri,lv=Y,dv=sv((function(e){var t=iv(av(this)),n="",r=rv(e);if(r<0||Infinity===r)throw new ov("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n})),hv=sv("".slice),fv=Math.ceil,pv=function(e){return function(t,n,r){var i,a,o=uv(lv(t)),s=cv(n),c=o.length,u=void 0===r?" ":uv(r);return s<=c||""===u?o:((a=dv(u,fv((i=s-c)/u.length))).length>i&&(a=hv(a,0,i)),e?o+a:a+o)}},mv={start:pv(!1),end:pv(!0)},vv=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ue),_v=mv.start;vi({target:"String",proto:!0,forced:vv},{padStart:function(e){return _v(this,e,arguments.length>1?arguments[1]:void 0)}});var gv=S,yv=hr,Ev=nv,Tv=h,kv=vt,Sv=cn,bv=kv("species"),Iv=RegExp.prototype,Av=L,Rv=gr,Cv=Ri,wv=Y,Dv=Av("".charAt),xv=Av("".charCodeAt),Ov=Av("".slice),Nv=function(e){return function(t,n){var r,i,a=Cv(wv(t)),o=Rv(n),s=a.length;return o<0||o>=s?e?"":void 0:(r=xv(a,o))<55296||r>56319||o+1===s||(i=xv(a,o+1))<56320||i>57343?e?Dv(a,o):r:e?Ov(a,o,o+2):i-56320+(r-55296<<10)+65536}},Pv={codeAt:Nv(!1),charAt:Nv(!0)},Mv=Pv.charAt,Lv=L,Uv=Ze,Vv=Math.floor,Fv=Lv("".charAt),Bv=Lv("".replace),qv=Lv("".slice),jv=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Hv=/\$([$&'`]|\d{1,2})/g,Gv=S,Wv=Jt,zv=ee,Jv=B,Kv=nv,Yv=TypeError,Xv=Ml,Qv=S,$v=L,Zv=h,e_=Jt,t_=ee,n_=z,r_=gr,i_=Ir,a_=Ri,o_=Y,s_=function(e,t,n){return t+(n?Mv(e,t).length:1)},c_=Me,u_=function(e,t,n,r,i,a){var o=n+e.length,s=r.length,c=Hv;return void 0!==i&&(i=Uv(i),c=jv),Bv(a,c,(function(a,c){var u;switch(Fv(c,0)){case"$":return"$";case"&":return e;case"`":return qv(t,0,n);case"'":return qv(t,o);case"<":u=i[qv(c,1,-1)];break;default:var l=+c;if(0===l)return a;if(l>s){var d=Vv(l/10);return 0===d?a:d<=s?void 0===r[d-1]?Fv(c,1):r[d-1]+Fv(c,1):a}u=r[l-1]}return void 0===u?"":u}))},l_=function(e,t){var n=e.exec;if(zv(n)){var r=Gv(n,e,t);return null!==r&&Wv(r),r}if("RegExp"===Jv(e))return Gv(Kv,e,t);throw new Yv("RegExp#exec called on incompatible receiver")},d_=vt("replace"),h_=Math.max,f_=Math.min,p_=$v([].concat),m_=$v([].push),v_=$v("".indexOf),__=$v("".slice),g_=function(e){return void 0===e?e:String(e)},y_="$0"==="a".replace(/./,"$0"),E_=!!/./[d_]&&""===/./[d_]("a","$0"),T_=!Zv((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));!function(e,t,n,r){var i=kv(e),a=!Tv((function(){var t={};return t[i]=function(){return 7},7!==""[e](t)})),o=a&&!Tv((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[bv]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return t=!0,null},n[i](""),!t}));if(!a||!o||n){var s=/./[i],c=t(i,""[e],(function(e,t,n,r,i){var o=t.exec;return o===Ev||o===Iv.exec?a&&!i?{done:!0,value:gv(s,t,n,r)}:{done:!0,value:gv(e,n,t,r)}:{done:!1}}));yv(String.prototype,e,c[0]),yv(Iv,i,c[1])}r&&Sv(Iv[i],"sham",!0)}("replace",(function(e,t,n){var r=E_?"$":"$0";return[function(e,n){var r=o_(this),i=n_(e)?void 0:c_(e,d_);return i?Qv(i,e,r,n):Qv(t,a_(r),e,n)},function(e,i){var a=e_(this),o=a_(e);if("string"==typeof i&&-1===v_(i,r)&&-1===v_(i,"$<")){var s=n(t,a,o,i);if(s.done)return s.value}var c=t_(i);c||(i=a_(i));var u,l=a.global;l&&(u=a.unicode,a.lastIndex=0);for(var d,h=[];null!==(d=l_(a,o))&&(m_(h,d),l);)""===a_(d[0])&&(a.lastIndex=s_(o,i_(a.lastIndex),u));for(var f="",p=0,m=0;m<h.length;m++){for(var v,_=a_((d=h[m])[0]),g=h_(f_(r_(d.index),o.length),0),y=[],E=1;E<d.length;E++)m_(y,g_(d[E]));var T=d.groups;if(c){var k=p_([_],y,g,o);void 0!==T&&m_(k,T),v=a_(Xv(i,void 0,k))}else v=u_(_,o,g,y,T,i);g>=p&&(f+=__(o,p,g)+v,p=g+_.length)}return f+__(o,p)}]}),!T_||!y_||E_);var k_="\t\n\v\f\r                 \u2028\u2029\ufeff",S_=Y,b_=Ri,I_=k_,A_=L("".replace),R_=RegExp("^["+I_+"]+"),C_=RegExp("(^|[^"+I_+"])["+I_+"]+$"),w_=function(e){return function(t){var n=b_(S_(t));return 1&e&&(n=A_(n,R_,"")),2&e&&(n=A_(n,C_,"$1")),n}},D_={start:w_(1),end:w_(2),trim:w_(3)},x_=vn.PROPER,O_=h,N_=k_,P_=D_.trim;vi({target:"String",proto:!0,forced:function(e){return O_((function(){return!!N_[e]()||"​…᠎"!=="​…᠎"[e]()||x_&&N_[e].name!==e}))}("trim")},{trim:function(){return P_(this)}});var M_,L_,U_,V_={},F_={get exports(){return V_},set exports(e){V_=e}},B_=nc,q_=p,j_=u,H_=ee,G_=ne,W_=nt,z_=bi,J_=Ce,K_=cn,Y_=hr,X_=Di,Q_=oe,$_=ja,Z_=go,eg=vt,tg=st,ng=Gn.enforce,rg=Gn.get,ig=j_.Int8Array,ag=ig&&ig.prototype,og=j_.Uint8ClampedArray,sg=og&&og.prototype,cg=ig&&$_(ig),ug=ag&&$_(ag),lg=Object.prototype,dg=j_.TypeError,hg=eg("toStringTag"),fg=tg("TYPED_ARRAY_TAG"),pg="TypedArrayConstructor",mg=B_&&!!Z_&&"Opera"!==z_(j_.opera),vg=!1,_g={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},gg={BigInt64Array:8,BigUint64Array:8},yg=function(e){var t=$_(e);if(G_(t)){var n=rg(t);return n&&W_(n,pg)?n[pg]:yg(t)}},Eg=function(e){if(!G_(e))return!1;var t=z_(e);return W_(_g,t)||W_(gg,t)};for(M_ in _g)(U_=(L_=j_[M_])&&L_.prototype)?ng(U_)[pg]=L_:mg=!1;for(M_ in gg)(U_=(L_=j_[M_])&&L_.prototype)&&(ng(U_)[pg]=L_);if((!mg||!H_(cg)||cg===Function.prototype)&&(cg=function(){throw new dg("Incorrect invocation")},mg))for(M_ in _g)j_[M_]&&Z_(j_[M_],cg);if((!mg||!ug||ug===lg)&&(ug=cg.prototype,mg))for(M_ in _g)j_[M_]&&Z_(j_[M_].prototype,ug);if(mg&&$_(sg)!==ug&&Z_(sg,ug),q_&&!W_(ug,hg))for(M_ in vg=!0,X_(ug,hg,{configurable:!0,get:function(){return G_(this)?this[fg]:void 0}}),_g)j_[M_]&&K_(j_[M_],fg,M_);var Tg={NATIVE_ARRAY_BUFFER_VIEWS:mg,TYPED_ARRAY_TAG:vg&&fg,aTypedArray:function(e){if(Eg(e))return e;throw new dg("Target is not a typed array")},aTypedArrayConstructor:function(e){if(H_(e)&&(!Z_||Q_(cg,e)))return e;throw new dg(J_(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(q_){if(n)for(var i in _g){var a=j_[i];if(a&&W_(a.prototype,e))try{delete a.prototype[e]}catch(jj){try{a.prototype[e]=t}catch(p){}}}ug[e]&&!n||Y_(ug,e,n?t:mg&&ag[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(q_){if(Z_){if(n)for(r in _g)if((i=j_[r])&&W_(i,e))try{delete i[e]}catch(jj){}if(cg[e]&&!n)return;try{return Y_(cg,e,n?t:mg&&cg[e]||t)}catch(jj){}}for(r in _g)!(i=j_[r])||i[e]&&!n||Y_(i,e,t)}},getTypedArrayConstructor:yg,isView:function(e){if(!G_(e))return!1;var t=z_(e);return"DataView"===t||W_(_g,t)||W_(gg,t)},isTypedArray:Eg,TypedArray:cg,TypedArrayPrototype:ug},kg=u,Sg=h,bg=zf,Ig=Tg.NATIVE_ARRAY_BUFFER_VIEWS,Ag=kg.ArrayBuffer,Rg=kg.Int8Array,Cg=!Ig||!Sg((function(){Rg(1)}))||!Sg((function(){new Rg(-1)}))||!bg((function(e){new Rg,new Rg(null),new Rg(1.5),new Rg(e)}),!0)||Sg((function(){return 1!==new Rg(new Ag(2),1,void 0).length})),wg=ne,Dg=Math.floor,xg=Number.isInteger||function(e){return!wg(e)&&isFinite(e)&&Dg(e)===e},Og=gr,Ng=RangeError,Pg=RangeError,Mg=function(e,t){var n=function(e){var t=Og(e);if(t<0)throw new Ng("The argument can't be less than 0");return t}(e);if(n%t)throw new Pg("Wrong offset");return n},Lg=Math.round,Ug=bi,Vg=St,Fg=TypeError,Bg=function(e){var t=Vg(e,"number");if("number"==typeof t)throw new Fg("Can't convert number to bigint");return BigInt(t)},qg=Fl,jg=S,Hg=cl,Gg=Ze,Wg=Rr,zg=Sf,Jg=vf,Kg=lf,Yg=Tg.aTypedArrayConstructor,Xg=Bg,Qg=function(e){var t,n,r,i,a,o,s,c,u=Hg(this),l=Gg(e),d=arguments.length,h=d>1?arguments[1]:void 0,f=void 0!==h,p=Jg(l);if(p&&!Kg(p))for(c=(s=zg(l,p)).next,l=[];!(o=jg(c,s)).done;)l.push(o.value);for(f&&d>2&&(h=qg(h,arguments[2])),n=Wg(l),i=function(e){var t=Ug(e);return"BigInt64Array"===t||"BigUint64Array"===t}(r=new(Yg(u))(n)),t=0;n>t;t++)a=f?h(l[t],t):l[t],r[t]=i?Xg(a):+a;return r},$g=gs,Zg=il,ey=ne,ty=vt("species"),ny=Array,ry=Fl,iy=W,ay=Ze,oy=Rr,sy=function(e,t){return new(function(e){var t;return $g(e)&&(t=e.constructor,(Zg(t)&&(t===ny||$g(t.prototype))||ey(t)&&null===(t=t[ty]))&&(t=void 0)),void 0===t?ny:t}(e))(0===t?0:t)},cy=L([].push),uy=function(e){var t=1===e,n=2===e,r=3===e,i=4===e,a=6===e,o=7===e,s=5===e||a;return function(c,u,l,d){for(var h,f,p=ay(c),m=iy(p),v=oy(m),_=ry(u,l),g=0,y=d||sy,E=t?y(c,v):n||o?y(c,0):void 0;v>g;g++)if((s||g in m)&&(f=_(h=m[g],g,p),e))if(t)E[g]=f;else if(f)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:cy(E,h)}else switch(e){case 4:return!1;case 7:cy(E,h)}return a?-1:r||i?i:E}},ly={forEach:uy(0),map:uy(1),filter:uy(2),some:uy(3),every:uy(4),find:uy(5),findIndex:uy(6),filterReject:uy(7)},dy=Rr,hy=vi,fy=u,py=S,my=p,vy=Cg,_y=Tg,gy=Pu,yy=sc,Ey=x,Ty=cn,ky=xg,Sy=Ir,by=dc,Iy=Mg,Ay=At,Ry=nt,Cy=bi,wy=ne,Dy=Ae,xy=Ta,Oy=oe,Ny=go,Py=fr.f,My=Qg,Ly=ly.forEach,Uy=Fu,Vy=Di,Fy=jt,By=l,qy=function(e,t,n){for(var r=0,i=arguments.length>2?n:dy(t),a=new e(i);i>r;)a[r]=t[r++];return a},jy=Oc,Hy=Gn.get,Gy=Gn.set,Wy=Gn.enforce,zy=Fy.f,Jy=By.f,Ky=fy.RangeError,Yy=gy.ArrayBuffer,Xy=Yy.prototype,Qy=gy.DataView,$y=_y.NATIVE_ARRAY_BUFFER_VIEWS,Zy=_y.TYPED_ARRAY_TAG,eE=_y.TypedArray,tE=_y.TypedArrayPrototype,nE=_y.isTypedArray,rE="BYTES_PER_ELEMENT",iE="Wrong length",aE=function(e,t){Vy(e,t,{configurable:!0,get:function(){return Hy(this)[t]}})},oE=function(e){var t;return Oy(Xy,e)||"ArrayBuffer"===(t=Cy(e))||"SharedArrayBuffer"===t},sE=function(e,t){return nE(e)&&!Dy(t)&&t in e&&ky(+t)&&t>=0},cE=function(e,t){return t=Ay(t),sE(e,t)?Ey(2,e[t]):Jy(e,t)},uE=function(e,t,n){return t=Ay(t),!(sE(e,t)&&wy(n)&&Ry(n,"value"))||Ry(n,"get")||Ry(n,"set")||n.configurable||Ry(n,"writable")&&!n.writable||Ry(n,"enumerable")&&!n.enumerable?zy(e,t,n):(e[t]=n.value,e)};my?($y||(By.f=cE,Fy.f=uE,aE(tE,"buffer"),aE(tE,"byteOffset"),aE(tE,"byteLength"),aE(tE,"length")),hy({target:"Object",stat:!0,forced:!$y},{getOwnPropertyDescriptor:cE,defineProperty:uE}),F_.exports=function(e,t,n){var r=e.match(/\d+/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=fy[i],c=s,u=c&&c.prototype,l={},d=function(e,t){zy(e,t,{get:function(){return function(e,t){var n=Hy(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=Hy(e);a.view[o](t*r+a.byteOffset,n?function(e){var t=Lg(e);return t<0?0:t>255?255:255&t}(i):i,!0)}(this,t,e)},enumerable:!0})};$y?vy&&(c=t((function(e,t,n,i){return yy(e,u),jy(wy(t)?oE(t)?void 0!==i?new s(t,Iy(n,r),i):void 0!==n?new s(t,Iy(n,r)):new s(t):nE(t)?qy(c,t):py(My,c,t):new s(by(t)),e,c)})),Ny&&Ny(c,eE),Ly(Py(s),(function(e){e in c||Ty(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,n,i){yy(e,u);var a,o,s,l=0,h=0;if(wy(t)){if(!oE(t))return nE(t)?qy(c,t):py(My,c,t);a=t,h=Iy(n,r);var f=t.byteLength;if(void 0===i){if(f%r)throw new Ky(iE);if((o=f-h)<0)throw new Ky(iE)}else if((o=Sy(i)*r)+h>f)throw new Ky(iE);s=o/r}else s=by(t),a=new Yy(o=s*r);for(Gy(e,{buffer:a,byteOffset:h,byteLength:o,length:s,view:new Qy(a)});l<s;)d(e,l++)})),Ny&&Ny(c,eE),u=c.prototype=xy(tE)),u.constructor!==c&&Ty(u,"constructor",c),Wy(u).TypedArrayConstructor=c,Zy&&Ty(u,Zy,i);var h=c!==s;l[i]=c,hy({global:!0,constructor:!0,forced:h,sham:!$y},l),rE in c||Ty(c,rE,r),rE in u||Ty(u,rE,r),Uy(i)}):F_.exports=function(){},V_("Float32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),V_("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var lE=Cc,dE=Bg,hE=bi,fE=S,pE=h,mE=Tg.aTypedArray,vE=Tg.exportTypedArrayMethod,_E=L("".slice);vE("fill",(function(e){var t=arguments.length;mE(this);var n="Big"===_E(hE(this),0,3)?dE(e):+e;return fE(lE,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),pE((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))),(0,Tg.exportTypedArrayStaticMethod)("from",Qg,Cg);var gE=u,yE=S,EE=Tg,TE=Rr,kE=Mg,SE=Ze,bE=h,IE=gE.RangeError,AE=gE.Int8Array,RE=AE&&AE.prototype,CE=RE&&RE.set,wE=EE.aTypedArray,DE=EE.exportTypedArrayMethod,xE=!bE((function(){var e=new Uint8ClampedArray(2);return yE(CE,e,{length:1,0:3},1),3!==e[1]})),OE=xE&&EE.NATIVE_ARRAY_BUFFER_VIEWS&&bE((function(){var e=new AE(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));DE("set",(function(e){wE(this);var t=kE(arguments.length>1?arguments[1]:void 0,1),n=SE(e);if(xE)return yE(CE,this,n,t);var r=this.length,i=TE(n),a=0;if(i+t>r)throw new IE("Wrong length");for(;a<i;)this[t+a]=n[a++]}),!xE||OE);var NE=Wu,PE=h,ME=Oe,LE=ws,UE=xs,VE=Os,FE=ve,BE=Ps,qE=Tg.aTypedArray,jE=Tg.exportTypedArrayMethod,HE=u.Uint16Array,GE=HE&&NE(HE.prototype.sort),WE=!(!GE||PE((function(){GE(new HE(2),null)}))&&PE((function(){GE(new HE(2),{})}))),zE=!!GE&&!PE((function(){if(FE)return FE<74;if(UE)return UE<67;if(VE)return!0;if(BE)return BE<602;var e,t,n=new HE(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(GE(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));jE("sort",(function(e){return void 0!==e&&ME(e),zE?GE(this,e):LE(qE(this),function(e){return function(t,n){return void 0!==e?+e(t,n)||0:n!=n?-1:t!=t?1:0===t&&0===n?1/t>0&&1/n<0?1:-1:t>n}}(e))}),!zE||WE);var JE={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},KE=Dt("span").classList,YE=KE&&KE.constructor&&KE.constructor.prototype,XE=YE===Object.prototype?void 0:YE,QE=ly.forEach,$E=cs("forEach")?[].forEach:function(e){return QE(this,e,arguments.length>1?arguments[1]:void 0)},ZE=u,eT=JE,tT=XE,nT=$E,rT=cn,iT=function(e){if(e&&e.forEach!==nT)try{rT(e,"forEach",nT)}catch(jj){e.forEach=nT}};for(var aT in eT)eT[aT]&&iT(ZE[aT]&&ZE[aT].prototype);iT(tT);var oT=u,sT=JE,cT=XE,uT=Qo,lT=cn,dT=to,hT=vt("iterator"),fT=uT.values,pT=function(e,t){if(e){if(e[hT]!==fT)try{lT(e,hT,fT)}catch(jj){e[hT]=fT}if(dT(e,t,!0),sT[t])for(var n in uT)if(e[n]!==uT[n])try{lT(e,n,uT[n])}catch(jj){e[n]=uT[n]}}};for(var mT in sT)pT(oT[mT]&&oT[mT].prototype,mT);pT(cT,"DOMTokenList");var vT=Pv.charAt,_T=Ri,gT=Gn,yT=Vo,ET=Fo,TT="String Iterator",kT=gT.set,ST=gT.getterFor(TT);yT(String,"String",(function(e){kT(this,{type:TT,string:_T(e),index:0})}),(function(){var e,t=ST(this),n=t.string,r=t.index;return r>=n.length?ET(void 0,!0):(e=vT(n,r),t.index+=e.length,ET(e,!1))}));var bT=h,IT=p,AT=vt("iterator"),RT=!bT((function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,n=new URLSearchParams("a=1&a=2&b=3"),r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),n.delete("a",2),n.delete("b",void 0),!t.size&&!IT||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[AT]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==r||"x"!==new URL("https://x",void 0).host})),CT=p,wT=L,DT=S,xT=h,OT=Zi,NT=jr,PT=I,MT=Ze,LT=W,UT=Object.assign,VT=Object.defineProperty,FT=wT([].concat),BT=!UT||xT((function(){if(CT&&1!==UT({b:1},UT(VT({},"a",{enumerable:!0,get:function(){VT(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol("assign detection"),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!==UT({},e)[n]||OT(UT({},t)).join("")!==r}))?function(e,t){for(var n=MT(e),r=arguments.length,i=1,a=NT.f,o=PT.f;r>i;)for(var s,c=LT(arguments[i++]),u=a?FT(OT(c),a(c)):OT(c),l=u.length,d=0;l>d;)s=u[d++],CT&&!DT(o,c,s)||(n[s]=c[s]);return n}:UT,qT=Jt,jT=Rf,HT=p,GT=jt,WT=x,zT=Fl,JT=S,KT=Ze,YT=function(e,t,n,r){try{return r?t(qT(n)[0],n[1]):t(n)}catch(jj){jT(e,"throw",jj)}},XT=lf,QT=il,$T=Rr,ZT=function(e,t,n){HT?GT.f(e,t,WT(0,n)):e[t]=n},ek=Sf,tk=vf,nk=Array,rk=L,ik=2147483647,ak=/[^\0-\u007E]/,ok=/[.\u3002\uFF0E\uFF61]/g,sk="Overflow: input needs wider integers to process",ck=RangeError,uk=rk(ok.exec),lk=Math.floor,dk=String.fromCharCode,hk=rk("".charCodeAt),fk=rk([].join),pk=rk([].push),mk=rk("".replace),vk=rk("".split),_k=rk("".toLowerCase),gk=function(e){return e+22+75*(e<26)},yk=function(e,t,n){var r=0;for(e=n?lk(e/700):e>>1,e+=lk(e/t);e>455;)e=lk(e/35),r+=36;return lk(r+36*e/(e+38))},Ek=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=hk(e,n++);if(i>=55296&&i<=56319&&n<r){var a=hk(e,n++);56320==(64512&a)?pk(t,((1023&i)<<10)+(1023&a)+65536):(pk(t,i),n--)}else pk(t,i)}return t}(e);var n,r,i=e.length,a=128,o=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&pk(t,dk(r));var c=t.length,u=c;for(c&&pk(t,"-");u<i;){var l=ik;for(n=0;n<e.length;n++)(r=e[n])>=a&&r<l&&(l=r);var d=u+1;if(l-a>lk((ik-o)/d))throw new ck(sk);for(o+=(l-a)*d,a=l,n=0;n<e.length;n++){if((r=e[n])<a&&++o>ik)throw new ck(sk);if(r===a){for(var h=o,f=36;;){var p=f<=s?1:f>=s+26?26:f-s;if(h<p)break;var m=h-p,v=36-p;pk(t,dk(gk(p+m%v))),h=lk(m/v),f+=36}pk(t,dk(gk(h))),s=yk(o,d,u===c),o=0,u++}}o++,a++}return fk(t,"")},Tk=vi,kk=L,Sk=kr,bk=RangeError,Ik=String.fromCharCode,Ak=String.fromCodePoint,Rk=kk([].join);Tk({target:"String",stat:!0,arity:1,forced:!!Ak&&1!==Ak.length},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,i=0;r>i;){if(t=+arguments[i++],Sk(t,1114111)!==t)throw new bk(t+" is not a valid code point");n[i]=t<65536?Ik(t):Ik(55296+((t-=65536)>>10),t%1024+56320)}return Rk(n,"")}});var Ck=vi,wk=u,Dk=yd,xk=ae,Ok=S,Nk=L,Pk=p,Mk=RT,Lk=hr,Uk=Di,Vk=ic,Fk=to,Bk=co,qk=Gn,jk=sc,Hk=ee,Gk=nt,Wk=Fl,zk=bi,Jk=Jt,Kk=ne,Yk=Ri,Xk=Ta,Qk=x,$k=Sf,Zk=vf,eS=Fo,tS=ql,nS=ws,rS=vt("iterator"),iS="URLSearchParams",aS=iS+"Iterator",oS=qk.set,sS=qk.getterFor(iS),cS=qk.getterFor(aS),uS=Dk("fetch"),lS=Dk("Request"),dS=Dk("Headers"),hS=lS&&lS.prototype,fS=dS&&dS.prototype,pS=wk.TypeError,mS=wk.encodeURIComponent,vS=String.fromCharCode,_S=xk("String","fromCodePoint"),gS=parseInt,yS=Nk("".charAt),ES=Nk([].join),TS=Nk([].push),kS=Nk("".replace),SS=Nk([].shift),bS=Nk([].splice),IS=Nk("".split),AS=Nk("".slice),RS=Nk(/./.exec),CS=/\+/g,wS=/^[0-9a-f]+$/i,DS=function(e,t){var n=AS(e,t,t+2);return RS(wS,n)?gS(n,16):NaN},xS=function(e){for(var t=0,n=128;n>0&&e&n;n>>=1)t++;return t},OS=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},NS=function(e){for(var t=(e=kS(e,CS," ")).length,n="",r=0;r<t;){var i=yS(e,r);if("%"===i){if("%"===yS(e,r+1)||r+3>t){n+="%",r++;continue}var a=DS(e,r+1);if(a!=a){n+=i,r++;continue}r+=2;var o=xS(a);if(0===o)i=vS(a);else{if(1===o||o>4){n+="�",r++;continue}for(var s=[a],c=1;c<o&&!(3+ ++r>t||"%"!==yS(e,r));){var u=DS(e,r+1);if(u!=u){r+=3;break}if(u>191||u<128)break;TS(s,u),r+=2,c++}if(s.length!==o){n+="�";continue}var l=OS(s);null===l?n+="�":i=_S(l)}}n+=i,r++}return n},PS=/[!'()~]|%20/g,MS={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},LS=function(e){return MS[e]},US=function(e){return kS(mS(e),PS,LS)},VS=Bk((function(e,t){oS(this,{type:aS,target:sS(e).entries,index:0,kind:t})}),iS,(function(){var e=cS(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,eS(void 0,!0);var r=t[n];switch(e.kind){case"keys":return eS(r.key,!1);case"values":return eS(r.value,!1)}return eS([r.key,r.value],!1)}),!0),FS=function(e){this.entries=[],this.url=null,void 0!==e&&(Kk(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===yS(e,0)?AS(e,1):e:Yk(e)))};FS.prototype={type:iS,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,a,o,s,c=this.entries,u=Zk(e);if(u)for(n=(t=$k(e,u)).next;!(r=Ok(n,t)).done;){if(a=(i=$k(Jk(r.value))).next,(o=Ok(a,i)).done||(s=Ok(a,i)).done||!Ok(a,i).done)throw new pS("Expected sequence with length 2");TS(c,{key:Yk(o.value),value:Yk(s.value)})}else for(var l in e)Gk(e,l)&&TS(c,{key:l,value:Yk(e[l])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=IS(e,"&"),a=0;a<i.length;)(t=i[a++]).length&&(n=IS(t,"="),TS(r,{key:NS(SS(n)),value:NS(ES(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],TS(n,US(e.key)+"="+US(e.value));return ES(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var BS=function(){jk(this,qS);var e=oS(this,new FS(arguments.length>0?arguments[0]:void 0));Pk||(this.size=e.entries.length)},qS=BS.prototype;if(Vk(qS,{append:function(e,t){var n=sS(this);tS(arguments.length,2),TS(n.entries,{key:Yk(e),value:Yk(t)}),Pk||this.length++,n.updateURL()},delete:function(e){for(var t=sS(this),n=tS(arguments.length,1),r=t.entries,i=Yk(e),a=n<2?void 0:arguments[1],o=void 0===a?a:Yk(a),s=0;s<r.length;){var c=r[s];if(c.key!==i||void 0!==o&&c.value!==o)s++;else if(bS(r,s,1),void 0!==o)break}Pk||(this.size=r.length),t.updateURL()},get:function(e){var t=sS(this).entries;tS(arguments.length,1);for(var n=Yk(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){var t=sS(this).entries;tS(arguments.length,1);for(var n=Yk(e),r=[],i=0;i<t.length;i++)t[i].key===n&&TS(r,t[i].value);return r},has:function(e){for(var t=sS(this).entries,n=tS(arguments.length,1),r=Yk(e),i=n<2?void 0:arguments[1],a=void 0===i?i:Yk(i),o=0;o<t.length;){var s=t[o++];if(s.key===r&&(void 0===a||s.value===a))return!0}return!1},set:function(e,t){var n=sS(this);tS(arguments.length,1);for(var r,i=n.entries,a=!1,o=Yk(e),s=Yk(t),c=0;c<i.length;c++)(r=i[c]).key===o&&(a?bS(i,c--,1):(a=!0,r.value=s));a||TS(i,{key:o,value:s}),Pk||(this.size=i.length),n.updateURL()},sort:function(){var e=sS(this);nS(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=sS(this).entries,r=Wk(e,arguments.length>1?arguments[1]:void 0),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new VS(this,"keys")},values:function(){return new VS(this,"values")},entries:function(){return new VS(this,"entries")}},{enumerable:!0}),Lk(qS,rS,qS.entries,{name:"entries"}),Lk(qS,"toString",(function(){return sS(this).serialize()}),{enumerable:!0}),Pk&&Uk(qS,"size",{get:function(){return sS(this).entries.length},configurable:!0,enumerable:!0}),Fk(BS,iS),Ck({global:!0,constructor:!0,forced:!Mk},{URLSearchParams:BS}),!Mk&&Hk(dS)){var jS=Nk(fS.has),HS=Nk(fS.set),GS=function(e){if(Kk(e)){var t,n=e.body;if(zk(n)===iS)return t=e.headers?new dS(e.headers):new dS,jS(t,"content-type")||HS(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Xk(e,{body:Qk(0,Yk(n)),headers:Qk(0,t)})}return e};if(Hk(uS)&&Ck({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return uS(e,arguments.length>1?GS(arguments[1]):{})}}),Hk(lS)){var WS=function(e){return jk(this,hS),new lS(e,arguments.length>1?GS(arguments[1]):{})};hS.constructor=WS,WS.prototype=hS,Ck({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:WS})}}var zS,JS=vi,KS=p,YS=RT,XS=u,QS=Fl,$S=L,ZS=hr,eb=Di,tb=sc,nb=nt,rb=BT,ib=function(e){var t=KT(e),n=QT(this),r=arguments.length,i=r>1?arguments[1]:void 0,a=void 0!==i;a&&(i=zT(i,r>2?arguments[2]:void 0));var o,s,c,u,l,d,h=tk(t),f=0;if(!h||this===nk&&XT(h))for(o=$T(t),s=n?new this(o):nk(o);o>f;f++)d=a?i(t[f],f):t[f],ZT(s,f,d);else for(s=n?new this:[],l=(u=ek(t,h)).next;!(c=JT(l,u)).done;f++)d=a?YT(u,i,[c.value,f],!0):c.value,ZT(s,f,d);return s.length=f,s},ab=Is,ob=Pv.codeAt,sb=Ri,cb=to,ub=ql,lb={URLSearchParams:BS,getState:sS},db=Gn,hb=db.set,fb=db.getterFor("URL"),pb=lb.URLSearchParams,mb=lb.getState,vb=XS.URL,_b=XS.TypeError,gb=XS.parseInt,yb=Math.floor,Eb=Math.pow,Tb=$S("".charAt),kb=$S(/./.exec),Sb=$S([].join),bb=$S(1..toString),Ib=$S([].pop),Ab=$S([].push),Rb=$S("".replace),Cb=$S([].shift),wb=$S("".split),Db=$S("".slice),xb=$S("".toLowerCase),Ob=$S([].unshift),Nb="Invalid scheme",Pb="Invalid host",Mb="Invalid port",Lb=/[a-z]/i,Ub=/[\d+-.a-z]/i,Vb=/\d/,Fb=/^0x/i,Bb=/^[0-7]+$/,qb=/^\d+$/,jb=/^[\da-f]+$/i,Hb=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Gb=/[\0\t\n\r #/:<>?@[\\\]^|]/,Wb=/^[\u0000-\u0020]+/,zb=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,Jb=/[\t\n\r]/g,Kb=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)Ob(t,e%256),e=yb(e/256);return Sb(t,".")}if("object"==k(e)){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++i);return i>n?r:t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=bb(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},Yb={},Xb=rb({},Yb,{" ":1,'"':1,"<":1,">":1,"`":1}),Qb=rb({},Xb,{"#":1,"?":1,"{":1,"}":1}),$b=rb({},Qb,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Zb=function(e,t){var n=ob(e,0);return n>32&&n<127&&!nb(t,e)?e:encodeURIComponent(e)},eI={ftp:21,file:null,http:80,https:443,ws:80,wss:443},tI=function(e,t){var n;return 2===e.length&&kb(Lb,Tb(e,0))&&(":"===(n=Tb(e,1))||!t&&"|"===n)},nI=function(e){var t;return e.length>1&&tI(Db(e,0,2))&&(2===e.length||"/"===(t=Tb(e,2))||"\\"===t||"?"===t||"#"===t)},rI=function(e){return"."===e||"%2e"===xb(e)},iI={},aI={},oI={},sI={},cI={},uI={},lI={},dI={},hI={},fI={},pI={},mI={},vI={},_I={},gI={},yI={},EI={},TI={},kI={},SI={},bI={},II=function(e,t,n){var r,i,a,o=sb(e);if(t){if(i=this.parse(o))throw new _b(i);this.searchParams=null}else{if(void 0!==n&&(r=new II(n,!0)),i=this.parse(o,null,r))throw new _b(i);(a=mb(new pb)).bindURL(this),this.searchParams=a}};II.prototype={type:"URL",parse:function(e,t,n){var r,i,a,o,s,c=this,u=t||iI,l=0,d="",h=!1,f=!1,p=!1;for(e=sb(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=Rb(e,Wb,""),e=Rb(e,zb,"$1")),e=Rb(e,Jb,""),r=ib(e);l<=r.length;){switch(i=r[l],u){case iI:if(!i||!kb(Lb,i)){if(t)return Nb;u=oI;continue}d+=xb(i),u=aI;break;case aI:if(i&&(kb(Ub,i)||"+"===i||"-"===i||"."===i))d+=xb(i);else{if(":"!==i){if(t)return Nb;d="",u=oI,l=0;continue}if(t&&(c.isSpecial()!==nb(eI,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&eI[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?u=_I:c.isSpecial()&&n&&n.scheme===c.scheme?u=sI:c.isSpecial()?u=dI:"/"===r[l+1]?(u=cI,l++):(c.cannotBeABaseURL=!0,Ab(c.path,""),u=kI)}break;case oI:if(!n||n.cannotBeABaseURL&&"#"!==i)return Nb;if(n.cannotBeABaseURL&&"#"===i){c.scheme=n.scheme,c.path=ab(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=bI;break}u="file"===n.scheme?_I:uI;continue;case sI:if("/"!==i||"/"!==r[l+1]){u=uI;continue}u=hI,l++;break;case cI:if("/"===i){u=fI;break}u=TI;continue;case uI:if(c.scheme=n.scheme,i===zS)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=ab(n.path),c.query=n.query;else if("/"===i||"\\"===i&&c.isSpecial())u=lI;else if("?"===i)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=ab(n.path),c.query="",u=SI;else{if("#"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=ab(n.path),c.path.length--,u=TI;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=ab(n.path),c.query=n.query,c.fragment="",u=bI}break;case lI:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=TI;continue}u=fI}else u=hI;break;case dI:if(u=hI,"/"!==i||"/"!==Tb(d,l+1))continue;l++;break;case hI:if("/"!==i&&"\\"!==i){u=fI;continue}break;case fI:if("@"===i){h&&(d="%40"+d),h=!0,a=ib(d);for(var m=0;m<a.length;m++){var v=a[m];if(":"!==v||p){var _=Zb(v,$b);p?c.password+=_:c.username+=_}else p=!0}d=""}else if(i===zS||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===d)return"Invalid authority";l-=ib(d).length+1,d="",u=pI}else d+=i;break;case pI:case mI:if(t&&"file"===c.scheme){u=yI;continue}if(":"!==i||f){if(i===zS||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===d)return Pb;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(o=c.parseHost(d))return o;if(d="",u=EI,t)return;continue}"["===i?f=!0:"]"===i&&(f=!1),d+=i}else{if(""===d)return Pb;if(o=c.parseHost(d))return o;if(d="",u=vI,t===mI)return}break;case vI:if(!kb(Vb,i)){if(i===zS||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==d){var g=gb(d,10);if(g>65535)return Mb;c.port=c.isSpecial()&&g===eI[c.scheme]?null:g,d=""}if(t)return;u=EI;continue}return Mb}d+=i;break;case _I:if(c.scheme="file","/"===i||"\\"===i)u=gI;else{if(!n||"file"!==n.scheme){u=TI;continue}switch(i){case zS:c.host=n.host,c.path=ab(n.path),c.query=n.query;break;case"?":c.host=n.host,c.path=ab(n.path),c.query="",u=SI;break;case"#":c.host=n.host,c.path=ab(n.path),c.query=n.query,c.fragment="",u=bI;break;default:nI(Sb(ab(r,l),""))||(c.host=n.host,c.path=ab(n.path),c.shortenPath()),u=TI;continue}}break;case gI:if("/"===i||"\\"===i){u=yI;break}n&&"file"===n.scheme&&!nI(Sb(ab(r,l),""))&&(tI(n.path[0],!0)?Ab(c.path,n.path[0]):c.host=n.host),u=TI;continue;case yI:if(i===zS||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&tI(d))u=TI;else if(""===d){if(c.host="",t)return;u=EI}else{if(o=c.parseHost(d))return o;if("localhost"===c.host&&(c.host=""),t)return;d="",u=EI}continue}d+=i;break;case EI:if(c.isSpecial()){if(u=TI,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==zS&&(u=TI,"/"!==i))continue}else c.fragment="",u=bI;else c.query="",u=SI;break;case TI:if(i===zS||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=xb(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||Ab(c.path,"")):rI(d)?"/"===i||"\\"===i&&c.isSpecial()||Ab(c.path,""):("file"===c.scheme&&!c.path.length&&tI(d)&&(c.host&&(c.host=""),d=Tb(d,0)+":"),Ab(c.path,d)),d="","file"===c.scheme&&(i===zS||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)Cb(c.path);"?"===i?(c.query="",u=SI):"#"===i&&(c.fragment="",u=bI)}else d+=Zb(i,Qb);break;case kI:"?"===i?(c.query="",u=SI):"#"===i?(c.fragment="",u=bI):i!==zS&&(c.path[0]+=Zb(i,Yb));break;case SI:t||"#"!==i?i!==zS&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":Zb(i,Yb)):(c.fragment="",u=bI);break;case bI:i!==zS&&(c.fragment+=Zb(i,Xb))}l++}},parseHost:function(e){var t,n,r;if("["===Tb(e,0)){if("]"!==Tb(e,e.length-1))return Pb;if(t=function(e){var t,n,r,i,a,o,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,h=function(){return Tb(e,d)};if(":"===h()){if(":"!==Tb(e,1))return;d+=2,l=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=n=0;n<4&&kb(jb,h());)t=16*t+gb(h(),16),d++,n++;if("."===h()){if(0===n)return;if(d-=n,u>6)return;for(r=0;h();){if(i=null,r>0){if(!("."===h()&&r<4))return;d++}if(!kb(Vb,h()))return;for(;kb(Vb,h());){if(a=gb(h(),10),null===i)i=a;else{if(0===i)return;i=10*i+a}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++r&&4!==r||u++}if(4!==r)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(o=u-l,u=7;0!==u&&o>0;)s=c[u],c[u--]=c[l+o-1],c[l+--o]=s;else if(8!==u)return;return c}(Db(e,1,-1)),!t)return Pb;this.host=t}else if(this.isSpecial()){if(e=function(e){var t,n,r=[],i=vk(mk(_k(e),ok,"."),".");for(t=0;t<i.length;t++)n=i[t],pk(r,uk(ak,n)?"xn--"+Ek(n):n);return fk(r,".")}(e),kb(Hb,e))return Pb;if(t=function(e){var t,n,r,i,a,o,s,c=wb(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(n=[],r=0;r<t;r++){if(""===(i=c[r]))return e;if(a=10,i.length>1&&"0"===Tb(i,0)&&(a=kb(Fb,i)?16:8,i=Db(i,8===a?1:2)),""===i)o=0;else{if(!kb(10===a?qb:8===a?Bb:jb,i))return e;o=gb(i,a)}Ab(n,o)}for(r=0;r<t;r++)if(o=n[r],r===t-1){if(o>=Eb(256,5-t))return null}else if(o>255)return null;for(s=Ib(n),r=0;r<n.length;r++)s+=n[r]*Eb(256,3-r);return s}(e),null===t)return Pb;this.host=t}else{if(kb(Gb,e))return Pb;for(t="",n=ib(e),r=0;r<n.length;r++)t+=Zb(n[r],Yb);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return nb(eI,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&tI(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,o=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=n+(r?":"+r:"")+"@"),u+=Kb(i),null!==a&&(u+=":"+a)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?o[0]:o.length?"/"+Sb(o,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw new _b(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new AI(e.path[0]).origin}catch(jj){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+Kb(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(sb(e)+":",iI)},getUsername:function(){return this.username},setUsername:function(e){var t=ib(sb(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=Zb(t[n],$b)}},getPassword:function(){return this.password},setPassword:function(e){var t=ib(sb(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=Zb(t[n],$b)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?Kb(e):Kb(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,pI)},getHostname:function(){var e=this.host;return null===e?"":Kb(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,mI)},getPort:function(){var e=this.port;return null===e?"":sb(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=sb(e))?this.port=null:this.parse(e,vI))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+Sb(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,EI))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=sb(e))?this.query=null:("?"===Tb(e,0)&&(e=Db(e,1)),this.query="",this.parse(e,SI)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=sb(e))?("#"===Tb(e,0)&&(e=Db(e,1)),this.fragment="",this.parse(e,bI)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var AI=function(e){var t=tb(this,RI),n=ub(arguments.length,1)>1?arguments[1]:void 0,r=hb(t,new II(e,!1,n));KS||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},RI=AI.prototype,CI=function(e,t){return{get:function(){return fb(this)[e]()},set:t&&function(e){return fb(this)[t](e)},configurable:!0,enumerable:!0}};if(KS&&(eb(RI,"href",CI("serialize","setHref")),eb(RI,"origin",CI("getOrigin")),eb(RI,"protocol",CI("getProtocol","setProtocol")),eb(RI,"username",CI("getUsername","setUsername")),eb(RI,"password",CI("getPassword","setPassword")),eb(RI,"host",CI("getHost","setHost")),eb(RI,"hostname",CI("getHostname","setHostname")),eb(RI,"port",CI("getPort","setPort")),eb(RI,"pathname",CI("getPathname","setPathname")),eb(RI,"search",CI("getSearch","setSearch")),eb(RI,"searchParams",CI("getSearchParams")),eb(RI,"hash",CI("getHash","setHash"))),ZS(RI,"toJSON",(function(){return fb(this).serialize()}),{enumerable:!0}),ZS(RI,"toString",(function(){return fb(this).serialize()}),{enumerable:!0}),vb){var wI=vb.createObjectURL,DI=vb.revokeObjectURL;wI&&ZS(AI,"createObjectURL",QS(wI,vb)),DI&&ZS(AI,"revokeObjectURL",QS(DI,vb))}cb(AI,"URL"),JS({global:!0,constructor:!0,forced:!YS,sham:!KS},{URL:AI});var xI=S;vi({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return xI(URL.prototype.toString,this)}});var OI=!0,NI=!0;function PI(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function MI(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var a=function(e){var t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,a),i.apply(this,[e,a])};var a=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return a.apply(this,arguments);if(!this._eventMap[t].has(n))return a.apply(this,arguments);var r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,a.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get: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 LI(e){return"boolean"!=typeof e?new Error("Argument type: "+k(e)+". Please use a boolean."):(OI=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function UI(e){return"boolean"!=typeof e?new Error("Argument type: "+k(e)+". Please use a boolean."):(NI=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function VI(){if("object"==("undefined"==typeof window?"undefined":k(window))){if(OI)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function FI(e,t){NI&&console.warn(e+" is deprecated, please use "+t+" instead.")}function BI(e){return"[object Object]"===Object.prototype.toString.call(e)}function qI(e){return BI(e)?Object.keys(e).reduce((function(t,n){var r=BI(e[n]),i=r?qI(e[n]):e[n],a=r&&!Object.keys(i).length;return void 0===i||a?t:Object.assign(t,c({},n,i))}),{}):e}function jI(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((function(r){r.endsWith("Id")?jI(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((function(t){jI(e,e.get(t),n)}))})))}function HI(e,t,n){var r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var a=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&a.push(e)})),a.forEach((function(t){e.forEach((function(n){n.type===r&&n.trackId===t.id&&jI(e,n,i)}))})),i}var GI=VI;function WI(e,t){var n=e&&e.navigator;if(n.mediaDevices){var r=function(e){if("object"!=k(e)||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach((function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==k(e[n])?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var a={};"number"==typeof r.ideal?(a[i("min",n)]=r.ideal,t.optional.push(a),(a={})[i("max",n)]=r.ideal,t.optional.push(a)):(a[i("",n)]=r.ideal,t.optional.push(a))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))}})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==k(e.audio)){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};a((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==k(e.video)){var o=e.video.facingMode;o=o&&("object"==k(o)?o:{ideal:o});var s,c=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||c)&&(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?s=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(s=["front"]),s))return n.mediaDevices.enumerateDevices().then((function(t){var n=(t=t.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return s.some((function(t){return e.label.toLowerCase().includes(t)}))}));return!n&&t.length&&s.includes("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=o.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=r(e.video),GI("chrome: "+JSON.stringify(e)),i(e)}));e.video=r(e.video)}return GI("chrome: "+JSON.stringify(e)),i(e)},a=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(function(e){n.webkitGetUserMedia(e,t,(function(e){r&&r(a(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){var o=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return o(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(a(e))}))}))}}}}function zI(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function JI(e){if("object"==k(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 n=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find((function(e){return e.track&&e.track.id===r.track.id})):{track:r.track};var a=new Event("track");a.track=r.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],n.dispatchEvent(a)})),t.stream.getTracks().forEach((function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find((function(e){return e.track&&e.track.id===r.id})):{track:r};var a=new Event("track");a.track=r,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],n.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else MI(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function KI(e){if("object"==k(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 n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.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 n=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){n._senders.push(t(n,e))}))};var a=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],a.apply(this,[e]),e.getTracks().forEach((function(e){var n=t._senders.find((function(t){return t.track===e}));n&&t._senders.splice(t._senders.indexOf(n),1)}))}}else if("object"==k(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var o=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=o.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 YI(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,n=Array.prototype.slice.call(arguments),r=n[0],i=n[1],a=n[2];if(arguments.length>0&&"function"==typeof r)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof r))return t.apply(this,[]);var o=function(e){var t={};return e.result().forEach((function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){n[t]=e.stat(t)})),t[n.id]=n})),t},s=function(e){return new Map(Object.keys(e).map((function(t){return[t,e[t]]})))};return arguments.length>=2?t.apply(this,[function(e){i(s(o(e)))},r]):new Promise((function(n,r){t.apply(e,[function(e){n(s(o(e)))},r])})).then(i,a)}}}function XI(e){if("object"==k(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,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return HI(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=r.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),MI(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 HI(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,n,r,a=arguments[0];return this.getSenders().forEach((function(e){e.track===a&&(t?r=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===a&&(n?r=!0:n=e),e.track===a})),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function QI(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,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};var n=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 r=this.getSenders();n.apply(this,arguments);var i=this.getSenders().filter((function(e){return-1===r.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(i)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};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(n){var r=t._shimmedLocalStreams[n].indexOf(e);-1!==r&&t._shimmedLocalStreams[n].splice(r,1),1===t._shimmedLocalStreams[n].length&&delete t._shimmedLocalStreams[n]})),i.apply(this,arguments)}}function $I(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return QI(e);var n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=n.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map((function(t){return e._reverseStreams[t.id]}))};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){if(n.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}r.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,n){var r=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");if(this.getSenders().find((function(e){return e.track===t})))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var a=this._streams[n.id];if(a)a.addTrack(t),Promise.resolve().then((function(){r.dispatchEvent(new Event("negotiationneeded"))}));else{var o=new e.MediaStream([t]);this._streams[n.id]=o,this._reverseStreams[o.id]=n,this.addStream(o)}return this.getSenders().find((function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=c({},t,(function(){var e=this,t=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[function(n){var r=s(e,n);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):n.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=r[t]}));var a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};var o=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=o.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,n=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(r){n._streams[r].getTracks().find((function(t){return e.track===t}))&&(t=n._streams[r])})),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 n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}}function ZI(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=c({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=r[t]}))}function eA(e,t){MI(e,"negotiationneeded",(function(e){var n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}var tA=Object.freeze({__proto__:null,shimMediaStream:zI,shimOnTrack:JI,shimGetSendersWithDtmf:KI,shimGetStats:YI,shimSenderReceiverGetStats:XI,shimAddTrackRemoveTrackWithNative:QI,shimAddTrackRemoveTrack:$I,shimPeerConnection:ZI,fixNegotiationNeeded:eA,shimGetUserMedia:WI,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then((function(t){var r=n.video&&n.video.width,i=n.video&&n.video.height,a=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:a||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});function nA(e,t){var n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){FI("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var i=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},a=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==k(e)&&"object"==k(e.audio)&&(e=JSON.parse(JSON.stringify(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),a(e)},r&&r.prototype.getSettings){var o=r.prototype.getSettings;r.prototype.getSettings=function(){var e=o.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(r&&r.prototype.applyConstraints){var s=r.prototype.applyConstraints;r.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==k(e)&&(e=JSON.parse(JSON.stringify(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function rA(e){"object"==k(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 iA(e,t){if("object"==k(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=c({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=r[t]}));var n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),i=e[0],a=e[1],o=e[2];return r.apply(this,[i||null]).then((function(e){if(t.version<53&&!a)try{e.forEach((function(e){e.type=n[e.type]||e.type}))}catch(wR){if("TypeError"!==wR.name)throw wR;e.forEach((function(t,r){e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(a,o)}}}function aA(e){if("object"==k(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,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function oA(e){if("object"==k(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,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n}),MI(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function sA(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;FI("removeStream","removeTrack"),this.getSenders().forEach((function(n){n.track&&e.getTracks().includes(n.track)&&t.removeTrack(n)}))})}function cA(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function uA(e){if("object"==k(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 n=(e=E(e)).length>0;n&&e.forEach((function(e){if("rid"in e&&!/^[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 r=t.apply(this,arguments);if(n){var i=r.sender,a=i.getParameters();(!("encodings"in a)||1===a.encodings.length&&0===Object.keys(a.encodings[0]).length)&&(a.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(a).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return r})}}function lA(e){if("object"==k(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 dA(e){if("object"==k(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,n=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(n,e)})).finally((function(){n.setParametersPromises=[]})):t.apply(this,arguments)}}}function hA(e){if("object"==k(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,n=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(n,e)})).finally((function(){n.setParametersPromises=[]})):t.apply(this,arguments)}}}var fA=Object.freeze({__proto__:null,shimOnTrack:rA,shimPeerConnection:iA,shimSenderGetStats:aA,shimReceiverGetStats:oA,shimRemoveStream:sA,shimRTCDataChannel:cA,shimAddTransceiver:uA,shimGetParameters:lA,shimCreateOffer:dA,shimCreateAnswer:hA,shimGetUserMedia:nA,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){var r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});function pA(e){if("object"==k(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 n=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var n=this,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i&&i.forEach((function(e){n._localStreams?n._localStreams.includes(e)||n._localStreams.push(e):n._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 n=this._localStreams.indexOf(e);if(-1!==n){this._localStreams.splice(n,1);var r=e.getTracks();this.getSenders().forEach((function(e){r.includes(e.track)&&t.removeTrack(e)}))}})}}function mA(e){if("object"==k(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 n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});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 n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function vA(e){if("object"==k(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,a=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=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},t.createAnswer=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};var s=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){var r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}}function _A(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var n=t.mediaDevices,r=n.getUserMedia.bind(n);t.mediaDevices.getUserMedia=function(e){return r(gA(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function gA(e){return e&&void 0!==e.video?Object.assign({},e,{video:qI(e.video)}):e}function yA(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var r=[],i=0;i<e.iceServers.length;i++){var a=e.iceServers[i];void 0===a.urls&&a.url?(FI("RTCIceServer.url","RTCIceServer.urls"),(a=JSON.parse(JSON.stringify(a))).urls=a.url,delete a.url,r.push(a)):r.push(e.iceServers[i])}e.iceServers=r}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function EA(e){"object"==k(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 TA(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var n=this.getTransceivers().find((function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&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.offerToReceiveAudio||n||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var r=this.getTransceivers().find((function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&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.offerToReceiveVideo||r||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function kA(e){"object"!=k(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var SA=Object.freeze({__proto__:null,shimLocalStreamsAPI:pA,shimRemoteStreamsAPI:mA,shimCallbacksAPI:vA,shimGetUserMedia:_A,shimConstraints:gA,shimRTCIceServerUrls:yA,shimTrackEventTransceiver:EA,shimCreateOfferLegacy:TA,shimAudioContext:kA}),bA={},IA={get exports(){return bA},set exports(e){bA=e}};!function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){var n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((function(e){return 0===e.indexOf(n)}))},t.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{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]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:void 0===n[t[r]]&&(n[t[r]]=t[r+1])}return n},t.writeCandidate=function(e){var t=[];t.push(e.foundation);var n=e.component;"rtp"===n?t.push(1):"rtcp"===n?t.push(2):t.push(n),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){var t=e.substring(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){for(var t,n={},r=e.substring(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},t.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach((function(t){void 0!==e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substring(7,t),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substring(t+1,r),n.value=e.substring(r+1)):n.attribute=e.substring(t+1),n},t.parseSsrcGroup=function(e){var t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substring(6)},t.parseFingerprint=function(e){var t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){var t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==k(e.keyParams)?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){var r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substring(12),password:i.substring(10)}:null},t.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},t.parseRtpParameters=function(e){var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" ");n.profile=r[2];for(var i=3;i<r.length;i++){var a=r[i],o=t.matchPrefix(e,"a=rtpmap:"+a+" ")[0];if(o){var s=t.parseRtpMap(o),c=t.matchPrefix(e,"a=fmtp:"+a+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+a+" ").map(t.parseRtcpFb),n.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(s.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((function(e){n.headerExtensions.push(t.parseExtmap(e))}));var u=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return n.codecs.forEach((function(e){u.forEach((function(t){e.rtcpFeedback.find((function(e){return e.type===t.type&&e.parameter===t.parameter}))||e.rtcpFeedback.push(t)}))})),n},t.writeRtpDescription=function(e,n){var r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" "+(n.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=n.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));var i=0;return n.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),n.headerExtensions&&n.headerExtensions.forEach((function(e){r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){var n,r=[],i=t.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substring(17).split(" ").map((function(e){return parseInt(e,10)}))}));u.length>0&&u[0].length>1&&u[0][0]===c&&(n=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&n&&(t.rtx={ssrc:n}),r.push(t),a&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},r.push(t))}})),0===r.length&&c&&r.push({ssrc:c});var l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substring(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substring(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=l}))),r},t.parseRtcpParameters=function(e){var n={},r=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;var a=t.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},t.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},t.parseMsid=function(e){var n,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(n=r[0].substring(7).split(" "))[0],track:n[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(n=i[0].value.split(" "))[0],track:n[1]}:void 0},t.parseSctpDescription=function(e){var n,r=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(n=parseInt(i[0].substring(19),10)),isNaN(n)&&(n=65536);var a=t.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substring(12),10),protocol:r.fmt,maxMessageSize:n};var o=t.matchPrefix(e,"a=sctpmap:");if(o.length>0){var s=o[0].substring(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,n,r){var i=void 0!==n?n:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,n){for(var r=t.splitLines(e),i=0;i<r.length;i++)switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substring(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var n=t.splitLines(e)[0].substring(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var n=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var n=t.splitLines(e),r=0;r<n.length;r++)if(n[r].length<2||"="!==n[r].charAt(1))return!1;return!0},e.exports=t}(IA);var AA=bA,RA=function(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}({__proto__:null,default:AA},[bA]);function CA(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==k(e)&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){var n=new t(e),r=AA.parseCandidate(e.candidate);for(var i in r)i in n||Object.defineProperty(n,i,{value:r[i]});return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,MI(e,"icecandidate",(function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function wA(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||MI(e,"icecandidate",(function(e){if(e.candidate){var t=AA.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function DA(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 n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76&&"plan-b"===this.getConfiguration().sdpSemantics&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0}),function(e){if(!e||!e.sdp)return!1;var t=AA.splitSections(e.sdp);return t.shift(),t.some((function(e){var t=AA.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){var e,r=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),i=function(e){var n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n}(r),a=function(e,n){var r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);var i=AA.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?r=parseInt(i[0].substring(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r}(arguments[0],r);e=0===i&&0===a?Number.POSITIVE_INFINITY:0===i||0===a?Math.max(i,a):Math.min(i,a);var o={};Object.defineProperty(o,"maxMessageSize",{get:function(){return e}}),this._sctp=o}return n.apply(this,arguments)}}}function xA(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 n(e,this),e},MI(e,"datachannel",(function(e){return n(e.channel,e.target),e}))}function n(e,t){var n=e.send;e.send=function(){var r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}}function OA(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 n=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 n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}}function NA(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var r=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:r}):t.sdp=r}return n.apply(this,arguments)}}}function PA(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function MA(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var n=e.RTCPeerConnection.prototype.setLocalDescription;n&&0!==n.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!=k(t)||t.type&&t.sdp)return n.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"}return t.sdp||"offer"!==t.type&&"answer"!==t.type?n.apply(this,[t]):("offer"===t.type?this.createOffer:this.createAnswer).apply(this).then((function(t){return n.apply(e,[t])}))})}}var LA=Object.freeze({__proto__:null,shimRTCIceCandidate:CA,shimRTCIceCandidateRelayProtocol:wA,shimMaxMessageSize:DA,shimSendThrowTypeError:xA,shimConnectionState:OA,removeExtmapAllowMixed:NA,shimAddIceCandidateNullOrEmpty:PA,shimParameterlessSetLocalDescription:MA});!function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=VI,r=function(e){var t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;var n=e.navigator;if(n.mozGetUserMedia)t.browser="firefox",t.version=PI(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=PI(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=PI(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:r,commonShim:LA,extractVersion:PI,disableLog:LI,disableWarnings:UI,sdp:RA};switch(r.browser){case"chrome":if(!tA||!ZI||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(null===r.version)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=tA,PA(e,r),MA(e),WI(e,r),zI(e),ZI(e,r),JI(e),$I(e,r),KI(e),YI(e),XI(e),eA(e,r),CA(e),wA(e),OA(e),DA(e,r),xA(e),NA(e,r);break;case"firefox":if(!fA||!iA||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=fA,PA(e,r),MA(e),nA(e,r),iA(e,r),rA(e),sA(e),aA(e),oA(e),cA(e),uA(e),lA(e),dA(e),hA(e),CA(e),OA(e),DA(e,r),xA(e);break;case"safari":if(!SA||!t.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=SA,PA(e,r),MA(e),yA(e),TA(e),vA(e),pA(e),mA(e),EA(e),_A(e),kA(e),CA(e),wA(e),DA(e,r),xA(e),NA(e,r);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var UA,VA=Object.create,FA=Object.defineProperty,BA=Object.defineProperties,qA=Object.getOwnPropertyDescriptor,jA=Object.getOwnPropertyDescriptors,HA=Object.getOwnPropertyNames,GA=Object.getOwnPropertySymbols,WA=Object.getPrototypeOf,zA=Object.prototype.hasOwnProperty,JA=Object.prototype.propertyIsEnumerable,KA=Reflect.get,YA=Math.pow,XA=function(e,t,n){return t in e?FA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},QA=function(e,t){for(var n in t||(t={}))zA.call(t,n)&&XA(e,n,t[n]);if(GA){var r,i=s(GA(t));try{for(i.s();!(r=i.n()).done;)n=r.value,JA.call(t,n)&&XA(e,n,t[n])}catch(a){i.e(a)}finally{i.f()}}return e},$A=function(e,t){return BA(e,jA(t))},ZA=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}},eR=function(e,t){for(var n in t)FA(e,n,{get:t[n],enumerable:!0})},tR=function(e,t,n){return n=null!=e?VA(WA(e)):{},function(e,t,n,r){if(t&&"object"==k(t)||"function"==typeof t){var i,a=s(HA(t));try{var o=function(){var n=i.value;!zA.call(e,n)&&void 0!==n&&FA(e,n,{get:function(){return t[n]},enumerable:!(r=qA(t,n))||r.enumerable})};for(a.s();!(i=a.n()).done;)o()}catch(c){a.e(c)}finally{a.f()}}return e}(!t&&e&&e.__esModule?n:FA(n,"default",{value:e,enumerable:!0}),e)},nR=function(e,t,n,r){for(var i,a=r>1?void 0:r?qA(t,n):t,o=e.length-1;o>=0;o--)(i=e[o])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&FA(t,n,a),a},rR=function(e,t,n){return XA(e,"symbol"!=k(t)?t+"":t,n)},iR=function(e,t,n){return KA(WA(e),n,t)},aR=function(e,t,n){return new Promise((function(r,i){var a=function(e){try{s(n.next(e))}catch(fO){i(fO)}},o=function(e){try{s(n.throw(e))}catch(fO){i(fO)}},s=function(e){return e.done?r(e.value):Promise.resolve(e.value).then(a,o)};s((n=n.apply(e,t)).next())}))},oR=ZA((function(e,t){var n=Object.prototype.hasOwnProperty,r="~";function i(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new a(n,i||e,o),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 s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)n.call(e,t)&&i.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},c.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,a=n.length,o=new Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,o),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,u=[],l=o.length;c<l;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&u.push(o[c]);u.length?this._events[a]=1===u.length?u[0]:u:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),sR=ZA((function(e,t){var n=t.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")+(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":"")+(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(n).forEach((function(e){n[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),cR=ZA((function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r){var i=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:i&&!n[e.name]&&(n[e.name]={});var a=e.push?{}:i?n[e.name]:n;(function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var a=0;a<r.length;a+=1)null!=e[a+1]&&(n[r[a]]=t(e[a+1]))})(r.match(e.reg),a,e.names,e.name),e.push&&n[e.push].push(a)},r=sR(),i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},a=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(a.push({rtp:[],fmtp:[]}),o=a[a.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(i))return n(c,o,i)}})),t.media=a,t};var a=function(e,n){var r=n.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&n.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(" ").map(t),i=0;i<r.length;i+=3)n.push({component:r[i],ip:r[i+1],port:r[i+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,r=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),r=!0),{scid:n,paused:r}}))}))}})),uR=ZA((function(e,t){var n=sR(),r=/%[sdv%]/g,i=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,(function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},a=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var a=0;a<t.names.length;a+=1){var o=t.names[a];t.name?r.push(n[t.name][o]):r.push(n[t.names[a]])}else r.push(n[t.name]);return i.apply(null,r)},o=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=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||o,i=t.innerOrder||s,c=[];return r.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))})),e.media.forEach((function(e){c.push(a("m",n.m[0],e)),i.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),lR=ZA((function(e){var t=cR(),n=uR();e.write=n,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),dR=ZA((function(e,t){var n=t.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")+(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":"")+(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(n).forEach((function(e){n[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),hR=ZA((function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r){var i=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:i&&!n[e.name]&&(n[e.name]={});var a=e.push?{}:i?n[e.name]:n;(function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var a=0;a<r.length;a+=1)null!=e[a+1]&&(n[r[a]]=t(e[a+1]))})(r.match(e.reg),a,e.names,e.name),e.push&&n[e.push].push(a)},r=dR(),i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},a=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(a.push({rtp:[],fmtp:[]}),o=a[a.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(i))return n(c,o,i)}})),t.media=a,t};var a=function(e,n){var r=n.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&n.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(" ").map(t),i=0;i<r.length;i+=3)n.push({component:r[i],ip:r[i+1],port:r[i+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,r=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),r=!0),{scid:n,paused:r}}))}))}})),fR=ZA((function(e,t){var n=dR(),r=/%[sdv%]/g,i=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,(function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},a=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var a=0;a<t.names.length;a+=1){var o=t.names[a];t.name?r.push(n[t.name][o]):r.push(n[t.names[a]])}else r.push(n[t.name]);return i.apply(null,r)},o=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=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||o,i=t.innerOrder||s,c=[];return r.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))})),e.media.forEach((function(e){c.push(a("m",n.m[0],e)),i.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),pR=ZA((function(e){var t=hR(),n=fR();e.write=n,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),mR=tR(oR()),vR=((UA=vR||{})[UA.INVALID_PARAMETER=4096]="INVALID_PARAMETER",UA[UA.INVALID_OPERATION=4097]="INVALID_OPERATION",UA[UA.NOT_SUPPORTED=4098]="NOT_SUPPORTED",UA[UA.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",UA[UA.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",UA[UA.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",UA[UA.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",UA[UA.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",UA[UA.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",UA[UA.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",UA[UA.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",UA[UA.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",UA[UA.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",UA[UA.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",UA[UA.CLIENT_BANNED=16448]="CLIENT_BANNED",UA[UA.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",UA[UA.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",UA[UA.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",UA[UA.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",UA[UA.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",UA[UA.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",UA[UA.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",UA[UA.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",UA[UA.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",UA[UA.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",UA[UA.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",UA[UA.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",UA[UA.API_CALL_ABORTED=16461]="API_CALL_ABORTED",UA[UA.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",UA[UA.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",UA[UA.UNKNOWN=65535]="UNKNOWN",UA),_R=vR,gR=function(e){function i(e){var a;r(this,i);var o=e.name,s=void 0===o?"RtcError":o,c=e.message,u=e.code,l=void 0===u?_R.UNKNOWN:u,d=e.extraCode,h=void 0===d?0:d,f=e.constraint,p="<".concat(function(e){for(var t in _R)if(_R[t]===e)return t;return"UNKNOWN"}(l)," 0x").concat(l.toString(16),">"),m="".concat(c).concat(f?" constraint: ".concat(f):"").concat(null!=c&&c.includes(p)?"":" ".concat(p));return a=n(this,i,[m]),rR(t(a),"code"),rR(t(a),"extraCode"),rR(t(a),"message"),rR(t(a),"originMessage"),rR(t(a),"name"),rR(t(a),"constraint"),a.code=l,a.extraCode=h,a.name=s,a.message=m,a.constraint=f,a.originMessage=c,a}return d(i,e),o(i,[{key:"getCode",value:function(){return this.code}},{key:"getExtraCode",value:function(){return this.extraCode}},{key:"toString",value:function(){return this.originMessage}}])}(b(Error)),yR=gR,ER=((new Date).getTime(),0),TR=function(){return(new Date).getTime()+ER},kR=function(){var e=new Date;return e.setTime(TR()),e.toLocaleString()},SR=function(e){var t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),"".concat(e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t)},bR={};eR(bR,{bytes2ms:function(){return fw},convertObjectNumberToInt:function(){return nD},copyProperties:function(){return hw},deepClone:function(){return zw},deepMerge:function(){return Ww},delay:function(){return rD},fibonacci:function(){return Ew},formatedTime:function(){return Yw},getConstructorName:function(){return Pw},getContainerFromElement:function(){return Kw},getEnv:function(){return iw},getInternalVersion:function(){return Fw},getLoggerUrl:function(){return ow},getMuteStateFromFlag:function(){return jw},getNetworkType:function(){return cw},getNumNetworkType:function(){return dw},getReconnectionTimeout:function(){return Tw},getStringByteLength:function(){return $w},getTurnServer:function(){return Hw},getUint32Version:function(){return tD},getValueType:function(){return kw},getViewListFromView:function(){return Jw},glog:function(){return _w},ipv4ToUint32:function(){return Gw},isArray:function(){return ww},isAudioWorkletSupported:function(){return Mw},isBoolean:function(){return Rw},isConstructor:function(){return Nw},isEmpty:function(){return qw},isFunction:function(){return Sw},isLangChinese:function(){return gw},isMediaStreamTrack:function(){return Dw},isNumber:function(){return Aw},isObject:function(){return Cw},isOverseaSdkAppId:function(){return aw},isPlainObject:function(){return yw},isPortrait:function(){return Zw},isPromise:function(){return Ow},isRemoteTrack:function(){return xw},isString:function(){return Iw},isUndefined:function(){return bw},loadImage:function(){return eD},ms2bytes:function(){return mw},ms2samples:function(){return vw},performanceNow:function(){return Uw},promiseAny:function(){return Lw},samples2ms:function(){return pw},setNetworkType:function(){return lw},stringify:function(){return Xw},stringifyIncludeValue:function(){return Qw},throttlePromise:function(){return iD}});var IR={};eR(IR,{AUDIO_MUTE_BIT:function(){return lC},AUDIO_STAT_BIT:function(){return uC},AUX_STAT_BIT:function(){return cC},AUX_STREAM_MSID:function(){return mC},BACKEND_ENV:function(){return iC},BASE_DOC_URL:function(){return BR},BASE_HOST:function(){return LR},CAPABILITIES_KEYS:function(){return nw},CLASS_NAME:function(){return JC},CLOUD_CONSOLE_URL:function(){return FR},CROSS_ROOM_BIT:function(){return fC},DATA_FREEZE_TIMING:function(){return BC},DEFAULT_ASSETS_URL:function(){return qR},DOC_URL:function(){return jR},DTLS_STATE_UNKNOWN:function(){return IC},ENV_NAME:function(){return JR},EXCHANGE_SDP_TIMEOUT:function(){return MC},IS_WORKER:function(){return xR},IS_WORKLET:function(){return OR},KIBANA_EVENT:function(){return OC},LOCAL_STREAM_PUBLISH_STATE:function(){return FC},LOGGER_CMD_TYPE:function(){return zR},LOGGER_DOMAIN:function(){return HR},LOGGER_DOMAIN_OVERSEA:function(){return GR},LOG_LEVEL:function(){return KR},LOG_LEVEL_NAME:function(){return $C},MAIN_STREAM_MSID:function(){return pC},MAX_RTT:function(){return rw},MICROPHONE_COMMUNICATIONS:function(){return QC},MICROPHONE_DEFAULT:function(){return YC},MUTE_ALL_BIT:function(){return hC},NAME:function(){return nC},NETWORK_TYPE:function(){return QR},NOT_SUPPORTED_H264:function(){return VC},PAUSED_RETRY_COUNT:function(){return KC},PEERCONNECTION_CONNECTING_TIMEOUT:function(){return GC},PEER_CONNECTION_STATE:function(){return AC},PEER_LEAVE_REASON:function(){return ZC},RECOVER_CAPTURE_INTERVAL:function(){return tw},REMOTE_STREAM_TYPE_AUX:function(){return _C},REMOTE_STREAM_TYPE_MAIN:function(){return vC},RENDER_FREEZE_TIMING:function(){return qC},SCHEDULE_DOMAIN:function(){return WC},SCHEDULE_TIMEOUT:function(){return zC},SDP_SEMANTICS_PLAN_B:function(){return UC},SDP_SEMANTICS_UNIFIED_PLAN:function(){return LC},SECOND_HOST:function(){return UR},SIGNAL_PING_PONG_INTERVAL:function(){return XR},SIGNAL_PING_TIMEOUT:function(){return YR},SIGNAL_RECONNECTION_COUNT:function(){return xC},SMALL_STAT_BIT:function(){return sC},SPEAKER_DEFAULT:function(){return XC},STORAGE_EXPIRES_TIME:function(){return $R},STREAM_TYPE_BIG:function(){return jC},STREAM_TYPE_SMALL:function(){return HC},SUBSCRIBE_SMALL_RETRY_COUNT:function(){return ew},SYNC_USER_LIST_INTERVAL:function(){return NC},Scene:function(){return aC},THIRD_HOST:function(){return VR},TRANSPORT_DIRECTION:function(){return rC},TRTC_ERROR_ASSISTANCE:function(){return WR},TRTC_QUALITY_BAD:function(){return kC},TRTC_QUALITY_DISCONNECTED:function(){return bC},TRTC_QUALITY_EXCELLENT:function(){return yC},TRTC_QUALITY_GOOD:function(){return EC},TRTC_QUALITY_POOR:function(){return TC},TRTC_QUALITY_UNKNOWN:function(){return gC},TRTC_QUALITY_VERY_BAD:function(){return SC},UPDATE_OFFER_TIMEOUT:function(){return PC},VIDEO_MUTE_BIT:function(){return dC},VIDEO_STAT_BIT:function(){return oC},audioProfileMap:function(){return ZR},getRetryCount:function(){return wC},getScriptDir:function(){return NR},innerVersion:function(){return AR},loggerProxy:function(){return PR},screenProfileMap:function(){return tC},setLoggerProxy:function(){return MR},setRetryCount:function(){return CC},setVersion:function(){return CR},version:function(){return RR},videoProfileMap:function(){return eC}});var AR="4.15.00.1600",RR="5.0.0";function CR(e){RR=e;var t=v(e.split(".").map((function(e){return parseInt(e,10)})),3),n=t[0],r=t[1],i=t[2];AR="".concat(n,".").concat(Math.min(15,r),".").concat(Math.min(15,i),".").concat(r.toString().padStart(2,"0")).concat(i.toString().padStart(2,"0"))}var wR,DR,xR="undefined"!=typeof importScripts,OR="undefined"!=typeof registerProcessor,NR=function(){var e=xR?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},PR="",MR=function(e){return PR=e},LR="web.sdk.qcloud.com",UR="web.sdk.tencent.cn",VR="web.sdk.cloud.tencent.cn",FR="https://console.cloud.tencent.com/trtc",BR="https://".concat(LR,"/trtc/webrtc/v5/doc"),qR="https://web.sdk.qcloud.com/trtc/webrtc/v5/assets/",jR="".concat(BR,"/zh-cn/"),HR="https://yun.tim.qq.com",GR="https://apisgp.my-imcloud.com",WR="trtc_error_assistance",zR={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},JR={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},KR=((DR=KR||{})[DR.TRACE=0]="TRACE",DR[DR.DEBUG=1]="DEBUG",DR[DR.INFO=2]="INFO",DR[DR.WARN=3]="WARN",DR[DR.ERROR=4]="ERROR",DR[DR.NONE=5]="NONE",DR),YR=18e3,XR=2e3,QR={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},$R=6048e5,ZR={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:128},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},eC={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},tC={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},nC={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"},rC={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},iC={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},aC=((wR=aC||{}).LIVE="live",wR.RTC="rtc",wR),oC=1,sC=2,cC=4,uC=8,lC=64,dC=16,hC=112,fC=128,pC="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",mC="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",vC=nC.MAIN,_C=nC.AUXILIARY,gC=0,yC=1,EC=2,TC=3,kC=4,SC=5,bC=6,IC="unknown",AC={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},RC=1/0;function CC(e){RC=e}function wC(){return RC}var DC,xC=30,OC={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry"},NC=1e4,PC=1e4,MC=1e4,LC="unified-plan",UC="plan-b",VC=1028,FC=((DC=FC||{})[DC.UNPUBLISH=-1]="UNPUBLISH",DC[DC.PUBLISHING=0]="PUBLISHING",DC[DC.PUBLISHED=1]="PUBLISHED",DC),BC=500,qC=1e3,jC=nC.BIG,HC=nC.SMALL,GC=1e4,WC={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.cloud-rtc.net",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_BACKUP:"intl-schedule.cloud-rtc.com"},zC=2e3,JC={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},KC=5,YC="default",XC=YC,QC="communications",$C=Object.keys(KR),ZC=["normal leave","timeout leave","kick","role change"],ew=10,tw=2e3,nw=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],rw=1e4,iw=function(){return new URLSearchParams(location.search).get("trtc_env")||""},aw=function(e){return Number(e)<14e8},ow=function(e,t){var n;n=PR||(aw(e)?GR:HR);var r=Math.floor(Math.random()*YA(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},sw="unknown";function cw(){if("unknown"!==sw)return sw;var e=navigator,t=e.userAgent,n=e.connection,r=(t.match(/NetType\/\S+/)||[])[0]||"";"3gnet"===(r=r.toLowerCase().replace("nettype/",""))&&(r="3g");var i=n&&n.type&&n.type.toLowerCase(),a=n&&n.effectiveType&&n.effectiveType.toLowerCase();return"slow-2"===a&&(a="2g"),i&&(sw=uw(i,a)),sw}function uw(e,t){if(QR[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function lw(e){sw=uw(e)}function dw(){return QR[cw()]}function hw(e,t){var n,r=s(Reflect.ownKeys(t));try{for(r.s();!(n=r.n()).done;){var i=n.value;if("constructor"!==i&&"prototype"!==i&&"name"!==i){var a=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,a)}}}catch(o){r.e(o)}finally{r.f()}return e}function fw(e){return pw(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function pw(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function mw(e){return 4*vw(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function vw(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var _w="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:function(){},gw=function(){var e=navigator.language;return"zh"===(e=e.substring(0,2))},yw=function(e){if(!e||"object"!=k(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)};function Ew(e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:Ew(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function Tw(e){return e>8?3e4:1e3*Ew(e)}function kw(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var Sw=function(e){return"function"==typeof e},bw=function(e){return void 0===e},Iw=function(e){return"string"==typeof e},Aw=function(e){return"number"==typeof e},Rw=function(e){return"boolean"==typeof e},Cw=function(e){return"object"===kw(e)},ww=function(e){return"array"===kw(e)},Dw=function(e){return kw(e)==="MediaStreamTrack".toLowerCase()},xw=function(e){return e.isRemote},Ow=function(e){return"promise"===kw(e)},Nw=function(e){return Sw(e)&&e.prototype.constructor===e},Pw=function(e){return Nw(e)?e.prototype.constructor.name:""},Mw="undefined"!=typeof AudioWorkletNode;function Lw(e){return new Promise((function(t,n){var r=[];e.forEach((function(i){i.then(t).catch((function(t){r.push(t),r.length===e.length&&n(r)}))}))}))}function Uw(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var Vw=function(e){return+e<10?"0".concat(e):e},Fw=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),r=Vw(n[1])+Vw(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),"".concat(n.join("."),".").concat(r)},Bw=Object.prototype.hasOwnProperty;function qw(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(yw(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(Bw.call(e,t))return!1;return!0}return!1}function jw(e,t){return{userId:t,hasAudio:!!(e&uC),hasVideo:!!(e&oC),hasAuxiliary:!!(e&cC),hasSmall:!!(e&sC),audioMuted:!!(e&lC),videoMuted:!!(e&dC),audioAvailable:!(!(e&uC)||e&lC),videoAvailable:!(!(e&oC)||e&dC)}}function Hw(e){var t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!bw(e.username)&&!bw(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",bw(e.credentialType)||(t.credentialType=e.credentialType)),t}function Gw(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!Iw(e))return 0;var n=e.split(".");return t?(Number(n[0])<<24|Number(n[1])<<16|Number(n[2])<<8|Number(n[3]))>>>0:(Number(n[3])<<24|Number(n[2])<<16|Number(n[1])<<8|Number(n[0]))>>>0}var Ww=function(e,t,n,r){if(!Cw(e)||!Cw(t))return 0;for(var i,a=0,o=Object.keys(t),s=0,c=o.length;s<c;s++)if(i=o[s],!(bw(t[i])||n&&n.includes(i)))if(Cw(e[i])&&Cw(t[i]))a+=Ww(e[i],t[i],n,r);else{if(r&&r.includes(t[i]))continue;e[i]!==t[i]&&(e[i]=zw(t[i]),a+=1)}return a};function zw(e){if(ww(e)){var t=[];return e.forEach((function(e,n){t[n]=zw(e)})),t}if(Cw(e)){var n={};return Object.keys(e).forEach((function(t){n[t]=zw(e[t])})),n}return e}var Jw=function(e){var t=[];if(ww(e))t=E(e);else if(Iw(e)){var n=document.getElementById(e);n&&t.push(n)}else e&&t.push(e);return t},Kw=function(e){return Iw(e)?document.getElementById(e):e},Yw=function(){return function(e){var t=function(e){return e<10?"0".concat(e):"".concat(e)},n=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),a=t(e.getHours()),o=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(n,"/").concat(r,"/").concat(i," ").concat(a,":").concat(o,":").concat(s)}(new Date)};function Xw(e,t){var n=t.keysToInclude,r=t.keysToExclude;try{if(ww(e))return"[".concat(e.map((function(e){return Xw(e,{keysToInclude:n,keysToExclude:r})})).join(","),"]");if(!yw(e)||!ww(n)&&!ww(r))return JSON.stringify(e);var i={},a=new Set(n),o=new Set(r);return Object.keys(e).forEach((function(t){(0===o.size&&a.has(t)||0===a.size&&!o.has(t))&&(i[t]=yw(e[t])||ww(e[t])?JSON.parse(Xw(e[t],{keysToExclude:r,keysToInclude:n})):e[t])})),JSON.stringify(i)}catch(DC){return"{}"}}function Qw(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[];return Object.keys(e).forEach((function(r){t===e[r]&&n.push(r)})),Xw(e,{keysToInclude:n})}function $w(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var Zw=function(){var e,t,n,r;return null!=(e=window.screen)&&e.orientation?!(null==(r=null==(n=null==(t=window.screen)?void 0:t.orientation)?void 0:n.type)||!r.includes("portrait")):0===window.orientation||180===window.orientation},eD=function(e){return aR(void 0,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){var r;if(Iw(e))(r=new Image).crossOrigin="anonymous",r.src=e;else if((r=e).complete)return void t(r);r.onload=function(){return t(r)},r.onerror=function(){n(new yR({code:_R.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}})));case 1:case"end":return t.stop()}}),t)})))},tD=function(e){var t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},nD=function(e){return Object.keys(e).forEach((function(t){Aw(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(yw(e[t])||ww(e[t]))&&nD(e[t])})),e};function rD(e,t){return new Promise((function(n){var r=setTimeout(n,e);t&&t(r)}))}function iD(e,t){var n=null;return function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return n||((n=e.apply(t||this,i)).finally((function(){return n=null})),n)}}function aD(e){var t=e.url,n=e.body,r=e.method,i=void 0===r?"POST":r,a=e.timeout,o=e.priority;return new Promise((function(e,r){if("fetch"in window)return fetch(t,{method:i,body:n,priority:o}).then((function(e){return e.text()})).then((function(t){try{e({data:JSON.parse(t)})}catch(fO){e({data:t})}}),r);var s=new XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState)if(s.status>=200&&s.status<300)try{var n=JSON.parse(s.response);e({data:n})}catch(t){e({data:s.response})}else r({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=a||5e3,s.open(i,t,!0),s.send(n)}))}function oD(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Uw(),r=JSON.stringify(e),t.prev=1,CompressionStream&&!(r.length<=2800)){t.next=4;break}return t.abrupt("return",r);case 4:return i=new Blob([r],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),t.next=7,new Response(i);case 7:return t.next=9,t.sent.blob();case 9:return t.next=11,t.sent.arrayBuffer();case 11:return a=t.sent,t.abrupt("return",(sO.debug("compressJSON ".concat(r.length," -> ").concat(a.byteLength," ").concat(Uw()-n,"ms")),a));case 15:return t.prev=15,t.t0=t.catch(1),t.abrupt("return",r);case 18:case"end":return t.stop()}}),t,null,[[1,15]])})))}var sD=Object.prototype.hasOwnProperty,cD=function(e){return"function"==typeof e},uD=function(e){return void 0===e},lD=function(e){return e.isRemote},dD=function(e){var t=e.retryFunction,n=e.settings,r=e.onError,i=e.onRetrying,a=e.onRetryFailed,o=e.onRetrySuccess,s=e.context;return function(){for(var e=this,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];var d=n.retries,h=void 0===d?5:d,p=n.timeout,m=void 0===p?1e3:p,v=0,_=-1,g=0,y=function(n,c){return aR(e,null,f().mark((function e(){var l,d,p,E,T=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=s||this,e.prev=1,e.next=4,t.apply(l,u);case 4:d=e.sent,v>0&&o&&o.call(this,v),v=0,n(d),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),p=function(){clearTimeout(_),v=0,g=2,c(e.t0)},E=function(){2!==g&&v<(cD(h)?h():h)?(v++,g=1,cD(i)&&i.call(T,v,p),_=window.setTimeout((function(){_=-1,y(n,c)}),cD(m)?m(v):m)):(p(),cD(a)&&a.call(T,e.t0))},cD(r)?r.call(this,{error:e.t0,retry:E,reject:c,retryFuncArgs:u,retriedCount:v}):E();case 12:case"end":return e.stop()}}),e,this,[[1,8]])})))};return new Promise(y)}},hD=function(){return o((function e(t){r(this,e),rR(this,"userId"),rR(this,"remoteUserId"),rR(this,"id"),rR(this,"sdkAppId"),rR(this,"type"),rR(this,"isLocal"),this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal="boolean"!=typeof t.isLocal||t.isLocal,this.type=this.isLocal?"":t.type}),[{key:"createChild",value:function(e){return Object.setPrototypeOf(e,this)}},{key:"setUserId",value:function(e){this.userId=e}},{key:"setSdkAppId",value:function(e){this.sdkAppId=e}},{key:"log",value:function(e,t){var n=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(n?"|".concat(n):"","]")),sO.log(e,t,uD(this.userId)||function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if(!e||"object"!=k(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(sD.call(e,t))return!1;return!0}return!1}(this.userId),this.userId,this.sdkAppId)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(2,t)}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(1,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(4,t)}}])}(),fD={};eR(fD,{ANDROID_VERSION:function(){return AD},CHROME_MAJOR_VERSION:function(){return Dx},CHROME_VERSION:function(){return xx},EDGE_VERSION:function(){return ND},EDG_MAJOR_VERSION:function(){return LD},EDG_VERSION:function(){return MD},FIREFOX_MAJOR_VERSION:function(){return xD},FIREFOX_VERSION:function(){return DD},HUAWEI_VERSION:function(){return _x},IE_VERSION:function(){return JD},IOS_MAIN_VERSION:function(){return Ux},IOS_VERSION:function(){return Lx},IPADQQB_VERSION:function(){return ix},IS_ANDROID:function(){return ID},IS_ANDROID_WEBVIEW:function(){return Mx},IS_ANY_SAFARI:function(){return Nx},IS_CHROME:function(){return Cx},IS_CHROME_OS:function(){return cx},IS_CHROMIUM_BASE:function(){return Rx},IS_EDG:function(){return PD},IS_EDGE:function(){return OD},IS_ELECTRON:function(){return dx},IS_FIREFOX:function(){return wD},IS_HEADLESS_CHROME:function(){return wx},IS_HONOR:function(){return vx},IS_HUAWEI:function(){return mx},IS_HUAWEIBROWSER:function(){return px},IS_IE:function(){return zD},IS_IE8:function(){return WD},IS_IOS:function(){return bD},IS_IOS_13_OR_14:function(){return Bx},IS_IOS_15_1:function(){return Fx},IS_IPAD:function(){return ED},IS_IPADQQB:function(){return rx},IS_IPAD_PRO:function(){return TD},IS_IPHONE:function(){return kD},IS_IPOD:function(){return SD},IS_LINUX:function(){return sx},IS_LOCAL:function(){return qx},IS_MAC:function(){return ox},IS_MACQQB:function(){return tx},IS_MIBROWSER:function(){return hx},IS_MQQB:function(){return QD},IS_NATIVE_ANDROID:function(){return CD},IS_OLD_ANDROID:function(){return RD},IS_OPENHARMONY:function(){return bx},IS_OPPOBROWSER:function(){return Ex},IS_SAFARI:function(){return Ox},IS_SAFARI_15_1:function(){return Vx},IS_SAMSUNGBROWSER:function(){return gx},IS_SOGOU:function(){return FD},IS_SOGOUM:function(){return UD},IS_TBS:function(){return qD},IS_UCBROWSER:function(){return lx},IS_VIVOBROWSER:function(){return kx},IS_WECHAT:function(){return KD},IS_WIN:function(){return ax},IS_WQQB:function(){return ZD},IS_WX:function(){return ux},IS_X5MQQB:function(){return XD},IS_XWEB:function(){return HD},MACQQB_VERSION:function(){return nx},MI_VERSION:function(){return fx},MQQB_VERSION:function(){return $D},OPENHARMONY_VERSION:function(){return Ix},OPPO_VERSION:function(){return Tx},SAFARI_VERSION:function(){return Px},SAMSUNG_VERSION:function(){return yx},SOGOUM_VERSION:function(){return VD},SOGOU_VERSION:function(){return BD},TBS_VERSION:function(){return jD},UA_DATA_STRING:function(){return Jx},USER_AGENT:function(){return pD},VIVO_VERSION:function(){return Sx},WECHAT_VERSION:function(){return YD},WQQB_VERSION:function(){return ex},XWEB_VERSION:function(){return GD},browserInfo:function(){return Hx},getBrowserInfo:function(){return Gx},getChromeMajorVersion:function(){return Ax},getDeviceModel:function(){return Yx},getOSName:function(){return Qx},getOSNumber:function(){return $x},getOSString:function(){return Zx},getOSType:function(){return tO},getTerminalType:function(){return eO},getUserAgentData:function(){return Kx},isLocalStorageEnabled:function(){return jx},isMobile:function(){return zx}});var pD="undefined"==typeof navigator?"":navigator.userAgent,mD=function(e){return new RegExp(e,"i").test(pD)},vD=function(e){if(mD(e)){var t=new RegExp("".concat(e,"\\/([\\d.]+)")),n=pD.match(t);if(n&&n[1])return n[1]}return""},_D=function(e){if(mD(e)){var t=new RegExp("".concat(e,"\\/(\\d+)")),n=pD.match(t);if(n&&n[1])return parseFloat(n[1])}return NaN},gD=/AppleWebKit\/([\d.]+)/i.exec(pD),yD=gD?parseFloat(gD[1]):NaN,ED=mD("iPad"),TD="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&mD("Macintosh"),kD=mD("iPhone")&&!ED,SD=mD("iPod"),bD=kD||ED||SD||TD,ID=mD("Android"),AD=function(){if(ID){var e=pD.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);if(t&&n)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}return NaN}(),RD=ID&&mD("webkit")&&AD<2.3,CD=ID&&AD<5&&yD<537,wD=mD("Firefox"),DD=vD("Firefox"),xD=_D("Firefox"),OD=mD("Edge"),ND=vD("Edge"),PD=mD("Edg"),MD=vD("Edg"),LD=_D("Edg"),UD=mD("SogouMobileBrowser"),VD=vD("SogouMobileBrowser"),FD=mD("MetaSr\\s"),BD=vD("MetaSr\\s"),qD=mD("TBS"),jD=vD("TBS"),HD=mD("XWEB"),GD=vD("XWEB"),WD=mD("MSIE\\s8\\.0"),zD=mD("MSIE\\/\\d+"),JD=function(){if(zD){var e=/MSIE\s(\d+)\.\d/.exec(pD),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(pD)&&/rv:11.0/.test(pD)&&(t=11),t}return NaN}(),KD=mD("(micromessenger|webbrowser)"),YD=vD("MicroMessenger"),XD=!qD&&mD("MQQBrowser")&&mD("COVC"),QD=!qD&&mD("MQQBrowser")&&!mD("COVC"),$D=QD||XD?vD("MQQBrowser"):"",ZD=!qD&&mD(" QQBrowser"),ex=vD(" QQBrowser"),tx=!qD&&mD("QQBrowserLite"),nx=vD("QQBrowserLite"),rx=!qD&&mD("MQBHD"),ix=vD("MQBHD"),ax=mD("Windows"),ox=!bD&&mD("MAC OS X"),sx=!ID&&mD("Linux"),cx=mD("CrOS"),ux=mD("MicroMessenger"),lx=mD("UCBrowser"),dx=mD("Electron"),hx=mD("MiuiBrowser"),fx=vD("MiuiBrowser"),px=mD("HuaweiBrowser"),mx=mD("Huawei")||mD("HUAWEI"),vx=mD("Honor")||mD("HONOR"),_x=vD("HuaweiBrowser"),gx=mD("SamsungBrowser"),yx=vD("SamsungBrowser"),Ex=mD("HeyTapBrowser"),Tx=vD("HeyTapBrowser"),kx=mD("VivoBrowser"),Sx=vD("VivoBrowser"),bx=mD("OpenHarmony"),Ix=vD("OpenHarmony"),Ax=function(){return _D("Chrome")},Rx=mD("Chrome"),Cx=!OD&&!FD&&!UD&&!qD&&!HD&&!PD&&!ZD&&!hx&&!px&&!gx&&!Ex&&!kx&&Rx,wx=mD("HeadlessChrome"),Dx=Ax(),xx=vD("Chrome"),Ox=!Rx&&!QD&&!XD&&!tx&&!rx&&mD("Safari"),Nx=Ox||bD,Px=vD("Version"),Mx=/Android.*(wv|.0.0.0)/.test(pD),Lx=function(){if(TD)return Px;if(bD){var e=pD.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),Ux=Number(Lx.split(".")[0]),Vx="15.1"===Px,Fx="15.1"===Lx,Bx=function(){var e=Number(Lx.split(".")[0]);return 14===e||13===e}(),qx="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),jx=function(){var e;return function(){if(void 0===e)try{e=!!window.localStorage}catch(mO){e=!1}return e}}(),Hx=Gx();function Gx(){var e,t=new Map([[wD,["Firefox",DD]],[PD,["Edg",MD]],[Cx,["Chrome",xx]],[Ox,["Safari",Px]],[qD,["TBS",jD]],[HD,["XWEB",GD]],[KD&&kD,["WeChat",YD]],[ZD,["QQ(Win)",ex]],[QD,["QQ(Mobile)",$D]],[XD,["QQ(Mobile X5)",$D]],[tx,["QQ(Mac)",nx]],[rx,["QQ(iPad)",ix]],[hx,["MI",fx]],[px,["HW",_x]],[gx,["Samsung",yx]],[Ex,["OPPO",Tx]],[kx,["VIVO",Sx]],[OD,["EDGE",ND]],[UD,["SogouMobile",VD]],[FD,["Sogou",BD]]]),n="unknown",r="unknown";return t.has(!0)&&(n=(e=v(t.get(!0),2))[0],r=e[1]),{name:n,version:r}}var Wx=null;function zx(){return Wx&&"boolean"==typeof Wx.mobile?Wx.mobile:ID||bD||kD||ED||bx}var Jx="";function Kx(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Wx){e.next=2;break}return e.abrupt("return",Wx);case 2:if(navigator.userAgentData&&"function"==typeof navigator.userAgentData.getHighEntropyValues){e.next=4;break}return e.abrupt("return",null);case 4:return e.prev=4,e.next=7,navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]);case 7:if(e.t0=Wx=e.sent,!e.t0){e.next=10;break}e.t0=!Jx;case 10:if(e.t1=e.t0,!e.t1){e.next=13;break}Jx="UAData: ".concat(Wx.platform,"/").concat(Wx.platformVersion),Wx.architecture&&Wx.bitness&&(Jx+=" ".concat(Wx.architecture,"/").concat(Wx.bitness)),Wx.mobile&&(Jx+=" mobile"),Wx.model&&(Jx+=" model: ".concat(Wx.model)),Wx.fullVersionList&&(Jx+=" ".concat(Wx.fullVersionList.filter((function(e){return"Not/A)Brand"!==e.brand})).map((function(e){return"".concat(e.brand,"/").concat(e.version)})).join(",")));case 13:return e.abrupt("return",Wx);case 16:return e.prev=16,e.t2=e.catch(4),e.abrupt("return",null);case 19:case"end":return e.stop()}}),e,null,[[4,16]])})))}function Yx(){return(null==Wx?void 0:Wx.model)||""}var Xx=new Map([[ID,"Android"],[bD,"iOS"],[ax,"Windows"],[ox,"MacOS"],[sx,"Linux"],[cx,"ChromeOS"]]),Qx=function(){return Xx.get(!0)?Xx.get(!0):Wx?Wx.platform:"unknown"};function $x(){return ax?1:ID?2:ox?3:bD?4:sx?5:cx?6:0}var Zx=function(){var e=Qx();return e+="/".concat(Hx.name,"/").concat(Ox?Hx.version:Hx.version.split(".")[0]),null!=Wx&&Wx.platformVersion&&(e+="/".concat(Wx.platformVersion)),null!=Wx&&Wx.architecture&&(e+="/".concat(Wx.architecture)),e};function eO(){return ID?4:kD?2:ED?3:ox?12:ax?5:sx?13:bx?22:1}function tO(){return ID?"Android":kD?"iPhone":ED?"iPad":ox?"Mac":ax?"Windows":sx?"Linux":"unknown"}var nO,rO=new(tR(oR(),1).default),iO=((nO=iO||{}).ROOM_DESTROY="1",nO.JOIN_START="21",nO.JOIN_SCHEDULE_SUCCESS="22",nO.JOIN_SIGNAL_CONNECTION_START="23",nO.JOIN_SIGNAL_CONNECTION_END="24",nO.JOIN_SEND_CMD="25",nO.JOIN_RECEIVED_CMD_RES="26",nO.JOIN_SUCCESS="27",nO.JOIN_FAILED="28",nO.LEAVE_START="51",nO.LEAVE_SEND_CMD="52",nO.LEAVE_SUCCESS="53",nO.PUBLISH_START="61",nO.SEND_FIRST_VIDEO_FRAME="62",nO.PUBLISH_FAILED="63",nO.SUBSCRIBE_START="81",nO.SUBSCRIBE_SUCCESS="82",nO.SUBSCRIBE_FAILED="84",nO.UNSUBSCRIBE_SUCCESS="83",nO.LOCAL_TRACK_CAPTURE_START="101",nO.LOCAL_TRACK_CAPTURE_SUCCESS="102",nO.LOCAL_TRACK_CAPTURE_FAILED="103",nO.LOCAL_TRACK_PUBLISHED="104",nO.LOCAL_TRACK_UNPUBLISHED="105",nO.LOCAL_TRACK_REPLACED="106",nO.SWITCH_DEVICE_SUCCESS="107",nO.TRACK_MUTED="108",nO.TRACK_UNMUTED="109",nO.REMOTE_TRACK_SUBSCRIBED="110",nO.REMOTE_TRACK_UNSUBSCRIBED="111",nO.LOCAL_TRACK_RECAPTURE="112",nO.PLAY_TRACK_START="151",nO.PLAYER_STATE_CHANGED="152",nO.VIDEO_LOADED_DATA="153",nO.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",nO.SIGNAL_CONNECTION_STATE_CHANGED="201",nO.PEER_CONNECTION_STATE_CHANGED="202",nO.SINGLE_CONNECTION_STAT="203",nO.SPC_RECONNECTED="204",nO.HEARTBEAT_REPORT="251",nO.RECEIVED_PUBLISHED_USER_LIST="252",nO.REMOTE_PUBLISH_STATE_CHANGED="253",nO.AUDIO_LEVEL_INTERVAL="260",nO.NETWORK_QUALITY="261",nO.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",nO.QUALITY_LIMITATION_CHANGED="263",nO.LOG="264",nO),aO=iO,oO=function(){function e(){r(this,e),rR(this,"_isEnableUploadLog",!0),rR(this,"_localJoinedUser",new Map),rR(this,"_queue",[]),rR(this,"_timeoutId",-1),rR(this,"_logLevel",1),rR(this,"_logLevelToUpload",2),!xR&&!OR&&(this.checkURLParam(),this.installEvents())}return o(e,[{key:"isAbleToUpload",get:function(){return this._isEnableUploadLog&&-1!==this._timeoutId}},{key:"installEvents",value:function(){var e=this;rO.on(aO.JOIN_SCHEDULE_SUCCESS,(function(t){var n,r=t.schedule;null!=(n=null==r?void 0:r.config)&&n.logLevelToUpload&&KR[r.config.logLevelToUpload]&&(e._logLevelToUpload=r.config.logLevelToUpload)})),rO.on(aO.JOIN_SUCCESS,(function(t){var n=t.room;e.addJoinedUser({userId:n.userId,sdkAppId:n.sdkAppId}),e.startUpload()})),rO.once(aO.JOIN_FAILED,(function(){e.startUpload()})),rO.on(aO.LEAVE_SUCCESS,(function(t){var n=t.room;e.deleteJoinedUser(n.userId)}))}},{key:"startUpload",value:function(){-1===this._timeoutId&&this.uploadInterval()}},{key:"addJoinedUser",value:function(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}},{key:"deleteJoinedUser",value:function(e){this._localJoinedUser.delete(e)}},{key:"uploadInterval",value:function(){var e=this;this.upload().catch((function(){})),this._timeoutId=window.setTimeout((function(){return e.uploadInterval()}),5e3)}},{key:"getLogsToUpload",value:function(){var e=this,t={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return t;for(var n=0,r=function(){var r=e._queue[n];if(r.forAllJoinedClients)e._localJoinedUser.forEach((function(e){var n=e.userId,i=e.sdkAppId;t.map.has(n)?t.map.get(n).logs.push(r):t.map.set(n,{userId:n,sdkAppId:i,logs:[r]})}));else if(Iw(r.userId)&&Aw(r.sdkAppId)){var i=r.userId,a=r.sdkAppId;t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:a,logs:[r]})}};n<this._queue.length&&50!==n;n++)r();return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,n)),t}},{key:"upload",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u,l;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._queue.length&&this._isEnableUploadLog){e.next=2;break}return e.abrupt("return");case 2:if(t=this.getLogsToUpload(),n=t.map,r=t.splicedQueue,0!==n.size){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,i=E(n.values()),a=0;case 8:if(!(a<i.length)){e.next=16;break}return o=i[a],s=o.userId,c=o.sdkAppId,u=o.logs,e.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:kR(),sdkAppId:String(c),userId:s,version:RR,log:u.map((function(e){return e.log})).join("\n")}),c);case 12:u.forEach((function(e){return e.uploaded=!0}));case 13:a++,e.next=8;break;case 16:e.next=20;break;case 18:e.prev=18,e.t0=e.catch(5);case 20:l=r.filter((function(e){return!e.uploaded})),l.length>0&&(this._queue=l.concat(this._queue));case 22:case"end":return e.stop()}}),e,this,[[5,18]])})))}},{key:"uploadLogWithRetry",value:function(e,t){return dD({retryFunction:function(){return aD({url:ow(t,zR.LOG),body:e,timeout:5e3,priority:"low"})},settings:{retries:3,timeout:2e3},onError:function(e){(0,e.retry)()}})()}},{key:"getPrefix",value:function(e){var t=new Date;return t.setTime(TR()),"[".concat(SR(t),"] <").concat(KR[e],">")}},{key:"getLogLevel",value:function(){return this._logLevel}},{key:"setLogLevel",value:function(e){bw(KR[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}},{key:"enableUploadLog",value:function(){this._isEnableUploadLog=!0}},{key:"disableUploadLog",value:function(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}},{key:"logChunkToString",value:function(e){if(Iw(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(wR){return""}}},{key:"log",value:function(t,n){var r,i,a,o=this,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=arguments.length>3?arguments[3]:void 0,u=arguments.length>4?arguments[4]:void 0;n.unshift(this.getPrefix(t));var l={log:n.reduce((function(e,t){return"".concat(e," ").concat(o.logChunkToString(t)).trim()}),""),level:t,userId:c,sdkAppId:u,forAllJoinedClients:s};if(rO.emit(aO.LOG,{log:l}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(l),!(t<this._logLevel)){var d=(null==(a=KR[t])?void 0:a.toLowerCase())||"info";e.PRINT_LOG_TAG?(r=console)[d].apply(r,["%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline"].concat(E(n))):(i=console)[d].apply(i,E(n))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(1,t)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(2,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(4,t)}},{key:"createLogger",value:function(e){return new hD(e)}},{key:"checkURLParam",value:function(){var e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;KR[t]&&(this._logLevelToUpload=t)}},{key:"getQueue",value:function(){return this._queue}}])}();rR(oO,"PRINT_LOG_TAG",!(bD||ID||wx));var sO=new oO,cO=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},uO=new(function(){return o((function e(){r(this,e),rR(this,"_prefix","TRTC"),rR(this,"_queue",new Map)}),[{key:"getRealKey",value:function(e){return"".concat(this._prefix,"_").concat(e)}},{key:"checkStorage",value:function(){var e=this;jx()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((function(t){if(t.startsWith(e._prefix))try{var n=localStorage.getItem(t);if(!n)return!1;var r=JSON.parse(n);if(r&&r.expiresIn<Date.now())return!0}catch(vO){return!1}return!1})).forEach((function(e){return localStorage.removeItem(e)})))}},{key:"doFlush",value:function(){if(jx())try{var e,t=s(this._queue);try{for(t.s();!(e=t.n()).done;){var n=v(e.value,2),r=n[0],i=n[1];localStorage.setItem(r,JSON.stringify(i))}}catch(a){t.e(a)}finally{t.f()}}catch(mO){sO.warn(mO)}}},{key:"getItem",value:function(e){if(!jx())return null;try{var t=localStorage.getItem(this.getRealKey(e));if(!t)return null;var n=JSON.parse(t);return n&&n.expiresIn>=Date.now()?n.value:null}catch(wR){sO.warn(wR)}}},{key:"setItem",value:function(e,t){if(jx())try{var n={expiresIn:Date.now()+$R,value:t};this._queue.set(this.getRealKey(e),n)}catch(DC){sO.warn(DC)}}},{key:"deleteItem",value:function(e){if(!jx())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(wR){return sO.warn(wR),!1}}},{key:"clear",value:function(){if(jx())try{localStorage.clear()}catch(mO){sO.warn(mO)}}}])}()),lO={};eR(lO,{HTTPS_API:function(){return qN},IS_GET_CAPABILITIES_SUPPORTED:function(){return oP},IS_GET_SETTINGS_SUPPORTED:function(){return aP},IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:function(){return iP},IS_INSERTABLE_STREAM_SUPPORTED:function(){return sP},IS_JITTER_BUFFER_TARGET_SUPPORTED:function(){return yP},IS_RTC_RTP_SENDER_SUPPORTED:function(){return tP},IS_SCRIPT_TRANSFORM_SUPPORTED:function(){return cP},IS_SEI_SUPPORTED:function(){return uP},IS_SPC_SUPPORTED:function(){return ZN},basis:function(){return mP},capabilityCheck:function(){return _P},checkSystemRequirementsInternal:function(){return UN},decodeSupportStatus:function(){return LN},encodeSupportStatus:function(){return MN},getBrowserInfo:function(){return CN},getDisplayResolution:function(){return HN},isAddTransceiverSupported:function(){return $N},isBrowserSupported:function(){return wN},isGetReceiversSupported:function(){return YN},isGetSendersSupported:function(){return XN},isGetTransceiversSupported:function(){return QN},isGetUserMediaSupported:function(){return GN},isMediaDevicesSupported:function(){return xN},isMediaSessionSupported:function(){return hP},isMediaStreamTrackProcessorSupported:function(){return PN},isReplaceTrackSupported:function(){return nP},isRequestVideoFrameCallbackSupported:function(){return gP},isSIMDSupported:function(){return pP},isScreenCaptureApiAvailable:function(){return FN},isSelectedCandidatePair:function(){return jN},isSetParametersSupported:function(){return rP},isSmallStreamAPISupported:function(){return zN},isSmallStreamSupported:function(){return JN},isStopTransceiverSupported:function(){return eP},isTRTCSupported:function(){return VN},isUnifiedPlanDefault:function(){return KN},isUsedInHttpProtocol:function(){return NN},isWebAudioSupported:function(){return WN},isWebCodecSupported:function(){return dP},isWebCodecsSupported:function(){return DN},isWebRTCSupported:function(){return lP},isWebTransportSupported:function(){return fP}});var dO={};eR(dO,{AUDIO_LEVEL_SCALE:function(){return tN},AudioCodecPipelineType:function(){return oN},AudioDecoderDowngradeState:function(){return LO},AudioPlayerMode:function(){return $O},AudioType:function(){return jO},BASIC_TYPE:function(){return rN},BannedReason:function(){return ZO},CONNECTION_CLOSED_REASON:function(){return SO},ClientEvent:function(){return bO},CodecType:function(){return sN},ConnectionEvent:function(){return kO},ConnectionState:function(){return MO},DECODE_FAILED_ERROR_CODE:function(){return cN},FacingMode:function(){return XO},LeaveReason:function(){return eN},LocalTrackEvent:function(){return AO},MULTI_VIDEO_DATA_TYPE:function(){return zO},MediaType:function(){return BO},MediaTypeLabel:function(){return qO},MonitorEventId:function(){return JO},MutedFlag:function(){return xO},NetworkQualityValue:function(){return KO},PlayerState:function(){return RO},ReceiveMode:function(){return YO},RemoteStreamType:function(){return WO},RemoteTrackEvent:function(){return DO},RoomEvent:function(){return CO},SceneNumber:function(){return OO},StreamEvent:function(){return IO},StreamType:function(){return GO},SubscribeMediaType:function(){return nN},TIMER_TYPE:function(){return lN},TRACK_ACTION:function(){return FO},TRACK_KIND:function(){return VO},TrackEvent:function(){return wO},UserRole:function(){return PO},UserRoleNumber:function(){return NO},VideoCodec:function(){return iN},VideoCodecPipelineType:function(){return aN},VideoContentHint:function(){return uN},VideoDecoderDowngradeState:function(){return UO},VideoPlayerMode:function(){return QO},VideoType:function(){return HO}});var hO,fO,pO,mO,vO,_O,gO,yO,EO,TO,kO=((TO=kO||{}).TRACK_ADDED="track-added",TO.TRACK_UPDATED="track-updated",TO.TRACK_SUBSCRIBED="track-subscribed",TO.STREAM_ADDED="stream-added",TO.STREAM_REMOVED="stream-removed",TO.STREAM_UPDATED="stream-updated",TO.STREAM_PUBLISHED="stream-published",TO.STREAM_SUBSCRIBED="stream-subscribed",TO.STREAM_UNSUBSCRIBED="stream-unsubscribed",TO.STATE_CHANGED="state-changed",TO.ERROR="error",TO.CONNECTION_STATE_CHANGED="connection-state-changed",TO.FIREWALL_RESTRICTION="firewall-restriction",TO.SEI_MESSAGE="sei-message",TO.CLOSED="closed",TO),SO=function(e){return e.REMOTE_LEAVE="remote user exitRoom",e.REMOTE_UNPUBLISH="remote user unpublished",e.LOCAL_LEAVE="you exitRoom",e.LOCAL_UNPUBLISH="you unpublished",e.LOCAL_UNSUBSCRIBE="you unsubscribed",e.SWITCH_ROLE="you switch role to audience",e}(SO||{}),bO=((EO=bO||{}).STREAM_ADDED="stream-added",EO.STREAM_REMOVED="stream-removed",EO.STREAM_UPDATED="stream-updated",EO.STREAM_SUBSCRIBED="stream-subscribed",EO.CONNECTION_STATE_CHANGED="connection-state-changed",EO.PEER_JOIN="peer-join",EO.PEER_LEAVE="peer-leave",EO.MUTE_AUDIO="mute-audio",EO.MUTE_VIDEO="mute-video",EO.UNMUTE_AUDIO="unmute-audio",EO.UNMUTE_VIDEO="unmute-video",EO.CLIENT_BANNED="client-banned",EO.NETWORK_QUALITY="network-quality",EO.AUDIO_VOLUME="audio-volume",EO.SEI_MESSAGE="sei-message",EO.ERROR="error",EO),IO=((yO=IO||{}).PLAYER_STATE_CHANGED="player-state-changed",yO.SCREEN_SHARING_STOPPED="screen-sharing-stopped",yO.CONNECTION_STATE_CHANGED="connection-state-changed",yO.DEVICE_AUTO_RECOVERED="device-auto-recovered",yO.ERROR="error",yO),AO=function(e){return e.DEVICE_AUTO_RECOVERED="1",e.DEVICE_RECOVER_FAILED="5",e.DEVICE_CHANGED="2",e.ERROR="3",e.PUBLISH_STATE_CHANGED="4",e.ENCODE_FAILED="6",e}(AO||{}),RO=function(e){return e.PAUSED="PAUSED",e.PLAYING="PLAYING",e.STOPPED="STOPPED",e}(RO||{}),CO=((gO=CO||{}).PEER_JOIN="peer-join",gO.PEER_LEAVE="peer-leave",gO.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",gO.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",gO.BANNED="banned",gO.NETWORK_QUALITY="network-quality",gO.AUDIO_VOLUME="audio-volume",gO.SEI_MESSAGE="sei-message",gO.ERROR="error",gO.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",gO.REMOTE_PUBLISHED="remote-published",gO.REMOTE_UNPUBLISHED="remote-unpublished",gO.FIREWALL_RESTRICTION="firewall-restriction",gO.HEARTBEAT_REPORT="heartbeat-report",gO.CUSTOM_MESSAGE="custom-message",gO.LAYER_DATA="layerData",gO.FIRST_VIDEO_FRAME="first-video-frame",gO.DUMP="dump",gO),wO=((_O=wO||{}).PLAYER_STATE_CHANGED="player-state-changed",_O.MUTE="mute",_O.UNMUTE="unmute",_O.ERROR="error",_O.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",_O.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",_O.FIRST_VIDEO_FRAME="first-video-frame",_O),DO=function(e){return e.DECODE_FAILED="decode-failed",e.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",e}(DO||{}),xO=function(e){return e[e.VIDEO=1]="VIDEO",e[e.SMALL=2]="SMALL",e[e.AUX=4]="AUX",e[e.AUDIO=8]="AUDIO",e[e.VIDEO_MUTE=16]="VIDEO_MUTE",e[e.AUX_MUTE=32]="AUX_MUTE",e[e.AUDIO_MUTE=64]="AUDIO_MUTE",e}(xO||{}),OO=function(e){return e[e.RTC=1]="RTC",e[e.LIVE=2]="LIVE",e}(OO||{}),NO=function(e){return e[e.ANCHOR=20]="ANCHOR",e[e.AUDIENCE=21]="AUDIENCE",e}(NO||{}),PO=function(e){return e.ANCHOR="anchor",e.AUDIENCE="audience",e}(PO||{}),MO=function(e){return e.CONNECTED="CONNECTED",e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.RECONNECTED="RECONNECTED",e.RECONNECTING="RECONNECTING",e}(MO||{}),LO=((vO=LO||{}).INITIALIZED="INITIALIZED",vO.STARTING="STARTING",vO.STARTED="STARTED",vO.FAILED="FAILED",vO),UO=function(e){return e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e}(UO||{}),VO=function(e){return e.AUDIO="audio",e.VIDEO="video",e.AUXILIARY="auxVideo",e}(VO||{}),FO=function(e){return e.ADD="add",e.REMOVE="remove",e}(FO||{}),BO=function(e){return e[e.NULL=0]="NULL",e[e.AUDIO=1]="AUDIO",e[e.AUX_VIDEO=2]="AUX_VIDEO",e[e.BIG_VIDEO=4]="BIG_VIDEO",e[e.SMALL_VIDEO=8]="SMALL_VIDEO",e}(BO||{}),qO={1:"audio",2:"auxVideo",4:"video"},jO=((mO=jO||{})[mO.opus=111]="opus",mO),HO=function(e){return e[e.h264=100]="h264",e[e.vp8=101]="vp8",e}(HO||{}),GO=function(e){return e.Big="big",e.Small="small",e}(GO||{}),WO=function(e){return e.Main="main",e.Aux="auxiliary",e}(WO||{}),zO=function(e){return e[e.MULTI_DATA_AUDIO=1]="MULTI_DATA_AUDIO",e[e.MULTI_DATA_BIG_IMG=2]="MULTI_DATA_BIG_IMG",e[e.MULTI_DATA_SMALL_IMG=3]="MULTI_DATA_SMALL_IMG",e[e.MULTI_DATA_AUX_IMG=7]="MULTI_DATA_AUX_IMG",e[e.MULTI_DATA_TYPE_BUTT=12]="MULTI_DATA_TYPE_BUTT",e}(zO||{}),JO=((pO=JO||{})[pO.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",pO[pO.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",pO[pO.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",pO[pO.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",pO[pO.MUTE_AUDIO=32772]="MUTE_AUDIO",pO[pO.MUTE_VIDEO=32773]="MUTE_VIDEO",pO[pO.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",pO[pO.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",pO[pO.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",pO[pO.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",pO[pO.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",pO[pO.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",pO[pO.SWITCH_CAMERA=32780]="SWITCH_CAMERA",pO[pO.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",pO[pO.REPLACE_VIDEO=32782]="REPLACE_VIDEO",pO[pO.REPLACE_AUDIO=32783]="REPLACE_AUDIO",pO[pO.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",pO[pO.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",pO[pO.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",pO[pO.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",pO[pO.JOIN=32788]="JOIN",pO[pO.LEAVE=32789]="LEAVE",pO[pO.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",pO[pO.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",pO[pO.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",pO[pO.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",pO[pO.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",pO[pO.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",pO[pO.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",pO[pO.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",pO[pO.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",pO[pO.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",pO[pO.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",pO[pO.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",pO[pO.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",pO[pO.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",pO[pO.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",pO[pO.PUBLISH_AUX=32805]="PUBLISH_AUX",pO[pO.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",pO[pO.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",pO[pO.VIDEO_ENCODER=4004]="VIDEO_ENCODER",pO[pO.VIDEO_DECODER=4005]="VIDEO_DECODER",pO),KO=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.VERY_BAD=5]="VERY_BAD",e[e.DISCONNECTED=6]="DISCONNECTED",e}(KO||{}),YO=function(e){return e[e.MANUAL=0]="MANUAL",e[e.AUTO_AUDIO=1]="AUTO_AUDIO",e[e.AUTO_VIDEO=2]="AUTO_VIDEO",e[e.AUTO_ALL=3]="AUTO_ALL",e}(YO||{}),XO=function(e){return e.user="user",e.environment="environment",e}(XO||{}),QO=function(e){return e[e.ELEMENT=0]="ELEMENT",e[e.CANVAS_FROM_ELEMENT=1]="CANVAS_FROM_ELEMENT",e[e.CANVAS_WITHOUT_ELEMENT=2]="CANVAS_WITHOUT_ELEMENT",e}(QO||{}),$O=function(e){return e[e.ELEMENT=0]="ELEMENT",e[e.CONTEXT=1]="CONTEXT",e}($O||{}),ZO=function(e){return e.BANNED="banned",e.KICK="kick",e.USER_TIME_OUT="user_time_out",e.ROOM_DISBAND="room_disband",e}(ZO||{}),eN=((fO=eN||{})[fO.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",fO[fO.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",fO[fO.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",fO[fO.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",fO[fO.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",fO[fO.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",fO[fO.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",fO[fO.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",fO[fO.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",fO),tN=1e8,nN=function(){return o((function e(){r(this,e),rR(this,"mediaType",0)}),[{key:"audio",get:function(){return!!(1&this.mediaType)},set:function(e){e?this.mediaType|=1:this.mediaType&=-2}},{key:"video",get:function(){return!!(4&this.mediaType)},set:function(e){e?this.mediaType|=4:this.mediaType&=-5}},{key:"auxiliary",get:function(){return!!(2&this.mediaType)},set:function(e){e?this.mediaType|=2:this.mediaType&=-3}},{key:"smallVideo",get:function(){return!!(8&this.mediaType)},set:function(e){e?this.mediaType|=8:this.mediaType&=-9}}])}(),rN=function(e){return e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object",e}(rN||{}),iN=function(e){return e.H264="h264",e.H265="h265",e.VP8="vp8",e}(iN||{}),aN=function(e){return e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.DUMP=1]="DUMP",e[e.SEI=2]="SEI",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e}(aN||{}),oN=function(e){return e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.NTP_TO_AUDIO_FRAME=1]="NTP_TO_AUDIO_FRAME",e[e.DUMP=2]="DUMP",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e}(oN||{}),sN=function(e){return e.WebRTC="webrtc",e.WebCodecs="webcodecs",e.WebAssembly="webassembly",e}(sN||{}),cN=((hO=cN||{})[hO.SUCCESS=0]="SUCCESS",hO[hO.FAILED=1]="FAILED",hO[hO.WEBCODEC_INIT=2]="WEBCODEC_INIT",hO[hO.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",hO[hO.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",hO[hO.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",hO[hO.WASM_INIT=6]="WASM_INIT",hO[hO.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",hO[hO.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",hO[hO.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",hO[hO.TEST=10]="TEST",hO),uN=function(e){return e.NONE="",e.DETAIL="detail",e.MOTION="motion",e.TEXT="text",e}(uN||{}),lN=function(e){return e.INTERVAL="interval",e.TIMEOUT="timeout",e.RAF="raf",e.RIC="ric",e.INTERVAL_IN_WORKER="intervalInWorker",e}(lN||{}),dN={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},hN={AVOID_REPEATED_CALL:function(e){return"previous ".concat(e.name,"() is ongoing, please avoid repeated calls.")},INVALID_PARAMETER_REQUIRED:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_PARAMETER_TYPE:function(e){var t,n=e.key,r=e.rule,i=e.fnName,a=e.value,o="".concat(n||r.name);return t=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(o,"' must be type of ").concat(t," when calling ").concat(i,"(), received type: ").concat(kw(a),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' cannot be '").concat(i,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value,a="".concat(t||n.name),o="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(a,"' must be instanceof ").concat(o," when calling ").concat(r,"(), received type: ").concat(kw(i),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_PARAMETER_MIN:function(e){var t=e.key,n=e.rule;e.fnName;var r=e.value;return"the min value of ".concat(t||n.name," is ").concat(n.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX:function(e){var t=e.key,n=e.rule;e.fnName;var r=e.value;return"the max value of ".concat(t||n.name," is ").concat(n.max,", received: ").concat(r,".")},API_CALL_TIMEOUT:function(e){return"".concat(e.commandDesc||e.command," timeout observed.")},SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:function(e){return"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," }).")},ERROR_MESSAGE:function(e){var t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:function(e){return"exchange sdp failed ".concat(e.errMsg,".")},UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:function(e){return"'".concat(e,"' must be validate string when useStringRoomId is true.")},INVALID_ROOMID_INTEGER:function(e){return"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false.")},INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED:function(e){var t=e.error,n=e.code;return"Failed to join room - ".concat(t," code: ").concat(n)},REJOIN_ROOM_FAILED:function(e){return"reJoin room: ".concat(e.roomId," failed, please check your network.")},INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:'no permission to publish() under live/audience, please call switchRole("anchor") firstly before publish().',INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:function(e){return"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish.")},INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED:function(e){var t=e.message,n=e.userId,r=e.streamType;return"failed to subscribe ".concat(n," ").concat(r," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as anchor or audience.",INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:function(e){return"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,".")},CLIENT_BANNED:function(e){return"client was banned because of ".concat(e.message,".")},INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:function(e){return"startPublishCDNStream failed, errMsg: ".concat(e.message,".")},STOP_PUBLISH_CDN_FAILED:function(e){return"stopPublishCDNStream failed, errMsg: ".concat(e.message,".")},INVALID_STREAM_ID:function(e){return"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:function(e){return"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track")},NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:function(e){return"startMixTranscode failed, errMsg: ".concat(e.message,".")},STOP_MIX_TRANSCODE_FAILED:function(e){return"stopMixTranscode failed, errMsg: ".concat(e.message,".")},MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO:function(e){var t=e.key,n=e.rule,r=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(r,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:function(e){return"'".concat(e,"' is required and must be between 1 and 15.")},MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:function(e){var t=e.key,n=e.fnName;return"'".concat(t,"' is not found in the document object when calling ").concat(n,"().")},INVALID_ELEMENT_ID_TYPE:function(e){var t=e.key,n=e.fnName,r=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(n,"(), received: ").concat(r,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failed, browser exception: ").concat(e.error.toString())},INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:function(e){return"".concat(e,"Track is not supported on your browser.")},NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:function(e){return"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,".")},CATCH_HANDLER_ERROR:function(e){var t=e.name,n=e.event;return"an error was caught in ".concat(t,".on('").concat(n,"', handler), please check your code in 'handler'.")},API_NOT_EXIST:function(e){var t=e.name;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:function(e){return"please avoid repeated join."},CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED:function(e){var t=e.funName;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:function(e){return"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":"")},SEI_DISABLED:"SEI is disabled",SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:function(e){var t=e.isSize,n=e.name,r=e.timesInSecond,i=e.maxSizeInSecond;return"api ".concat(n," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(i," bytes"):r," in a second.")},CONNECTION_ABORTED:function(e){return"connection aborted due to: ".concat(e)},API_CALL_ABORTED:function(e){return e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message)},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:function(e){return"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")}},fN=function(e,t){return t?"".concat(BR,"/").concat(e,"/").concat(t):"".concat(BR,"/").concat(e,"/index.html")},pN=function(){if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};var e=null==localStorage?void 0:localStorage.getItem(WR);if(e){e=JSON.parse(e);var t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);var n=window.TRTC_ERROR_INFO,r=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:n,TRTC_ERROR_LINK:r}}return{}};function mN(e){var t=e.key,n=e.data,r=e.link,i=e.addDocLink,a=void 0===i||i,o="",s="",c="";Sw(hN[t])?o=hN[t](n):Iw(hN[t])&&(o=hN[t]);var u=pN(),l=u.TRTC_ERROR_INFO,d=u.TRTC_ERROR_LINK;r?c="".concat(r.className,".html#").concat(r.fnName):d&&d[t]&&(Sw(d[t])?c=d[t](n):Iw(d[t])&&(c=d[t]));var h=o;return gw()&&(l&&l[t]&&(Sw(l[t])?s=l[t](n):Iw(l[t])&&(s=l[t])),s&&(h=a?"".concat(s,"\n请查看文档: ").concat(fN("zh-cn",c),"\n\n"):"".concat(s,"\n\n"),h+=o)),a&&(h+=" \nRefer to: ".concat(fN("en",c),"\n")),h}var vN,_N=tR(lR(),1),gN=function(){return o((function e(){var t=this;r(this,e);var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];rR(this,"countMap",new Map),rR(this,"distributionMap",new Map),rR(this,"version"),rR(this,"log",sO.createLogger({id:"kv"})),n&&(rO.on("102",(function(e){var n=e.track,r=e.cost;t.addSuccessEvent({key:n.kind===nC.AUDIO?501700:511700,cost:r})})),rO.on("103",(function(e){var n=e.track,r=e.error;t.addFailedEvent({key:n.kind===nC.AUDIO?501700:511700,error:r})})))}),[{key:"getReportData",value:function(){var e={msg_sdk_basic_info:{uint32_sdk_version:tD(this.version||RR),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:E(this.countMap.entries()).map((function(e){var t=v(e,2);return{uint32_key:t[0],uint32_count:t[1]}})),stats_distribution:E(this.distributionMap.entries()).map((function(e){var t=v(e,2);return{uint32_key:t[0],distribution_items:E(t[1].entries()).map((function(e){var t=v(e,2);return{uint32_item_key:t[0],uint32_item_value:t[1]}}))}}))};return this.countMap.clear(),this.distributionMap.clear(),e}},{key:"clear",value:function(){this.countMap.clear(),this.distributionMap.clear()}},{key:"isEnumKey",value:function(e){var t=+String(e).slice(-3);return t>=700&&t<799}},{key:"isErrorCodeKey",value:function(e){var t=+String(e).slice(-3);return t>=600&&t<699}},{key:"isCountKey",value:function(e){var t=+String(e).slice(-3);return t>=0&&t<599}},{key:"isNumberKey",value:function(e){var t=+String(e).slice(-3);return t>=800&&t<899}},{key:"addCount",value:function(e){var t=e.key,n=e.useUV,r=void 0!==n&&n;this.isCountKey(t)?r&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}},{key:"addEnum",value:function(e){var t,n=e.key,r=e.value,i=e.useUV,a=void 0===i||i;if(!this.isEnumKey(n))return this.log.debug("".concat(n," is not enum key, last 3 number should be 700~799"));if(!a||!this.countMap.has(n)){this.countMap.set(n,(this.countMap.get(n)||0)+1);var o=(null==(t=this.distributionMap)?void 0:t.get(n))||new Map;o.set(r,(o.get(r)||0)+1),this.distributionMap.set(n,o)}}},{key:"addNumber",value:function(e){var t,n=e.key,r=e.value,i=e.split,a=void 0===i?100:i,o=e.useUV,s=void 0!==o&&o;if(!this.isNumberKey(n))return this.log.debug("".concat(n," is not number key, last 3 number should be 800~899"));if(!s||!this.countMap.has(n)){this.countMap.set(n,(this.countMap.get(n)||0)+1);var c=(null==(t=this.distributionMap)?void 0:t.get(n))||new Map,u=0;if(Aw(a))u=Math.floor(r/a);else for(var l=a.length-1;l>0;l--)if(r>a[l]){u=l;break}c.set(u,(c.get(u)||0)+1),this.distributionMap.set(n,c)}}},{key:"addSuccessEvent",value:function(e){var t=e.key,n=e.cost,r=e.timeKey,i=e.split;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),n)){var a=+String(t).slice(-3);a<800&&a>=700?this.addNumber({key:r||t+100,value:n,split:i}):r||this.log.debug("time stat ignored, ".concat(t))}}},{key:"addFailedEvent",value:function(e){var t=e.key,n=e.error;if(t){var r=_R.UNKNOWN;n&&(Aw(n)?r=n:(!bw(n.extraCode)||!bw(n.code))&&(r=n.extraCode||n.code)),this.addEnum({key:t,value:0,useUV:!1}),this.addEnum({key:t,value:Math.abs(r),useUV:!1})}}}])}(),yN=((vN=yN||{})[vN.enterRoom=500700]="enterRoom",vN[vN.exitRoom=500701]="exitRoom",vN[vN.switchRole=500702]="switchRole",vN[vN.destroy=500703]="destroy",vN[vN.startLocalAudio=500704]="startLocalAudio",vN[vN.updateLocalAudio=500705]="updateLocalAudio",vN[vN.stopLocalAudio=500706]="stopLocalAudio",vN[vN.startLocalVideo=500707]="startLocalVideo",vN[vN.updateLocalVideo=500708]="updateLocalVideo",vN[vN.stopLocalVideo=500709]="stopLocalVideo",vN[vN.startScreenShare=500710]="startScreenShare",vN[vN.updateScreenShare=500711]="updateScreenShare",vN[vN.stopScreenShare=500712]="stopScreenShare",vN[vN.startRemoteVideo=500713]="startRemoteVideo",vN[vN.updateRemoteVideo=500714]="updateRemoteVideo",vN[vN.stopRemoteVideo=500715]="stopRemoteVideo",vN[vN.muteRemoteAudio=500716]="muteRemoteAudio",vN[vN.setRemoteAudioVolume=500717]="setRemoteAudioVolume",vN[vN.use=500718]="use",vN[vN.sendSEIMessage=5e5]="sendSEIMessage",vN[vN.sendCustomMessage=500001]="sendCustomMessage",vN),EN=function(e){return e[e.AudioMixer=550700]="AudioMixer",e[e.AIDenoiser=551700]="AIDenoiser",e[e.VirtualBackground=570700]="VirtualBackground",e[e.Beauty=571700]="Beauty",e[e.Watermark=572700]="Watermark",e[e.BasicBeauty=574700]="BasicBeauty",e[e.CDNStreaming=590700]="CDNStreaming",e[e.DeviceDetector=591700]="DeviceDetector",e[e.Debug=592700]="Debug",e}(EN||{}),TN=function(e){return e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e[e.BasicBeauty=574701]="BasicBeauty",e[e.CDNStreaming=590701]="CDNStreaming",e[e.DeviceDetector=591701]="DeviceDetector",e[e.Debug=592701]="Debug",e}(TN||{}),kN=function(e){return e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e[e.BasicBeauty=574702]="BasicBeauty",e[e.CDNStreaming=590702]="CDNStreaming",e[e.DeviceDetector=591702]="DeviceDetector",e[e.Debug=592702]="Debug",e}(kN||{}),SN=new gN(!0),bN=new gN(!1),IN=SN,AN={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},RN=new Map([[wD,["Firefox",DD]],[PD,["Edg",MD]],[Cx,["Chrome",xx]],[Ox,["Safari",Px]],[qD,["TBS",jD]],[HD,["XWEB",GD]],[KD&&kD,["WeChat",YD]],[ZD,["QQ(Win)",ex]],[QD,["QQ(Mobile)",$D]],[XD,["QQ(Mobile X5)",$D]],[tx,["QQ(Mac)",nx]],[rx,["QQ(iPad)",ix]],[hx,["MI",fx]],[px,["HW",_x]],[gx,["Samsung",yx]],[Ex,["OPPO",Tx]],[kx,["VIVO",Sx]],[OD,["EDGE",ND]],[UD,["SogouMobile",VD]],[FD,["Sogou",BD]]]);function CN(){var e=RN.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var wN=function(){return!(lx||OD||PD&&LD<80||wD&&xD<56)},DN=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((function(e){return e in window}))},xN=function(){if(!navigator.mediaDevices)return NN()||sO.error(hN.NOT_SUPPORTED_MEDIA),!1;var e=["getUserMedia","enumerateDevices"];return e.filter((function(e){return e in navigator.mediaDevices})).length===e.length},ON=!1;function NN(){return"http:"===location.protocol&&!qx&&(ON||sO.error(mN({key:dN.NOT_SUPPORTED_HTTP})),ON=!0,!0)}var PN=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},MN=function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!AN.detail.isH264EncodeSupported||!AN.detail.isVp8EncodeSupported){e.next=2;break}return e.abrupt("return",{isH264EncodeSupported:AN.detail.isH264EncodeSupported,isVp8EncodeSupported:AN.detail.isVp8EncodeSupported});case 2:return n=!1,r=!1,e.prev=3,i=new RTCPeerConnection,(a=document.createElement(nC.CANVAS)).getContext("2d"),o=a.captureStream(0),i.addTrack(o.getVideoTracks()[0],o),e.next=10,i.createOffer();case 10:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),AN.detail.isH264EncodeSupported=n,AN.detail.isVp8EncodeSupported=r,e.abrupt("return",{isH264EncodeSupported:AN.detail.isH264EncodeSupported,isVp8EncodeSupported:AN.detail.isVp8EncodeSupported});case 19:return e.prev=19,e.t0=e.catch(3),e.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 22:case"end":return e.stop()}}),e,null,[[3,19]])})))},LN=function(){return aR(this,null,f().mark((function e(){var t,n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!AN.detail.isH264DecodeSupported||!AN.detail.isVp8DecodeSupported){e.next=2;break}return e.abrupt("return",{isH264DecodeSupported:AN.detail.isH264DecodeSupported,isVp8DecodeSupported:AN.detail.isVp8DecodeSupported});case 2:return n=!1,r=!1,e.prev=3,i=new RTCPeerConnection,e.next=7,i.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});case 7:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),e.abrupt("return",{isH264DecodeSupported:n,isVp8DecodeSupported:r});case 14:return e.prev=14,e.t0=e.catch(3),e.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 17:case"end":return e.stop()}}),e,null,[[3,14]])})))},UN=iD((function(){return aR(void 0,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u,l,d,h,p,m,_;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(AN.result&&AN.detail.isH264EncodeSupported&&AN.detail.isVp8EncodeSupported&&AN.detail.isH264DecodeSupported&&AN.detail.isVp8DecodeSupported)){e.next=2;break}return e.abrupt("return",AN);case 2:return t=Date.now(),n=wN(),r=lP(),i=DN(),a=xN(),e.next=9,MN();case 9:return o=e.sent,s=o.isH264EncodeSupported,c=o.isVp8EncodeSupported,e.next=14,LN();case 14:if(u=e.sent,l=u.isH264DecodeSupported,d=u.isVp8DecodeSupported,s&&c){e.next=22;break}return e.next=20,MN();case 20:h=e.sent,sO.warn("detect encode again h264:".concat(s," vp8:").concat(c," result: ").concat(JSON.stringify(h))),s=h.isH264EncodeSupported,c=h.isVp8EncodeSupported;case 22:if(!(s&&l&&ID&&Rx)||HD||qD){e.next=29;break}return e.next=25,function(){return aR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",BN||(BN=new Promise((function(e){return aR(t,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d,h,p,m,_,g=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={encode:!1,decode:!1},r=function(){},t.prev=1,i=document.createElement("canvas"),a=i.getContext("2d"),i.width=320,i.height=240,o=setInterval((function(){a.fillText("test",Math.floor(320*Math.random()),Math.floor(240*Math.random()))}),66),s=-1,c=-1,r=function(){clearInterval(s),clearInterval(o),clearTimeout(c),l.close(),d.close(),u.getTracks().forEach((function(e){return e.stop()}))},c=setTimeout((function(){r(),e(n)}),2e3),u=i.captureStream(),l=new RTCPeerConnection({}),d=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),l.addEventListener("icecandidate",(function(e){return d.addIceCandidate(e.candidate)})),d.addEventListener("icecandidate",(function(e){return l.addIceCandidate(e.candidate)})),l.addTrack(u.getVideoTracks()[0],u),t.next=10,l.createOffer();case 10:return h=t.sent,t.next=13,l.setLocalDescription(h);case 13:return t.next=15,d.setRemoteDescription(h);case 15:return t.next=17,d.createAnswer();case 17:return p=t.sent,m=_N.default.parse(p.sdp),_=m.media[0].rtp.findIndex((function(e){return"H264"===e.codec})),m.media[0].rtp=[m.media[0].rtp[_]],m.media[0].fmtp=m.media[0].fmtp.filter((function(e){return e.payload===m.media[0].rtp[0].payload})),m.media[0].rtcpFb&&(m.media[0].rtcpFb=m.media[0].rtcpFb.filter((function(e){return e.payload===m.media[0].rtp[0].payload}))),p.sdp=_N.default.write(m),t.next=26,d.setLocalDescription(p);case 26:return t.next=28,l.setRemoteDescription(p);case 28:s=setInterval((function(){return aR(g,null,f().mark((function t(){var i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.encode&&n.decode&&(r(),e(n)),t.next=3,Promise.all([l.getSenders()[0].getStats(),d.getReceivers()[0].getStats()]);case 3:i=t.sent,a=v(i,2),o=a[0],s=a[1],n.encode||o.forEach((function(e){"outbound-rtp"===e.type&&e.mediaType===nC.VIDEO&&e.bytesSent>0&&(n.encode=!0)})),n.decode||s.forEach((function(e){"inbound-rtp"===e.type&&e.mediaType===nC.VIDEO&&e.bytesReceived>0&&(n.decode=!0)}));case 8:case"end":return t.stop()}}),t)})))}),100),t.next=34;break;case 31:t.prev=31,t.t0=t.catch(1),r(),sO.warn("detectH264Supported failed",t.t0),e({encode:!0,decode:!0});case 34:case"end":return t.stop()}}),t,null,[[1,31]])})))})).then((function(e){return e.encode||(e.decode=!0),(!e.encode||!e.decode)&&sO.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat(Jx)),e})),BN));case 1:case"end":return e.stop()}}),e)})))}();case 25:p=e.sent,m=p.encode,_=p.decode,s=m,l=_;case 29:return e.abrupt("return",(AN.result=n&&r&&a&&(s||c)&&(l||d),AN.detail.isBrowserSupported=n,AN.detail.isWebRTCSupported=r,AN.detail.isWebCodecsSupported=i,AN.detail.isMediaDevicesSupported=a,AN.detail.isScreenShareSupported=FN(),AN.detail.isSmallStreamSupported=JN(),AN.detail.isH264EncodeSupported=s,AN.detail.isVp8EncodeSupported=c,AN.detail.isH264DecodeSupported=l,AN.detail.isVp8DecodeSupported=d,AN.result||sO.error("".concat(navigator.userAgent," ").concat(Qw(AN.detail,!1))),uO.setItem(vP,{ua:navigator.userAgent,checkResult:AN}),IN.addNumber({key:523800,value:Date.now()-t}),AN));case 30:case"end":return e.stop()}}),e)})))})),VN=function(){return AN.result},FN=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},BN=null,qN=function(e,t,n){"http:"===location.protocol&&!qx&&(e[t]=function(){throw new yR({code:_R.INVALID_OPERATION,message:hN.NOT_SUPPORTED_HTTP})})},jN=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state||Rw(e.selected)&&!e.selected)};function HN(){var e="";if(screen.width){var t=screen.width?screen.width*window.devicePixelRatio:"",n=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(n)}return e}function GN(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function WN(){for(var e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"],n=0;n<t.length;n++)if(t[n]in window){e.isSupported=!0;break}return e.isSupported}function zN(){return"captureStream"in HTMLCanvasElement.prototype}function JN(){return!(KD||bD||Dx&&Dx<63||!wN()||!zN())}var KN=function(){if(bw(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var e=null,t=!1;try{(e=new RTCPeerConnection({sdpSemantics:LC})).addTransceiver(nC.AUDIO),t=!0}catch(wR){}return null==e||e.close(),t};function YN(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function XN(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function QN(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function $N(){return 11!==Ux&&"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}var ZN=!(!$N()||Rx&&Dx<86);function eP(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var tP="RTCRtpSender"in window;function nP(){return tP&&"replaceTrack"in window.RTCRtpSender.prototype}function rP(){return tP&&"setParameters"in window.RTCRtpSender.prototype&&XN()}var iP="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,aP=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,oP=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,sP=tP&&"createEncodedStreams"in window.RTCRtpSender.prototype&&Ax()>=86,cP="RTCRtpScriptTransform"in window,uP=tP&&(sP||cP),lP=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((function(e){return e in window})).length>0};function dP(){var e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return bw(window.AudioDecoder)||(e.AudioDecoder=!0),bw(window.AudioEncoder)||(e.AudioEncoder=!0),bw(window.VideoDecoder)||(e.VideoDecoder=!0),bw(window.VideoEncoder)||(e.VideoEncoder=!0),bw(window.ImageDecoder)||(e.ImageDecoder=!0),e}function hP(){return"mediaSession"in navigator&&!bw(navigator.mediaSession.setActionHandler)}function fP(){return!bw(window.WebTransport)}function pP(){return"undefined"!=typeof WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}function mP(){var e={browser:"".concat(Hx.name,"/").concat(Hx.version),os:Qx(),displayResolution:HN(),isScreenShareSupported:FN(),isWebRTCSupported:lP(),isGetUserMediaSupported:GN(),isWebAudioSupported:WN(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:dP(),isMediaSessionSupported:hP(),isWebTransportSupported:fP()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var vP="checkResult";function _P(){NN();var e=uO.getItem(vP);e&&e.ua===navigator.userAgent&&(AN=e.checkResult),UN()}function gP(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var yP="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype,EP=tR(oR(),1),TP=Symbol("instance"),kP=Symbol("cacheResult"),SP=function(){return o((function e(t,n,i){r(this,e),this.oldState=t,this.newState=n,this.action=i,this.aborted=!1}),[{key:"abort",value:function(e){this.aborted=!0,CP.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),bP=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[i])).state=e,o.message=i,o.cause=a,o}return d(t,e),o(t)}(b(Error)),IP=new Map;function AP(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r,i,a){var o=n.action||i;if(!n.context){var s=IP.get(r)||[];IP.has(r)||IP.set(r,s),s.push({from:e,to:t,action:o})}var c=a.value;a.value=function(){for(var r,i=this,a=this,s=arguments.length,u=new Array(s),l=0;l<s;l++)u[l]=arguments[l];if(n.context&&(a=wP.get("function"==typeof n.context?(r=n.context).call.apply(r,[this].concat(u)):n.context)),a.state===t)return n.sync?a[kP]:Promise.resolve(a[kP]);a.state instanceof SP&&a.state.action==n.abortAction&&a.state.abort(a);var d=null;Array.isArray(e)?0==e.length?a.state instanceof SP&&a.state.abort(a):("string"!=typeof a.state||!e.includes(a.state))&&(d=new bP(a._state,"".concat(a.name," ").concat(o," to ").concat(t," failed: current state ").concat(a._state," not from ").concat(e.join("|")))):e!==a.state&&(d=new bP(a._state,"".concat(a.name," ").concat(o," to ").concat(t," failed: current state ").concat(a._state," not from ").concat(e)));var h=function(e){if(n.fail&&n.fail.call(i,e),n.sync){if(n.ignoreError)return e;throw e}return n.ignoreError?Promise.resolve(e):Promise.reject(e)};if(d)return h(d);var f=a.state,p=new SP(f,t,o);CP.call(a,p);var m=function(e){var r;return a[kP]=e,p.aborted||(CP.call(a,t),null===(r=n.success)||void 0===r||r.call(i,a[kP])),e},v=function(e){return CP.call(a,f,e),h(e)};try{var _=c.apply(this,u);return function(e){return"object"==k(e)&&e&&"then"in e}(_)?_.then(m).catch(v):n.sync?m(_):Promise.resolve(m(_))}catch(EO){return v(new bP(a._state,"".concat(a.name," ").concat(o," from ").concat(e," to ").concat(t," failed: ").concat(EO),EO instanceof Error?EO:new Error(String(EO))))}}}}var RP="undefined"!=typeof window&&window.__AFSM__?function(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?function(e,t){postMessage({type:e,payload:t})}:function(){};function CP(e,t){var n=this._state;this._state=e;var r=e.toString();e&&this.emit(r,n),this.emit(wP.STATECHANGED,e,n,t),this.updateDevTools({value:e,old:n,err:t instanceof Error?t.message:String(t)})}var wP=function(e){function i(e,a,o){var s;r(this,i),(s=n(this,i)).name=e,s.groupName=a,s._state=i.INIT,e||(e=Date.now().toString(36)),o?Object.setPrototypeOf(t(s),o):o=Object.getPrototypeOf(t(s)),a||(s.groupName=s.constructor.name);var c=o[TP];return c?s.name=c.name+"-"+c.count++:o[TP]={name:s.name,count:0},s.updateDevTools({diagram:s.stateDiagram}),s}return d(i,e),o(i,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=IP.get(e)||[],n=new Set,r=[],i=[],a=new Set,o=Object.getPrototypeOf(e);IP.has(o)&&(o.stateDiagram.forEach((function(e){return n.add(e)})),o.allStates.forEach((function(e){return a.add(e)}))),t.forEach((function(e){var t=e.from,n=e.to,a=e.action;"string"==typeof t?r.push({from:t,to:n,action:a}):t.length?t.forEach((function(e){r.push({from:e,to:n,action:a})})):i.push({to:n,action:a})})),r.forEach((function(e){var t=e.from,r=e.to,i=e.action;a.add(t),a.add(r),a.add(i+"ing"),n.add("".concat(t," --\x3e ").concat(i,"ing : ").concat(i)),n.add("".concat(i,"ing --\x3e ").concat(r," : ").concat(i," 🟢")),n.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🔴"))})),i.forEach((function(e){var t=e.to,r=e.action;n.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),a.forEach((function(e){e!==t&&n.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));var s=E(n);return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:a}}),s}},{key:"updateDevTools",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};RP(i.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){CP.call(this,e)}}],[{key:"get",value:function(e){var t;return"string"==typeof e?(t=i.instances.get(e))||i.instances.set(e,t=new i(e,void 0,Object.create(i.prototype))):(t=i.instances2.get(e))||i.instances2.set(e,t=new i(e.constructor.name,void 0,Object.create(i.prototype))),t}},{key:"getState",value:function(e){var t;return null===(t=i.get(e))||void 0===t?void 0:t.state}}])}(EP.default);wP.STATECHANGED="stateChanged",wP.UPDATEAFSM="updateAFSM",wP.INIT="[*]",wP.ON="on",wP.OFF="off",wP.instances=new Map,wP.instances2=new WeakMap;var DP="undefined"!=typeof window,xP=DP&&window.requestIdleCallback||function(e){var t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})}),1e3)},OP=DP&&window.cancelIdleCallback||function(e){clearTimeout(e)},NP=DP&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),PP=function(){function e(){r(this,e)}return o(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(e,t,n){null!=n&&n.fps&&(n.delay=n.delay||Number((1e3/n.fps).toFixed(2))),n=QA("interval"===e?{delay:2e3,count:0,backgroundTask:!0}:"ric"===e?{delay:1e4,count:0}:"raf"===e?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},n);var r=$A(QA({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},n),{delay:n.delay});return this.taskMap.set(r.taskID,r),this[e](r),r.taskID}},{key:"interval",value:function(t){return t.intervalID=setInterval((function(){t.callback(),t.loopCount+=1,e.isBreakLoop(t)}),t.delay)}},{key:"intervalInWorker",value:function(t){e.sharedWorker||(e.sharedWorker=new Worker(URL.createObjectURL(new Blob(["\n const timers = new Map();\n self.onmessage = function(e) {\n const { taskId, delay, type } = e.data;\n if (type === 'start') {\n timers.set(taskId, setInterval(() => {\n self.postMessage({ type: 'tick', taskId });\n }, delay));\n } else if (type === 'stop') {\n clearInterval(timers.get(taskId));\n timers.delete(taskId);\n }\n };\n "],{type:"application/javascript"}))),e.sharedWorker.onmessage=function(t){var n;if("tick"===t.data.type){var r=e.workerTasks.get(t.data.taskId);r&&(r.callback(),r.loopCount+=1,e.isBreakLoop(r)&&(null==(n=e.sharedWorker)||n.postMessage({type:"stop",taskId:r.taskID}),e.workerTasks.delete(r.taskID)))}}),e.workerTasks.set(t.taskID,t),e.sharedWorker.postMessage({taskId:t.taskID,delay:t.delay,type:"start"})}},{key:"timeout",value:function(t){var n=function(){if(t.callback(),t.loopCount+=1,!e.isBreakLoop(t))return t.timeoutID=setTimeout(n,t.delay)};return t.timeoutID=setTimeout(n,t.delay)}},{key:"ric",value:function(t){var n,r=Uw(),i=function(){if((n=Uw()-r)>=t.delay&&(r=Uw()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=xP(i,{timeout:t.delay})};return t.ricID=xP(i,{timeout:t.delay})}},{key:"raf",value:function(t){var n,r=Uw(),i=function(){return document.hidden&&t.backgroundTask?(n=Uw()-r,r=Uw(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(i,t.delay-Math.floor(n%t.delay))):((n=Uw()-r)>=t.delay&&(r=Uw()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(i))};if(t.rafID=requestAnimationFrame(i),t.backgroundTask){var a=function(){if(document.hidden){var e=Uw()-r;e>=t.delay?i():t.timeoutID=setTimeout(i,t.delay-e)}};document.addEventListener("visibilitychange",a),t.onVisibilitychange=a,document.hidden&&a()}return t.taskID}},{key:"hasTask",value:function(e){return this.taskMap.has(e)}},{key:"clearTask",value:function(e){if(!this.taskMap.has(e))return!0;var t=this.taskMap.get(e),n=t.intervalID,r=t.timeoutID,i=t.rafID,a=t.ricID,o=t.onVisibilitychange,s=t.worker;return s&&s.terminate(),n&&clearInterval(n),r&&clearTimeout(r),i&&NP&&NP(i),a&&OP(a),o&&document.removeEventListener("visibilitychange",o),this.taskMap.delete(e),!0}},{key:"isBreakLoop",value:function(e){return!this.taskMap.has(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}}])}();rR(PP,"taskMap",new Map),rR(PP,"currentTaskID",1),rR(PP,"sharedWorker",null),rR(PP,"workerTasks",new Map);var MP=PP;nC.SEI_MESSAGE;var LP={LOADED_DATA:nC.LOADEDDATA,LOADED_META_DATA:nC.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error"},UP={};eR(UP,{create:function(){return FP},remove:function(){return BP}});var VP=new WeakMap;function FP(e,t){VP.has(e)||VP.set(e,[]);var n=VP.get(e),r={add:function(e,i){return"addEventListener"in t?(n.push(t.removeEventListener.bind(t,e,i)),t.addEventListener(e,i)):(n.push(t.off.bind(t,e,i)),t.on(e,i)),r}};return r}function BP(e){var t=VP.get(e);t&&(t.forEach((function(e){return e()})),VP.delete(e))}var qP=new(function(){return o((function e(){r(this,e),rR(this,"_roomIdMap",new Map),rR(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:RR,env:JR.QCLOUD,browserVersion:Hx.name+Hx.version,ua:navigator.userAgent})}),[{key:"setConfig",value:function(e){var t=e.sdkAppId,n=e.env,r=e.userId,i=e.roomId;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=n,this._configs.userId=r,this._roomIdMap.set(r,String(i))}},{key:"logSuccessEvent",value:function(e){qx||!sO.isAbleToUpload||this._configs.env===JR.QCLOUD&&this.uploadEventToKibana($A(QA({},e),{result:"success"}))}},{key:"logFailedEvent",value:function(e){if(!qx&&sO.isAbleToUpload){var t=e.eventType,n=e.code,r=e.error,i=e.userId,a={roomId:this._roomIdMap.get(i||this._configs.userId),userId:i,eventType:t,result:"failed",code:n||(null==r?void 0:r.extraCode)||(null==r?void 0:r.code)||_R.UNKNOWN};this._configs.env===JR.QCLOUD&&this.uploadEventToKibana($A(QA({},a),{error:r}))}}},{key:"uploadEventToKibana",value:function(e){var t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}},{key:"uploadEvent",value:function(e){var t=e.log,n=e.userId,r=e.error,i={timestamp:kR(),sdkAppId:this._configs.sdkAppId,userId:n||this._configs.userId,version:RR,log:t};r&&(i.errorInfo=r.message,r.stack&&(i.errorInfo+="\n".concat(r.stack))),this.sendRequest(ow(this._configs.sdkAppId,zR.LOG),i)}},{key:"sendRequest",value:function(e,t){setTimeout((function(){return aD({url:e,body:JSON.stringify(t),priority:"low"}).catch((function(){}))}),2e3)}}])}()),jP=new WeakMap;function HP(e){var t=e.settings,n=void 0===t?{retries:5,timeout:2e3}:t,r=e.onError,i=e.onRetrying,a=e.onRetryFailed;return function(e,t,o){var s=dD({retryFunction:o.value,settings:n,onError:function(n){var i,a=n.error,o=n.retry,s=n.reject,c=n.retryFuncArgs;r?r.call(this,a,(function(){var n;null!=(n=jP.get(e))&&n.has(t)?o():s(a)}),s,c):null!=(i=jP.get(e))&&i.has(t)?o():s(a)},onRetrying:function(n,r){var a;cD(i)&&i.call(this,n,r),null!=(a=jP.get(e))&&a.has(t)&&(jP.get(e).get(t).stopRetry=r)},onRetryFailed:a});return o.value=function(){for(var n=jP.get(e),r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return n?n.set(t,{args:i}):jP.set(e,new Map([[t,{args:i}]])),s.apply(this,i).finally((function(){var n;return null==(n=jP.get(e))?void 0:n.delete(t)}))},o}}function GP(e){var t=e.fnName,n=e.callback,r=e.validateArgs,i=void 0===r||r;return function(e,r,a){var o=a.value;return a.value=function(){for(var r,a,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];if(null!=(r=jP.get(e))&&r.has(t)){var d=jP.get(e).get(t),h=d.stopRetry,f=d.args,p=!0;if(i){var m,v=s(f);try{var _=function(){var e=m.value;if(!u.find((function(t){return t===e})))return p=!1,1};for(v.s();!(m=v.n()).done&&!_(););}catch(g){v.e(g)}finally{v.f()}}p&&(n&&n.apply(this,u),h&&h(),null==(a=jP.get(e))||a.delete(t))}return o.apply(this,u)},a}}var WP=function(e){function i(e,a){var o;return r(this,i),(o=n(this,i,[e.id,"".concat(a,"-player")])).kind=a,rR(t(o),"id"),rR(t(o),"element",null),rR(t(o),"track"),rR(t(o),"url"),rR(t(o),"attr"),rR(t(o),"mode"),rR(t(o),"muted"),rR(t(o),"_log"),rR(t(o),"_pausedRetryCount"),rR(t(o),"_isElementPlayingFired",!1),rR(t(o),"_interval"),rR(t(o),"_delayDestroyTimeoutId",0),rR(t(o),"_playSuccessResolve"),rR(t(o),"_isReplayByRecreateMediaStreamCalled",!1),rR(t(o),"isInAutoPlayFailedState",!1),o.id=e.id,o._log=e.log,o.track=e.track,o.muted=e.muted,o._pausedRetryCount=KC,o._state="STOPPED",o.bindTrackEvents(),o._log.info("create ".concat(a,"-player ").concat(o.id)),o}return d(i,e),o(i,[{key:"isPlaying",get:function(){var e;return"PLAYING"===this._state&&(!1===(null==(e=this.element)?void 0:e.paused)||this.track&&"live"===this.track.readyState&&!this.track.muted)}},{key:"isStopped",get:function(){return"STOPPED"===this._state}},{key:"setAttr",value:function(e){this.attr=e}},{key:"setUrl",value:function(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}},{key:"play",value:function(){return aR(this,null,f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isPlaying){e.next=13;break}return e.prev=1,this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),e.next=6,new Promise((function(e,t){n._playSuccessResolve=e,n.element.play().then(e,t)}));case 6:e.next=13;break;case 8:if(e.prev=8,e.t0=e.catch(1),t=mN({key:dN.PLAY_FAILED,data:{media:this.kind,error:e.t0}}),this.track&&!this.track.muted&&this._log.warn(e.t0),!t.includes("NotAllowedError")){e.next=13;break}throw this.isInAutoPlayFailedState=!0,new yR({code:_R.PLAY_NOT_ALLOWED,message:t});case 13:case"end":return e.stop()}}),e,this,[[1,8]])})))}},{key:"stop",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._isElementPlayingFired=!1,this.unbindEvents(),t>0&&!Nx?this._delayDestroyTimeoutId||(this._log.info("destroy element after 3 * ".concat(t)),this._delayDestroyTimeoutId=setTimeout((function(){return e.destroyElement()}),3*t)):this.destroyElement(),this.handleStopped(nC.ENDED),this._interval>0&&MP.clearTask(this._interval)}},{key:"destroyElement",value:function(){this.element&&(this._log.debug("destroy element"),this.element.remove(),this.element.srcObject=null,this.element=null),clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0}},{key:"pause",value:function(){var e;this.isPlaying&&(null==(e=this.element)||e.pause())}},{key:"resume",value:function(){return this._log.info("resume"),this.isPlaying?Promise.resolve():Fx?this.replay():this.play().catch((function(){}))}},{key:"setMuted",value:function(e){this.element&&(this.element.muted=e),this.muted=e}},{key:"replay",value:function(){return this.stop(),this.play().catch((function(){}))}},{key:"bindElementEvents",value:function(){if(this.element){var e=this.handleElementEvent.bind(this);return FP(this.element,this.element).add(nC.PLAYING,e).add(nC.ENDED,e).add(nC.PAUSE,e).add(nC.ERROR,e).add(nC.LOADEDDATA,e).add(nC.LOADEDMETADATA,e)}}},{key:"bindTrackEvents",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){var t=this.handleTrackEvent.bind(this);null==UP||UP.create(e,e).add(nC.ENDED,t).add(nC.MUTE,t).add(nC.UNMUTE,t),e.readyState===nC.ENDED&&this.handleTrackEvent({type:nC.ENDED}),e.muted&&this.handleTrackEvent({type:nC.MUTE})}}},{key:"bindAutoPlayEvent",value:function(){rO.on(aO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}},{key:"unbindTrackEvents",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&BP(e)}},{key:"unbindEvents",value:function(){this.element&&BP(this.element),this.unbindTrackEvents(),rO.off(aO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}},{key:"handleElementEvent",value:function(e){var t=this;switch(e.type){case nC.PLAYING:this.isInAutoPlayFailedState=!1,this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(nC.PLAYING),this._interval&&(MP.clearTask(this._interval),this._interval=-1);break;case nC.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(nC.ENDED);break;case nC.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(nC.PAUSE),bD&&(this._interval=MP.run("timeout",(function(){t.element&&"PAUSED"===t._state&&t.resume()}),{delay:3e3}));break;case nC.ERROR:if(this.element&&this.element.error){this.handlePaused(nC.ERROR);var n=this.element.error,r=n.code,i=n.message;this._log.error("".concat(this.kind," ").concat(this._log.isLocal?"local":"remote"," MediaError code: ").concat(r," message: ").concat(i," userAgent: ").concat(navigator.userAgent)),qP.uploadEvent({log:"stat-".concat(this.kind,"-").concat(OC.PLAYER_ERROR,"-").concat(r,"-").concat(navigator.userAgent),error:this.element.error}),vx||mx?this.emit(LP.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case nC.LOADEDDATA:this.kind===nC.VIDEO&&this.emit(LP.LOADED_DATA);break;case nC.LOADEDMETADATA:this.kind===nC.VIDEO&&this.emit(LP.LOADED_META_DATA)}}},{key:"replayByRecreateMediaStream",value:function(e){var t=this;if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then((function(){t._log.warn("replayByRecreateMediaStream success"),qP.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),IN.addSuccessEvent({key:t.kind===nC.AUDIO?506700:516700})})).catch((function(){var n;t._log.error("replayByRecreateMediaStream failed"),qP.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),IN.addFailedEvent({key:t.kind===nC.AUDIO?506700:516700,error:null==(n=t.element)?void 0:n.error}),t.emit(LP.ERROR,e)}))}},{key:"doReplayByRecreateMediaStream",value:function(e){var t=this;return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise((function(n,r){rD(e).then((function(){t.element&&(t.element.srcObject=null,t.element.srcObject=new MediaStream([t.track]),t._log.warn("recreated mediaStream"),t.element.onerror=function(){var e,n,i;t._log.warn("element onerror ".concat(null==(n=null==(e=t.element)?void 0:e.error)?void 0:n.code," fired after recreated mediaStream")),r(null==(i=t.element)?void 0:i.error)}),rD(5e3).then((function(){var e,i;(!t.isPlaying||null!=(e=t.element)&&e.error)&&r(null==(i=t.element)?void 0:i.error),n()}))}))})).finally((function(){t.element&&(t.element.onerror=null)}))}},{key:"handleTrackEvent",value:function(e){switch(e.type){case nC.ENDED:this.handleStopped(nC.ENDED);break;case nC.MUTE:this.handlePaused(nC.MUTE);break;case nC.UNMUTE:this._isElementPlayingFired?this.handlePlaying(nC.UNMUTE):this.mode>0&&this.handlePlaying(this.mode.toString())}}},{key:"handlePlaying",value:function(e){var t;null==(t=this._playSuccessResolve)||t.call(this,e),this.emit(LP.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}},{key:"handlePaused",value:function(e){this.emit(LP.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}},{key:"handleStopped",value:function(e){this.emit(LP.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}},{key:"getElement",value:function(){return this.element}}])}(wP);nR([HP({settings:{retries:2,timeout:0},onError:function(e,t,n,r){r[0]=(r[0]||1e3)+1e3,t()}})],WP.prototype,"doReplayByRecreateMediaStream",1),nR([AP([],"PLAYING",{sync:!0})],WP.prototype,"handlePlaying",1),nR([AP("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],WP.prototype,"handlePaused",1),nR([AP([],"STOPPED",{sync:!0})],WP.prototype,"handleStopped",1);var zP,JP="trtc_autoplay",KP="".concat(JP,"_mask"),YP="".concat(JP,"_wrapper"),XP="".concat(JP,"_header"),QP="".concat(JP,"_content"),$P="".concat(JP,"_action_wrapper"),ZP="".concat(JP,"_question"),eM="".concat(JP,"_collapse"),tM="".concat(JP,"_action_confirm"),nM="".concat(JP,"_detail"),rM="#2473E8",iM="dialog",aM="".concat(iM,"-show"),oM="".concat(iM,"-1"),sM="".concat(iM,"-2"),cM=!1,uM=function(){return!!document.querySelector(".".concat(YP))},lM="".concat(BR,"/").concat(gw()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),dM="<br><a href='".concat(lM,"' target='_blank'>").concat(gw()?"其他方案?":"Any other solution?","</a>"),hM="".concat(gw()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(dM):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(dM)),fM=function(){return o((function e(){if(r(this,e),rR(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),rR(this,"_dialogNode",null),rR(this,"_bodyPosition",""),rR(this,"_showDetail",!1),rR(this,"_isCollapseClicked",!1),rR(this,"_isQuestionClicked",!1),gw()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!cM){var t=document.createElement("style");t.innerHTML=".".concat(KP,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(KP," div:not(.").concat($P,"){display:block !important;}.").concat(YP,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(YP," a{color:").concat(rM,";}.").concat(XP,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(QP,"{margin:8px 0;}.").concat($P,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(eM,"{margin-right:auto;cursor:pointer}.").concat(ZP,"{height:100%;line-height:16px;cursor:pointer;}.").concat(tM,"{margin-left:8px;color:#fff;background:").concat(rM,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(tM,":hover{opacity:0.9;}.").concat(eM,",.").concat(tM,",.").concat(QP,",.").concat(ZP,"{font-size:14px;}@media screen and (max-width:750px){.").concat(YP,"{width:80vw;}}"),document.head.appendChild(t),cM=!0}this.addDiaLog()}),[{key:"createDiaLog",value:function(){var e=document.createElement("template");e.innerHTML='<div class="'.concat(KP,"\"><div class='").concat(YP,"'><div class='").concat(XP,"'>").concat(location.host,"</div><div class='").concat(QP,"'>").concat(this.content,"</div><div class='").concat(nM,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(hM,"</div><div class='").concat($P,"'></div></div></div>").trim();var t=document.createElement("button");t.className=tM,t.innerText=gw()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);var n=document.createElement("div");n.className=ZP,n.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',n.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=eM,r.innerText="".concat(gw()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var i=e.content.firstChild,a=i.querySelector(".".concat($P));return a.appendChild(r),a.appendChild(n),a.appendChild(t),i}},{key:"addDiaLog",value:function(){uM()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(YP)).onclick=function(e){return e.stopPropagation()},this._bodyPosition=document.body.style.position,document.body.style.position="fixed",sO.info("show autoplay dialog"),qP.uploadEvent({log:aM}))}},{key:"deleteDiaLog",value:function(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}},{key:"onConfirm",value:function(){sO.warn("confirm clicked, try resume stream"),rO.emit(aO.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var e=this._dialogNode.querySelector(".".concat(nM));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||qP.uploadEvent({log:oM}),this._isCollapseClicked=!0}},{key:"onQuestionClick",value:function(){window.open(lM,"_blank"),this._isQuestionClicked||qP.uploadEvent({log:sM}),this._isQuestionClicked=!0}}])}(),pM=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e,nC.VIDEO]),rR(t(a),"stat",{}),rR(t(a),"_calculateTimeout",-1),rR(t(a),"viewMirror",!1),rR(t(a),"objectFit"),rR(t(a),"container"),rR(t(a),"canvas"),rR(t(a),"canvasTrack"),a.mode=e.canvas?1:0,a.container=e.container,a.canvas=e.canvas,bw(e.viewMirror)||(a.viewMirror=e.viewMirror),bw(e.objectFit)||(a.objectFit=e.objectFit),a.initializeElement(),a}return d(i,e),o(i,[{key:"initializeElement",value:function(){var e,t=document.createElement(nC.VIDEO);this.track&&2!==this.mode&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents(),this.calculateStat()}},{key:"styleAttribute",get:function(){var e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}},{key:"setContainer",value:function(e){var t;this.container=e,(this.track||this.canvasTrack)&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}},{key:"bindElementEvents",value:function(){var e=g(i,"bindElementEvents",this,3)([]);this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(nC.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(nC.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}},{key:"handleTrackEvent",value:function(e){var t;g(i,"handleTrackEvent",this,3)([e]),e.type===nC.MUTE&&null!=(t=this.stat)&&t.fps&&(this.stat.fps=0)}},{key:"handleElementEvent",value:function(e){var t;if(2!==this.mode){g(i,"handleElementEvent",this,3)([e]);var n=e.type;if(n===nC.PAUSE&&(this.container&&document.getElementById(this.container.id)||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(t=this.container)?void 0:t.id)),this._pausedRetryCount>0&&!uM()&&(this._log.info("".concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){var r=this.element.style.transform;n===nC.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=r.replace("scaleX(-1)",""):n===nC.LEAVE_PICTURE_IN_PICTURE&&!r.includes("scaleX")&&(this.element.style.transform="".concat(r," scaleX(-1)"))}}}},{key:"setCanvas",value:function(e){var t,n,r,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.canvas!==e&&(null==(t=this.canvas)||t.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,this.mode=e?a:0,2===this.mode&&this.setTrack(e.captureStream().getVideoTracks()[0]),e?(null==(n=this.element)||n.remove(),null==(r=this.container)||r.appendChild(e)):this.element&&(null==(i=this.container)||i.appendChild(this.element)))}},{key:"setAttr",value:function(e){var t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),g(i,"setAttr",this,3)([t])}},{key:"mirror",get:function(){return this.viewMirror}},{key:"setRect",value:function(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}},{key:"setViewMirror",value:function(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}},{key:"setObjectFit",value:function(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}},{key:"setPoster",value:function(e){this.element&&(this.element.poster=e)}},{key:"stop",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;g(i,"stop",this,3)([t]),null==(e=this.canvas)||e.remove()}},{key:"play",value:function(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),2===this.mode?Promise.resolve():g(i,"play",this,3)([])}},{key:"elementToRender",get:function(){return this.canvas||this.element}},{key:"setTrack",value:function(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(LP.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}},{key:"getVideoFrame",value:function(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";var e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}},{key:"getElement",value:function(){return this.element}},{key:"calculateStat",value:function(){var e=this;try{if(gP()&&this.element&&this._calculateTimeout<0){var t=0,n=null,r=function(i,a){e.stat.width=a.width,e.stat.height=a.height,n&&(e.stat.fps=Math.round((a.presentedFrames-n.presentedFrames)/(i-t)*1e3)),t=i,n=a,e._calculateTimeout=-1,e.element&&(e._calculateTimeout=setTimeout((function(){var t;return null==(t=e.element)?void 0:t.requestVideoFrameCallback(r)}),2e3))};this.element.requestVideoFrameCallback(r)}}catch(wR){this._log.warn("init stat failed",wR)}}}])}(WP);function mM(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.audioWorklet){n.next=2;break}return n.abrupt("return",Promise.reject("audioWorklet is not supported"));case 2:return n.prev=2,n.next=5,e.audioWorklet.addModule(t);case 5:sO.info("worklet addModule success"),n.next=11;break;case 8:throw n.prev=8,n.t0=n.catch(2),sO.info("worklet addModule catch error. ".concat(n.t0.message)),n.t0;case 11:case"end":return n.stop()}}),n,null,[[2,8]])})))}"undefined"!=typeof AudioContext?zP=AudioContext:"undefined"!=typeof webkitAudioContext?zP=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(zP=mozAudioContext);var vM,_M=-1;!function e(){try{if(vM)return;(vM=new zP({sampleRate:48e3})).onstatechange=function(){sO.info("context state: ".concat(vM.state).concat("running"!==vM.state?" visibilityState: ".concat(document.visibilityState):"")),gM()},clearTimeout(_M)}catch(t){sO.error("initAudioContext failed: ".concat(t," typeof AudioContextClass: ").concat(k(zP))),_M=setTimeout(e,1e3)}}();var gM=function(){"suspended"===vM.state?(TM(),document.addEventListener("click",gM)):"interrupted"===vM.state?TM():(document.removeEventListener("visibilitychange",gM),document.removeEventListener("click",gM))},yM=0,EM=-1;function TM(){return new Promise((function(e,t){if("running"===vM.state)return e();Date.now()-yM<1e3?(clearTimeout(EM),EM=setTimeout((function(){yM=Date.now(),vM.resume().then(e,t)}),1e3)):(clearTimeout(EM),yM=Date.now(),vM.resume().then(e,t))})).catch((function(e){sO.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",gM)}))}document.addEventListener("click",gM);var kM=function(e){return vM},SM=function(){return o((function e(){r(this,e),rR(this,"node"),rR(this,"node2"),rR(this,"pre",new Set),rR(this,"next",new Set),rR(this,"context"),rR(this,"connectedNodes",new Set)}),[{key:"setContext",value:function(e){this.context=e,this.node&&e.addMixWeight()}},{key:"removeContext",value:function(){var e;this.node&&(null==(e=this.context)||e.reduceMixWeight()),delete this.context}},{key:"replaceNode",value:function(e){var t;if(e!==this.node)try{this.node?this._disconnect():null==(t=this.context)||t.addMixWeight(),this.node=e,this.preNodeReconnect(),this.reconnect()}catch(DC){sO.error(DC)}}},{key:"setNode",value:function(e,t){var n;if(!this.node)try{null==(n=this.context)||n.addMixWeight(),this.node=e,t&&(this.node2=t),this.preNodeReconnect(),this.reconnect(),IN.addSuccessEvent({key:502701})}catch(vO){sO.error(vO),IN.addFailedEvent({key:502701,error:vO})}}},{key:"deleteNode",value:function(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),IN.addSuccessEvent({key:502702})}catch(wR){sO.error(wR),IN.addFailedEvent({key:502702,error:wR})}}},{key:"preNodeReconnect",value:function(){this.pre.forEach((function(e){e.node?e.reconnect():e.preNodeReconnect()}))}},{key:"connectNext",value:function(e){this.next.forEach((function(t){e._connect(t.node)||t.connectNext(e)}))}},{key:"_connect",value:function(e){return!(!this.node||!e||((this.node2||this.node).connect(e),this.connectedNodes.add(e),0))}},{key:"_disconnect",value:function(){var e=this;this.connectedNodes.forEach((function(t){var n;return null==(n=e.node2||e.node)?void 0:n.disconnect(t)})),this.connectedNodes.clear()}},{key:"reconnect",value:function(){this._disconnect(),this.connectNext(this)}},{key:"pipeTo",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.forEach((function(t){e.next.add(t),t.pre.add(e)})),this}}])}(),bM=function(e){function i(){var e;r(this,i);var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;return(e=n(this,i)).fftSize=a,rR(t(e),"dataArray",new Uint8Array(0)),e}return d(i,e),o(i,[{key:"setNode",value:function(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),g(i,"setNode",this,3)([e])}},{key:"getByteTimeDomainData",value:function(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}},{key:"level",get:function(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max.apply(Math,E(this.dataArray))/128-1}},{key:"timeDomainPathData",get:function(){for(var e=this.getByteTimeDomainData(),t=0,n=0,r="M".concat(t,",").concat(n),i=0;i<e.length;i++)n=e[i]/128*100/2,r+="L".concat(t,",").concat(n),t+=1;return r}}])}(SM),IM=function(){return o((function e(){r(this,e),rR(this,"source",new SM),rR(this,"gain",new SM),rR(this,"destination",new SM)}),[{key:"volume",get:function(){var e;return(null==(e=this.gain.node)?void 0:e.gain.value)||1}},{key:"setVolume",value:function(e){1!==e?(this.gain.node||this.gain.setNode(kM().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},{key:"replaceSource",value:function(e){this.source.replaceNode(wM(e))}},{key:"track",get:function(){var e;return null==(e=this.stream)?void 0:e.getAudioTracks()[0]}},{key:"stream",get:function(){var e;return null==(e=this.destination.node)?void 0:e.stream}}])}(),AM=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).context=e,rR(t(a),"denoiser",new SM),rR(t(a),"voiceChanger",new SM),a.source.pipeTo(a.denoiser.pipeTo(a.voiceChanger.pipeTo(a.gain.pipeTo(a.destination)))),a}return d(i,e),o(i,[{key:"connect",value:function(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.denoiser.setContext(this.context),this.voiceChanger.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}},{key:"disconnect",value:function(){this.context.inputs.has(this)&&(this.destination.deleteNode(),this.source.removeContext(),this.denoiser.removeContext(),this.voiceChanger.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}},{key:"remove",value:function(){this.gain.deleteNode(),this.denoiser.deleteNode(),this.voiceChanger.deleteNode(),this.source.deleteNode(),this.disconnect()}},{key:"setVolume",value:function(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}}])}(IM),RM=function(){return o((function e(){r(this,e),rR(this,"audioContext",kM()),rR(this,"destination",this.audioContext.createMediaStreamDestination()),rR(this,"inputs",new Set),rR(this,"mixWeight",0),this.destination.channelCount=1}),[{key:"addMixWeight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}},{key:"reduceMixWeight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}},{key:"close",value:function(){this.inputs.forEach((function(e){return e.remove()}))}},{key:"mixTrack",get:function(){return this.destination.stream.getAudioTracks()[0]}}])}(),CM=new WeakMap;function wM(e){var t=CM.get(e);if(t)return t;var n=kM();if(e instanceof HTMLAudioElement)t=n.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=n.createMediaStreamSource(new MediaStream([e]))}return CM.set(e,t),t}var DM=function(){function e(t){r(this,e),rR(this,"_volume",0),rR(this,"_volumeDb",0),rR(this,"_log"),rR(this,"_scriptProcessorNode",null),rR(this,"_audioWorkletNode",null),rR(this,"_interval",200),rR(this,"ready",this.preload());var n=t.log;this._log=n,rO.on(aO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}return o(e,[{key:"node",get:function(){return this._audioWorkletNode||this._scriptProcessorNode}},{key:"preload",value:function(){var t=this;return e.workletReady||(e.workletReady=mM(e.audioContext,URL.createObjectURL(new Blob(['class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(i<h?(s[0].set(this.cache.slice(0,i)),this.cache=this.cache.slice(i)):this.unmute&&s[0].set(t[0]),(i<h?s:t)[0]);if(a){let e=0;for(let t=0;t<a.length;++t)e=Math.max(Math.abs(a[t]),e);s=a.reduce((t,e)=>t+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);'],{type:"application/javascript"})))),e.workletReady.then((function(){return t.initAudioWorklet()})).catch((function(e){return t._log.error("volumeMeter preload error: ".concat(e)),t.initScriptProcessor()}))}},{key:"initAudioWorklet",value:function(){var t=this;if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(e.audioContext,"volume-meter");var n=!1;this._audioWorkletNode.port.onmessage=function(r){e.lastMessageTime=Date.now(),t._volume=r.data.volume||0,t._volumeDb=r.data.volumeDb||0,!n&&r.data.cacheLen&&r.data.outputLen&&(t._log.warn("worklet play success"),n=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(mO){this._log.error("volumeMeter init audio worklet error: ".concat(mO)),qP.logFailedEvent({userId:this._log.userId,eventType:OC.LOAD_WORKLET,error:mO}),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this._scriptProcessorNode)try{this._scriptProcessorNode=kM().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=function(n){e.lastMessageTime=Date.now();for(var r=n.inputBuffer.getChannelData(0),i=0,a=0;a<r.length;++a)i+=r[a]*r[a];t._volume=Math.sqrt(i/r.length)||0}}catch(mO){this._log.error("volumeMeter init script processor error: ".concat(mO))}}},{key:"destroy",value:function(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,rO.off(aO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}},{key:"getInternalAudioLevel",value:function(){return this._volume}},{key:"getCalculatedVolume",value:function(){return parseFloat(this._volume.toFixed(2))}},{key:"getVolumeDb",value:function(){return Math.floor(100*this._volumeDb)}},{key:"handleAudioLevelInterval",value:function(e){var t,n=e.interval;this._interval=n,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:n})}}],[{key:"isRunning",get:function(){return Date.now()-e.lastMessageTime<2e3}}])}();rR(DM,"lastMessageTime",0),rR(DM,"audioContext",kM()),rR(DM,"workletReady");var xM=DM,OM=function(e){function i(e){var a;return r(this,i),a=n(this,i),rR(t(a),"_volumeMeter"),a._volumeMeter=new xM(e),a}return d(i,e),o(i,[{key:"deleteNode",value:function(){g(i,"deleteNode",this,3)([]),this._volumeMeter.destroy()}},{key:"init",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._volumeMeter.preload();case 2:this.setNode(this._volumeMeter.node);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getCalculatedVolume",value:function(){return this._volumeMeter.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this._volumeMeter.getInternalAudioLevel()}},{key:"getVolumeDb",value:function(){return this._volumeMeter.getVolumeDb()}},{key:"write",value:function(e){if(this.node){var t=e.allocationSize({planeIndex:0}),n=new Float32Array(t>>2);e.copyTo(n,{planeIndex:0}),this.node.port.postMessage({name:"chunk",data:n},[n.buffer]),e.close()}}}])}(SM),NM=xM,PM=tR(oR(),1),MM=function(e){return function(t){return t.deviceId===e}},LM=function(){return o((function e(t){r(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";rR(this,"kind"),rR(this,"type"),rR(this,"devices",[]),this.kind=t,this.type=n}),[{key:"update",value:function(e,t){var n=this,r=e.filter((function(e){return e.kind==="".concat(n.kind).concat(n.type.toLocaleLowerCase())}));1===this.devices.length&&FM(this.devices[0])||t&&(r.forEach((function(e){if(e.deviceId&&!n.devices.find(MM(e.deviceId))){var r="".concat(n.kind).concat(n.type,"Added");sO.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices.forEach((function(e){if(e.deviceId&&!r.find(MM(e.deviceId))){var i="".concat(n.kind).concat(n.type,"Removed");sO.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}}))),this.devices=r}},{key:"hasDevice",value:function(e){return!!this.devices.find((function(t){return t.deviceId===e}))}}])}(),UM=function(e){function i(){var e;return r(this,i),e=n(this,i),rR(t(e),"audioInputs",new LM(nC.AUDIO)),rR(t(e),"videoInputs",new LM(nC.VIDEO)),rR(t(e),"audioOutputs",new LM(nC.AUDIO,"Output")),e.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(function(){return e.update()})),"ondevicechange"in navigator.mediaDevices||MP.run("interval",(function(){e.update()}),{delay:1e4})),e}return d(i,e),o(i,[{key:"init",value:function(){var e=this;BM().then((function(t){e.audioInputs.update(t),e.videoInputs.update(t),e.audioOutputs.update(t)}))}},{key:"update",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,BM(t);case 2:return r=n.sent,n.abrupt("return",(e.audioInputs.update(r,e),e.videoInputs.update(r,e),e.audioOutputs.update(r,e),e));case 4:case"end":return n.stop()}}),n)}))()}))}}])}(PM.EventEmitter),VM=OR||xR?null:new UM;function FM(e){return e.deviceId===e.groupId&&""===e.groupId}function BM(){return aR(this,arguments,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return f().mark((function t(){var n,r,i;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!NN()&&xN()){t.next=2;break}return t.abrupt("return",[]);case 2:return t.next=4,navigator.mediaDevices.enumerateDevices();case 4:if(n=t.sent,0===e){t.next=22;break}if(r={audio:!1,video:!1},n.forEach((function(e){FM(e)&&(e.kind===nC.AUDIO_INPUT?r.audio=!0:e.kind===nC.VIDEO_INPUT&&(r.video=!0))})),2===e&&(r.audio=!1),1===e&&(r.video=!1),!r.audio&&!r.video){t.next=22;break}return t.prev=8,t.next=11,navigator.mediaDevices.getUserMedia(r);case 11:i=t.sent,r.audio&&TM(),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),sO.debug("capture before getDevices failed: ",t.t0);case 18:return t.next=20,navigator.mediaDevices.enumerateDevices();case 20:n=t.sent,null==i||i.getTracks().forEach((function(e){return e.stop()}));case 22:return t.abrupt("return",n.map((function(e,t){var n={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&WM.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(n.getCapabilities=function(){return e.getCapabilities()}),n})));case 23:case"end":return t.stop()}}),t,null,[[8,15]])}))()}))}function qM(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return VM.update(e?1:0).then((function(e){return e.audioInputs.devices}))}function jM(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return VM.update(e?2:0).then((function(e){return e.videoInputs.devices}))}var HM=!1;function GM(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",((bD||Ox)&&(e=!1),VM.update(e?1:0).then((function(e){return e.audioOutputs.devices}))));case 1:case"end":return t.stop()}}),t)})))}var WM=new Set;function zM(e,t){return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,qM();case 2:return r=n.sent.find((function(e){return e.deviceId===YC})),n.abrupt("return",!t&&(null==r?void 0:r.groupId)===e||(null==r?void 0:r.groupId)===e&&r.label===t);case 4:case"end":return n.stop()}}),n)})))}var JM,KM=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).log=e,rR(t(a),"volumeMeter"),rR(t(a),"volumeDestination"),rR(t(a),"analyser",new bM),a.volumeMeter=new OM({log:a.log}),a.volumeDestination=new SM,a.volumeMeter.pipeTo(a.volumeDestination),a}return d(i,e),o(i,[{key:"destroy",value:function(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}}])}(IM),YM=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e,nC.AUDIO]),rR(t(a),"_outputDeviceId"),rR(t(a),"_volume",1),rR(t(a),"_destination",kM().createMediaStreamDestination()),rR(t(a),"pipeline"),rR(t(a),"volumeMeterMode","worklet"),a.mode=0,a.pipeline=new KM(a._log),a}return d(i,e),o(i,[{key:"getMediaStream",value:function(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}},{key:"initializeElement",value:function(e){if("15.2"!==Lx&&"15.3"!==Lx&&"15.4"!==Lx||!this.muted){var t=JM||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.element=t,Aw(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===JM&&(JM=void 0),this.bindElementEvents()}else this._log.info("audioElement is muted.")}},{key:"play",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.track){t.next=10;break}if(this.pipeline.source.node||this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==e?void 0:e.volume),t.t0=this._outputDeviceId,!t.t0){t.next=7;break}return t.next=7,this.setSinkId(this._outputDeviceId);case 7:return"worklet"===this.volumeMeterMode?this.pipeline.volumeMeter.init():"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(kM().createAnalyser()),function(){aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,e.t0=HM,e.t0){e.next=11;break}return HM=!0,e.t1=sO,e.t2="speakers:",e.next=8,GM();case 8:e.t3=e.sent.map((function(e){return" ".concat(e.deviceId.slice(0,8),": ").concat(e.label)})),e.t4=e.t2.concat.call(e.t2,e.t3),e.t1.info.call(e.t1,e.t4);case 11:e.next=15;break;case 13:e.prev=13,e.t5=e.catch(0);case 15:case"end":return e.stop()}}),e,null,[[0,13]])})))}(),t.abrupt("return",iR(i.prototype,this,"play").call(this));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),g(i,"stop",this,3)([e])}},{key:"setSinkId",value:function(e){return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._outputDeviceId!==e&&(this._outputDeviceId=e),t.t0=this.element&&this.element.sinkId!==e,!t.t0){t.next=5;break}return t.next=5,null==(r=(n=this.element).setSinkId)?void 0:r.call(n,e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"useDestination",get:function(){return!!this.pipeline.stream}},{key:"setLoop",value:function(e){this.element&&(this.element.loop=e)}},{key:"getAudioLevel",value:function(){return this.pipeline.volumeMeter.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this.pipeline.volumeMeter.getInternalAudioLevel()}}])}(WP),XM=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"setTrack",value:function(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(LP.MEDIA_TRACK_CHANGED,e),e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]))))}},{key:"setVolume",value:function(e){this._volume=e,this.element&&(this.element.volume=e)}}])}(YM),QM=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e]),rR(t(a),"_sourceElement"),rR(t(a),"_output",new SM),a.pipeline.source.pipeTo(a.pipeline.gain.pipeTo(a.pipeline.volumeMeter.pipeTo(a._output),a.pipeline.destination)),a}return d(i,e),o(i,[{key:"setOutput",value:function(){this.mode=1,this._output.setNode(kM().destination)}},{key:"write",value:function(e){this.pipeline.volumeMeter.write(e)}},{key:"setTrack",value:function(e){var t,n;(null==(n=null==(t=this.element)?void 0:t.error)?void 0:n.code)!==MediaError.MEDIA_ERR_DECODE&&this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(LP.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this._sourceElement?this._sourceElement.srcObject=new MediaStream([e]):!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e])),this.pipeline.replaceSource(e)):this.pipeline.source.deleteNode())}},{key:"setVolume",value:function(e){this._volume=e,this.useDestination?(this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e))):e<=1?this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element"):bD||(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),BP(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play()))}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();var t=this._sourceElement||this.element;t&&Nx&&(JM=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),g(i,"stop",this,3)([e])}}])}(YM),$M=function(e){function i(e){var a;r(this,i);var o,s=e.userId,c=e.sdkAppId,u=e.mediaType,l=e.room,d=e.PlayerClass,h=void 0===d?1===u?QM:pM:d;return a=n(this,i),rR(t(a),"id",cO()),rR(t(a),"userId",""),rR(t(a),"isRemote"),rR(t(a),"mediaType"),rR(t(a),"room"),rR(t(a),"user"),rR(t(a),"_log"),rR(t(a),"_inputTrack"),rR(t(a),"_outputTrack"),rR(t(a),"isPlayCalled"),rR(t(a),"container",null),rR(t(a),"player"),rR(t(a),"subVideoPlayerMap"),rR(t(a),"muted",!1),rR(t(a),"abortCtrl"),rR(t(a),"objectFit","cover"),rR(t(a),"mirror"),rR(t(a),"isScreen",!1),rR(t(a),"manager"),rR(t(a),"trackSettings"),rR(t(a),"isFirstVideoFrameEmitted",!1),a.userId=s||"",a.mediaType=u,a._log=sO.createLogger({id:"".concat(a.kind[0],"t"),userId:null==(o=l||a.room)?void 0:o.userId,remoteUserId:t(a)instanceof EL?void 0:a.userId,sdkAppId:c,type:2===a.mediaType?"auxiliary":"main",isLocal:t(a)instanceof EL}),a.player=new h({id:a.userId||a.id,track:null,muted:!1,container:null,log:a._log}),a.player.on(LP.PLAYER_STATE_CHANGED,(function(e){rO.emit(aO.PLAYER_STATE_CHANGED,QA({track:t(a)},e)),a.emit("player-state-changed",e)})),a.kind===nC.VIDEO&&(a.player.on(LP.LOADED_DATA,(function(){a.emitFirstVideoFrameEvent(LP.LOADED_DATA),rO.emit(aO.VIDEO_LOADED_DATA,{track:t(a)})})),a.player.on(LP.LOADED_META_DATA,(function(){a.emitFirstVideoFrameEvent(LP.LOADED_META_DATA)})),a.player.on(LP.MEDIA_TRACK_CHANGED,(function(e){var t;null==(t=a.subVideoPlayerMap)||t.forEach((function(t){return t.setTrack(e)}))}))),a.onTrackMuted=a.onTrackMuted.bind(t(a)),a.onTrackUnmuted=a.onTrackUnmuted.bind(t(a)),a.onTrackEnded=a.onTrackEnded.bind(t(a)),a.onPlayerError&&a.player.on(LP.ERROR,a.onPlayerError.bind(t(a))),a}return d(i,e),o(i,[{key:"log",get:function(){return this._log||sO}},{key:"kind",get:function(){return 1===this.mediaType?nC.AUDIO:nC.VIDEO}},{key:"strMediaType",get:function(){return 4===this.mediaType?nC.VIDEO:2===this.mediaType?nC.SCREEN:nC.AUDIO}},{key:"streamType",get:function(){return 2&this.mediaType?"auxiliary":"main"}},{key:"isMediaTrackActive",get:function(){return!!this.mediaTrack&&!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled}},{key:"play",value:function(e,t){return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=ww(e)?e[0]:e,!this.isPlayCalled){n.next=16;break}if(this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!bw(t.muted)&&this.setPlayerMute(t.muted),t&&!bw(t.objectFit)&&(this.objectFit=t.objectFit),n.t0=this.player instanceof pM,!n.t0){n.next=15;break}if(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(this.container=r,this.player.setContainer(r)),n.t1=ww(e)&&e.length>=1,!n.t1){n.next=14;break}return n.next=13,this.playSubContainer(e.slice(1),t);case 13:n.t1=n.sent;case 14:n.t0=n.t1;case 15:return n.abrupt("return",void n.t0);case 16:if(t&&!bw(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===nC.VIDEO)&&this.setPlayerMute(!0),t&&!bw(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof pM&&(this.player.setObjectFit(this.objectFit),t&&!bw(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof pM&&this.player.setContainer(r)),rO.emit(aO.PLAY_TRACK_START,{track:this}),!this._outputTrack){n.next=33;break}return this._log.info("play with options: ".concat(JSON.stringify(t))),n.prev=18,this.player.setTrack(this.playerMediaTrack),n.next=22,this.player.play(t);case 22:if(n.t2=ww(e)&&e.length>1,!n.t2){n.next=26;break}return n.next=26,this.playSubContainer(e.slice(1),t);case 26:n.next=31;break;case 28:throw n.prev=28,n.t3=n.catch(18),this.handleAutoPlayFailed(n.t3),n.t3;case 31:n.next=34;break;case 33:this.log.info("play has not mediaTrack, abort");case 34:case"end":return n.stop()}}),n,this,[[18,28]])})))}},{key:"setMirror",value:function(e,t){if(!this.isScreen&&this.kind===nC.VIDEO&&!bw(e)&&e!==this.mirror){this.mirror=e;var n=this.player;t&&(n=t);var r=this.manager;if(Rw(this.mirror))return n.setViewMirror(this.mirror),void(r&&(r.mirror=!1));switch(this.mirror){case"view":r&&(r.mirror=!1),n.setViewMirror(!0);break;case"publish":r&&(r.mirror=!0),n.setViewMirror(!0);break;case"both":r&&(r.mirror=!0),n.setViewMirror(!1)}}}},{key:"playSubContainer",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,c,u,l,d,h,p,m=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._outputTrack&&this.kind!==nC.AUDIO){n.next=2;break}return n.abrupt("return");case 2:this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach((function(t,n){var r;e.find((function(e){return n===e}))||(t.stop(),null==(r=m.subVideoPlayerMap)||r.delete(n))})),r=s(e.entries());try{for(r.s();!(i=r.n()).done;)a=v(i.value,2),o=a[0],c=a[1],(u=this.subVideoPlayerMap.get(c))?t&&(bw(t.objectFit)||u.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(c,new pM({id:this.userId||this.id,track:this.playerMediaTrack,container:c,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(o+1)})}))}catch(f){r.e(f)}finally{r.f()}l=E(this.subVideoPlayerMap.values()),d=s(l),n.prev=7,d.s();case 9:if((h=d.n()).done){n.next=16;break}return(p=h.value).setViewMirror(this.player.mirror),n.next=14,p.play();case 14:n.next=9;break;case 16:n.next=21;break;case 18:n.prev=18,n.t0=n.catch(7),d.e(n.t0);case 21:return n.prev=21,d.f(),n.finish(21);case 24:case"end":return n.stop()}}),n,this,[[7,18,21,24]])})))}},{key:"setAudioOutput",value:function(e){return this.player.setSinkId(e)}},{key:"setAudioVolume",value:function(e){this.player.setVolume(e)}},{key:"getAudioLevel",value:function(){return this.player.getAudioLevel()||0}},{key:"getInternalAudioLevel",value:function(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isPlayCalled&&(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(lD(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((function(e){e.stop()})),this.container=null)}},{key:"resume",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isPlayCalled,!e.t0){e.next=4;break}return e.next=4,null==(t=this.player)?void 0:t.resume();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.log.info("close"),this.isPlayCalled&&this.stop(!0)}},{key:"setMute",value:function(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),rO.emit(e?aO.TRACK_MUTED:aO.TRACK_UNMUTED,{track:this})}},{key:"setPlayerMute",value:function(e){this.player.setMuted(e)}},{key:"mediaTrack",get:function(){return this._inputTrack||null}},{key:"outMediaTrack",get:function(){return this._outputTrack||null}},{key:"playerMediaTrack",get:function(){return this.outMediaTrack}},{key:"installTrackEvent",value:function(e){FP(e,e).add(nC.MUTE,this.onTrackMuted).add(nC.UNMUTE,this.onTrackUnmuted).add(nC.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===nC.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){BP(e)}},{key:"setInputMediaStreamTrack",value:function(e){var t,n=this._inputTrack;if(e!==n)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,n&&this.uninstallTrackEvent(n),this.installTrackEvent(e),this.emit("input-media-track-changed",e||null,n||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}},{key:"setOutputMediaStreamTrack",value:function(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this._inputTrack&&(this._outputTrack.contentHint=this._inputTrack.contentHint,this._outputTrack.enabled=this._inputTrack.enabled),this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}},{key:"setMediaType",value:function(e){this.mediaType=e}},{key:"updatePlayingState",value:function(e){var t=this;if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((function(e){return t.handleAutoPlayFailed(e)})),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(lD(this)?this.jitterBufferDelay:0),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}},{key:"handleAutoPlayFailed",value:function(e){var t=this;if(this.room&&this.room.enableAutoPlayDialog)new fM;else{var n=function(){t.resume().then((function(){document.removeEventListener("click",n,!0)}))};document.addEventListener("click",n,!0)}this.emit("error",e)}},{key:"getVideoFrame",value:function(){return this.player instanceof pM?this.player.getVideoFrame():""}},{key:"emitFirstVideoFrameEvent",value:function(e){var t,n,r;if(!this.isFirstVideoFrameEmitted){var i=null==(t=this.mediaTrack)?void 0:t.getSettings(),a=(null==i?void 0:i.width)||(null==(n=this.player.element)?void 0:n.videoWidth)||0,o=(null==i?void 0:i.height)||(null==(r=this.player.element)?void 0:r.videoHeight)||0;e===LP.LOADED_META_DATA&&!a&&!o||(e===LP.LOADED_DATA&&!a&&!o&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,this.emit("first-video-frame",{width:a,height:o,streamType:this.streamType,userId:this.isRemote?this.userId:""}))}}},{key:"onTrackMuted",value:function(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}},{key:"onTrackUnmuted",value:function(){this._log.info("".concat(this.kind," track is able to provide media output"))}},{key:"onTrackEnded",value:function(){this._log.warn("".concat(this.kind," track ended"))}}])}(wP);nR([AP([],wP.INIT,{sync:!0})],$M.prototype,"close",1);var ZM=Object.prototype.hasOwnProperty,eL=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(yw(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(ZM.call(e,t))return!1;return!0}return!1},tL=dD({retryFunction:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=function(e){return{audio:rL(e),video:iL(e)}}(e),sO.info("getUserMedia with constraints: ".concat(JSON.stringify(n))),r=[],i=[],a=["label","deviceId","groupId"],t.t0=n.audio,!t.t0){t.next=9;break}return t.next=7,qM();case 7:r=t.sent,sO.info("microphones: ".concat(Xw(r.map((function(e){return $A(QA({},e),{groupId:e.groupId.substring(0,8)})})),{keysToInclude:a})));case 9:if(t.t1=n.video,!t.t1){t.next=15;break}return t.next=13,jM();case 13:i=t.sent,sO.info("cameras: ".concat(Xw(i,{keysToInclude:a})));case 15:return t.prev=15,t.next=18,navigator.mediaDevices.getUserMedia(n);case 18:return o=t.sent,t.abrupt("return",(oP&&o.getTracks().forEach((function(e){sO.info("".concat(e.kind," capabilities: ").concat(Xw(e.getCapabilities(),{keysToInclude:nw})))})),n.audio&&TM(),o));case 22:throw t.prev=22,t.t2=t.catch(15),s=t.t2.message,"NotFoundError"===t.t2.name&&(e.video&&i&&0===i.length&&(s=mN({key:dN.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(s=mN({key:dN.MICROPHONE_NOT_FOUND}))),new yR({code:_R.INITIALIZE_FAILED,name:t.t2.name,message:s,constraint:t.t2.constraint});case 26:case"end":return t.stop()}}),t,null,[[15,22]])})))},settings:{retries:3,timeout:500},onError:function(e){var t=e.error,n=e.retry,r=e.reject,i=e.retryFuncArgs,a=e.retriedCount+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name?(1===a?(i[0].video&&(i[0].maxResolution=!1,(!Ox||i[0].width*i[0].height<=2073600)&&i[0].frameRate&&(i[0].frameRate=i[0].frameRate>10?10:5)),i[0].retryWhenExactFailed&&i[0].useExactDeviceId&&(i[0].useExactDeviceId=!1)):2===a?i[0].useDeviceIdOnly=!0:3===a&&!i[0].useExactDeviceId&&(i[0].useTrueAsConstraint=!0),n()):r(t),i[0].microphoneId&&nL(i[0].microphoneId,!1),i[0].cameraId&&nL(i[0].cameraId,!0)},onRetrying:function(e){sO.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:function(e){qP.logFailedEvent({eventType:OC.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:function(e){qP.logSuccessEvent({eventType:OC.GET_USER_MEDIA_RETRY}),qP.uploadEvent({log:"stat-".concat(OC.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function nL(e,t){return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!t){n.next=6;break}return n.next=3,jM();case 3:n.t0=n.sent,n.next=9;break;case 6:return n.next=8,qM();case 8:n.t0=n.sent;case 9:r=n.t0.find((function(t){return t.deviceId===e})),r&&Sw(r.getCapabilities)&&sO.warn(Xw(r.getCapabilities(),{keysToInclude:nw}));case 11:case"end":return n.stop()}}),n)})))}function rL(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!eL(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(Aw(e.channelCount)&&(t.channelCount=e.channelCount),Rw(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),Rw(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),Rw(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!eL(t)||t)}function iL(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;var t=e.maxResolution,n=void 0===t||t,r={};return e.cameraId?r.deviceId=e.useExactDeviceId?{exact:e.cameraId}:e.cameraId:e.facingMode&&(r.facingMode=e.facingMode),e.useDeviceIdOnly&&!eL(r)?r:(e.width&&(r.width={ideal:e.width},n&&!wD&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},n&&!wD&&(r.height.max=e.height)),wD&&ox&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!eL(r)||r)}var aL=tL;function oL(e){return uL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.apply(this,r);case 2:return n.abrupt("return",t.apply(this,r));case 3:case"end":return n.stop()}}),n,this)})))}}))}function sL(e){return uL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return aR(this,null,f().mark((function n(){var i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.apply(this,r);case 2:return i=n.sent,n.next=5,e.call.apply(e,[this].concat(r));case 5:return n.abrupt("return",i);case 6:case"end":return n.stop()}}),n,this)})))}}))}function cL(e){return uL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,t.apply(this,r);case 3:return n.abrupt("return",n.sent);case 6:n.prev=6,n.t0=n.catch(0),e.call(this,n.t0);case 9:case"end":return n.stop()}}),n,this,[[0,6]])})))}}))}function uL(e){return function(t,n,r){return r.value=e(r.value,n),r}}var lL=function(){var e=!1,t=document.visibilityState;return function(){document.visibilityState!==t&&sO.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(function(){sO.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}}(),dL=0,hL=function(){return o((function e(){r(this,e),rR(this,"log",sO.createLogger({id:"fq".concat(++dL)})),rR(this,"isRunning",!1),rR(this,"queue",[])}),[{key:"length",get:function(){return this.queue.length}},{key:"lastQueueItem",get:function(){return 0===this.length?null:this.queue[this.length-1]}},{key:"push",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=QA({},e),a=new Promise((function(e,t){i.resolve=e,i.reject=t}));return i.promise=a,r?this.length<=1?this.queue.push(i):null==(n=null==(t=this.lastQueueItem)?void 0:t.promise)||n.then(i.resolve,i.reject):this.queue.push(i),this.log.debug("push ".concat(this.length)),this.isRunning||this.callNext(),a}},{key:"shift",value:function(){var e=this.queue.shift();return this.log.debug("shift ".concat(this.length)),e}},{key:"callNext",value:function(){var e=this;if(!this.isRunning&&0!==this.length){this.log.debug("callNext ",this.length);var t=this.queue[0],n=t.fn,r=t.args,i=t.context,a=t.resolve,o=t.reject;this.isRunning=!0,n.apply(i,r).then(a,o).finally((function(){e.isRunning=!1,e.shift(),e.callNext()}))}}}])}(),fL=new WeakMap,pL=new WeakMap;function mL(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,n,r){var i=r.value;return r.value=function(){for(var t=fL.get(this)||new hL,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return fL.set(this,t),t.push({fn:i,args:r,context:this},e)},r}}function vL(e){return function(t,n,r){var i=r.value;return r.value=function(){for(var t,n,r,a=[],o=arguments.length,s=new Array(o),c=0;c<o;c++)s[c]=arguments[c];return null==(n=null==(t=fL.get(this))?void 0:t.queue)||n.forEach((function(e){return a.push(e)})),null==(r=pL.get(this))||r.forEach((function(e){return null==e?void 0:e.queue.forEach((function(e){return a.push(e)}))})),a.forEach((function(t){t.reject(new yR({code:_R.API_CALL_ABORTED,message:e}))})),fL.delete(this),pL.delete(this),i.apply(this,s)},r}}function _L(e){return function(t,n,r){var i=r.value,a=function(t){return e.apply(void 0,E(t))};return r.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=pL.get(this)||new Map,o=r.get(a(t))||new hL;return r.set(a(t),o),pL.set(this,r),o.push({fn:i,args:t,context:this})},r}}function gL(e,t){return uL((function(n,r){return function(){var r=e;try{for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];var s=n.apply(this,a),c=Uw();return Ow(s)?s.then((function(e){return t?IN.addSuccessEvent({key:r,cost:Uw()-c}):IN.addSuccessEvent({key:r}),e})).catch((function(e){throw IN.addFailedEvent({key:r,error:e}),e})):(IN.addSuccessEvent({key:r}),s)}catch(DR){throw IN.addFailedEvent({key:r,error:DR}),DR}}}))}var yL=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[{mediaType:e,PlayerClass:a}]),rR(t(o),"isRemote",!1),rR(t(o),"deviceId"),rR(t(o),"groupId",""),rR(t(o),"label",""),rR(t(o),"_isRecapturing",!1),rR(t(o),"_lastRecaptureTime",0),rR(t(o),"_onMuteTimeoutId",-1),rR(t(o),"_encodeCheckTimeoutId",-1),rR(t(o),"profile"),o}return d(i,e),o(i,[{key:"enableEncodeFrame",get:function(){return!1}},{key:"isPublishing",get:function(){return"publishing"===this.state.toString()}},{key:"isPublished",get:function(){return"publish"===this.state}},{key:"encodeFrame",value:function(e,t){throw new Error("Method not implemented.")}},{key:"installTrackEvent",value:function(e){FP(e,e).add(nC.MUTE,this.onTrackMuted).add(nC.UNMUTE,this.onTrackUnmuted).add(nC.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===nC.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){BP(e)}},{key:"setStateToCapture",value:function(){}},{key:"capture",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,i=Uw(),rO.emit(aO.LOCAL_TRACK_CAPTURE_START,{track:this}),!e.customSource){t.next=7;break}(r=new MediaStream).addTrack(e.customSource),t.next=11;break;case 7:return null==(n=this.mediaTrack)||n.stop(),t.next=10,aL(e);case 10:r=t.sent;case 11:return a=r.getTracks()[0],t.next=14,this.setInputMediaStreamTrack(a);case 14:return e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),rO.emit(aO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:Uw()-i}),t.abrupt("return",r);case 19:throw t.prev=19,t.t0=t.catch(0),rO.emit(aO.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:t.t0}),this.log.error("getUserMedia error observed ".concat(t.t0)),t.t0;case 22:case"end":return t.stop()}}),t,this,[[0,19]])})))}},{key:"setInputMediaStreamTrack",value:function(e){return this.state===wP.INIT&&this.setStateToCapture(),g(i,"setInputMediaStreamTrack",this,3)([e])}},{key:"setOutputMediaStreamTrack",value:function(e){var t;if(g(i,"setOutputMediaStreamTrack",this,3)([e]),this.isPublishing||this.isPublished)return null==(t=this.room)?void 0:t.replaceTrack(this)}},{key:"publish",value:function(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),t}},{key:"unpublish",value:function(){this.room&&this.room.localTracks.delete(this),rO.emit(aO.LOCAL_TRACK_UNPUBLISHED,{track:this})}},{key:"updateDeviceIdInUse",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaTrack||!aP){e.next=7;break}return t=this.mediaTrack.getSettings(),n=t.deviceId,r=t.groupId,i=this.mediaTrack.label,e.next=4,function(e){return aR(this,arguments,(function(e){var t=e.newDeviceId,n=e.oldDeviceId,r=e.oldGroupId,i=e.oldLabel,a=e.kind;return f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=t===n,!e.t0){e.next=8;break}if(e.t1=a!==nC.AUDIO||t!==YC,e.t1){e.next=7;break}return e.next=6,zM(r,i);case 6:e.t1=e.sent;case 7:e.t0=e.t1;case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e)}))()}))}({newDeviceId:n,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind});case 4:if(e.t0=e.sent,e.t0){e.next=7;break}this.deviceId=n,this.label=i,r&&(this.groupId=r),BM().then((function(e){var t=e.find((function(e){return e.deviceId===n}));t&&a.emit("2",t)}));case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setProfile",value:function(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}},{key:"isNeedToRecapture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===nC.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;var t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;var n="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(nC.AUDIO_INPUT);return!!WM.has(n)}(this.mediaTrack)||this.kind===nC.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;var t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;var n="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(nC.VIDEO_INPUT);return!!WM.has(n)}(this.mediaTrack)||this._isRecapturing||e&&ox&&Ox)}},{key:"onTrackMuted",value:function(){var e=this;if(g(i,"onTrackMuted",this,3)([]),lL(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<tw)return void setTimeout((function(){return e.onTrackMuted()}),tw);this._onMuteTimeoutId=setTimeout((function(){return aR(e,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(t=this.mediaTrack)||!t.muted){e.next=8;break}if(!bD&&!ID||"visible"===document.visibilityState){e.next=3;break}return e.abrupt("return");case 3:return e.t0=this,e.next=6,this.getRecoverCaptureDeviceId();case 6:e.t1=e.sent,e.t0.recapture.call(e.t0,e.t1);case 8:case"end":return e.stop()}}),e,this)})))}),5e3)}}},{key:"onTrackUnmuted",value:function(){g(i,"onTrackUnmuted",this,3)([]),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}},{key:"onTrackEnded",value:function(){return aR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(iR(i.prototype,this,"onTrackEnded").call(this),!this.isNeedToRecapture()){e.next=8;break}if(!(Date.now()-this._lastRecaptureTime<tw)){e.next=3;break}return e.abrupt("return",void setTimeout((function(){return t.onTrackEnded()}),tw));case 3:return e.t0=this,e.next=6,this.getRecoverCaptureDeviceId();case 6:e.t1=e.sent,e.t0.recapture.call(e.t0,e.t1);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"recapture",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isRecapturing&&this._inputTrack){t.next=2;break}return t.abrupt("return");case 2:if(this.log.warn("recapture trying"),null==(n=this._inputTrack)||n.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now(),r={useExactDeviceId:!0},"user"!==e&&"environment"!==e){t.next=8;break}r.facingMode=e,t.next=21;break;case 8:if("audio"!==this.kind){t.next=14;break}return t.next=11,qM();case 11:t.t0=t.sent,t.next=17;break;case 14:return t.next=16,jM();case 16:t.t0=t.sent;case 17:if(t.t1=t.t0.find((function(t){return t.deviceId===e})),!t.t1){t.next=20;break}i=e;case 20:r.deviceId=i;case 21:return t.abrupt("return",this.capture(r).then((function(){a._isRecapturing=!1,a.log.warn("recapture success"),a.emit("1",{deviceId:a.deviceId}),rO.emit(aO.LOCAL_TRACK_RECAPTURE,{track:a})})).catch((function(e){a._isRecapturing=!1,a.log.warn("recapture failed ".concat(e.message)),a.emit("5",e),rO.emit(aO.LOCAL_TRACK_RECAPTURE,{track:a,error:e})})));case 22:case"end":return t.stop()}}),t,this)})))}},{key:"getRecoverCaptureDeviceId",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=this instanceof AL)||!this.facingMode){e.next=3;break}return e.abrupt("return",this.facingMode);case 3:if(!(n=this.deviceId)){e.next=18;break}if(r=(TL.get(n)||0)+1,TL.set(n,r),!(r>=3)){e.next=18;break}if(!t){e.next=13;break}return e.next=10,jM();case 10:e.t0=e.sent.find((function(e){return!TL.has(e.deviceId)})),e.next=16;break;case 13:return e.next=15,qM();case 15:e.t0=e.sent.find((function(e){return!TL.has(e.deviceId)}));case 16:(i=e.t0)&&(this.log.warn("".concat(n," capture fail ").concat(r," times, change new ").concat(i.deviceId)),n=i.deviceId);case 18:return e.abrupt("return",n);case 19:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){var e;g(i,"close",this,3)([]),this._inputTrack&&(this._inputTrack.stop(),this.uninstallTrackEvent(this._inputTrack)),null==(e=this.manager)||e.removeInput(this)}}])}($M);nR([AP(wP.INIT,"capture",{ignoreError:!0,sync:!0})],yL.prototype,"setStateToCapture",1),nR([mL()],yL.prototype,"capture",1),nR([AP("capture","publish",{ignoreError:!0,success:function(){var e,t,n=this;this.room.localTracks.add(this),rO.emit(aO.LOCAL_TRACK_PUBLISHED,{track:this}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"}),!(((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&(this._encodeCheckTimeoutId=setTimeout((function(){var e,t;if(!(((null==(t=null==(e=n.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&n.isPublished&&n.isMediaTrackActive){var r=n.kind===nC.AUDIO,i=n.stat.bytesSent>0;IN[i?"addSuccessEvent":"addFailedEvent"]({key:r?503700:513702}),i||(IN.addEnum({key:r?503701:513703,value:$x()}),qP.uploadEvent({log:"stat-encode-failed-".concat(n.kind,"-").concat(Yx()||Zx()),userId:n.userId}),n.log.warn("encode failed"),n.emit("6",n))}}),5e3))},fail:function(e){var t="error";if(e.cause instanceof RTCError){var n=e.cause;n.message.includes("timeout")?t="timeout":n.code===_R.API_CALL_ABORTED&&(t="api-call")}this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:e.cause||e})}}),gL(521714,!1)],yL.prototype,"publish",1),nR([uL((function(e){return function(){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n="publish"===this.state?"started":"starting",e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:n,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId);case 2:case"end":return t.stop()}}),t,this)})))}})),AP([],"capture",{sync:!0})],yL.prototype,"unpublish",1);var EL=yL,TL=new Map;rO.on(aO.SWITCH_DEVICE_SUCCESS,(function(e){e.track.deviceId&&TL.delete(e.track.deviceId)}));var kL=function(e){function i(e){var a;return r(this,i),a=n(this,i,[1,XM]),rR(t(a),"mediaType",1),rR(t(a),"volume",0),rR(t(a),"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),rR(t(a),"playerMuted",!0),rR(t(a),"pipeline"),rR(t(a),"earMonitorGainNode",new SM),rR(t(a),"_output",new SM),rR(t(a),"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),a.manager=e,a.pipeline=new AM(e),a.pipeline.gain.pipeTo(a.earMonitorGainNode.pipeTo(a._output),a.player.pipeline.volumeMeter),a.handleMicrophoneAdded=a.handleMicrophoneAdded.bind(t(a)),a.handleMicrophoneRemoved=a.handleMicrophoneRemoved.bind(t(a)),a}return d(i,e),o(i,[{key:"dbVolume",get:function(){return NM.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}},{key:"getAudioLevel",value:function(){var e=(this.volume||g(i,"getAudioLevel",this,3)([]))*this.captureVolume;return e>1?1:e}},{key:"setInputMediaStreamTrack",value:function(e){return aR(this,null,f().mark((function t(){var n,r,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.trackSettings||{},IN.addEnum({key:501701,value:n.channelCount||0,useUV:!1}),IN.addEnum({key:501702,value:n.sampleRate||0,useUV:!1}),IN.addEnum({key:502700,value:0}),r=n.sampleRate,a=n.channelCount,this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:r,channelCount:a}))),this.pipeline.replaceSource(e),t.next=7,iR(i.prototype,this,"setInputMediaStreamTrack").call(this,e);case 7:this.updatePlayingState(!!e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"capture",value:function(e){var t=e.deviceId,n=e.customSource,r=e.useExactDeviceId,a=void 0===r||r,o=e.retryWhenExactFailed,s=void 0===o||o;return g(i,"capture",this,3)([{video:!1,audio:!0,microphoneId:t,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExactDeviceId:a,retryWhenExactFailed:s,customSource:n}])}},{key:"switchDevice",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.mediaTrack){t.next=20;break}if(this.deviceId!==e){t.next=8;break}if(e===YC){t.next=4;break}return t.abrupt("return");case 4:return t.next=6,zM(this.groupId,this.label);case 6:if(!t.sent){t.next=8;break}return t.abrupt("return");case 8:return t.prev=8,this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),t.next=13,this.capture({deviceId:e,useExactDeviceId:!0,retryWhenExactFailed:!1});case 13:rO.emit(aO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success"),t.next=20;break;case 17:throw t.prev=17,t.t0=t.catch(8),this.log.error("switch microphone failed ".concat(t.t0)),this.deviceId&&this.recapture(this.deviceId),t.t0;case 20:case"end":return t.stop()}}),t,this,[[8,17]])})))}},{key:"listenDeviceChange",value:function(){VM&&!VM.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&VM.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}},{key:"handleMicrophoneRemoved",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.deviceId!==this.deviceId){t.next=6;break}return this.log.warn("current microphone is lost: ".concat(JSON.stringify(e))),_F(this.userId,{eventId:2003,param1:6,streamType:1}),t.next=4,qM();case 4:(n=t.sent)[0]?this.recapture(n[0].deviceId):VM.on("audioInputAdded",this.handleMicrophoneAdded,this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"handleMicrophoneAdded",value:function(e){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}},{key:"update3A",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.echoCancellation,r=e.noiseSuppression,i=e.autoGainControl;return f().mark((function e(){var a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=!1,!bw(n)&&n!==t.profile.echoCancellation&&(t.profile.echoCancellation=n,a=!0),!bw(r)&&r!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=r,a=!0),!bw(i)&&i!==t.profile.autoGainControl&&(t.profile.autoGainControl=i,a=!0),e.t0=a&&t.deviceId,!e.t0){e.next=8;break}return e.next=8,t.recapture(t.deviceId);case 8:case"end":return e.stop()}}),e)}))()}))}},{key:"captureVolume",get:function(){return this.pipeline.volume}},{key:"setCaptureVolume",value:function(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&IN.addEnum({key:502700,value:2})}},{key:"setAudioVolume",value:function(e){g(i,"setAudioVolume",this,3)([0]),bD&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(kM().createGain()),this._output.setNode(kM().destination)),this.earMonitorGainNode.node.gain.value=e}},{key:"enableTrackANS",value:function(e){var t=this;if(this._inputTrack){var n=this._inputTrack.getConstraints();return n.noiseSuppression=e,this._inputTrack.applyConstraints(n).catch((function(n){return t._log.warn("".concat(e?"enable":"disable"," ANS failed "),n)}))}}},{key:"addDenoiser",value:function(e){var t;Dx<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(IN.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.enableTrackANS(!1))}},{key:"removeDenoiser",value:function(e){this.pipeline.denoiser.node===e&&(this.pipeline.denoiser.deleteNode(),this.enableTrackANS(!0))}},{key:"close",value:function(){this.pipeline.remove(),this.earMonitorGainNode.deleteNode(),this._output.deleteNode(),VM.off("audioInputAdded",this.handleMicrophoneAdded,this),VM.off("audioInputRemoved",this.handleMicrophoneRemoved,this),g(i,"close",this,3)([])}},{key:"recapture",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,iR(i.prototype,this,"recapture").call(this,e);case 3:t.next=14;break;case 5:return t.prev=5,t.t0=t.catch(0),t.next=9,qM();case 9:if(n=t.sent.find((function(t){return t.deviceId!==e})),n){t.next=12;break}throw t.t0;case 12:return t.next=14,iR(i.prototype,this,"recapture").call(this,n.deviceId);case 14:case"end":return t.stop()}}),t,this,[[0,5]])})))}},{key:"encodeFrame",value:function(e){return this.manager?this.manager.encodePipeline.reduceRight((function(e,t){return t?t({frame:e}):e}),e):e}},{key:"enableEncodeFrame",get:function(){return!!this.manager&&this.manager.encodePipeline.some((function(e){return e}))}}])}(EL),SL=function(){return o((function e(t){r(this,e);var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}),[{key:"addPreventionByte",value:function(){for(var e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,n=[],r=0,i=e;i<=t;i++){var a=this.dataView.getInt8(i);switch(a){case 0:case 1:case 2:case 3:2===r&&(n.push(3),r=0),0==a?r++:r=0,n.push(a);break;default:r=0,n.push(a)}}n.push(this.dataView.getInt8(this.dataView.byteLength-1));var o=new DataView(new Uint8Array([].concat(E(new Uint8Array(this.dataView.buffer).slice(0,e)),n)).buffer);this.dataView=o}},{key:"removePreventionByte",value:function(){for(var e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,n=[],r=0,i=e;i<=t;i++)switch(this.dataView.getInt8(i)){case 0:r++,n.push(this.dataView.getInt8(i));break;case 3:2!==r&&n.push(this.dataView.getInt8(i)),r=0;break;default:n.push(this.dataView.getInt8(i)),r=0}var a=new DataView(new Uint8Array([].concat(E(new Uint8Array(this.dataView.buffer).slice(0,e)),n)).buffer);this.dataView=a}},{key:"isSEI",get:function(){return 6===this.dataView.getUint8(4)}},{key:"seiPayloadStartIndex",get:function(){for(var e=6,t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var e=0,t=6,n=6;n<this.dataView.buffer.byteLength;n++){var r=this.dataView.getUint8(n);if(t++,255!==r){e+=r;break}e+=255}for(var i=new ArrayBuffer(e),a=new DataView(i),o=0;o<i.byteLength;o++,t++)a.setInt8(o,this.dataView.getInt8(t));return a}}])}(),bL=function(){return o((function e(){r(this,e),rR(this,"_seiMessageList",[]),rR(this,"_smallSeiMessageList",[]),rR(this,"_seiPayloadType",243)}),[{key:"encodeSEINalu",value:function(e){var t=e.byteLength,n=parseInt(String(t/255),10),r=t%255,i=[];i.push(0,0,0,1,6,this._seiPayloadType);for(var a=0;a<n;a++)i.push(255);i.push(r);var o=new DataView(e);return i.push.apply(i,E(new Uint8Array(o.buffer))),i.push(128),new SL(new DataView(new Uint8Array(i).buffer),!0)}},{key:"sendSEI",value:function(e,t){null!=t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),null!=t&&t.small&&this._smallSeiMessageList.push(e)}},{key:"isEmpty",value:function(){return!this._seiMessageList.length}},{key:"getNaluCount",value:function(e){for(var t=0,n=0,r=new DataView(e),i=0;i<e.byteLength;i++)switch(r.getUint8(i)){case 0:t++;break;case 1:(2===t||3===t)&&n++,t=0;break;default:t=0}return n}},{key:"encode",value:function(e,t){var n=t?this._smallSeiMessageList:this._seiMessageList;if(n.length>0&&e.data.byteLength>0){var r=9-this.getNaluCount(e.data);if(r<=0)return 0;for(var i=n.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),a=i.reduce((function(e,t){return e+t.dataView.byteLength}),0),o=new ArrayBuffer(a+e.data.byteLength),s=new DataView(o),c=new DataView(e.data),u=0,l=0;l<i.length;l++)for(var d=0;d<i[l].dataView.byteLength;d++)s.setInt8(u++,i[l].dataView.getInt8(d));for(var h=0;h<e.data.byteLength;h++)s.setInt8(u++,c.getInt8(h));return e.data=o,i.length}return 0}}])}(),IL=function(e){function i(e){var a;r(this,i),a=n(this,i,[arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,pM]),rR(t(a),"profile",{width:640,height:480,frameRate:15,bitrate:500}),rR(t(a),"avoidCropping",!1),rR(t(a),"_scaleResolutionDownBy"),rR(t(a),"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0}),rR(t(a),"small"),rR(t(a),"isNeedToSetBandwidth"),rR(t(a),"muteImage"),rR(t(a),"manager"),rR(t(a),"_seiCodec",new bL),a.manager=e;var o=function(){a.isAllowed2k4k(a.profile)?a.room&&a.settings.height>=1440&&"publish"===a.state&&a.room.sendAbilityStatus({"2k4k":1}):(a.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),a.setProfile($A(QA({},a.profile),{width:1920,height:1080})),a.applyProfile())};return a.on("input-media-track-changed",o),a.on("publish",o),a.handleCameraAdded=a.handleCameraAdded.bind(a),a.handleCameraRemoved=a.handleCameraRemoved.bind(a),a}return d(i,e),o(i,[{key:"facingMode",get:function(){if(aP&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}},{key:"isQosClearFirst",get:function(){var e;return"detail"===(null==(e=this._inputTrack)?void 0:e.contentHint)}},{key:"setMute",value:function(e){return aR(this,null,f().mark((function t(){var n,r,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Iw(e)){t.next=11;break}if(this.muteImage!==e){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,null==(n=this.manager)?void 0:n.deleteWatermark("mute");case 5:return t.next=7,null==(r=this.manager)?void 0:r.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:e});case 7:this.muteImage=e,iR(i.prototype,this,"setMute").call(this,!1),t.next=15;break;case 11:return t.next=13,null==(a=this.manager)?void 0:a.deleteWatermark("mute");case 13:this.muteImage=void 0,iR(i.prototype,this,"setMute").call(this,e);case 15:case"end":return t.stop()}}),t,this)})))}},{key:"capture",value:function(e){var t=e.deviceId,n=e.facingMode,r=e.useExactDeviceId,a=void 0===r||r,o=e.customSource,s=e.retryWhenExactFailed,c=void 0===s||s;return g(i,"capture",this,3)([{audio:!1,video:!0,facingMode:n||this.facingMode,cameraId:t,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExactDeviceId:a,retryWhenExactFailed:c,customSource:o}])}},{key:"setProfile",value:function(e){var t=QA({},e),n=t.width>t.height;t.width*t.height<=19200&&ID&&Rx&&(this.log.warn("resolution is ".concat(t.width,"*").concat(t.height,", fallback to 240*180")),t.width=n?240:180,t.height=n?180:240,t.bitrate=Math.max(t.bitrate,150)),t.width*t.height>921600&&Bx&&(t.width=n?1280:720,t.height=n?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),this.avoidCropping&&(Rx||wD)&&!zx()&&t.width*t.height<=230400&&t.width/t.height==16/9&&(this._scaleResolutionDownBy=1280/t.width,t.width=1280,t.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),t.bitrate&&(this.isNeedToSetBandwidth=t.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?g(i,"setProfile",this,3)([t]):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),g(i,"setProfile",this,3)([$A(QA({},this.profile),{width:1920,height:1080})]))}},{key:"applyProfile",value:function(){return aR(this,null,f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaTrack){e.next=2;break}return e.abrupt("return");case 2:if(n=this.settings,e.t0=(n.height!==this.profile.height||n.width!==this.profile.width||n.frameRate!==this.profile.frameRate)&&this.deviceId,!e.t0){e.next=15;break}if(16!==Ux){e.next=10;break}return e.next=8,this.recapture(this.deviceId);case 8:e.next=13;break;case 10:return e.next=12,null==(t=this.mediaTrack)?void 0:t.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate});case 12:this.manager&&this.manager.changeInput(this);case 13:this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}),e.t0=this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth;case 15:if(!e.t0){e.next=19;break}e.t1=(this.isNeedToSetBandwidth=!1,this.room.setBandWidth({bandwidth:this.profile.bitrate,type:nC.VIDEO,videoType:nC.BIG})),e.next=20;break;case 19:e.t1=void 0;case 20:return e.abrupt("return",e.t1);case 21:case"end":return e.stop()}}),e,this)})))}},{key:"settings",get:function(){var e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate};return aP&&this.mediaTrack&&Object.assign(e,this.mediaTrack.getSettings()),e}},{key:"scaleResolutionDownBy",get:function(){if(this._scaleResolutionDownBy)return this._scaleResolutionDownBy;var e=this.settings;return e.width===this.profile.width&&e.height===this.profile.height?1:Zw()&&this.profile.width>this.profile.height&&e.height>e.width?Math.max(e.width/this.profile.height,e.height/this.profile.width,1):Math.max(e.width/this.profile.width,e.height/this.profile.height,1)}},{key:"isAllowed2k4k",value:function(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}},{key:"isNeedToSwitchDevice",value:function(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}},{key:"switchDevice",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,this.isNeedToSwitchDevice(e)){t.next=3;break}return t.abrupt("return");case 3:return n={useExactDeviceId:!0,retryWhenExactFailed:!1},"user"===e||"environment"===e?n.facingMode=e:n.deviceId=e,this.mediaTrack.stop(),t.next=8,this.capture(n);case 8:rO.emit(aO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success"),t.next=15;break;case 12:throw t.prev=12,t.t0=t.catch(0),this.log.error("switch camera failed ".concat(t.t0)),this.deviceId&&this.recapture(this.deviceId),t.t0;case 15:case"end":return t.stop()}}),t,this,[[0,12]])})))}},{key:"listenDeviceChange",value:function(){VM&&!VM.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&VM.on("videoInputRemoved",this.handleCameraRemoved,this)}},{key:"handleCameraRemoved",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.deviceId!==this.deviceId){t.next=6;break}return this.log.warn("current camera is lost: ".concat(JSON.stringify(e))),_F(this.userId,{eventId:2003,param1:7,streamType:2}),t.next=4,jM();case 4:(n=t.sent)[0]?this.recapture(n[0].deviceId):VM.on("videoInputAdded",this.handleCameraAdded,this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"handleCameraAdded",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId);case 1:case"end":return t.stop()}}),t,this)})))}},{key:"encodeFrame",value:function(e,t){if(!this.manager)return e;var n=t?8:this.mediaType;return this.manager.encodePipeline.reduceRight((function(e,t){return t?t({frame:e,mediaType:n}):e}),e)}},{key:"enableEncodeFrame",get:function(){return!!this.manager&&this.manager.encodePipeline.some((function(e){return e}))}},{key:"play",value:function(e,t){return bw(this.mirror)&&!this.isScreen&&this.setMirror("view"),g(i,"play",this,3)([e,t])}},{key:"close",value:function(){VM.off("videoInputAdded",this.handleCameraAdded,this),VM.off("videoInputRemoved",this.handleCameraRemoved,this),g(i,"close",this,3)([])}},{key:"recapture",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,iR(i.prototype,this,"recapture").call(this,e);case 3:t.next=14;break;case 5:return t.prev=5,t.t0=t.catch(0),t.next=9,jM();case 9:if(n=t.sent.find((function(t){return t.deviceId!==e})),n){t.next=12;break}throw t.t0;case 12:return t.next=14,iR(i.prototype,this,"recapture").call(this,n.deviceId);case 14:case"end":return t.stop()}}),t,this,[[0,5]])})))}},{key:"setContentHint",value:function(e){this.mediaTrack&&"contentHint"in this.mediaTrack&&(this.mediaTrack.contentHint!==e&&(this.log.info("setContentHint ".concat(e)),this.mediaTrack.contentHint=e),this.outMediaTrack&&this.outMediaTrack.contentHint!==e&&(this.outMediaTrack.contentHint=e))}}])}(EL);nR([sL((function(e){this.setContentHint(e.contentHint||"motion")}))],IL.prototype,"capture",1);var AL=IL,RL=cO();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:RL,exposeOrigin:!0,permittedOrigins:["*"]})}catch(Hj){}var CL=function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=null,r=function(e){var t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:Ox?{max:e.width}:{ideal:e.width,max:e.width},height:Ox?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=n,e.systemAudio){var r=e.echoCancellation,i=void 0===r||r,a=e.noiseSuppression,o=void 0!==a&&a,s=e.autoGainControl,c=void 0!==s&&s;t.audio={echoCancellation:i,noiseSuppression:o,autoGainControl:c,sampleRate:48e3}}return t}(e),sO.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r))),t.next=4,navigator.mediaDevices.getDisplayMedia(r);case 4:if(i=t.sent,e.systemAudio&&0===i.getAudioTracks().length&&(Cx&&Dx<74||Ox||wD)&&sO.warn("Your browser not support capture system audio"),!(a=i.getVideoTracks()[0])){t.next=21;break}if(!e.frameRate){t.next=17;break}return t.prev=9,t.next=12,a.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height});case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(9),sO.warn("screen applyConstraints failed: ".concat(t.t0));case 17:if(t.t1=e.captureElement,!t.t1){t.next=21;break}return t.next=21,function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!("CropTarget"in window&&"fromElement"in CropTarget&&Sw(e.cropTo))){n.next=14;break}if(n.prev=1,(null==(r=e.getCaptureHandle())?void 0:r.handle)===RL){n.next=4;break}return n.abrupt("return");case 4:return n.next=6,CropTarget.fromElement(t);case 6:return i=n.sent,n.next=9,e.cropTo(i);case 9:n.next=14;break;case 11:n.prev=11,n.t0=n.catch(1),sO.warn("cropTo target failed ".concat(n.t0));case 14:case"end":return n.stop()}}),n,null,[[1,11]])})))}(a,e.captureElement);case 21:if(!e.audio){t.next=28;break}return r=function(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return bw(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e),sO.info("getUserMedia with constraints: ".concat(JSON.stringify(r))),t.next=26,navigator.mediaDevices.getUserMedia(r);case 26:n=t.sent,i.addTrack(n.getAudioTracks()[0]);case 28:return t.abrupt("return",i);case 29:case"end":return t.stop()}}),t,null,[[9,14]])})))},wL=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e,2]),rR(t(a),"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),rR(t(a),"objectFit","contain"),rR(t(a),"isScreen",!0),a._log.id="s-".concat(a._log.id),a}return d(i,e),o(i,[{key:"capture",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.systemAudio,r=void 0!==n&&n,i=e.autoGainControl,a=e.echoCancellation,o=e.noiseSuppression,s=e.audioTrack,c=e.videoTrack,u=e.captureElement,l=e.preferDisplaySurface;return f().mark((function e(){var n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!c&&!s){e.next=5;break}n=new MediaStream,c&&n.addTrack(c),s&&n.addTrack(s),e.next=8;break;case 5:return e.next=7,CL({audio:!1,systemAudio:r,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:i,echoCancellation:a,noiseSuppression:o,captureElement:u,preferDisplaySurface:l});case 7:n=e.sent;case 8:return e.next=10,t.setInputMediaStreamTrack(n.getVideoTracks()[0]);case 10:return e.abrupt("return",n);case 13:throw e.prev=13,e.t0=e.catch(0),t.log.error("getDisplayMedia error observed ".concat(e.t0)),e.t0 instanceof yR?e.t0:new yR({code:_R.INITIALIZE_FAILED,name:e.t0.name,message:e.t0.message});case 16:case"end":return e.stop()}}),e,null,[[0,13]])}))()}))}},{key:"switchDevice",value:function(e){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return e.stop()}}),e)})))}}])}(AL);nR([sL((function(e){this.setContentHint(e.contentHint||"detail")}))],wL.prototype,"capture",1);var DL,xL=function(e){function t(e){var i;return r(this,t),(i=n(this,t,[e]))._log.id="s-".concat(i._log.id),i}return d(t,e),o(t)}(kL);function OL(e){return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=kM(),DL||(DL=mM(n,URL.createObjectURL(new Blob(["registerProcessor('dumper', class extends AudioWorkletProcessor {process(inputs) {this.port.postMessage(inputs);return true;}});"],{type:"application/javascript"})))),t.next=4,DL;case 4:return r=new AudioWorkletNode(n,"dumper",{numberOfInputs:e.length,numberOfOutputs:0}),t.abrupt("return",(e.forEach((function(e,t){return e.connect(r,0,t)})),new ReadableStream({start:function(e){r.port.onmessage=function(t){e.enqueue(t.data)}},cancel:function(){e.forEach((function(e){return e.disconnect(r)})),r.port.close()}})));case 6:case"end":return t.stop()}}),t)})))}var NL=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).room=e,rR(t(a),"_localAudioTrack"),rR(t(a),"_localScreenAudioTrack"),rR(t(a),"log",sO.createLogger({id:"am"})),rR(t(a),"denoiser"),rR(t(a),"voiceChanger"),rR(t(a),"mixChangedDebounce"),rR(t(a),"encodePipeline",[]),rR(t(a),"decodePipeline",[]),e&&(a.log.setUserId(e.userId),a.log.setSdkAppId(e.sdkAppId)),a}return d(i,e),o(i,[{key:"_localAudioPipline",get:function(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}},{key:"dump",value:function(e){var t,n,r=this;if(this._localAudioTrack){var i=[],a=[];null!=(t=this._localAudioPipline)&&t.source.node&&(i.push(this._localAudioPipline.source.node),a.push("mic")),null!=(n=this._localAudioPipline)&&n.denoiser.node&&(i.push(this._localAudioPipline.denoiser.node),a.push("mic-processed")),this.mixWeight>1&&(i.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),a.push("mix")),this.log.info("dump audio track ".concat(a,", duration: ").concat(e));var o=new AbortController,s=[],c=setTimeout((function(){r.log.info('dump audio track complete please input "download()" to download.'),o.abort("timeout")}),1e3*e),u=function(){for(var e=0;e<a.length;e++){var t=URL.createObjectURL(new Blob(s[e])),n=document.createElement("a");n.href=t,n.download="".concat(a[e],".pcm"),n.style.display="none",document.body.appendChild(n),n.click(),URL.revokeObjectURL(t),n.remove()}clearTimeout(c),o.abort("download")},l=OL(i).then((function(e){return e.pipeTo(new WritableStream({write:function(e){e.forEach((function(e,t){return s[t]=s[t]?s[t].concat(e[0]):[e[0]]}))}}),o).catch((function(e){return u}))}));return{then:l.then.bind(l),download:u}}}},{key:"getPCM",value:function(e){var t,n=this;if(bw(WritableStream))this.log.warn("getPCM failed: browser not support WritableStream");else{if(null!=(t=this._localAudioPipline)&&t.source.node){this.log.warn("getPCM");var r=new Float32Array(1920),i=0,a=new AbortController;return OL([this._localAudioPipline.source.node]).then((function(t){return t.pipeTo(new WritableStream({write:function(t){t[0][0]&&(r.set(t[0][0],i),(i+=t[0][0].length)>=1920&&(i=0,e(r),r=new Float32Array(1920)))}}),a).catch((function(e){return n.log.warn("stop getPCM reason:".concat(e))}))})),a}this.log.warn("getPCM failed: no local audio track")}}},{key:"hasScreenAudioTrack",get:function(){return null!==this._localScreenAudioTrack}},{key:"hasAudioTrack",get:function(){return!bw(this._localAudioTrack)}},{key:"changeInput",value:function(e){return e instanceof xL?(this._localScreenAudioTrack=e,e.pipeline.connect(),this.mixOnChange()):e instanceof kL?(this._localAudioTrack=e,this.denoiser&&e.addDenoiser(this.denoiser),e.pipeline.connect(),this.mixOnChange()):e instanceof XV?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}},{key:"mixOnChange",value:function(){var e=this;return this.mixChangedDebounce||(this.mixChangedDebounce=Promise.resolve().then((function(){var t,n;return delete e.mixChangedDebounce,Promise.all([null==(t=e._localAudioTrack)?void 0:t.setOutputMediaStreamTrack(e.mixWeight>1?e.mixTrack:e._localAudioTrack.mediaTrack),null==(n=e._localScreenAudioTrack)?void 0:n.setOutputMediaStreamTrack(e.mixWeight>1?e.mixTrack:e._localScreenAudioTrack.mediaTrack)])}))),this.mixChangedDebounce}},{key:"removeInput",value:function(e){e instanceof xL?delete this._localScreenAudioTrack:e instanceof kL&&delete this._localAudioTrack}},{key:"addDenoiser",value:function(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}},{key:"removeDenoiser",value:function(e){var t;delete this.denoiser,null==(t=this._localAudioTrack)||t.removeDenoiser(e)}},{key:"addVoiceChanger",value:function(e,t){var n;this.voiceChanger=[e,t],null==(n=this._localAudioTrack)||n.pipeline.voiceChanger.setNode(e,t)}},{key:"removeVoiceChanger",value:function(){var e;delete this.voiceChanger,null==(e=this._localAudioTrack)||e.pipeline.voiceChanger.deleteNode()}},{key:"destroy",value:function(){this.close()}},{key:"addEncodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.encodePipeline.includes(n)||(this.encodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"addDecodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.decodePipeline.includes(n)||(this.decodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"removeEncodeProcessor",value:function(e){var t=e.type;this.encodePipeline[t]=void 0}},{key:"removeDecodeProcessor",value:function(e){var t=e.type;this.decodePipeline[t]=void 0}}])}(RM);function PL(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return uL((function(n,r){return function(){for(var i=this,a=arguments.length,o=new Array(a),s=0;s<a;s++)o[s]=arguments[s];return new Promise((function(a,s){var c=setTimeout((function(){var n=new yR({code:_R.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(r,"() timeout ").concat(e,"s")});sO.warn(n),2===t?s(n):1===t&&a()}),1e3*e);n.apply(i,o).then(a,s).finally((function(){clearTimeout(c)}))}))}}))}var ML={};function LL(){}eR(ML,{Events:function(){return QL},Inspect:function(){return jL},LastSink:function(){return HL},Sink:function(){return GL},Subscribe:function(){return WL},TimeoutError:function(){return $L},audit:function(){return nV},bindCallback:function(){return xU},bindNodeCallback:function(){return OU},buffer:function(){return dU},bufferCount:function(){return lU},bufferTime:function(){return FV},call:function(){return UL},catchError:function(){return qV},combineLatest:function(){return oU},concat:function(){return rU},concatMap:function(){return RV},concatMapTo:function(){return CV},count:function(){return VU},create:function(){return JL},debounce:function(){return aV},debounceTime:function(){return oV},defer:function(){return pU},delay:function(){return BV},deliver:function(){return KL},dispose:function(){return FL},elementAt:function(){return sV},empty:function(){return MU},every:function(){return hV},exhaustMap:function(){return MV},exhaustMapTo:function(){return LV},filter:function(){return jU},find:function(){return cV},findIndex:function(){return uV},first:function(){return lV},fromAnimationFrame:function(){return wU},fromArray:function(){return gU},fromEvent:function(){return SU},fromEventPattern:function(){return kU},fromFetch:function(){return IU},fromIterable:function(){return AU},fromPromise:function(){return bU},fromReadableStream:function(){return CU},fromReader:function(){return RU},groupBy:function(){return UV},identity:function(){return VL},ignoreElements:function(){return HU},iif:function(){return aU},inspect:function(){return BL},interval:function(){return yU},last:function(){return dV},map:function(){return vV},mapTo:function(){return _V},max:function(){return FU},merge:function(){return tU},mergeMap:function(){return xV},mergeMapTo:function(){return OV},min:function(){return BU},never:function(){return NU},nothing:function(){return LL},of:function(){return _U},pairwise:function(){return pV},pipe:function(){return zL},race:function(){return nU},range:function(){return DU},reduce:function(){return UU},retry:function(){return JV},scan:function(){return fV},share:function(){return eU},shareReplay:function(){return iU},skip:function(){return KU},skipUntil:function(){return YU},skipWhile:function(){return XU},startWith:function(){return cU},subject:function(){return fU},subscribe:function(){return GV},sum:function(){return qU},switchMap:function(){return kV},switchMapTo:function(){return bV},take:function(){return GU},takeLast:function(){return JU},takeUntil:function(){return WU},takeWhile:function(){return zU},tap:function(){return WV},throttle:function(){return eV},throwError:function(){return PU},timeInterval:function(){return VV},timeout:function(){return zV},timer:function(){return EU},toPromise:function(){return jV},toReadableStream:function(){return HV},withLatestFrom:function(){return uU},zip:function(){return sU}});var UL=function(e){return e()},VL=function(e){return e};function FL(){this.dispose()}var BL=function(){return"undefined"!=typeof __FASTRX_DEVTOOLS__},qL=1,jL=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"toString",value:function(){return"".concat(this.name,"(").concat(this.args.length?E(this.args).join(", "):"",")")}},{key:"subscribe",value:function(e){var t=new XL(e,this,this.streamId++);return QL.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}}])}(b(Function)),HL=function(){return o((function e(){r(this,e),this.defers=new Set,this.disposed=!1}),[{key:"next",value:function(e){}},{key:"complete",value:function(){this.dispose()}},{key:"error",value:function(e){this.dispose()}},{key:"bindDispose",get:function(){var e=this;return function(){return e.dispose()}}},{key:"dispose",value:function(){this.disposed=!0,this.complete=LL,this.error=LL,this.next=LL,this.dispose=LL,this.subscribe=LL,this.doDefer()}},{key:"subscribe",value:function(e){return e instanceof jL?e.subscribe(this):e(this),this}},{key:"bindSubscribe",get:function(){var e=this;return function(t){return e.subscribe(t)}}},{key:"doDefer",value:function(){this.defers.forEach(UL),this.defers.clear()}},{key:"defer",value:function(e){this.defers.add(e)}},{key:"removeDefer",value:function(e){this.defers.delete(e)}},{key:"reset",value:function(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}},{key:"resetNext",value:function(){delete this.next}},{key:"resetComplete",value:function(){delete this.complete}},{key:"resetError",value:function(){delete this.error}}])}(),GL=function(e){function t(e){var i;return r(this,t),(i=n(this,t)).sink=e,e.defer(i.bindDispose),i}return d(t,e),o(t,[{key:"next",value:function(e){this.sink.next(e)}},{key:"complete",value:function(){this.sink.complete()}},{key:"error",value:function(e){this.sink.error(e)}}])}(HL),WL=function(e){function t(e){var i;r(this,t);var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:LL,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:LL,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:LL;if((i=n(this,t))._next=a,i._error=o,i._complete=s,i.then=LL,e instanceof jL){var c={toString:function(){return"subscribe"},id:0,source:e};i.defer((function(){QL.defer(c,0)})),QL.create(c),QL.pipe(c),i.sourceId=c.id,i.subscribe(e),QL.subscribe({id:c.id,end:!0}),a==LL?i._next=function(e){return QL.next(c,0,e)}:i.next=function(e){QL.next(c,0,e),a(e)},s==LL?i._complete=function(){return QL.complete(c,0)}:i.complete=function(){i.dispose(),QL.complete(c,0),s()},o==LL?i._error=function(e){return QL.complete(c,0,e)}:i.error=function(e){i.dispose(),QL.complete(c,0,e),o()}}else i.subscribe(e);return i}return d(t,e),o(t,[{key:"next",value:function(e){this._next(e)}},{key:"complete",value:function(){this.dispose(),this._complete()}},{key:"error",value:function(e){this.dispose(),this._error(e)}}])}(HL);function zL(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((function(e,t){return t(e)}),e)}function JL(e,t,n){if(BL()){var r=Object.defineProperties(Object.setPrototypeOf(e,jL.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:n,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});QL.create(r);for(var i=0;i<n.length;i++){var a=n[i];"function"==typeof a&&a instanceof jL&&QL.addSource(r,a)}return r}return e}function KL(e,t){return function(){for(var n=arguments,r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return function(r){if(r instanceof jL){var o=JL((function(t){var n=i(e,[t].concat(a));n.sourceId=o.id,n.subscribe(r)}),t,n);return o.source=r,QL.pipe(o),o}return function(t){return r(i(e,[t].concat(a)))}}}}function YL(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var XL=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).source=i,o.id=a,o.sourceId=e.sourceId,o.defer((function(){QL.defer(o.source,o.id)})),o}return d(t,e),o(t,[{key:"next",value:function(e){QL.next(this.source,this.id,e),this.sink.next(e)}},{key:"complete",value:function(){QL.complete(this.source,this.id),this.sink.complete()}},{key:"error",value:function(e){QL.complete(this.source,this.id,e),this.sink.error(e)}}])}(GL),QL={addSource:function(e,t){YL("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next:function(e,t,n){YL("next",{id:e.id,streamId:t,data:n&&n.toString()})},subscribe:function(e,t){YL("subscribe",{id:e.id,end:e.end,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete:function(e,t,n){YL("complete",{id:e.id,streamId:t,err:n?n.toString():null})},defer:function(e,t){YL("defer",{id:e.id,streamId:t})},pipe:function(e){YL("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update:function(e){YL("update",{id:e.id,name:e.toString()})},create:function(e){e.id||(e.id=qL++),YL("create",{name:e.toString(),id:e.id})}},$L=function(e){function t(e){var i;return r(this,t),(i=n(this,t,["timeout after ".concat(e,"ms")])).timeout=e,i}return d(t,e),o(t)}(b(Error)),ZL=function(e){function t(e){var i;return r(this,t),(i=n(this,t)).source=e,i.sinks=new Set,i}return d(t,e),o(t,[{key:"add",value:function(e){var t=this;e.defer((function(){return t.remove(e)})),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}},{key:"remove",value:function(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}},{key:"next",value:function(e){this.sinks.forEach((function(t){return t.next(e)}))}},{key:"complete",value:function(){this.sinks.forEach((function(e){return e.complete()})),this.sinks.clear()}},{key:"error",value:function(e){this.sinks.forEach((function(t){return t.error(e)})),this.sinks.clear()}}])}(HL);function eU(){var e=arguments;return function(t){var n=new ZL(t);if(t instanceof jL){var r=JL((function(e){n.add(e)}),"share",e);return n.sourceId=r.id,r.source=t,QL.pipe(r),r}return JL(n.add.bind(n),"share",e)}}function tU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return JL((function(e){var n=new GL(e),r=t.length;n.complete=function(){0==--r&&e.complete()},t.forEach(n.bindSubscribe)}),"merge",arguments)}function nU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return JL((function(e){var n=new Map;t.forEach((function(t){var r=new GL(e);n.set(t,r),r.complete=function(){n.delete(t),0===n.size?e.complete():r.dispose()},r.next=function(e){n.delete(t),n.forEach((function(e){return e.dispose()})),r.resetNext(),r.resetComplete(),r.next(e)}})),t.forEach((function(e){return n.get(e).subscribe(e)}))}),"race",arguments)}function rU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return JL((function(e){var n=0,r=t.length,i=new GL(e);i.complete=function(){n<r&&!i.disposed?(i.doDefer(),i.subscribe(t[n++])):e.complete()},i.complete()}),"concat",arguments)}function iU(e){var t=arguments;return function(n){var r=new ZL(n),i=[];return r.next=function(t){i.push(t),i.length>e&&i.shift(),this.sinks.forEach((function(e){return e.next(t)}))},JL((function(e){e.defer((function(){return r.remove(e)})),i.forEach((function(t){return e.next(t)})),r.add(e)}),"shareReplay",t)}}function aU(e,t,n){return JL((function(r){return e()?t(r):n(r)}),"iif",arguments)}function oU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return JL((function(e){var n=t.length,r=n,i=n,a=new Array(n),o=function(){0==--i&&e.complete()};t.forEach((function(t,n){var i=new GL(e);i.next=function(t){0==--r?(i.next=function(t){a[n]=t,e.next(a)},i.next(t)):a[n]=t},i.complete=o,i.subscribe(t)}))}),"combineLatest",arguments)}function sU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return JL((function(e){var n=t.length,r=n,i=new Array(n),a=function(){0==--r&&e.complete()};t.forEach((function(t,n){var r=new GL(e),o=[];i[n]=o,r.next=function(t){o.push(t),i.every((function(e){return e.length}))&&e.next(i.map((function(e){return e.shift()})))},r.complete=a,r.subscribe(t)}))}),"zip",arguments)}function cU(){for(var e=arguments,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return JL((function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.length;r<i&&!e.disposed;)e.next(n[r++]);e.disposed||e.subscribe(t)}),"startWith",e)}}var uU=KL(function(e){function t(e){var i;r(this,t),i=n(this,t,[e]);for(var a=new GL(i.sink),o=arguments.length,s=new Array(o>1?o-1:0),c=1;c<o;c++)s[c-1]=arguments[c];return a.next=function(e){return i.buffer=e},a.complete=LL,a.subscribe(oU.apply(void 0,s)),i}return d(t,e),o(t,[{key:"next",value:function(e){this.buffer&&this.sink.next([e].concat(E(this.buffer)))}}])}(GL),"withLatestFrom"),lU=KL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).bufferSize=i,o.startBufferEvery=a,o.buffer=[],o.count=0,o.startBufferEvery&&(o.buffers=[[]]),o}return d(t,e),o(t,[{key:"next",value:function(e){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach((function(t){t.push(e)})),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(e),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}},{key:"complete",value:function(){var e=this;this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach((function(t){return e.sink.next(t)})),g(t,"complete",this,3)([])}}])}(GL),"bufferCount"),dU=KL(function(e){function t(e,i){var a;r(this,t),(a=n(this,t,[e])).buffer=[];var o=new GL(e);return o.next=function(t){e.next(a.buffer),a.buffer=[]},o.complete=LL,o.subscribe(i),a}return d(t,e),o(t,[{key:"next",value:function(e){this.buffer.push(e)}},{key:"complete",value:function(){this.buffer.length&&this.sink.next(this.buffer),g(t,"complete",this,3)([])}}])}(GL),"buffer"),hU=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(hO){a(hO)}}function s(e){try{c(r.throw(e))}catch(hO){a(hO)}}function c(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())}))};function fU(e){var t=arguments,n=eU()(JL((function(t){n.next=function(e){return t.next(e)},n.complete=function(){return t.complete()},n.error=function(e){return t.error(e)},e&&t.subscribe(e)}),"subject",t));return n.next=LL,n.complete=LL,n.error=LL,n}function pU(e){return JL((function(t){return t.subscribe(e())}),"defer",arguments)}var mU=function(e){return function(t){setTimeout((function(){return e(t)}))}},vU=function(e){return mU((function(t){for(var n=0;!t.disposed&&n<e.length;n++)t.next(e[n]);t.complete()}))};function _U(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return JL(vU(t),"of",arguments)}function gU(e){return JL(vU(e),"fromArray",arguments)}function yU(e){return JL((function(t){var n=0,r=setInterval((function(){return t.next(n++)}),e);return t.defer((function(){clearInterval(r)})),"interval"}),"interval",arguments)}function EU(e,t){return JL((function(n){var r=0,i=setTimeout((function(){if(n.removeDefer(a),n.next(r++),t){var e=setInterval((function(){return n.next(r++)}),t);n.defer((function(){clearInterval(e)}))}else n.complete()}),e),a=function(){clearTimeout(i)};n.defer(a)}),"timer",arguments)}function TU(e,t){return function(n){var r=function(e){return n.next(e)};n.defer((function(){return t(r)})),e(r)}}function kU(e,t){return JL(TU(e,t),"fromEventPattern",arguments)}function SU(e,t){if("on"in e&&"off"in e)return JL(TU((function(n){return e.on(t,n)}),(function(n){return e.off(t,n)})),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return JL(TU((function(n){return e.addListener(t,n)}),(function(n){return e.removeListener(t,n)})),"fromEvent",arguments);if("addEventListener"in e)return JL(TU((function(n){return e.addEventListener(t,n)}),(function(n){return e.removeEventListener(t,n)})),"fromEvent",arguments);throw"target is not a EventDispachter"}function bU(e){return JL((function(t){e.then(t.next.bind(t),t.error.bind(t))}),"fromPromise",arguments)}function IU(e,t){return JL(pU((function(){return bU(fetch(e,t))})),"fromFetch",arguments)}function AU(e){return JL(mU((function(t){try{var n,r=s(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(t.disposed)return;t.next(i)}}catch(a){r.e(a)}finally{r.f()}t.complete()}catch(wR){t.error(wR)}})),"fromIterable",arguments)}function RU(e){var t=this,n=function(r){return hU(t,void 0,void 0,f().mark((function t(){var i,a,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.disposed){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.read();case 4:i=t.sent,a=i.done,o=i.value,a?r.complete():(r.next(o),n(r));case 8:case"end":return t.stop()}}),t)})))};return JL((function(e){n(e)}),"fromReader",arguments)}function CU(e){return JL((function(t){var n=new AbortController,r=n.signal;t.defer((function(){return n.abort("cancelled")})),e.pipeTo(new WritableStream({write:function(e){t.next(e)},close:function(){t.complete()},abort:function(e){t.error(e)}}),{signal:r}).then((function(){return t.complete()}),(function(e){return t.error(e)}))}),"fromReadableStream",arguments)}function wU(){return JL((function(e){var t=requestAnimationFrame((function n(r){e.disposed||(e.next(r),t=requestAnimationFrame(n))}));e.defer((function(){return cancelAnimationFrame(t)}))}),"fromAnimationFrame",arguments)}function DU(e,t){return JL((function(n){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t+e;r<i&&!n.disposed;)n.next(r++);return n.complete(),"range"}),"range",arguments)}function xU(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return JL((function(n){var i=r.concat((function(e){return n.next(e),n.complete()}));e.apply(t,i)}),"bindCallback",arguments)}function OU(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return JL((function(n){var i=r.concat((function(e,t){return e?n.error(e):(n.next(t),n.complete())}));e.apply(t,i)}),"bindNodeCallback",arguments)}function NU(){return JL((function(){}),"never",arguments)}function PU(e){return JL((function(t){return t.error(e)}),"throwError",arguments)}function MU(){return JL((function(e){return e.complete()}),"empty",arguments)}var LU=function(e){function t(e,i,a){var o;r(this,t),(o=n(this,t,[e])).f=i;var s=function(){o.sink.next(o.acc),o.sink.complete()};return void 0===a?o.next=function(e){o.acc=e,o.complete=s,o.resetNext()}:(o.acc=a,o.complete=s),o}return d(t,e),o(t,[{key:"next",value:function(e){this.acc=this.f(this.acc,e)}}])}(GL),UU=KL(LU,"reduce"),VU=function(e){return KL(LU,"count")((function(t,n){return e(n)?t+1:t}),0)},FU=function(){return KL(LU,"max")(Math.max)},BU=function(){return KL(LU,"min")(Math.min)},qU=function(){return KL(LU,"sum")((function(e,t){return e+t}),0)},jU=KL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).filter=i,o.thisArg=a,o}return d(t,e),o(t,[{key:"next",value:function(e){this.filter.call(this.thisArg,e)&&this.sink.next(e)}}])}(GL),"filter"),HU=KL(function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"next",value:function(e){}}])}(GL),"ignoreElements"),GU=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).count=i,a}return d(t,e),o(t,[{key:"next",value:function(e){this.sink.next(e),0==--this.count&&this.complete()}}])}(GL),"take"),WU=KL(function(e){function t(e,i){var a;r(this,t),a=n(this,t,[e]);var o=new GL(e);return o.next=function(){return e.complete()},o.complete=FL,o.subscribe(i),a}return d(t,e),o(t)}(GL),"takeUntil"),zU=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).f=i,a}return d(t,e),o(t,[{key:"next",value:function(e){this.f(e)?this.sink.next(e):this.complete()}}])}(GL),"takeWhile"),JU=function(e){return UU((function(t,n){return t.push(n),t.length>e&&t.shift(),t}),[])},KU=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).count=i,a}return d(t,e),o(t,[{key:"next",value:function(e){0==--this.count&&(this.next=g(t,"next",this,1))}}])}(GL),"skip"),YU=KL(function(e){function t(e,i){var a;r(this,t),a=n(this,t,[e]),e.next=LL;var o=new GL(e);return o.next=function(){o.dispose(),e.resetNext()},o.complete=FL,o.subscribe(i),a}return d(t,e),o(t)}(GL),"skipUntil"),XU=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).f=i,a}return d(t,e),o(t,[{key:"next",value:function(e){this.f(e)||(this.next=g(t,"next",this,1),this.next(e))}}])}(GL),"skipWhile"),QU={leading:!0,trailing:!1},$U=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).durationSelector=i,o.trailing=a,o}return d(t,e),o(t,[{key:"cacheValue",value:function(e){this.last=e,this.disposed&&this.throttle(e)}},{key:"send",value:function(e){this.sink.next(e),this.throttle(e)}},{key:"throttle",value:function(e){this.reset(),this.subscribe(this.durationSelector(e))}},{key:"next",value:function(){this.complete()}},{key:"complete",value:function(){this.dispose(),this.trailing&&this.send(this.last)}}])}(GL),ZU=function(e){function t(e,i){var a;r(this,t);var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:QU;return(a=n(this,t,[e])).durationSelector=i,a.config=o,a._throttle=new $U(a.sink,a.durationSelector,a.config.trailing),a._throttle.dispose(),a}return d(t,e),o(t,[{key:"next",value:function(e){this._throttle.disposed&&this.config.leading?this._throttle.send(e):this._throttle.cacheValue(e)}},{key:"complete",value:function(){this._throttle.throttle=LL,this._throttle.complete(),g(t,"complete",this,3)([])}}])}(GL),eV=KL(ZU,"throttle"),tV={leading:!1,trailing:!0},nV=function(e){return KL(ZU,"audit")(e,tV)},rV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"next",value:function(){this.complete()}},{key:"complete",value:function(){this.dispose(),this.sink.next(this.last)}}])}(GL),iV=function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).durationSelector=i,a._debounce=new rV(a.sink),a._debounce.dispose(),a}return d(t,e),o(t,[{key:"next",value:function(e){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=e,this._debounce.subscribe(this.durationSelector(e))}},{key:"complete",value:function(){this._debounce.complete(),g(t,"complete",this,3)([])}}])}(GL),aV=KL(iV,"debounce"),oV=function(e){return KL(iV,"debounceTime")((function(t){return EU(e)}))},sV=KL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).count=i,o.defaultValue=a,o}return d(t,e),o(t,[{key:"next",value:function(e){0==this.count--&&(this.defaultValue=e,this.complete())}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),g(t,"complete",this,3)([])):this.error(new Error("not enough elements in sequence"))}}])}(GL),"elementAt"),cV=function(e){return function(t){return GU(1)(XU((function(t){return!e(t)}))(t))}},uV=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).f=i,a.i=0,a}return d(t,e),o(t,[{key:"next",value:function(e){this.f(e)?(this.sink.next(this.i++),this.complete()):++this.i}}])}(GL),"findIndex"),lV=KL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).f=i,o.defaultValue=a,o.index=0,o}return d(t,e),o(t,[{key:"next",value:function(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e,this.complete())}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),g(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(GL),"first"),dV=KL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).f=i,o.defaultValue=a,o.index=0,o}return d(t,e),o(t,[{key:"next",value:function(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e)}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),g(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(GL),"last"),hV=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).predicate=i,a.index=0,a}return d(t,e),o(t,[{key:"next",value:function(e){this.predicate(e,this.index++)?this.result=!0:(this.result=!1,this.complete())}},{key:"complete",value:function(){void 0!==this.result?(this.sink.next(this.result),g(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(GL),"every"),fV=KL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).f=i,void 0===a?o.next=function(e){o.acc=e,o.resetNext(),o.sink.next(o.acc)}:o.acc=a,o}return d(t,e),o(t,[{key:"next",value:function(e){this.sink.next(this.acc=this.f(this.acc,e))}}])}(GL),"scan"),pV=KL(function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).hasLast=!1,e}return d(t,e),o(t,[{key:"next",value:function(e){this.hasLast?this.sink.next([this.last,e]):this.hasLast=!0,this.last=e}}])}(GL),"pairwise"),mV=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).mapper=i,o.thisArg=a,o}return d(t,e),o(t,[{key:"next",value:function(e){g(t,"next",this,3)([this.mapper.call(this.thisArg,e)])}}])}(GL),vV=KL(mV,"map"),_V=function(e){return KL(mV,"mapTo")((function(t){return e}))},gV=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).data=i,o.context=a,o}return d(t,e),o(t,[{key:"next",value:function(e){var t=this.context.combineResults;t?this.sink.next(t(this.data,e)):this.sink.next(e)}},{key:"tryComplete",value:function(){this.context.resetComplete(),this.dispose()}}])}(GL),yV=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).makeSource=i,o.combineResults=a,o.index=0,o}return d(t,e),o(t,[{key:"subInner",value:function(e,t){var n=this.currentSink=new t(this.sink,e,this);this.complete=this.tryComplete,n.complete=n.tryComplete,n.subscribe(this.makeSource(e,this.index++))}},{key:"tryComplete",value:function(){this.currentSink.resetComplete(),this.dispose()}}])}(GL),EV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t)}(gV),TV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"next",value:function(e){var t=this;this.subInner(e,EV),this.next=function(e){t.currentSink.dispose(),t.subInner(e,EV)}}}])}(yV),kV=KL(TV,"switchMap");function SV(e){return function(t,n){return e((function(){return t}),n)}}var bV=SV(KL(TV,"switchMapTo")),IV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"tryComplete",value:function(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}}])}(gV),AV=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).sources=[],e.next2=e.sources.push.bind(e.sources),e}return d(t,e),o(t,[{key:"next",value:function(e){this.next2(e),this.subNext()}},{key:"subNext",value:function(){this.next=this.next2,this.subInner(this.sources.shift(),IV),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}},{key:"tryComplete",value:function(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}}])}(yV),RV=KL(AV,"concatMap"),CV=SV(KL(AV,"concatMapTo")),wV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"tryComplete",value:function(){this.context.inners.delete(this),g(t,"dispose",this,3)([]),0===this.context.inners.size&&this.context.resetComplete()}}])}(gV),DV=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).inners=new Set,e}return d(t,e),o(t,[{key:"next",value:function(e){this.subInner(e,wV),this.inners.add(this.currentSink)}},{key:"tryComplete",value:function(){1===this.inners.size?this.inners.forEach((function(e){return e.resetComplete()})):this.dispose()}}])}(yV),xV=KL(DV,"mergeMap"),OV=SV(KL(DV,"mergeMapTo")),NV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"dispose",value:function(){this.context.resetNext(),g(t,"dispose",this,3)([])}}])}(gV),PV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"next",value:function(e){this.next=LL,this.subInner(e,NV)}}])}(yV),MV=KL(PV,"exhaustMap"),LV=SV(KL(PV,"exhaustMapTo")),UV=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).f=i,a.groups=new Map,a}return d(t,e),o(t,[{key:"next",value:function(e){var n=this.f(e),r=this.groups.get(n);void 0===r&&((r=fU()).key=n,this.groups.set(n,r),g(t,"next",this,3)([r])),r.next(e)}},{key:"complete",value:function(){this.groups.forEach((function(e){return e.complete()})),g(t,"complete",this,3)([])}},{key:"error",value:function(e){this.groups.forEach((function(t){return t.error(e)})),g(t,"error",this,3)([e])}}])}(GL),"groupBy"),VV=KL(function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).start=new Date,e}return d(t,e),o(t,[{key:"next",value:function(e){this.sink.next({value:e,interval:Number(new Date)-Number(this.start)}),this.start=new Date}}])}(GL),"timeInterval"),FV=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).miniseconds=i,a.buffer=[],a.id=setInterval((function(){a.sink.next(a.buffer.concat()),a.buffer.length=0}),a.miniseconds),a}return d(t,e),o(t,[{key:"next",value:function(e){this.buffer.push(e)}},{key:"complete",value:function(){this.sink.next(this.buffer),g(t,"complete",this,3)([])}},{key:"dispose",value:function(){clearInterval(this.id),g(t,"dispose",this,3)([])}}])}(GL),"bufferTime"),BV=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).buffer=[],a.delayTime=i,a}return d(t,e),o(t,[{key:"dispose",value:function(){clearTimeout(this.timeoutId),g(t,"dispose",this,3)([])}},{key:"delay",value:function(e){var n=this;this.timeoutId=setTimeout((function(){var e=n.buffer.shift();if(e){var r=e.time,i=e.data;g(t,"next",n,3)([i]),n.buffer.length&&n.delay(Number(n.buffer[0].time)-Number(r))}}),e)}},{key:"next",value:function(e){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:e})}},{key:"complete",value:function(){var e=this;this.timeoutId=setTimeout((function(){return g(t,"complete",e,3)([])}),this.delayTime)}}])}(GL),"delay"),qV=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).selector=i,a}return d(t,e),o(t,[{key:"error",value:function(e){this.dispose(),this.selector(e)(this.sink)}}])}(GL),"catchError"),jV=function(){return function(e){return new Promise((function(t,n){var r;new WL(e,(function(e){return r=e}),n,(function(){return t(r)}))}))}},HV=function(){return function(e){var t;return new ReadableStream({start:function(n){t=new WL(e,n.enqueue.bind(n),n.error.bind(n),n.close.bind(n))},cancel:function(){t.dispose()}})}},GV=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:LL,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:LL,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:LL;return function(r){return new WL(r,e,t,n)}},WV=KL(function(e){function t(e,i){var a;return r(this,t),a=n(this,t,[e]),i instanceof Function?a.next=function(t){i(t),e.next(t)}:(i.next&&(a.next=function(t){i.next(t),e.next(t)}),i.complete&&(a.complete=function(){i.complete(),e.complete()}),i.error&&(a.error=function(t){i.error(t),e.error(t)})),a}return d(t,e),o(t)}(GL),"tap"),zV=KL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).timeout=i,a.id=setTimeout((function(){return a.error(new $L(a.timeout))}),a.timeout),a}return d(t,e),o(t,[{key:"next",value:function(e){g(t,"next",this,3)([e]),clearTimeout(this.id),this.next=g(t,"next",this,1)}},{key:"dispose",value:function(){clearTimeout(this.id),g(t,"dispose",this,3)([])}}])}(GL),"timeout"),JV=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return function(t){if(t instanceof jL){var n=JL((function(r){var i=e,a=new GL(r);a.error=function(e){i-- >0?a.subscribe(t):r.error(e)},a.sourceId=n.id,a.subscribe(t)}),"retry",[e]);return n.source=t,QL.pipe(n),n}return function(n){var r=e,i=new GL(n);i.error=function(e){r-- >0?t(i):n.error(e)},t(i)}}},KV=function(e){function i(e,a,o){var s;r(this,i),(s=n(this,i,[{userId:a.userId,sdkAppId:e.sdkAppId,mediaType:o,room:e}])).room=e,s.user=a,rR(t(s),"tinyId"),rR(t(s),"isRemote",!0),rR(t(s),"jitterBufferDelay",0),rR(t(s),"availableState"),rR(t(s),"remotePublishState"),rR(t(s),"_triggerCheckDecodeSubject",fU(SU(t(s),i.STATE_SUBSCRIBE))),s.tinyId=a.tinyId,s.availableState=new wP("".concat(a.userId,"-").concat(s.mediaType,"-available"),"remote-track-available"),s.remotePublishState=new wP("".concat(a.userId,"-").concat(s.mediaType,"-remote-publish"),"remote-track-publish"),zL(tU(SU(t(s),wP.STATECHANGED),SU(s.remotePublishState,wP.STATECHANGED)),vV((function(){return s.isRemotePublished&&(s.isSubscribed||s.isSubscribing)})),GV((function(e){s.availableState.state!==(e?wP.ON:wP.OFF)&&(s.availableState.state=e?wP.ON:wP.OFF),s.updatePlayingState(e)})));var c=zL(SU(s.player,LP.ERROR),jU((function(e){return e.code===MediaError.MEDIA_ERR_DECODE}))),u=zL(EU(5e3),jU((function(){return!(s.ignoreDecodeError||!s.isSubscribed||!s.isPlayCalled||!s.stat.bytesReceived||(s.player.isPlaying||(s.kind===nC.AUDIO?s.getAudioLevel()>0:s.stat.framesDecoded>0))&&(s.reportDecodeResult(!0),1))}))),l=zL(nU(c,u),WU(SU(s,wP.INIT)));return zL(s._triggerCheckDecodeSubject,jU((function(){return!s.ignoreDecodeError})),bV(l),GV((function(e){s.reportDecodeResult(!1,e)}))),s}return d(i,e),o(i,[{key:"setMute",value:function(e){this.isRemotePublished&&g(i,"setMute",this,3)([e])}},{key:"setInputMediaStreamTrack",value:function(e){g(i,"setInputMediaStreamTrack",this,3)([e]),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}},{key:"checkDecodeResult",value:function(){this._triggerCheckDecodeSubject.next(!0)}},{key:"waitHasMediaTrack",value:function(){var e=this;return new Promise((function(t){e.mediaTrack?t():e.once("input-media-track-changed",t)}))}},{key:"ignoreDecodeError",get:function(){var e,t;return((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.downlinkNetworkQuality)||0)>3||this.player.isInAutoPlayFailedState}},{key:"isSubscribing",get:function(){return"subscribeing"===this.state.toString()}},{key:"isSubscribed",get:function(){return this.state===i.STATE_SUBSCRIBE}},{key:"isAvailable",get:function(){return this.availableState.state===wP.ON}},{key:"isNeedPlay",get:function(){return this.isAvailable&&this.isPlayCalled}},{key:"subscribe",value:function(e){return e}},{key:"unsubscribe",value:function(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}},{key:"reportDecodeResult",value:function(e,t){var n=this.kind===nC.AUDIO;IN[e?"addSuccessEvent":"addFailedEvent"]({key:n?504700:514702}),e||(IN.addEnum({key:n?504701:514703,value:$x()}),qP.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(Yx()||Zx()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===nC.AUDIO?"audioLevel: ".concat(this.getAudioLevel()):"framesDecoded: ".concat(this.stat.framesDecoded>0))),this.emit("decode-failed",{error:t}))}},{key:"updatePlayingState",value:function(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.isRemotePublished||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed: ".concat(this.isSubscribed," isAvailable: ").concat(this.isRemotePublished," hasTrack: ").concat(!!this.outMediaTrack," "));g(i,"updatePlayingState",this,3)([e])}}},{key:"close",value:function(){g(i,"close",this,3)([]),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}},{key:"onFlagChanged",value:function(){this.remotePublishState.state=this.isRemotePublished?wP.ON:wP.OFF}},{key:"onTrackMuted",value:function(){this.isNeedPlay&&g(i,"onTrackMuted",this,3)([])}},{key:"onTrackUnmuted",value:function(){this.isNeedPlay&&g(i,"onTrackUnmuted",this,3)([])}},{key:"onTrackEnded",value:function(){this.isNeedPlay&&g(i,"onTrackEnded",this,3)([])}}])}($M);rR(KV,"STATE_SUBSCRIBE","subscribe"),nR([PL(5,1)],KV.prototype,"waitHasMediaTrack",1),nR([AP(wP.INIT,KV.STATE_SUBSCRIBE,{success:function(){this.log.info("subscribed"),rO.emit(aO.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),gL(521716,!1)],KV.prototype,"subscribe",1),nR([AP(KV.STATE_SUBSCRIBE,wP.INIT,{sync:!0,success:function(){this.log.info("unsubscribed"),rO.emit(aO.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],KV.prototype,"unsubscribe",1);var YV=KV,XV=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,a,1]),rR(t(o),"volume",0),rR(t(o),"mediaType",1),rR(t(o),"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),o.manager=e.audioManager,o}return d(i,e),o(i,[{key:"dbVolume",get:function(){return NM.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}},{key:"decodeFrame",value:function(e){if(!this.manager)return e;var t,n=e,r=s(this.manager.decodePipeline);try{for(r.s();!(t=r.n()).done;){var i=t.value;if(i&&!(n=i({frame:n,track:this})))return}}catch(a){r.e(a)}finally{r.f()}return n}},{key:"getAudioLevel",value:function(){var e=this.volume||g(i,"getAudioLevel",this,3)([]);return e>1?1:e}},{key:"isRemotePublished",get:function(){return this.user.muteState.audioAvailable}}])}(YV),QV=[-1,-1,1,-1,-1,1,1,1],$V=[0,0,1,0,0,1,1,1],ZV=function(e){function i(e,a){var o;if(r(this,i),(o=n(this,i)).context=e,rR(t(o),"name"),rR(t(o),"input"),rR(t(o),"output"),rR(t(o),"texture"),rR(t(o),"ctx2d",null),rR(t(o),"fbo"),rR(t(o),"width",0),rR(t(o),"height",0),rR(t(o),"x",0),rR(t(o),"y",0),rR(t(o),"program"),rR(t(o),"vertexShader"),rR(t(o),"fragmentShader"),rR(t(o),"totalFrames",0),rR(t(o),"dropFrames",0),rR(t(o),"matchInputSize",!0),rR(t(o),"texCoordBuffer"),rR(t(o),"positionBuffer"),rR(t(o),"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),rR(t(o),"cost",0),rR(t(o),"_canvas",null),rR(t(o),"_image"),rR(t(o),"log"),o.context.on("disconnect",o.close,t(o)),o.name=a.name,o.log=a.logger,o.matchInputSize=!1!==a.matchInputSize,o.width=a.width||e.width,o.height=a.height||e.height,o._image=a.image,e instanceof fF)e.ctx&&a.create2d&&("function"==typeof OffscreenCanvas&&16!==Ux?o._canvas=new OffscreenCanvas(o.width,o.height):(o._canvas=document.createElement("canvas"),o._canvas.width=o.width,o._canvas.height=o.height),o.ctx2d=o._canvas.getContext("2d"),o._image=o._canvas);else try{var s=e.ctx;o.texCoordBuffer=o.createBuffer($V),o.positionBuffer=o.createBuffer(QV),!1!==a.createTexture&&(o.texture=s.createTexture(),o.useTexture(),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.pixelStorei(s.PACK_ALIGNMENT,1),s.pixelStorei(s.UNPACK_ALIGNMENT,1)),a.useFbo&&(o.fbo=s.createFramebuffer(),o.useBufferFrame(),o.useTexture(),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,o.width,o.height,0,s.RGBA,s.UNSIGNED_BYTE,null),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,o.texture,0)),a.useDefaultProgram?o.program=e.defaultProgam:(a.vertexShaderSource||a.fragmentShaderSource)&&(o.vertexShader=a.vertexShaderSource?e.createShader(s.VERTEX_SHADER,a.vertexShaderSource):e.defaultVShader,o.fragmentShader=a.fragmentShaderSource?e.createShader(s.FRAGMENT_SHADER,a.fragmentShaderSource):e.defaultFShader,o.program=e.createProgram(o.vertexShader,o.fragmentShader))}catch(vO){o.context.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(o.name," error ").concat(vO.message||vO)}))}return o}return d(i,e),o(i,[{key:"image",get:function(){return this._image},set:function(e){this._image=e}},{key:"createFramebuffer",value:function(e){var t=this.context.ctx,n=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),n}},{key:"connect",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.addInput.apply(e,[this].concat(n)),this.output=e,e}},{key:"addInput",value:function(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}},{key:"requestFrame",value:function(e){var t=Date.now();return!!(this.context instanceof hF&&this.render(e)||this.context instanceof fF&&this.render2d(e))&&(this.totalFrames++,this.cost=Date.now()-t,!0)}},{key:"render2d",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&this.draw2d(this.input.image,0,0,this.width,this.height)}},{key:"update",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;null==(e=this.output)||e.update(t)}},{key:"disconnect",value:function(){for(var e,t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];null==(t=this.output)||(e=t).removeInput.apply(e,[this].concat(r)),delete this.output}},{key:"removeInput",value:function(e){delete this.input}},{key:"close",value:function(){var e,t;if(this.context.off("disconnect",this.close,this),null==(e=this.output)||e.removeInput(this),delete this.output,null==(t=this.input)||t.disconnect(),this.context instanceof hF){var n=this.context.ctx;n.deleteBuffer(this.texCoordBuffer),n.deleteBuffer(this.positionBuffer),this.fbo&&n.deleteFramebuffer(this.fbo),this.texture&&n.deleteTexture(this.texture),this.vertexShader&&this.vertexShader!==this.context.defaultVShader&&n.deleteShader(this.vertexShader),this.fragmentShader&&this.fragmentShader!==this.context.defaultFShader&&n.deleteShader(this.fragmentShader),this.program&&this.program!==this.context.defaultProgam&&n.deleteProgram(this.program)}this._canvas&&(this._canvas.width=0,this._canvas.height=0,this.ctx2d=null),this.removeAllListeners()}},{key:"useTexture",value:function(){this.useTextures(this.texture)}},{key:"useInputTexture",value:function(){var e;this.useTextures(null==(e=this.input)?void 0:e.texture)}},{key:"useTextures",value:function(){for(var e=this.context.ctx,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t,n){t&&(e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,t))}))}},{key:"useProgram",value:function(){this.context.ctx.useProgram(this.program)}},{key:"useBufferFrame",value:function(){var e=this.context.ctx;e.bindFramebuffer(e.FRAMEBUFFER,this.fbo||null)}},{key:"createBuffer",value:function(e){var t=this.context.ctx,n=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),n}},{key:"setTexBuffer",value:function(e){var t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.texCoordBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}},{key:"setPosBuffer",value:function(e){var t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}},{key:"changeBufferData",value:function(e,t){var n=this.context.ctx;n.bindBuffer(n.ARRAY_BUFFER,e),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t),n.STATIC_DRAW)}},{key:"setAttributes",value:function(){for(var e=this.context.ctx,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t,n){e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,t),e.vertexAttribPointer(n,2,e.FLOAT,!1,0,0)}))}},{key:"getVertexPoint",value:function(e,t){return[e/this.width*2-1,t/this.height*2-1]}},{key:"layout2texCoords",value:function(e){return[].concat(E(this.getVertexPoint(e.x,e.y)),E(this.getVertexPoint(e.x+e.width,e.y)),E(this.getVertexPoint(e.x,e.y+e.height)),E(this.getVertexPoint(e.x+e.width,e.y+e.height)))}},{key:"resize",value:function(e,t){if(this.width!==e||this.height!==t){if(this.width=e,this.height=t,this._canvas&&(this._canvas.width=e,this._canvas.height=t),this.texture&&this.fbo){this.useTexture();var n=this.context.ctx;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e,t,0,n.RGBA,n.UNSIGNED_BYTE,null)}this.output&&this.output.matchInputSize&&this.output.resize(e,t)}}},{key:"draw",value:function(e,t){this.setAttributes(e||this.positionBuffer,t||this.texCoordBuffer);var n=this.context.ctx;n.drawArrays(n.TRIANGLE_STRIP,0,4)}},{key:"draw2d",value:function(e,t,n,r,i){return!(!this.ctx2d||!e||(e instanceof ImageData?this.ctx2d.putImageData(e,t,n):(this.ctx2d.drawImage(e,t,n,r,i),"undefined"!=typeof VideoFrame&&e instanceof VideoFrame&&e.close()),0))}},{key:"getInfo",value:function(){var e,t=this.totalFrames,n=this.x,r=this.y,i=this.width,a=this.height,o=this.name,s=this.cost,c=Date.now(),u=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:n,y:r,width:i,height:a,timestamp:c,fps:u,name:o,cost:s},QA({parent:null==(e=this.input)?void 0:e.getInfo()},this.lastInfo)}},{key:"createTexture",value:function(e){var t=this.context.ctx,n=t.createTexture();return this.useTextures(n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),n}}])}(wP);nR([AP(wP.INIT,"connected",{sync:!0})],ZV.prototype,"connect",1),nR([AP("connected",wP.INIT,{ignoreError:!0,sync:!0})],ZV.prototype,"disconnect",1),nR([AP([],"closed",{sync:!0})],ZV.prototype,"close",1);var eF=zL(yU(250),vV((function(){return performance.now()})),eU()),tF=[0,1,1,1,0,0,1,0],nF=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},a)]),rR(t(o),"_intervalId",0),rR(t(o),"_sequence",0),rR(t(o),"checkGLError",!1),rR(t(o),"checkVisibilityChange"),e instanceof fF?o.ctx2d=e.ctx||null:e.available&&null!=a&&a.mirrorUpAndDown&&o.setTexBuffer(tF),o}return d(i,e),o(i,[{key:"start",value:function(e){var t=this;this.log.info("".concat(this.name," start render ").concat(e," fps")),MP.clearTask(this._intervalId),this._intervalId=MP.run("intervalInWorker",(function(){if(e!==t.context.frameRate&&(MP.clearTask(t._intervalId),t.start(t.context.frameRate)),t.requestFrame(t._sequence++),t.checkGLError&&t.context instanceof hF){var n=t.context.ctx.getError();n&&t.context.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:5,message:"".concat(t.name," req ").concat(t._sequence," render ").concat(t.totalFrames," faild ").concat(n)}))}}),{fps:this.context.frameRate})}},{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}},{key:"addInput",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];g(i,"addInput",this,3)([e].concat(n)),this.start(this.context.frameRate)}},{key:"update",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._intervalId&&(MP.clearTask(this._intervalId),this._intervalId=0,1===t)){this.log.info("".concat(this.name," use requestVideoFrameCallback"));var n=function(){document.hidden&&(e.start(e.context.frameRate),e.log.info("".concat(e.name," use timer")),document.removeEventListener("visibilitychange",n))};document.addEventListener("visibilitychange",n)}this.requestFrame(this._sequence++)}},{key:"removeInput",value:function(e){g(i,"removeInput",this,3)([e]),MP.clearTask(this._intervalId)}},{key:"resize",value:function(e,t){g(i,"resize",this,3)([e,t]),this.context.setSize(e,t)}},{key:"close",value:function(){g(i,"close",this,3)([]),MP.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}}])}(ZV),rF=function(e){function i(e,a){var o,s;return r(this,i),s=n(this,i,[e,a]),rR(t(s),"_videoTrack"),rR(t(s),"_muteOb"),rR(t(s),"_closedOb",SU(t(s),"closed")),rR(t(s),"_subscription"),rR(t(s),"_canvasContainer"),Number(Px)<17&&(s._canvasContainer=document.createElement("div"),s._canvasContainer.style.display="none"),o=v(e._canvas.captureStream().getVideoTracks(),1),s._videoTrack=o[0],s._muteOb=SU(s._videoTrack,"mute"),zL(SU(s._videoTrack,"ended"),WU(s._closedOb),GV((function(){s.context.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))}))),s}return d(i,e),o(i,[{key:"enableCheckMute",value:function(){var e=this;this._subscription=zL(this._muteOb,WU(this._closedOb),bV((function(e){var t=performance.now();zL(eF,XU((function(e){return e-t<5e3})),GU(1))(e)})),GV((function(){var t;null!=(t=e._videoTrack)&&t.muted&&e.context.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:7,message:"video track muted"}))})))}},{key:"disableCheckMute",value:function(){var e;null==(e=this._subscription)||e.dispose()}},{key:"videoTrack",get:function(){return this._videoTrack}},{key:"putCanvasIntoDom",value:function(){!this.context._canvas||!this._canvasContainer||document.getElementById(this.context._canvas.id)||(this.log.info("".concat(this.name," put canvas to body")),document.body.appendChild(this._canvasContainer),this._canvasContainer.appendChild(this.context._canvas))}},{key:"render",value:function(e){return this.putCanvasIntoDom(),g(i,"render",this,3)([e])}},{key:"render2d",value:function(e){return this.putCanvasIntoDom(),g(i,"render2d",this,3)([e])}},{key:"close",value:function(){var e,t;g(i,"close",this,3)([]),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(t=this._canvasContainer)||t.remove()}}])}(nF),iF=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))}}])}(rF),aF=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e,{name:"smallDestination",logger:a}])).resolution=i,o}return d(t,e),o(t,[{key:"resize",value:function(e,n){var r,i=e*n,a=this.resolution.width*this.resolution.height;this.log.info("big res: ".concat(e,"*").concat(n," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),i>a?r=i/a:(this.log.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(n," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),r=i/19200),g(t,"resize",this,3)([e/Math.sqrt(r),n/Math.sqrt(r)])}}])}(rF),oF=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,QA({name:"imageSource"},a)]),rR(t(o),"_lastImage"),rR(t(o),"_totalFrames",0),rR(t(o),"_autoResize",!1),rR(t(o),"_canvasRendered"),rR(t(o),"_videoCallbackId",0),o._autoResize=!1!==(null==a?void 0:a.autoResize),16===Ux&&(o._canvasRendered=fU(),zL(o._canvasRendered,cU(o._image),kV((function(e){return e instanceof HTMLCanvasElement?SU(e,"rendered"):MU()})),WU(SU(t(o),"closed")),GV((function(){o.update()})))),o}return d(i,e),o(i,[{key:"tryVideoFrameCallback",value:function(e){var t=this;this._videoCallbackId&&e.cancelVideoFrameCallback(this._videoCallbackId),gP()&&!document.hidden&&(this._videoCallbackId=e.requestVideoFrameCallback((function(e,n){document.hidden||(t._totalFrames=n.presentedFrames,t.update(1))})))}},{key:"_render",value:function(e,t){var n,r=this.width,i=this.height,a=this.image;if(a instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(a),r=a.videoWidth,i=a.videoHeight,!r||!i)return!1;a.width=r,a.height=i}else if(a instanceof HTMLImageElement||a instanceof ImageData||a instanceof ImageBitmap){if(r=a.width,i=a.height,a!==this._lastImage)this._lastImage=a;else if(r===this.width&&i===this.height)return!1}else a instanceof HTMLCanvasElement||a instanceof OffscreenCanvas?(r=a.width,i=a.height,this._lastImage=a):"undefined"!=typeof VideoFrame&&a instanceof VideoFrame&&(r=a.displayWidth,i=a.displayHeight,null==(n=this._lastImage)||n.close(),this._lastImage=a);if(!this._autoResize)return!0;if(this.width===r&&this.height===i&&this.totalFrames){if(t){this.useTexture();var o=this.context.ctx;o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,a)}}else{if(t){this.useTexture();var s=this.context.ctx;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,a)}this.resize(r,i)}return!0}},{key:"image",get:function(){return this._image},set:function(e){var t;null==(t=this._canvasRendered)||t.next(e),this._image=e}},{key:"render",value:function(e){return this._render(e,!0)}},{key:"render2d",value:function(e){return this._render(e,!1)}}])}(ZV),sF=function(e){function i(e,a,o){var s;return r(this,i),(s=n(this,i,[e,o]))._player=a,s.name="videoPlayerSource",zL(SU(s._player,LP.PLAYER_STATE_CHANGED),WU(SU(t(s),"closed")),jU((function(e){return"PLAYING"===e.state})),GV((function(){s.tryVideoFrameCallback(s._player.element)}))),s}return d(i,e),o(i,[{key:"image",get:function(){return this._player.element}}])}(oF),cF=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e,new pM({id:a.name,track:i,muted:!0,container:null,objectFit:"contain",log:a.logger}),a])).name="videoTrackSource",o._player.play(),o}return d(t,e),o(t,[{key:"replaceTrack",value:function(e){this._player.setTrack(e),this._player.play()}},{key:"close",value:function(){g(t,"close",this,3)([]),this._player.stop()}}])}(sF),uF=function(e){function i(e){var a;return r(this,i),a=n(this,i),rR(t(a),"frameRate"),rR(t(a),"_canvas"),rR(t(a),"log"),rR(t(a),"hasAlpha",!1),rR(t(a),"name"),rR(t(a),"error"),a.name=e.name,a.log=e.logger.createChild({id:"vc-".concat(a.name)}),a.frameRate=e.frameRate,a}return d(i,e),o(i,[{key:"width",get:function(){var e;return(null==(e=this._canvas)?void 0:e.width)||0},set:function(e){this._canvas&&(this._canvas.width=e)}},{key:"height",get:function(){var e;return(null==(e=this._canvas)?void 0:e.height)||0},set:function(e){this._canvas&&(this._canvas.height=e)}},{key:"setSize",value:function(e,t){this._canvas&&(this._canvas.width=e,this._canvas.height=t)}},{key:"createVideoTrackSource",value:function(e,t){return new cF(this,e,{logger:this.log,name:t})}},{key:"createVideoTrackDestination",value:function(e){return new rF(this,e)}},{key:"createVideoImageSource",value:function(e,t){return new oF(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}},{key:"createVideoPlayerSource",value:function(e,t){return new sF(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}},{key:"available",get:function(){return"created"===this.state}},{key:"disconnect",value:function(){this.emit("disconnect")}}])}(wP);rR(uF,"_ids",0);var lF={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},dF=function(e){function i(){var e;return r(this,i),e=n(this,i,arguments),rR(t(e),"defaultProgam"),rR(t(e),"defaultVShader"),rR(t(e),"defaultFShader"),rR(t(e),"ctx"),e}return d(i,e),o(i,[{key:"create",value:function(){var e=this;if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(uF._ids++)),this.ctx=this._canvas.getContext("webgl2",lF),!this.ctx)throw new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:2,message:"webgl2 not supported"});this.defaultVShader=this.createShader(this.ctx.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),this.defaultFShader=this.createShader(this.ctx.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} "),this.defaultProgam=this.createProgram(this.defaultVShader,this.defaultFShader),this._canvas.addEventListener("webglcontextlost",(function(){e.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}},{key:"destroy",value:function(e){var t="";return e&&(t=e.message,this.error=e,IN.addFailedEvent({key:512702,error:e})),this.disconnect(),this.log.info("video context destroy".concat(t)?": ".concat(t):""),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),e}},{key:"width",set:function(e){var t;null==(t=this.ctx)||t.viewport(0,0,e,this.height),y(i,"width",e,this,1,1)}},{key:"height",set:function(e){var t;null==(t=this.ctx)||t.viewport(0,0,this.width,e),y(i,"height",e,this,1,1)}},{key:"setSize",value:function(e,t){var n;null==(n=this.ctx)||n.viewport(0,0,e,t),g(i,"setSize",this,3)([e,t])}},{key:"createShader",value:function(e,t){var n=this.ctx,r=n.createShader(e);return n.shaderSource(r,t),n.compileShader(r),r}},{key:"createProgram",value:function(e,t){var n=this.ctx,r=n.createProgram();return n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),n.getProgramParameter(r,n.LINK_STATUS)||this.log.error(n.getProgramInfoLog(r)),r}}])}(uF);rR(dF,"UNAVAILABLE","unavailable"),nR([AP(wP.INIT,"created",{sync:!0,fail:function(e){this.log.error("video gl context create failed",e.cause),IN.addFailedEvent({key:512700,error:e.cause||e})},success:function(){this.log.info("video context created use webgl"),IN.addSuccessEvent({key:512700})}})],dF.prototype,"create",1),nR([AP("created",wP.INIT,{ignoreError:!0,sync:!0,success:function(e){e&&this.emit(dF.UNAVAILABLE,e),this.removeAllListeners()}})],dF.prototype,"destroy",1);var hF=dF,fF=function(e){function i(){var e;return r(this,i),e=n(this,i,arguments),rR(t(e),"ctx"),e}return d(i,e),o(i,[{key:"create",value:function(e){var t=this;if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(uF._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._canvas.addEventListener("contextlost",(function(){t.log.error("2d context lost")})),this._canvas.addEventListener("contextrestored",(function(){t.log.warn("2d context restored")}))}},{key:"destroy",value:function(e){var t="";e&&(t=e.message,this.error=e,IN.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),IN.addSuccessEvent({key:512703})}}])}(uF);nR([AP(wP.INIT,"created",{sync:!0,fail:function(e){this.log.error("video 2d context create failed",e.cause),IN.addFailedEvent({key:512701,error:e.cause||e})},success:function(){this.log.info("video context created use 2d"),IN.addSuccessEvent({key:512701})}})],fF.prototype,"create",1),nR([AP("created",wP.INIT,{ignoreError:!0,sync:!0})],fF.prototype,"destroy",1);var pF=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,a,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4]),rR(t(o),"mediaType",4),rR(t(o),"source"),rR(t(o),"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),o.manager=e.videoManager,o.once("first-video-frame",(function(e){o.room.emit("first-video-frame",e)})),o}return d(i,e),o(i,[{key:"play",value:function(e,t){var n=this;return(Rw(null==t?void 0:t.canvasRender)?t.canvasRender:17===Ux)&&!this.source&&this.useCanvasPlayer(),g(i,"play",this,3)([e,t]).then((function(){n.player.calculateStat()}))}},{key:"useCanvasPlayer",value:function(){if(this.log.info("useCanvasPlayer(), has element:".concat(!!this.player.element)),this.player.element){var e=new fF({frameRate:15,logger:this.log,name:this.userId});e.create({alpha:!1});var t=new nF(e,{name:"remotePlayer",logger:this.log});this.source=e.createVideoPlayerSource(this.player),this.source.connect(t),this.player.setCanvas(e._canvas),gP()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,e),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}}},{key:"updateCanvasPlayerFPS",value:function(e){var t,n=this.decodeFPS,r=(t=n,[15,30,45,60].reduce((function(e,n){return Math.abs(n-t)<Math.abs(e-t)?n:e})));!Aw(n)||n<=0?this.log.debug("updateCanvasPlayerFPS() ignore decoder: ".concat(n," ")):r!==e.frameRate?(this.log.info("updateCanvasPlayerFPS() decoder: ".concat(n,", closest: ").concat(r,", current: ").concat(e.frameRate)),e.frameRate=r):this.log.debug("updateCanvasPlayerFPS() ignore ClosestFPS ".concat(r," == ").concat(e.frameRate))}},{key:"decodeFPS",get:function(){var e,t=this,n=((null==(e=this.room.heartbeatReport)?void 0:e.msg_down_stream_info.find((function(e){return e.msg_user_info.str_identifier===t.userId})))||{}).msg_video_status,r=2===this.mediaType?7:this.isSmall?3:2;if(!n||0===n.length)return 0;var i=n.find((function(e){return e.uint32_video_stream_type===r}));return(null==i?void 0:i.uint32_video_dec_fps)||0}},{key:"stop",value:function(){return this.room.off("heartbeat-report",this.updateCanvasPlayerFPS,this),g(i,"stop",this,3)([])}},{key:"decodeFrame",value:function(e){if(!this.manager)return e;var t,n=s(this.manager.decodePipeline);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r&&!(e=r({frame:e,track:this})))return}}catch(i){n.e(i)}finally{n.f()}return e}},{key:"isBig",get:function(){return 4===this.mediaType}},{key:"isSmall",get:function(){return 8===this.mediaType}},{key:"changeType",value:function(e){this.room.changeType(e,this.user)}},{key:"isRemotePublished",get:function(){return this.user.muteState.videoAvailable}},{key:"setMirror",value:function(e){"publish"===e||"both"===e||g(i,"setMirror",this,3)([e])}},{key:"onDecodeDowngradeStateChanged",value:function(e){this.emit("decode-downgrade-state-changed",e)}}])}(YV),mF=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,a,2]),rR(t(o),"mediaType",2),rR(t(o),"objectFit","contain"),o}return d(i,e),o(i,[{key:"isRemotePublished",get:function(){return this.user.muteState.hasAuxiliary}}])}(pF),vF=new Map;function _F(e,t){var n=$A(QA({},t),{timestamp:TR()});vF.has(e)?vF.get(e).push(n):vF.set(e,[n])}rO.on(aO.JOIN_SUCCESS,(function(e){_F(e.room.userId,{eventId:32788})})),rO.on(aO.LEAVE_START,(function(e){_F(e.room.userId,{eventId:32789})})),rO.on(aO.LOCAL_TRACK_PUBLISHED,(function(e){var t=e.track;if(t.room){var n=32769;4===t.mediaType?n=32768:2===t.mediaType&&(n=32805),_F(t.room.userId,{eventId:n})}})),rO.on(aO.LOCAL_TRACK_UNPUBLISHED,(function(e){var t=e.track;if(t.room){var n=32771;4===t.mediaType?n=32770:2===t.mediaType&&(n=32806),_F(t.room.userId,{eventId:n})}})),rO.on(aO.TRACK_MUTED,(function(e){var t=e.track;t.room&&(t.kind===nC.AUDIO?_F(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):_F(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),rO.on(aO.TRACK_UNMUTED,(function(e){var t=e.track;t.room&&(t.kind===nC.AUDIO?_F(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):_F(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),rO.on(aO.REMOTE_TRACK_SUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&_F(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&_F(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&_F(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),rO.on(aO.REMOTE_TRACK_UNSUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&_F(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&_F(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&_F(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),rO.on(aO.SWITCH_DEVICE_SUCCESS,(function(e){var t=e.track;t.room&&_F(t.room.userId,{eventId:t.kind===nC.VIDEO?32780:32781})})),rO.on(aO.LOCAL_TRACK_REPLACED,(function(e){var t=e.track;t.room&&_F(t.room.userId,{eventId:t.kind===nC.VIDEO?32782:32783})})),rO.on(aO.SIGNAL_CONNECTION_STATE_CHANGED,(function(e){var t,n=e.room,r=e.prevState;switch(e.state){case"CONNECTED":t="RECONNECTING"===r?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===r?32796:32790;break;case"RECONNECTING":t=32794}t&&_F(n.userId,{eventId:t})})),rO.on(aO.PEER_CONNECTION_STATE_CHANGED,(function(e){var t,n=e.room,r=e.prevState,i=e.state,a=e.remoteUserId,o=!!a;switch(i){case"CONNECTED":t="RECONNECTING"===r?o?32801:32798:o?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===r&&(t=o?32802:32799);break;case"RECONNECTING":t=o?32800:32797}t&&_F(n.userId,{eventId:t,remoteUserId:a})})),rO.on(aO.VIDEO_CODEC_IMPLEMENTATION_CHANGED,(function(e){e.implementation;var t=e.userId,n=e.remoteUserId,r=e.codec,i=e.isHWCodec,a=i?1:0;e.prevImplementation||(a=i?3:2);var o="h264"===r?0:2,s={eventId:4004,param1:a,param2:o,streamType:e.streamType||2};n&&(s.remoteUserId=n,s.eventId=4005),_F(t,s),IN.addEnum({key:n?514701:513701,value:a}),IN.addEnum({key:n?514700:513700,value:o})})),rO.on(aO.LOCAL_TRACK_RECAPTURE,(function(e){var t=e.track,n=e.error;if(t.userId){var r={eventId:2003,param1:0};t.kind===nC.AUDIO?(r.streamType=1,n&&(r.param1=2)):(r.streamType="auxiliary"===t.streamType?7:2,n&&(r.param1=8)),_F(t.userId,r)}}));var gF=function(e){function i(e,a){var o;r(this,i);var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";return(o=n(this,i)).mySelfId=e,o._log=a,o.key=s,rR(t(o),"userMap",new Map),rR(t(o),"remotePublishedUserMap",new Map),o}return d(i,e),o(i,[{key:"hasRobotUser",get:function(){return!!E(this.remotePublishedUserMap.values()).find((function(e){return e.isRobot}))}},{key:"getPublishedUser",value:function(e){return this.remotePublishedUserMap.get(e)}},{key:"addUser",value:function(e){var t=e[this.key],n=e.userId,r=e.tinyId,i=e.role;if(!this.userMap.has(t)){var a={userId:n,tinyId:r,role:20===i?"anchor":"audience"};this.userMap.set(t,a),this.emit("1",a)}}},{key:"deleteUser",value:function(e,t){var n=this.userMap.get(e);if(n){var r="peer leave [".concat(e,"]");bw(t)||(r+=":".concat(ZC[t])),this._log.info(r);var i=this.remotePublishedUserMap.get(e);if(i){var a=i.muteState;i.flag=0,this.emit("5",i.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:a,muteState:i.muteState,flag:0})}this.userMap.delete(e),this.emit("2",n.userId)}}},{key:"setUserList",value:function(e){var t=this;this.userMap.forEach((function(n){e.findIndex((function(e){return e[t.key]===n[t.key]}))<0&&t.deleteUser(n[t.key],0)})),e.forEach((function(e){!t.userMap.has(e[t.key])&&e[t.key]!==t.mySelfId&&t.addUser(e)}))}},{key:"addRemotePublishedUser",value:function(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}},{key:"deleteRemotePublishedUser",value:function(e){this.remotePublishedUserMap.has(e)&&this.remotePublishedUserMap.delete(e)}},{key:"setRemotePublishedUserList",value:function(e){var t=this;this.remotePublishedUserMap.forEach((function(n){var r=n[t.key];if(e.findIndex((function(e){return e[t.key]===n[t.key]}))<0){t._log.info("remote [".concat(r,"] unpublish"));var i=n.muteState;n.flag=0,t.emit("5",n.userId),t.deleteRemotePublishedUser(r),t.emit("6",{prevMuteState:i,muteState:n.muteState,flag:0})}})),e.forEach((function(e){var n,r=e[t.key];if(r!==t.mySelfId){var i=e.flag,a=e.userId,o=e.tinyId,s=jw(i,a),c=null==(n=t.remotePublishedUserMap.get(r))?void 0:n.muteState;if(c){var u=t.remotePublishedUserMap.get(r);u&&u.flag!==i&&(u.flag=i,t._log.info("remote publish updated: ".concat(JSON.stringify(u.muteState))),t.emit("6",{prevMuteState:c,muteState:s,flag:i}))}else t._log.info("remote publish. state: ".concat(JSON.stringify(s))),t.addUser({userId:a,tinyId:o,role:20}),t.emit("3",e),t.emit("6",{prevMuteState:jw(0,a),muteState:s,flag:i})}}))}},{key:"clear",value:function(){this.userMap.clear(),this.remotePublishedUserMap.clear()}}])}(tR(oR(),1).EventEmitter);function yF(e){var t=e.timesInSecond,n=e.maxSizeInSecond,r=e.getSize;return uL((function(e,i){var a=new WeakMap;return rO.on(aO.ROOM_DESTROY,(function(e){var t=e.room;return a.delete(t)})),function(){for(var o=a.get(this),s=arguments.length,c=new Array(s),u=0;u<s;u++)c[u]=arguments[u];if(o||(o={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},a.set(this,o)),0===o.timestamp?o.timestamp=Date.now():Date.now()-o.timestamp>1e3&&(o.timestamp=Date.now(),o.callCountInSecond=0,o.totalSizeInSecond=0),r&&(o.totalSizeInSecond+=r.apply(void 0,c)),0!==o.timestamp&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=t||o.totalSizeInSecond>n))throw new yR({code:_R.INVALID_OPERATION,message:mN({key:dN.CALL_FREQUENCY_LIMIT,data:{isTimes:o.callCountInSecond>=t,isSize:o.totalSizeInSecond>n,name:i,timesInSecond:t,maxSizeInSecond:n}})});o.callCountInSecond++,e.call.apply(e,[this].concat(c))}}))}var EF,TF=!0,kF={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"},SF={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},bF=((EF=bF||{})[EF.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",EF[EF.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",EF[EF.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",EF[EF.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",EF[EF.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",EF[EF.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",EF[EF.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",EF[EF.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",EF[EF.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",EF[EF.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",EF[EF.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",EF[EF.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",EF[EF.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",EF[EF.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",EF[EF.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",EF[EF.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",EF[EF.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",EF[EF.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",EF[EF.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",EF[EF.INVALID_OPERATION=5100]="INVALID_OPERATION",EF[EF.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",EF[EF.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",EF[EF.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",EF[EF.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",EF[EF.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",EF[EF.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",EF[EF.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",EF[EF.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",EF[EF.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",EF[EF.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",EF[EF.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",EF[EF.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",EF[EF.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",EF[EF.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",EF[EF.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",EF[EF.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",EF[EF.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",EF[EF.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",EF[EF.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",EF[EF.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",EF[EF.DEVICE_ERROR=5300]="DEVICE_ERROR",EF[EF.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",EF[EF.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",EF[EF.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",EF[EF.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",EF[EF.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",EF[EF.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",EF[EF.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",EF[EF.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",EF[EF.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",EF[EF.SERVER_ERROR=5400]="SERVER_ERROR",EF[EF.NEED_TO_BUY=5401]="NEED_TO_BUY",EF[EF.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",EF[EF.OPERATION_FAILED=5500]="OPERATION_FAILED",EF[EF.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",EF[EF.REJOIN_FAILED=5502]="REJOIN_FAILED",EF[EF.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",EF[EF.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",EF[EF.VIDEO_DECODE_ERROR=5505]="VIDEO_DECODE_ERROR",EF[EF.OPERATION_ABORT=5998]="OPERATION_ABORT",EF[EF.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",EF),IF=$A(QA({},hN),{INVALID_PARAMETER:function(e){var t=e.fnName;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_PARAMETER_TYPE:function(e){var t,n=e.key,r=e.rule,i=e.fnName,a=e.value,o="".concat(n||r.name);return t=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(o,"' must be type of ").concat(t," when calling ").concat(i,"(), received type: ").concat(kw(a),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' cannot be '").concat(i,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value,a="".concat(t||n.name),o="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(a,"' must be instanceof ").concat(o," when calling ").concat(r,"(), received type: ").concat(kw(i),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_PARAMETER_LESS_THAN_ZERO:function(e){var t=e.key,n=e.rule,r=e.fnName;return"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(r,"().")},INVALID_PARAMETER_MIN:function(e){var t=e.key,n=e.rule,r=e.value;return"the min value of ".concat(t||n.name," is ").concat(n.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX:function(e){var t=e.key,n=e.rule,r=e.value;return"the max value of ".concat(t||n.name," is ").concat(n.max,", received: ").concat(r,".")},INVALID_ELEMENT_ID:function(e){var t=e.key,n=e.fnName;return"'".concat(t,"' is not found in the document object when calling ").concat(n,"().")},INVALID_ELEMENT_ID_TYPE:function(e){var t=e.key,n=e.fnName,r=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(n,"(), received: ").concat(r,".")},INVALID_STREAM_ID:function(e){var t=e.key;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING:function(e){var t=e.key;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER:function(e){var t=e.key;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING:function(e){var t=e.key;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIED:function(){return"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required."},INVALID_STREAM_TYPE:function(e){var t=e.fnName;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION:function(e){var t=e.fnName;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED:function(e){var t=e.fnName;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST:function(e){var t=e.fnName,n=e.value;return"cannot ".concat(t," because remote user(userId: ").concat(n.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST:function(e){var t=e.fnName,n=e.value;return"cannot ".concat(t," because remote user(userId: ").concat(n.userId,") does not publishing ").concat(n.streamType," video.")},INVALID_OPERATION_REPEAT_CALL:function(e){var t=e.fnName;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO:function(e){var t=e.fnName;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO:function(e){var t=e.fnName;return"cannot call '".concat(t,"' because the microphone is not turned on.")},INVALID_BUFFER_EMPTY:function(e){var t=e.key;return"the buffer size of paramerter '".concat(t,"' cannot be empty")},INVALID_BUFFER_OVERSIZE:function(){return"buffer size is over 1000 Bytes"},INVALID_ROLE_AUDIENCE:function(){return"role: 'audience' cannot call this api."},INVALID_NOT_ENABLE_SEI:function(){return"you need to enable SEI in TRTC.create({ enableSEI: true })"},INVALID_NEED_CALL_PUBLISHED:function(e){var t=e.fnName;return"you need to call ".concat(t,"() after publish stream.")},ENV_NOT_SUPPORTED:function(e){var t=e.fnName;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION:function(e){var t=e.fnName;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' got device exception").concat(n?", error: ".concat(n.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n,i=e.error;return"NotFoundError, no ".concat(r," detected, please check your device and the configuration on '").concat(t,"'").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n,i=e.error;return"NotAllowedError, you have disabled ".concat(r," access, please allow the current application to use the ").concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n;return e.error,"NotReadableError, the ".concat(r," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR:function(e){var t=e.fnName,n=e.deviceType;void 0===n&&AF(t);var r=e.error;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n,i=e.error;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_SECURITY_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n,i=e.error;return"SecurityError, check whether the system security policy restricts the use of the ".concat(r,", and it is recommended to turn on the ").concat(r," after the user interacts with the page").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_ABORT_ERROR:function(e){var t=e.fnName,n=e.deviceType;void 0===n&&AF(t);var r=e.error;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(r?" error: ".concat(r.toString(),"."):".")},CAMERA_RECOVER_FAILED:function(e){var t=e.error;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED:function(e){var t=e.error;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' failed, reason: ").concat(null==n?void 0:n.toString())},FIREWALL_RESTRICTION:function(){return"media connection failure due to firewall restrictions, please try to change your network."},EVENT_HANDLER_ERROR:function(e){var t=e.eventName;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR:function(e){var t=e.reason,n=e.error;return"video context error ".concat(t," ").concat((null==n?void 0:n.name)||""," ").concat((null==n?void 0:n.message)||"")},SERVER_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' got server error: ").concat(null==n?void 0:n.toString(),", please check the SDK documentation.")},NEED_TO_BUY:function(e){var t=e.value,n=e.url;return"You need to buy packages for ".concat(t,". Refer to: ").concat(n)},ACCOUNT_NO_MONEY:function(e){var t=e.fnParams;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT:function(e){var t=e.fnName;return"'".concat(t,"' abort")},UNKNOWN_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' throw unknown exception").concat(n?", error: ".concat(n.toString(),"."):".")}});function AF(e){if(!e)return"camera";var t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var RF=function(e){function i(e){var a;r(this,i);var o,s,c=e.code,u=e.extraCode,l=e.message,d=void 0===l?"":l,h=e.messageParams,f=e.fnName,p=void 0===f?"":f,m=e.originError;return s=d||function(e){var t,n=e.params,r=e.enableDocLink,i=void 0!==r&&r,a="",o=bF[e.code];try{t=IF[o]}catch(p){t=IF.UNKNOWN_ERROR}return Sw(t)?a=t(n):Iw(t)&&(a=t),n.fnName&&!a.includes(n.fnName)&&("."!==a[a.length-1]&&(a+="."),a+=" thrown from ".concat(n.fnName,"()")),i&&(a+=" doc:"),a}({code:c===SF.SERVER_ERROR?c:u||c,params:QA({fnName:p,error:m},h)}),a=n(this,i,[s]),rR(t(a),"name","RtcError"),rR(t(a),"code"),rR(t(a),"extraCode"),rR(t(a),"functionName"),rR(t(a),"message"),rR(t(a),"handler"),rR(t(a),"originError"),a.name=bF[c],a.code=c,a.extraCode=u,a.functionName=p,a.originError=m,a.message=s,5302===a.extraCode&&null!=(o=a.originError)&&o.message.includes("system")&&(a.handler=function(){var e=document.createElement("a");ax?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[a.functionName]):ox&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[a.functionName])),e.href.length>0&&e.click()}),a}return d(i,e),o(i,null,[{key:"convertFrom",value:function(e,t,n){var r=e;if(e instanceof yR){var a=e.stack,o={code:SF.UNKNOWN_ERROR,fnName:t,originError:e};switch(e.getCode()){case _R.INVALID_PARAMETER:o.code=SF.INVALID_PARAMETER,o.message=e.message;break;case _R.INVALID_OPERATION:o.code=SF.INVALID_OPERATION;break;case _R.NOT_SUPPORTED:case _R.NOT_SUPPORTED_H264:o.code=SF.ENV_NOT_SUPPORTED,e.getCode()===_R.NOT_SUPPORTED_H264&&(o.extraCode=e.message.includes(hN.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case _R.JOIN_ROOM_FAILED:o.messageParams={fnParams:n};case _R.SERVER_TIMEOUT:case _R.SWITCH_ROLE_FAILED:o.code=SF.SERVER_ERROR,o.extraCode=e.getExtraCode();break;case _R.API_CALL_ABORTED:o.code=SF.OPERATION_ABORT;break;case _R.DEVICE_NOT_FOUND:case _R.DEVICE_AUTO_RECOVER_FAILED:case _R.INITIALIZE_FAILED:o.code=5300,e.name&&(o.extraCode=function(e){var t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(e.name));break;case _R.UNKNOWN:break;default:o.code=SF.OPERATION_FAILED}r=new i(o),a&&(r.stack+=a.substr(a.indexOf("\n")))}else{if(e instanceof i)return e;r=new i({code:SF.UNKNOWN_ERROR,fnName:t,originError:e})}return r}}])}(b(Error)),CF=RF,wF={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},DF={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},xF={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate:function(e,t,n){if(Iw(e)&&!document.getElementById(e))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5009,fnName:n,messageParams:{key:t}})}},OF={name:"userId",required:!0,type:"string"},NF={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[kF.AUDIO_PROFILE_STANDARD,kF.AUDIO_PROFILE_STANDARD_STEREO,kF.AUDIO_PROFILE_HIGH,kF.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function PF(e,t){if(!e)throw new CF({code:SF.INVALID_OPERATION,extraCode:5101,fnName:t})}function MF(e,t,n){if(!e)throw new CF({code:SF.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:n}})}var LF={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate:function(e,t,n){if(this._room.isJoined)throw new CF({code:SF.INVALID_OPERATION,extraCode:5104,fnName:n});if(e.roomId){if(Iw(e.roomId))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5016,fnName:n,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(e.roomId))&&e.roomId<4294967295))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5013,fnName:n,messageParams:{key:t}})}else{if(!e.strRoomId)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5015,fnName:n});if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e.strRoomId))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5012,fnName:n,messageParams:{key:t}})}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:xF,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:wF},validate:function(e){var t;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&NN())throw new CF({code:SF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:$A(QA({},xF),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:wF}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:NF},validate:function(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&NN())throw new CF({code:SF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:NF}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:xF,publish:{type:"boolean"},option:DF},validate:function(e,t,n,r,i){var a;if(null==(a=null==e?void 0:e.option)||!a.videoTrack){if(NN())throw new CF({code:SF.ENV_NOT_SUPPORTED,extraCode:5201});if(!FN())throw new CF({code:SF.ENV_NOT_SUPPORTED,fnName:n,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:xF,publish:{type:"boolean"},option:DF}},muteRemoteAudio:[OF,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[OF,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:xF,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate:function(e,t,n){PF(this._room.isJoined,n);var r=this._room.remotePublishedUserMap.get(e.userId);if(MF(!!r,n,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new CF({code:SF.INVALID_OPERATION,extraCode:5103,fnName:n,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:$A(QA({},xF),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate:function(e,t,n){PF(this._room.isJoined,n);var r=this._room.remotePublishedUserMap.get(e.userId);if(MF(!!r,n,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new CF({code:SF.INVALID_OPERATION,extraCode:5103,fnName:n,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate:function(e,t,n){if("*"!==e.userId&&bw(e.streamType))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5014,fnName:n})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate:function(e,t,n){PF(this._room.isJoining||this._room.isJoined,n)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e,t,n,r){if(!uP)throw new CF({code:SF.ENV_NOT_SUPPORTED,fnName:n,extraCode:5207});if(!this._room.enableSEI)throw new CF({code:SF.INVALID_OPERATION,fnName:n,extraCode:5108});if(e.byteLength>1e3)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5018,fnName:n});if(0===e.byteLength)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:n});PF(this._room.isJoined,n)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate:function(e,t,n){if(!e&&!this._room.isMainStreamPublished||e&&!this._room.isAuxStreamPublished)throw new CF({code:SF.INVALID_OPERATION,extraCode:5109,messageParams:{key:t},fnName:n})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate:function(e,t,n,r){if(e.byteLength>1e3)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5018,fnName:n});if(0===e.byteLength)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5017,fnName:n,messageParams:{key:t}})}}},validate:function(e,t,n){if(PF(this._room.isJoined,n),"live"===this._room.scene&&"audience"===this._room.role)throw new CF({code:SF.INVALID_OPERATION,extraCode:5107,fnName:n,messageParams:{key:t}})}}},UF={TRTC:LF},VF=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t)}(b(Error));function FF(e,t){for(var n=zw(e),r=0;r<t.length;r++)Ww(n[r],t[r]);return n}function BF(e){this._resolve=Promise.resolve(e)}function qF(e){this._reject=Promise.reject(e)}var jF=function(){function e(t,n){r(this,e),this.instance=t,this.group=n,rR(this,"started",!1),rR(this,"ops",[]),rR(this,"startSame",(function(){return!0})),rR(this,"mergeUpdate",FF);var i=e.instances.get(t);i?i.set(n,this):e.instances.set(t,new Map([[n,this]]))}return o(e,[{key:"action",value:function(e,t,n){var r=this,i=function(t){var n;return 0===e?r.started=!0:3===e&&(r.started=!1),r.ops.shift(),null==(n=r.currentOp)||n.action(),t},a=function(t){var n,i;throw r.ops.shift(),0===e&&2===(null==(n=r.currentOp)?void 0:n.type)&&r.ops.shift().reject(new VF("start failed")),null==(i=r.currentOp)||i.action(),t},o={type:e,action:function(){return t.apply(void 0,E(o.args)).then(i,a)},args:n,resolve:BF,reject:qF};try{switch(this.state){case 1:if(0===e)throw new VF("already started");break;case 4:if(2===e)throw new VF("not started");break;default:return this.cacheOp(o)}}catch(_O){return Promise.reject(_O)}return this.ops.push(o),o.promise=t.apply(void 0,E(o.args)).then(i,a)}},{key:"cacheOp",value:function(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new VF("already start");break;case 3:switch(e.type){case 2:throw new VF("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new VF("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;var t=new VF("keep stop");if(this.ops.slice(1).forEach((function(e){return e.reject(t)})),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise;break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new VF("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new VF("start not allowed after update");case 0:throw new VF("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new VF("keep start")),new VF("already start")}}e.promise=new Promise((function(t,n){e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(n):e.reject=n}));var n=e.action;return e.action=function(){return n().then(e.resolve,e.reject)},this.ops.push(e),e.promise}},{key:"lastOp",get:function(){return this.ops[this.ops.length-1]}},{key:"lastOpType",get:function(){return this.lastOp.type}},{key:"currentOp",get:function(){return this.ops[0]}},{key:"state",get:function(){return this.currentOp?this.currentOp.type:this.started?1:4}}],[{key:"get",value:function(t,n){if(n){var r=e.instances.get(t);return r&&r.get(n)||new e(t,n)}}},{key:"gets",value:function(t,n){var r=e.instances.get(t),i=[];return r&&r.forEach((function(e,t){n.test(t)&&i.push(e)})),i}}])}();rR(jF,"instances",new WeakMap);var HF=jF,GF=new WeakMap,WF=function(e,t){if(t instanceof VF){var n=t.stack;t=new CF({code:SF.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),n&&(t.stack+=n.substr(n.indexOf("\n")))}throw t};function zF(e,t){return uL((function(n,r){return function(){for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];var s=HF.get(this,"string"==typeof e?e:e.call.apply(e,[this].concat(a)));return s?(t&&(s.startSame=t.bind(this)),s.action(0,n.bind(this),a).catch(WF.bind(null,r))):n.apply(this,a)}}))}function JF(e,t){var n=t||{},r=n.merge,i=n.debounce;return uL((function(t,n){return function(){for(var a=this,o=arguments.length,s=new Array(o),c=0;c<o;c++)s[c]=arguments[c];var u=HF.get(this,"string"==typeof e?e:e.call.apply(e,[this].concat(s)));if(!u)return t.apply(this,s);if(r&&(u.mergeUpdate=r.bind(this)),i&&i.isNeedToDebounce.apply(this,s)){var l=i.delay,d=i.getKey;return new Promise((function(e,r){var i,o,c=null==(i=GF.get(a))?void 0:i.get(d.apply(void 0,s));if(c){var h=c.timeoutId,f=c.resolve;clearTimeout(h),f()}var p=setTimeout((function(){if(3===u.state||4===u.state)return e();u.action(2,t.bind(a),s).catch(WF.bind(null,n)).then(e,r)}),l);GF.has(a)?null==(o=GF.get(a))||o.set(d.apply(void 0,s),{timeoutId:p,resolve:e}):GF.set(a,new Map([[d.apply(void 0,s),{timeoutId:p,resolve:e}]]))}))}return u.action(2,t.bind(this),s).catch(WF.bind(null,n))}}))}function KF(e){return uL((function(t,n){return function(){for(var r=this,i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];var s="function"==typeof e?e.call.apply(e,[this].concat(a)):e;if(s instanceof RegExp)return Promise.all(HF.gets(this,s).map((function(e){return e.action(3,(function(){return Promise.resolve()}),a)}))).then((function(){return t.call.apply(t,[r].concat(a))}));var c=HF.get(this,s);return c?c.action(3,t.bind(this),a).catch(WF.bind(null,n)):t.apply(this,a)}}))}var YF={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame"},XF=new Set([YF.ERROR,YF.AUTOPLAY_FAILED,YF.KICKED_OUT,YF.REMOTE_USER_ENTER,YF.REMOTE_USER_EXIT,YF.REMOTE_AUDIO_AVAILABLE,YF.REMOTE_AUDIO_UNAVAILABLE,YF.REMOTE_VIDEO_AVAILABLE,YF.REMOTE_VIDEO_UNAVAILABLE,YF.CONNECTION_STATE_CHANGED,YF.PUBLISH_STATE_CHANGED,YF.SCREEN_SHARE_STOPPED,YF.DEVICE_CHANGED,YF.FIRST_VIDEO_FRAME]);function QF(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function $F(e){return e===kF.QOS_PREFERENCE_CLEAR?"detail":e===kF.QOS_PREFERENCE_SMOOTH?"motion":""}var ZF={};eR(ZF,{bytes2ms:function(){return fw},convertObjectNumberToInt:function(){return nD},copyProperties:function(){return hw},deepClone:function(){return zw},deepMerge:function(){return Ww},delay:function(){return rD},fibonacci:function(){return Ew},formatedTime:function(){return Yw},getConstructorName:function(){return Pw},getContainerFromElement:function(){return Kw},getEnv:function(){return iw},getInternalVersion:function(){return Fw},getLoggerUrl:function(){return ow},getMuteStateFromFlag:function(){return jw},getNetworkType:function(){return cw},getNumNetworkType:function(){return dw},getReconnectionTimeout:function(){return Tw},getStringByteLength:function(){return $w},getTurnServer:function(){return Hw},getUint32Version:function(){return tD},getValueType:function(){return kw},getViewListFromView:function(){return Jw},glog:function(){return _w},ipv4ToUint32:function(){return Gw},isArray:function(){return ww},isAudioWorkletSupported:function(){return Mw},isBoolean:function(){return Rw},isConstructor:function(){return Nw},isEmpty:function(){return qw},isFunction:function(){return Sw},isLangChinese:function(){return gw},isMediaStreamTrack:function(){return Dw},isNumber:function(){return Aw},isObject:function(){return Cw},isOverseaSdkAppId:function(){return aw},isPlainObject:function(){return yw},isPortrait:function(){return Zw},isPromise:function(){return Ow},isRemoteTrack:function(){return xw},isString:function(){return Iw},isUndefined:function(){return bw},loadImage:function(){return eD},ms2bytes:function(){return mw},ms2samples:function(){return vw},performanceNow:function(){return Uw},promiseAny:function(){return Lw},samples2ms:function(){return pw},setNetworkType:function(){return lw},stringify:function(){return Xw},stringifyIncludeValue:function(){return Qw},throttlePromise:function(){return iD}});var eB={};eR(eB,{ScheduleRequestType:function(){return sB},getAbilityConfig:function(){return uB},getScheduleDomain:function(){return lB},isNeedToSchedule:function(){return nB},scheduleProxy:function(){return aB},sendScheduleRequest:function(){return iB},setIsNeedToSchedule:function(){return rB},setScheduleProxy:function(){return oB}});var tB=null,nB=!0;function rB(e){Rw(e)&&e!==nB&&(nB=e,sO.info("setIsNeedToSchedule ".concat(e)))}function iB(e){return aR(this,arguments,(function(e){var t=e.userId,n=e.sdkAppId,r=e.useStringRoomId,i=e.roomId,a=e.userSig,o=e.version,c=e.frameWorkType,u=e.role,l=e.latencyLevel;return f().mark((function e(){var d,h,p,m,v,_,g,y,E;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(nB||!tB){e.next=2;break}return e.abrupt("return",{isCached:!0,result:tB});case 2:return d={delta:0,count:[1,1],msg:[],detail:[]},e.prev=3,(h=new FormData).append("userId",String(t)),h.append("sdkAppId",String(n)),h.append("isStrGroupId",String(r)),h.append("groupId",String(i)),h.append("sdkVersion",o),h.append("userSig",String(a)),u&&h.append("role",String(u)),l&&h.append("latencyLevel",String(l)),c&&h.append("frameWorkType",String(c)),p=Uw(),e.next=9,function(e,t,n){return new Promise((function(r,i){var a=null;Lw([hB((function(e){return t.count[0]=e+1}),(function(e){var r=e.error,i=e.retry,o=e.retriedCount,s=e.retryFuncArgs;t.msg[0]=r.message,a||(o>=1&&(s[0]=cB(n,"config",nC.MAIN,!0)),i())}))(cB(n,"config",nC.MAIN),e,{get timeout(){return 1e3*Ew(2+t.count[0])}}),hB((function(e){return t.count[1]=e+1}),(function(e){var r=e.error,i=e.retry,o=e.retriedCount,s=e.retryFuncArgs;t.msg[1]=r.message,a||(o>=2&&(s[0]=cB(n,"config",nC.BACKUP,!0)),i())}))(cB(n,"config",nC.BACKUP),e,{get timeout(){return 1e3*Ew(2+t.count[1])}})]).then((function(e){r(a=e)})).catch(i)}))}(h,d,n);case 9:return(m=e.sent).config&&(m.config.loggerDomain&&MR(m.config.loggerDomain),Rw(m.config.scheduleCache)&&rB(!m.config.scheduleCache)),d.delta=Uw()-p,v=function(e,t,n){var r={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{var i,o=performance.getEntriesByType("resource"),c=cB(e,"config",nC.MAIN),u=cB(e,"config",nC.BACKUP),l=s(o);try{for(l.s();!(i=l.n()).done;){var d=i.value;if(d.startTime>=n&&(d.name===c||d.name===u)&&d.transferSize>0){var h=d.name===c?nC.MAIN:nC.BACKUP,f=Math.round(d.duration),p=Math.round(d.domainLookupStart-d.startTime),m=d.redirectStart>0?Math.round(d.redirectEnd-d.redirectStart):0,v=d.fetchStart>0?Math.round(d.domainLookupStart-d.fetchStart):0,_=Math.round(d.domainLookupEnd-d.domainLookupStart),g=Math.round(d.requestStart-d.secureConnectionStart),y=Math.round(d.secureConnectionStart-d.connectStart),E=Math.round(d.responseStart-d.requestStart),T=Math.round(d.responseEnd-d.responseStart),k=[_,g,y,E,T];qP.uploadEvent({log:"stat-schedule-net:".concat(f,"(").concat(p,"(").concat(m,"->").concat(v,")->").concat(k.join("->"),") ").concat(h),userId:t}),r=$A(QA({},r),{totalCost:f,local:p,dns:_,tcp:y,tls:g,request:E,response:T});break}}}catch(S){l.e(S)}finally{l.f()}}catch(a){sO.error("getScheduleDetailCost error",a)}return r}(Number(n),t,p),e.abrupt("return",(tB=m,{isCached:!1,result:m,detailCost:v}));case 15:throw e.prev=15,e.t0=e.catch(3),_=ww(e.t0)?e.t0[0]:e.t0,g=Aw(_.code)?_.code:0,y="schedule failed".concat(_.message?": ".concat(_.message):""),E=new yR({code:_R.SCHEDULE_FAILED,extraCode:g,message:mN({key:dN.JOIN_ROOM_FAILED,data:{error:y,code:g}})}),sO.error(y,g),E;case 19:case"end":return e.stop()}}),e,null,[[3,15]])}))()}))}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(WC).map((function(e){return'<link rel="dns-prefetch" href="https://'.concat(e,'">')})).join("\r\n")),rO.on("28",(function(){return rB(!0)})),rO.on("63",(function(){return rB(!0)})),rO.on("84",(function(){return rB(!0)})),rO.on("201",(function(e){"RECONNECTING"===e.state&&rB(!0)})),rO.on("202",(function(e){"RECONNECTING"===e.state&&rB(!0)}));var aB={main:"",backup:""};function oB(e){ww(e)?(aB.main=e[0],aB.backup=e[1]):aB.main=e}var sB=function(e){return e.CONFIG="config",e.TRTC_AUTO_CONF="trtcAutoConf",e.AUDIO_AI_AUTH="audioAiAuth",e}(sB||{});function cB(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:nC.MAIN,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(aB[n]||lB(e,n,r),"/api/v1/").concat(t)}function uB(e,t,n){var r=cB(e,t),i=cB(e,t,nC.BACKUP),a=new URLSearchParams(n).toString();return Lw([fetch("".concat(r,"?").concat(a)).then((function(e){return e.json()})),fetch("".concat(i,"?").concat(a)).then((function(e){return e.json()}))])}function lB(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nC.MAIN,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return aw(e)?n?t===nC.MAIN?WC.MAIN_OVERSEA_BACKUP:WC.BACKUP_OVERSEA:t===nC.MAIN?WC.MAIN_OVERSEA:WC.BACKUP_OVERSEA:t===nC.MAIN?WC.MAIN:WC.BACKUP}function dB(e,t,n){return new Promise((function(r,i){aD({url:e,body:t,timeout:n.timeout,priority:"high"}).then((function(e){0===e.data.code?r(e.data.data):i({code:e.data.code,message:e.data.msg})})).catch(i)}))}var hB=function(e,t){return dD({retryFunction:dB,settings:{retries:3,timeout:0},onError:t,onRetrying:e})},fB=function(){return o((function e(){r(this,e),rR(this,"_log"),this._log=sO.createLogger({id:"fd"})}),[{key:"download",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=(t||{}).type,i=void 0===r?"blob":r,e=e.replace(/(^|[^:])\/{2,}/g,"$1/"),n.prev=2,o=Uw(),!Sw(fetch)){n.next=10;break}return n.next=7,this.downloadWithFetch(e,i);case 7:n.t0=n.sent,n.next=13;break;case 10:return n.next=12,this.downloadWithXHR(e,i);case 12:n.t0=n.sent;case 13:if((a=n.t0)&&a.data){n.next=16;break}throw new Error("data is empty");case 16:return s=Uw()-o,n.abrupt("return",(this._log.info("downloaded: ".concat(e,", return type: ").concat(i,", cost: ").concat(s,"ms")),IN.addSuccessEvent({key:522700,cost:Uw()-o}),a.data));case 20:throw n.prev=20,n.t1=n.catch(2),this._log.error("failed to download: ".concat(e,", error: ").concat(n.t1)),IN.addFailedEvent({key:522700,error:n.t1}),n.t1;case 23:case"end":return n.stop()}}),n,this,[[2,20]])})))}},{key:"downloadWithFetch",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._log.info("download with fetch: ".concat(e,", return type: ").concat(t)),n.prev=1,n.next=4,fetch(e);case 4:if((i=n.sent).ok){n.next=7;break}throw new Error("network response was not ok");case 7:if("arraybuffer"!==t){n.next=13;break}return n.next=10,i.arrayBuffer();case 10:n.t0=n.sent,n.next=16;break;case 13:return n.next=15,i.blob();case 15:n.t0=n.sent;case 16:return r=n.t0,n.abrupt("return",{data:r});case 20:throw n.prev=20,n.t1=n.catch(1),n.t1;case 23:case"end":return n.stop()}}),n,this,[[1,20]])})))}},{key:"downloadWithXHR",value:function(e,t){return this._log.info("download with xhr: ".concat(e,", return type: ").concat(t)),new Promise((function(n,r){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType=t,i.onload=function(){200===i.status||0===i.status&&i.response?n({data:i.response}):r(new Error("XHR failed"))},i.onerror=r,i.send(null)}))}},{key:"loadWasm",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._log.info("loadWasm ".concat(e,", importObject: ").concat(JSON.stringify(t))),r=Uw(),i=null,a=null,!Sw(WebAssembly.instantiateStreaming)||e.startsWith("data:application/octet-stream;base64,")||function(e){return e.startsWith("file://")}(e)||!Sw(fetch)){n.next=13;break}return n.prev=3,o=fetch(e),n.next=7,WebAssembly.instantiateStreaming(o,t);case 7:i=n.sent.instance,n.next=13;break;case 10:n.prev=10,n.t0=n.catch(3),a=n.t0;case 13:if(i){n.next=26;break}return n.prev=14,n.next=17,this.download(e,{type:"arraybuffer"});case 17:return s=n.sent,n.next=20,WebAssembly.instantiate(s,t);case 20:i=n.sent.instance,n.next=26;break;case 23:n.prev=23,n.t1=n.catch(14),a=n.t1;case 26:if(!i){n.next=29;break}return c=Uw()-r,n.abrupt("return",(this._log.info("loadedWasm ".concat(e,", cost: ").concat(c,"ms")),IN.addSuccessEvent({key:522701,cost:c}),i));case 29:throw this._log.error("failed to loadWasm ".concat(e,", error: ").concat(a)),IN.addFailedEvent({key:522701,error:a}),a;case 30:case"end":return n.stop()}}),n,this,[[3,10],[14,23]])})))}}])}();nR([HP({settings:{timeout:0,retries:3},onRetrying:function(e){this._log.warn("download retrying: ".concat(e))}})],fB.prototype,"download",1);var pB=new fB;function mB(e){var t=this,n=e.TRTC,r=e.room,i=e.errorModule;return{TRTC:n,room:r,assetsPath:e.assetsPath,fileDownloader:pB,innerEmitter:rO,constants:IR,environment:fD,utils:ZF,eventLogger:qP,log:this.room.getLogger(),loggerManager:sO,errorModule:i,kvStatManager:IN,rtcDectection:lO,trtc:this,rx:ML,enums:dO,schedule:eB,clearStarted:function(e,n){var r=e.getAlias(),i=HF.instances.get(t);if(i)if(n){var a=i.get(r+n);if(!a)return;a.started=!1}else i.forEach((function(e,t){t.startsWith(r)&&(e.started=!1)}))},startGetPCM:OL,createAudioNode:wM}}var vB=new WeakMap;function _B(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return uL((function(e,n){return function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];try{yB.call(this,t,i,n,this._name)}catch(vO){return Promise.reject(vO)}return e.apply(this,i)}}))}function gB(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return uL((function(e,n){return function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];try{yB.call(this,t,i,n,this._name)}catch(vO){throw vO}return e.apply(this,i)}}))}function yB(e,t,n,r){if(ww(e))for(var i=0;i<e.length;i++)EB.call(this,{rule:e[i],value:t[i],key:e[i].name,fnName:n,className:r});else EB.call(this,{rule:e,value:t[0],key:e.name,fnName:n,className:r})}function EB(e){var t=this,n=e.rule,r=e.value,i=e.key,a=e.fnName,o=e.className;function s(e){return{code:SF.INVALID_PARAMETER,extraCode:e,fnName:a,messageParams:{key:i,rule:n,value:r}}}if(bw(r)){if(n.required)throw new CF(s(5001));if(bw(n.defaultValue))return void(Sw(n.validate)&&n.validate.call(this,r,i,a,o,this));r=n.defaultValue}if(Array.isArray(n.type)){for(var c=!1,u=0;u<n.type.length;u++)null===n.type[u]&&null===r&&(c=!0),Sw(n.type[u])&&r instanceof n.type[u]&&(c=!0),Iw(n.type[u])&&kw(r)===n.type[u].toLowerCase()&&(c=!0);if(!c)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5002,fnName:a,messageParams:{key:i,rule:{type:n.type.map((function(e){return Nw(e)?Pw(e):Iw(e)?e:kw(e)}))},value:r}})}else if(!bw(n.type)&&kw(r)!==n.type)throw new CF(s(5002));if(!1===n.allowEmpty){var l=Aw(r)&&(0===r||Number.isNaN(r)),d=Iw(r)&&""===r.trim();if(l||d)throw new CF(s(5003))}if(n.notLessThanZero&&Aw(r)&&r<0)throw new CF(s(5006));if(!bw(n.min)&&Aw(r)&&r<n.min)throw new CF(s(5007));if(!bw(n.max)&&Aw(r)&&r>n.max)throw new CF(s(5008));if(Iw(n.instanceOf)){if(!r||r._name!==n.instanceOf)throw new CF(s(5004))}else if(Sw(n.instanceOf)&&!(r instanceof n.instanceOf))throw new CF(s(5004));if(Array.isArray(n.values)&&!n.values.includes(r))throw new CF(s(5005));var h=n.properties;yw(h)&&Cw(r)&&Object.keys(h).forEach((function(e){EB.call(t,{rule:h[e],value:r&&r[e],key:"".concat(e),fnName:a,className:o})}));var f=n.arrayItem;yw(f)&&ww(r)&&r.forEach((function(e,n){EB.call(t,{rule:f,value:e,key:"".concat(i,"[").concat(n,"]"),fnName:a,className:o})})),Sw(n.validate)&&n.validate.call(this,r,i,a,o,this)}function TB(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.getRemoteId,n=void 0===t?function(){return""}:t,r=e.replaceArg,i=e.getKVReportKey,a=e.ignoreLog;return uL((function(e,t){return function(){for(var o,s=this,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];function d(e,t,n){if(n&&n.includes(e))return"hided";if(r){var i=r.apply(void 0,u);if(u[i.argIndex]===t)return i.value}if(t===u||e in u)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(kw(t)):(JSON.stringify(t),t)}catch(TO){return"type:".concat(kw(t))}}var h=this._log||sO;if(null!=a&&a.apply(void 0,u))return e.apply(this,u);u.length>0?h.info("".concat(t,"() ").concat(JSON.stringify(u,(function(e,t){return d(e,t,["userSig","privateMapKey"])})))):h.info("".concat(t,"()"));var f=i?i.apply(void 0,u):yN[t];try{var p=e.apply(this,u),m=Uw();return Ow(p)?p.then((function(e){return h.info("".concat(t,"() success ").concat(n.call.apply(n,[s].concat(u)))),IN.addSuccessEvent({key:f,cost:Uw()-m}),e})).catch((function(e){var r,i=(e=CF.convertFrom.call(s,e,t,1===u.length?u[0]:u)).extraCode||e.code,a=null!=(r=e.message)&&r.includes(i)?"":" code:".concat(i);throw h.error("".concat(t,"() failed ").concat(n.call.apply(n,[s].concat(u))," ").concat(e).concat(a," params: ").concat(JSON.stringify(u,d))),IN.addFailedEvent({key:f,error:e}),e})):(IN.addSuccessEvent({key:f}),p)}catch(R){var v=(R=CF.convertFrom.call(this,R,t)).extraCode||R.code,_=null!=(o=R.message)&&o.includes(v)?"":" code:".concat(v);throw h.error("".concat(t,"() failed ").concat(R).concat(_," params: ").concat(JSON.stringify(u,d))),IN.addFailedEvent({key:f,error:R}),R}}}))}var kB=function(e){return uL((function(t,n){return function(r,i){return aR(this,null,f().mark((function a(){var o;return f().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(o=this._plugins.get(r)){a.next=3;break}throw this._log.error("plugin ".concat(String(r)," is not found")),new CF({code:SF.OPERATION_ABORT,message:"plugin ".concat(String(r)," is not found"),fnName:n});case 3:if(!Sw(o.constructor.isSupported)||o.constructor.isSupported()){a.next=5;break}throw this._log.error("plugin ".concat(String(r)," is not supported")),new CF({code:SF.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(r)," is not supported"),extraCode:5210,fnName:n});case 5:return a.abrupt("return",(yB.call(this,o.getValidateRule(e),[i],n,"TRTC"),t.call(this,o,i)));case 6:case"end":return a.stop()}}),a,this)})))}}))},SB=0,bB=function(){return o((function e(t,n){r(this,e),rR(this,"player"),rR(this,"publisher"),rR(this,"mixInput"),this.mixInput=new AM(n),t.url?(this.player=new Audio(t.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(t.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(t.track),this.mixInput.connect()}),[{key:"updateSettings",value:function(e){this.player&&(bw(e.volume)||(this.volume=e.volume),bw(e.loop)||(this.loop=e.loop),bw(e.playbackRate)||(this.playbackRate=e.playbackRate))}},{key:"updateListener",value:function(e){if(this.player){if(e.onDurationChange){var t=e.onDurationChange;this.player.ondurationchange=function(e){t(e.target.duration)}}if(e.onTimeUpdate){var n=e.onTimeUpdate,r=this.player;r.ontimeupdate=function(){n(r.currentTime,r.duration)}}e.onEnded&&(this.player.onended=e.onEnded)}}},{key:"reset",value:function(){this.seek(0),this.mixInput.connect()}},{key:"seek",value:function(e){this.player&&(e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e))}},{key:"play",value:function(){var e,t;return null==(e=this.publisher)||e.play(),null==(t=this.player)?void 0:t.play()}},{key:"pause",value:function(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}},{key:"stop",value:function(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}},{key:"setOperation",value:function(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}},{key:"volume",set:function(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}},{key:"loop",set:function(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}},{key:"playbackRate",set:function(e){!this.player||!this.publisher||(this.player.playbackRate=e,this.publisher.playbackRate=e)}}])}();function IB(e,t){if(t&&"function"!=typeof t)throw new CF({code:SF.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(e," should be a function.")})}var AB=function(){function e(t){r(this,e),this.core=t,rR(this,"log"),rR(this,"mixedMusicMap",new Map),rR(this,"cacheMusicMap",new Map),SB+=1,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(SB)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(SB)),this.core=t}return o(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"ax"}},{key:"getGroup",value:function(e){return null==e?void 0:e.id}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e.startValidateRule;case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}},{key:"start",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.core.room,this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track)),r=e.id,e.url,!this.mixedMusicMap.has(r)){t.next=5;break}return t.abrupt("return");case 5:return(i=this.cacheMusicMap.get(r))?e.url?i.reset():(i.mixInput.replaceSource(e.track),i.mixInput.connect()):(i=new bB(e,n.audioManager),this.cacheMusicMap.set(r,i)),i.updateListener(e),i.updateSettings(e),t.next=11,i.play();case 11:this.mixedMusicMap.set(r,i),this.log.info("start mix audio track ".concat(r," success.")),IN.addEnum({key:502700,value:3}),this.kvUpload(e);case 15:case"end":return t.stop()}}),t,this)})))}},{key:"update",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.id,r=e.operation,i=e.seekFrom,e.playbackRate,this.log.info("update music source, ".concat(JSON.stringify(e))),(a=this.mixedMusicMap.get(n))?(a.updateSettings(e),a.updateListener(e),bw(r)||a.setOperation(r),bw(i)||a.seek(i),this.kvUpload(e)):this.log.warn("update music source failed, music id: ".concat(n," not found."));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"stop",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.id;return f().mark((function e(){var r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.mixedMusicMap.has(n)&&(t.log.info("remove music source, music id: ".concat(n)),null==(r=t.mixedMusicMap.get(n))||r.stop(),t.mixedMusicMap.delete(n)),"*"===n&&t.destroyAllMusic();case 1:case"end":return e.stop()}}),e)}))()}))}},{key:"kvUpload",value:function(e){var t=e.track,n=e.loop,r=e.volume,i=e.playbackRate,a=e.operation,o=e.seekFrom,s=e.onTimeUpdate,c=e.onDurationChange,u=e.onEnded;t&&IN.addCount({key:502711}),n&&IN.addCount({key:502703}),r&&IN.addCount({key:502704}),i&&IN.addCount({key:502705}),a&&IN.addCount({key:502706}),o&&IN.addCount({key:502707}),"function"!=typeof s&&IN.addCount({key:502709}),"function"!=typeof u&&IN.addCount({key:502710}),"function"!=typeof c&&IN.addCount({key:502708})}},{key:"destroyAllMusic",value:function(){var e=this;this.log.info("destroy all music source."),this.mixedMusicMap.forEach((function(t,n){return e.stop({id:n})}))}},{key:"destroyAllCache",value:function(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}},{key:"destroy",value:function(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}}])}();rR(AB,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate:function(e,t,n){if(e.url&&"*"!==e.url){var r=e.url.split("?")[0],i=r.split(".").pop(),a=["mp3","ogg","wav","flac"].indexOf(i)>=0,o=r.startsWith("blob"),s=r.startsWith("data");if(!(a||o||s))throw new CF({code:SF.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:n})}if(!e.url&&!e.track)throw new CF({code:SF.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:n});IB("onTimeUpdate",e.onTimeUpdate),IB("onEnded",e.onEnded),IB("onDurationChange",e.onDurationChange)}}),rR(AB,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate:function(e,t,n){IB("onTimeUpdate",e.onTimeUpdate),IB("onEnded",e.onEnded),IB("onDurationChange",e.onDurationChange)}}),rR(AB,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),rR(AB,"Name","AudioMixer");var RB,CB=AB,wB=0,DB=function(){function e(t){r(this,e),this.core=t,rR(this,"log"),rR(this,"audioContext",kM()),rR(this,"workletNode"),wB+=1,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(wB)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(wB)),t.assetsPath&&this.preload("".concat(t.assetsPath,"/denoiser-wasm.js")).catch((function(e){}))}return o(e,[{key:"preload",value:function(e){return RB||(RB=this.doPreload(e)),RB}},{key:"doPreload",value:function(e){return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.core.fileDownloader.download(e,{type:"blob"});case 2:return n=t.sent,r=URL.createObjectURL(n),t.prev=4,t.next=7,mM(this.audioContext,r);case 7:t.next=12;break;case 9:throw t.prev=9,t.t0=t.catch(4),this.log.error("load worklet failed",t.t0),t.t0;case 12:return t.prev=12,URL.revokeObjectURL(r),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[4,9,12,15]])})))}},{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"ad"}},{key:"getGroup",value:function(){return"AIDenoiser_".concat(Date.now())}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e.startValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}},{key:"start",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.core,r=n.room,i=n.schedule,t.next=3,this.preload("".concat(e.assetsPath,"/denoiser-wasm.js"));case 3:if(this.workletNode){t.next=15;break}return a=String(Date.now()).slice(0,-3),t.next=7,function(e,t){return aR(this,arguments,(function(e,t){var n=t.sdkAppId,r=t.userId,i=t.userSig,a=t.timestamp;return f().mark((function t(){var o,s,c,u,l,d,h,p;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.getAbilityConfig(n,e.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:n,userId:r,userSig:i,timestamp:a});case 3:if(o=t.sent,s=o.data,c=s.errCode,u=s.errMsg,l=s.sign,"1"!==(d=s.status)){t.next=11;break}return t.abrupt("return",{auth:!0,sign:l,status:d,message:u});case 11:h="Init RTCAIDenoiser failed.",p="",t.t0=c,t.next=1===t.t0?15:2===t.t0?17:3===t.t0?19:4===t.t0?21:5===t.t0?23:6===t.t0?25:26;break;case 15:return p="Please check your params.",t.abrupt("break",26);case 17:return p="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",26);case 19:return p="Server is invalid. Please contact our engineer. ",t.abrupt("break",26);case 21:return p="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",26);case 23:return p="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",26);case 25:p="Your version is not supported.";case 26:return t.abrupt("return",{auth:!1,status:d,message:u?"".concat(h," Reason: ").concat(u,". ").concat(p):"".concat(h,", ").concat(p)});case 29:return t.prev=29,t.t1=t.catch(0),t.abrupt("return",{auth:!1,status:"0",message:"Init RTCAIDenoiser failed. All requests failed. ".concat(t.t1)});case 32:case"end":return t.stop()}}),t,null,[[0,29]])}))()}))}(i,$A(QA({},e),{timestamp:a}));case 7:if(o=t.sent,s=o.auth,c=o.sign,u=o.status,l=o.message,s){t.next=14;break}throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(s,". Message: ").concat(l)),new CF({code:SF.INVALID_PARAMETER,message:l});case 14:this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:a,sign:c,status:u}}),this.workletNode.port.onmessage=function(e){var t,n=e.data;if("cost"===n.type){var r=(null==n?void 0:n.max)>20?"warn":(null==n?void 0:n.max)>10?"info":"debug";d.log[r]("avg cost: ".concat(n.value," max: ").concat(null==n?void 0:n.max,"(").concat(SR(new Date(null==n?void 0:n.maxCostTimestamp)),") hist: ").concat(null==(t=null==n?void 0:n.hist)?void 0:t.join(" ")))}else"log"===n.type&&d.log[n.logLevel]("".concat(n.value))};case 15:this.workletNode.port.postMessage({type:"enable"}),r.audioManager.addDenoiser(this.workletNode),r.sendAbilityStatus({ai_denoise:1});case 16:case"end":return t.stop()}}),t,this)})))}},{key:"update",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"stop",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.workletNode){e.next=2;break}return e.abrupt("return");case 2:return t=this.core.room,this.workletNode.port.postMessage({type:"disable"}),e.next=6,t.audioManager.removeDenoiser(this.workletNode);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"destroy",value:function(){this.workletNode&&(this.workletNode.port.onmessage=null)}}],[{key:"startValidateRule",value:function(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate:function(t,n,r,i){if(!e.room.audioManager.hasAudioTrack)throw new CF({code:SF.INVALID_OPERATION,extraCode:5106,fnName:r})}}}}])}();rR(DB,"updateValidateRule",{type:"object"}),rR(DB,"stopValidateRule",{type:"object"}),rR(DB,"Name","AIDenoiser");var xB=DB,OB=function(e){function i(){var e;return r(this,i),e=n(this,i),rR(t(e),"observer"),rR(t(e),"state","nominal"),e.onPressureChange=e.onPressureChange.bind(t(e)),e}return d(i,e),o(i,[{key:"stateNum",get:function(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}},{key:"start",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.observer){e.next=12;break}if(e.prev=1,e.t0="PressureObserver"in window&&!ID,!e.t0){e.next=7;break}return this.observer=new PressureObserver(this.onPressureChange),e.next=7,this.observer.observe("cpu",{sampleInterval:2e3});case 7:e.next=12;break;case 9:e.prev=9,e.t1=e.catch(1),qP.uploadEvent({log:"stat-pressure-detector-start-failed",error:e.t1});case 12:case"end":return e.stop()}}),e,this,[[1,9]])})))}},{key:"onPressureChange",value:function(e){var t=this.stateNum,n=e[e.length-1];this.state=n.state,(this.stateNum>3||t>3)&&sO.info("".concat(n.source,": ").concat(n.state)),this.emit("state-changed",{type:n.source,state:this.state})}},{key:"destroy",value:function(){var e;try{null==(e=this.observer)||e.disconnect(),this.observer=null}catch(DC){qP.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:DC})}}}])}(tR(oR(),1).EventEmitter),NB=new OB;function PB(e){var t=v(e,2),n=t[0],r=t[1],i=r.byteLength,a=parseInt(String(i/255),10),o=i%255,s=[];s.push(0,0,0,1,6,n);for(var c=0;c<a;c++)s.push(255);s.push(o);var u=new DataView(r);return s.push.apply(s,E(new Uint8Array(u.buffer))),s.push(128),new SL(new DataView(new Uint8Array(s).buffer),!0)}function MB(e){return"empty"===e.type||0===e.data.byteLength}function LB(e){return 1===e.getInt32(0)&&6===e.getInt8(4)}function UB(e){for(var t=0,n=0,r=new DataView(e),i=0;i<e.byteLength;i++)switch(r.getUint8(i)){case 0:t++;break;case 1:(2===t||3===t)&&n++,t=0;break;default:t=0}return n}function VB(e){var t=e.frame,n=e.seiMessageList;if(!n||0===n.length||0===t.data.byteLength)return t;var r=9-UB(t.data);if(r<=0)return t;for(var i=n.splice(0,r).reverse().map(PB),a=i.reduce((function(e,t){return e+t.dataView.byteLength}),0),o=new ArrayBuffer(a+t.data.byteLength),s=new DataView(o),c=new DataView(t.data),u=0,l=0;l<i.length;l++)for(var d=0;d<i[l].dataView.byteLength;d++)s.setInt8(u++,i[l].dataView.getInt8(d));for(var h=0;h<t.data.byteLength;h++)s.setInt8(u++,c.getInt8(h));return t.data=o,t}function FB(e){var t=e.frame,n=e.onSEI;try{var r=new DataView(t.data);if(MB(t)||!LB(r))return t;for(var i=[],a=0,o=-1,s=-1,c=0;c<t.data.byteLength;c++){var u=r.getUint8(c);if(0===u)a++;else if(1===u){if(2===a||3===a){var l=c-a;if(-1===o?o=l:-1===s&&(s=l,i.push(new SL(new DataView(r.buffer.slice(o,s)))),o=l,s=-1),6!==r.getUint8(c+1)){t.data=r.buffer.slice(l);break}}a=0}else a=0}null==n||n(i.reverse())}catch(wR){}return t}var BB=0,qB=function(){function e(t){r(this,e),this.core=t,rR(this,"log"),rR(this,"_seiMessageList",[]),rR(this,"_smallSeiMessageList",[]),rR(this,"_subStreamSeiMessageList",[]),BB++,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(BB)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(BB)),this.core=t,this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}return o(e,[{key:"encode",value:function(e){var t=e.frame,n=e.mediaType;try{return VB({frame:t,seiMessageList:8===n?this._smallSeiMessageList:2===n?this._subStreamSeiMessageList:this._seiMessageList})}catch(DC){this.log.warn(DC)}return t}},{key:"decode",value:function(e){var t=this,n=e.frame,r=e.track;return FB({frame:n,onSEI:function(e){e.forEach((function(e){t.core.trtc.emit(YF.SEI_MESSAGE,{seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,userId:r.userId,streamType:2===r.mediaType?"sub":"main"})}))}})}},{key:"destroy",value:function(){this.log.debug("destory"),this.stop(),delete this.core}},{key:"getValidateRule",value:function(e){switch(e){case"start":case"update":case"stop":return{type:"object"}}}},{key:"start",value:function(){this.core.room.videoManager.addEncodeProcessor({processor:sP?this.encode:VB,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:sP?this.decode:FB,type:2})}},{key:"stop",value:function(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}},{key:"update",value:function(e){var t,n=e.buffer,r=e.options,i=[r.seiPayloadType,n],a=!!r.small;r.toSubStream?this._subStreamSeiMessageList.push(i):(this._seiMessageList.push(i),a&&this._smallSeiMessageList.push(i)),null==(t=this.core.room.scriptTransformWorker)||t.postMessage({type:"sei",data:i,isMain:!r.toSubStream,small:a})}},{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"sei"}},{key:"getGroup",value:function(){return"sei"}}])}();rR(qB,"autoStart",!0),rR(qB,"Name","SEI");var jB=qB;function HB(e){var t=e.frame,n=e.onDump;return null==n||n(),t}function GB(e){var t=e.frame,n=e.onDump;return null==n||n(),t}var WB,zB=0,JB=function(){function e(t){r(this,e),this.core=t,rR(this,"_core"),rR(this,"log"),rR(this,"dumpLocalVideoMap",{}),rR(this,"dumpRemoteVideoMap",{}),rR(this,"dialog"),this._core=t,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(++zB)}),this.log.info("created")}return o(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"dm"}},{key:"getGroup",value:function(){return"dm"}},{key:"getValidateRule",value:function(e){switch(e){case"start":return{name:"StartDebugOptions",required:!1};case"update":return{name:"UpdateDebugOptions",required:!1};case"stop":return{name:"StopDebugOptions",required:!1}}}},{key:"start",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=!new URLSearchParams(location.search).has("trtcDebug")&&"true"!==(null==(t=window.sessionStorage)?void 0:t.getItem("TRTC_ENABLE_DEBUG_PLUGIN")),e.t0){e.next=5;break}return e.next=4,this.openDebugDiaLog();case 4:this.addVideoProcessor();case 5:case"end":return e.stop()}}),e,this)})))}},{key:"update",value:function(){}},{key:"stop",value:function(){this.closeDebugDiaLog(),this.removeVideoProcessor()}},{key:"destroy",value:function(){this.stop()}},{key:"openDebugDiaLog",value:function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!WB){e.next=6;break}return e.next=4,WB;case 4:e.next=11;break;case 6:return n=Date.now(),r=new URLSearchParams(location.search).get("trtcDebugDialogPath")||(null==(t=window.sessionStorage)?void 0:t.getItem("TRTC_DEBUG_DIALOG_PATH"))||"https://unpkg.com/".concat("trtc-sdk-v5","@").concat(RR,"/assets/debug-dialog.js"),WB=this.loadScript(r),e.next=10,WB;case 10:this.log.info("download debug dialog script cost: ".concat(Date.now()-n,"ms"));case 11:this.dialog=new TRTCDebugDialog(this._core,this.log,this.dumpLocalVideoMap,this.dumpRemoteVideoMap),this._core.kvStatManager.addSuccessEvent({key:592705}),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(0),this._core.kvStatManager.addFailedEvent({key:592705}),this.log.error("load debug dialog script failed: ",JSON.stringify(e.t0));case 17:case"end":return e.stop()}}),e,this,[[0,14]])})))}},{key:"closeDebugDiaLog",value:function(){var e;null==(e=this.dialog)||e.closeDialog(),this.dialog=null}},{key:"addVideoProcessor",value:function(){this._core.room.videoManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeVideo.bind(this):HB,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):GB,type:1})}},{key:"removeVideoProcessor",value:function(){this._core.room.videoManager.removeEncodeProcessor({type:1}),this._core.room.videoManager.removeDecodeProcessor({type:1})}},{key:"encodeVideo",value:function(e){var t=this,n=e.frame,r=e.mediaType;return HB({frame:n,onDump:function(){if(r){var e=2===r?"sub":"main",i=t.dumpLocalVideoMap[e];i&&(i.data.push(n.data),i.duration>0&&Date.now()-i.startTimestamp>1e3*i.duration&&i.onDumpEnd())}}})}},{key:"decodeVideo",value:function(e){var t=this,n=e.frame,r=e.track;return GB({frame:n,onDump:function(){if(r){var e=t.dumpRemoteVideoMap["".concat(r.userId,"-").concat(r.streamType)];e&&(e.data.push(n.data),e.duration>0&&Date.now()-e.startTimestamp>1e3*e.duration&&e.onDumpEnd())}}})}},{key:"loadScript",value:function(e){var t=this;return new Promise((function(n,r){t.log.info("loading debug dialog from ".concat(e));var i=document.createElement("script");i.type="text/javascript",i.onload=n,i.onerror=r,i.crossOrigin="anonymous",i.src=e,document.head.append?document.head.append(i):document.getElementsByTagName("head")[0].appendChild(i)}))}}])}();rR(JB,"Name","Debug"),rR(JB,"autoStart",!0),nR([HP({settings:{timeout:3e3,retries:3},onError:function(e,t,n){var r;null!=(r=null==e?void 0:e.message)&&r.includes("timeout")?t():n(e)}})],JB.prototype,"loadScript",1);var KB=JB,YB=function(e){switch(e){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},XB=function(){return o((function e(t,n,i){var a=this;r(this,e),rR(this,"trackDoneOB"),rR(this,"startOB"),rR(this,"stopOB"),rR(this,"inputFrameCount",0),rR(this,"decodedFrameCount",0),rR(this,"type","auto"),rR(this,"config"),rR(this,"decoder"),rR(this,"_decodeSink");var o=t.kvStatManager;t.trtc,this.config=i.config,this.trackDoneOB=SU(n,wP.INIT),this.stopOB=fU(this.trackDoneOB),this.startOB=fU(),"auto"===i.type?this.type="webCodecs":this.type=i.type;var s=fU();zL(this.startOB,cU(0),kV((function(e){var t=a.pipe(n);return s.next("STARTING"),n.log.info("decoder type: ".concat(a.type)),zL(t,WU(a.stopOB),GV((function(){}),(function(t){n.log.error(t),o.addFailedEvent({key:YB(a.type),error:t}),e>4?a.startOB.error(t):a.startOB.next(e+1)}))),zL(t,GU(1),qV(MU))})),WU(this.stopOB),GV((function(){n.player.setOutput(),s.next("STARTED")}),(function(e){s.next("FAILED")}),(function(){o.addSuccessEvent({key:YB(a.type)}),o.addSuccessEvent({key:504702})})))}),[{key:"mock",value:function(e){this._decodeSink?this._decodeSink.error(e):this.startOB.next(0)}},{key:"close",value:function(e){this.stopOB.next(e)}},{key:"pipe",value:function(e){var t=this;return eU()((function(n){return aR(t,null,f().mark((function t(){var r,i=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._decodeSink=n,n.defer((function(){var e;null==(e=i.decoder)||e.close()})),r=this.type;try{"webCodecs"===r&&(this.decoder=new AudioDecoder({error:function(t){e.log.error(t),n.error(4)},output:function(t){i.decodedFrameCount++,n.next(t),e.player.write(t)}})),this.decoder.configure(this.config)}catch(vO){e.log.error(vO),n.error("webCodecs"===r?2:6)}case 3:case"end":return t.stop()}}),t,this)})))}))}},{key:"decodeFrame",value:function(e){var t;this.inputFrameCount++,"configured"===(null==(t=this.decoder)?void 0:t.state)&&this.decoder.decode(new EncodedAudioChunk({data:e.data,timestamp:e.timestamp,type:"key"}))}}])}(),QB={type:"object"},$B=function(){function e(t){r(this,e),this.core=t,rR(this,"log"),rR(this,"contextMap",new Map),rR(this,"decodeProcessorMap",new WeakMap),this.log=t.log.createChild({id:"".concat(this.getAlias())})}return o(e,[{key:"getAlias",value:function(){return e.Name}},{key:"getGroup",value:function(e){return e.track.userId+e.track.streamType}},{key:"getName",value:function(){return e.Name}},{key:"getValidateRule",value:function(e){return QB}},{key:"start",value:function(e){var t=this,n=e.track;this.decodeProcessorMap.set(n,this.decode(e)),this.core.room.audioManager.addDecodeProcessor({processor:function(e){var n=e.frame,r=e.track;return t.decodeProcessorMap.has(r)?t.decodeProcessorMap.get(r)({frame:n,track:r}):n},type:3})}},{key:"decode",value:function(e){var t=this;return function(n){var r=n.frame,i=n.track;if(i!==e.track)return r;if(t.contextMap.has(i))return t.contextMap.get(i).decodeFrame(r);var a=new XB(t.core,i,e);return zL(a.trackDoneOB,GU(1),GV((function(){t.core.clearStarted(t,t.getGroup(e)),t.stop({track:i})}))),t.contextMap.set(i,a),a.decodeFrame(r)}}},{key:"stop",value:function(e){var t=e.track,n=this.contextMap.get(t);n&&(n.close("stop"),this.contextMap.delete(t),0===this.contextMap.size&&this.core.room.audioManager.removeDecodeProcessor({type:3}))}},{key:"update",value:function(e){var t=this.contextMap.get(e.track);if(t){if("mock"===e.type)return void t.mock(10);t.close("update"),this.contextMap.set(e.track,new XB(this.core,e.track,e))}}}])}();rR($B,"Name","TRTCAudioDecoder");var ZB=$B,eq=0,tq=new Set,nq=null;CR("5.10.1-beta.3"),uO.checkStorage(),_P();var rq={RtcError:CF,ErrorCode:SF,ErrorCodeDictionary:bF},iq=function(e){function i(e,a){var o;return r(this,i),o=n(this,i),rR(t(o),"_room"),rR(t(o),"_eventListened",new Set),rR(t(o),"_localVideoTrack",null),rR(t(o),"_localAudioTrack",null),rR(t(o),"_localScreenTrack",null),rR(t(o),"_localScreenAudioTrack",null),rR(t(o),"_localVideoConfig",null),rR(t(o),"_localScreenConfig",null),rR(t(o),"_localAudioConfig",null),rR(t(o),"_remoteVideoConfigMap",new Map),rR(t(o),"_remoteAudioConfigMap",new Map),rR(t(o),"_remoteAudioVolumeMap",new Map),rR(t(o),"_remoteAudioMuteMap",new Map),rR(t(o),"_mediaTrackMap",new WeakMap),rR(t(o),"_log",sO.createLogger({id:"t".concat(++eq)})),rR(t(o),"_plugins",new Map),rR(t(o),"_networkQuality",null),rR(t(o),"_speakerId"),rR(t(o),"_getPCMAbortCtrl"),o._room=new e(QA({logger:o._log,frameWorkType:i.frameWorkType},a)),o._room.videoDecodeFallbackType=a.videoDecodeFallback,o._log.info("create() ".concat(JSON.stringify(a,(function(e,t){return"plugins"===e?t.map((function(e){return e.Name})):t})))),Object.defineProperties(t(o),{dumpAudio:{enumerable:!1,value:function(e){return this._room.audioManager.dump(e)}}}),a.plugins&&a.plugins.forEach((function(e){o._use(e,a.assetsPath)})),o._use(CB,a.assetsPath),o._use(xB,a.assetsPath),o._use(ZB,a.assetsPath||qR),o._use(KB),a.enableSEI&&uP&&o._use(jB),o._room.on("audio-volume",(function(e){!e.find((function(e){return""===e.userId}))&&o._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*o._localAudioTrack.getAudioLevel())}),1===a.volumeType&&e.forEach((function(e){var t,n=""===e.userId?o._localAudioTrack:null==(t=o.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;n&&(e.volume=n.dbVolume)})),o.emit(YF.AUDIO_VOLUME,{result:e.sort((function(e,t){return t.volume-e.volume}))})})),o._room.videoManager.on("error",(function(e){o._log.error(new CF({code:SF.OPERATION_FAILED,extraCode:5504,message:e.message,originError:e}))})),o._listenEvents(),o._initActiveSpeaker(),function(e){var t=e.emit;e.emit=function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];try{return t.apply(e,r)}catch(vO){var a=mN({key:dN.CATCH_HANDLER_ERROR,data:{name:"trtc",event:r[0]},addDocLink:!1});return sO.warn("".concat(a,"\n\n").concat(vO.stack)),!1}}}(t(o)),o}return d(i,e),o(i,[{key:"room",get:function(){return this._room}},{key:"_listenEvents",value:function(){var e=this;FP(this,this._room).add("peer-join",(function(t){var n=t.userId;e.emit(YF.REMOTE_USER_ENTER,{userId:n})})).add("peer-leave",(function(t){e.emit(YF.REMOTE_USER_EXIT,{userId:t}),e._remoteAudioVolumeMap.delete(t)})).add("banned",(function(t){e._exitRoom().finally((function(){e.emit(YF.KICKED_OUT,{reason:t.reason})}))})).add("error",(function(t){e._exitRoom().finally((function(){e.emit(YF.ERROR,CF.convertFrom(t))}))})).add("signal-connection-state-changed",(function(t){e.emit(YF.CONNECTION_STATE_CHANGED,t)})).add("network-quality",(function(t){e._networkQuality=t;var n=$A(QA({},t),{uplinkRTT:Math.min(t.uplinkRTT,rw),downlinkRTT:Math.min(t.downlinkRTT,rw)});e.emit(YF.NETWORK_QUALITY,n)})).add("remote-published",(function(t){[t.remoteAudioTrack,t.remoteVideoTrack,t.remoteAuxiliaryTrack].forEach((function(n){FP(n,n).add("player-state-changed",(function(r){var i=$A(QA({},r),{userId:t.userId});n.kind===nC.VIDEO&&(i.streamType=QF(n.streamType)),e.emit(n.kind===nC.AUDIO?YF.AUDIO_PLAY_STATE_CHANGED:YF.VIDEO_PLAY_STATE_CHANGED,i)})).add("error",(function(t){t.getCode()===_R.PLAY_NOT_ALLOWED&&e.emit(YF.AUTOPLAY_FAILED,{userId:n.userId,resume:function(){return n.player.resume()}})}))}))})).add("remote-unpublished",(function(e){[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((function(e){BP(e)}))})).add("remote-publish-state-changed",(function(t){var n=t.prevMuteState,r=t.muteState,i=r.userId,a=n.audioAvailable,o=n.videoAvailable,s=r.audioAvailable,c=r.videoAvailable;s||e._remoteAudioConfigMap.delete(i),c||e._remoteVideoConfigMap.delete("".concat(i,"_main")),r.hasAuxiliary||e._remoteVideoConfigMap.delete("".concat(i,"_sub")),o!==c&&(c?e._onVideoAvailable({userId:i,streamType:"main"}):e._onVideoUnavailable({userId:i,streamType:"main"}),e.emit(c?YF.REMOTE_VIDEO_AVAILABLE:YF.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"main"})),a!==s&&(s?e._onAudioAvailable({userId:i}):e._onAudioUnavailable({userId:i,muteState:r}),e.emit(s?YF.REMOTE_AUDIO_AVAILABLE:YF.REMOTE_AUDIO_UNAVAILABLE,{userId:i})),n.hasAuxiliary!==r.hasAuxiliary&&(r.hasAuxiliary?e._onVideoAvailable({userId:i,streamType:"sub"}):e._onVideoUnavailable({userId:i,streamType:"sub"}),e.emit(r.hasAuxiliary?YF.REMOTE_VIDEO_AVAILABLE:YF.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"sub"}))})).add("sei-message",(function(t){e.emit(YF.SEI_MESSAGE,$A(QA({},t),{streamType:QF(t.streamType)}))})).add("firewall-restriction",(function(){e.emit(YF.ERROR,new CF({code:SF.OPERATION_FAILED,extraCode:5501}))})).add("heartbeat-report",(function(t){var n,r,i,a,o,s,c,u={2:"big",3:"small",7:"sub"},l={rtt:Math.min(t.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(n=t.msg_down_stream_info[0])?void 0:n.msg_network_status.uint32_rtt)||(null==(r=e._networkQuality)?void 0:r.uplinkRTT)||(null==(i=e._networkQuality)?void 0:i.downlinkRTT)||0,rw),upLoss:(null==(a=e._networkQuality)?void 0:a.uplinkLoss)||0,downLoss:(null==(o=e._networkQuality)?void 0:o.downlinkLoss)||0,bytesSent:t.bytes_sent||0,bytesReceived:t.bytes_received||0,localStatistics:{audio:{bitrate:((null==(s=t.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(c=t.msg_up_stream_info.msg_audio_status)?void 0:c.uint32_audio_level)||0)/tN},video:t.msg_up_stream_info.msg_video_status.filter((function(e){return u[e.uint32_video_stream_type]})).map((function(e){return{bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:u[e.uint32_video_stream_type]}}))},remoteStatistics:t.msg_down_stream_info.map((function(e){return{userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/tN},video:e.msg_video_status.map((function(e){return{bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:u[e.uint32_video_stream_type]}}))}}))};e.emit(YF.STATISTICS,l)})).add("custom-message",(function(t){e.emit(YF.CUSTOM_MESSAGE,t)})).add("layerData",(function(t){return e.emit(YF.LAYER_DATA,t)})).add("first-video-frame",(function(t){e.emit(YF.FIRST_VIDEO_FRAME,$A(QA({},t),{streamType:QF(t.streamType)}))})),FP(this,VM).add("audioInputAdded",(function(t){e.emit(YF.DEVICE_CHANGED,{type:"microphone",action:"add",device:t})})).add("audioInputRemoved",(function(t){e.emit(YF.DEVICE_CHANGED,{type:"microphone",action:"remove",device:t})})).add("videoInputAdded",(function(t){e.emit(YF.DEVICE_CHANGED,{type:"camera",action:"add",device:t})})).add("videoInputRemoved",(function(t){e.emit(YF.DEVICE_CHANGED,{type:"camera",action:"remove",device:t})})).add("audioOutputAdded",(function(t){return aR(e,null,f().mark((function e(){var n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.emit(YF.DEVICE_CHANGED,{type:"speaker",action:"add",device:t}),!nq||nq.deviceId!==XC){e.next=5;break}return e.next=3,GM();case 3:n=e.sent.find((function(e){return e.deviceId===XC})),n&&nq.groupId!==n.groupId&&(nq=n,this.emit(YF.DEVICE_CHANGED,{type:"speaker",action:"active",device:n}));case 5:case"end":return e.stop()}}),e,this)})))})).add("audioOutputRemoved",(function(t){return aR(e,null,f().mark((function e(){var n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.emit(YF.DEVICE_CHANGED,{type:"speaker",action:"remove",device:t}),e.next=3,GM();case 3:if((n=e.sent[0])&&nq&&nq.groupId!==n.groupId){e.next=6;break}return e.abrupt("return");case 6:r=nq.deviceId===t.deviceId,i=nq.deviceId===XC&&nq.deviceId===n.deviceId,(r||i)&&(nq=n,this.emit(YF.DEVICE_CHANGED,{type:"speaker",action:"active",device:n}));case 8:case"end":return e.stop()}}),e,this)})))}))}},{key:"use",value:function(e){var t,n;"plugin"in e?(t=e.plugin,n=e.assetsPath):t=e,this._use(t,n||qR)}},{key:"_use",value:function(e,t){if(this._plugins.get(e.Name))this._log.warn("duplicate install plugin",e.Name);else{var n=new e(mB.call(this,{TRTC:i,room:this._room,errorModule:rq,assetsPath:t}));this._plugins.set(e.Name,n),e.autoStart&&this.startPlugin(e.Name)}}},{key:"enterRoom",value:function(e){return aR(this,null,f().mark((function t(){var n,r,a,o,s,c,u,l,d,h,p;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.scene,o=void 0===a?"rtc":a,s=e.enableAutoPlayDialog,c=void 0===s||s,u=e.autoReceiveAudio,l=void 0===u||u,d=e.autoReceiveVideo,h=void 0!==d&&d,e.proxy&&(this._room.setProxyServer(e.proxy),!Iw(e.proxy)&&e.proxy.turnServer&&(null==(r=(n=this._room).setTurnServer)||r.call(n,e.proxy.turnServer,e.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=c,this._room.autoReceiveAudio=l,this._room.autoReceiveVideo=h,Rw(e.preferHW)&&(this._room.preferHW=e.preferHW),e.playoutDelay&&(this._room.playoutDelay=e.playoutDelay),e.jitterBufferDelay&&(this._room.jitterBufferDelay=e.jitterBufferDelay),p={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,privateMapKey:e.privateMapKey||null,latencyLevel:e.latencyLevel,role:"audience"===e.role?21:20,roomId:e.roomId||0,strRoomId:e.strRoomId||"",businessInfo:e.businessInfo||null,streamId:null,userDefineRecordId:e.userDefineRecordId||null,frameWorkType:e.frameWorkType,component:e.component,language:e.language,priority:e.priority,useVp8:e.useVp8,keepAlive:e.keepAlive},e.strRoomId&&!e.roomId?this._room.useStringRoomId=!0:this._room.useStringRoomId=!1,t.next=6,this._room.join(p,o,i.frameWorkType);case 6:this._checkTrackToPublish(),NB.start();case 8:case"end":return t.stop()}}),t,this)})))}},{key:"exitRoom",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._exitRoom();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"switchRole",value:function(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),null!=t&&t.latencyLevel&&(this._room.latencyLevel=t.latencyLevel),n.next=4,this._room.switchRole(e);case 4:"anchor"===e&&this._checkTrackToPublish();case 5:case"end":return n.stop()}}),n,this)})))}},{key:"destroy",value:function(){BP(this),this.removeAllListeners(),this._room.destroy(),tq.delete(this),0===tq.size&&NB.destroy(),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),this._plugins.forEach((function(e){var t;return null==(t=e.destroy)?void 0:t.call(e)})),this._plugins.clear(),rO.off("102",this._onLocalTrackCaptured,this)}},{key:"startLocalAudio",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return f().mark((function n(){var r,a,o,s,c,u,l;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e._localAudioTrack){n.next=2;break}return n.abrupt("return",void e._log.warn("local audio is already started"));case 2:return r=t.publish,a=void 0===r||r,o=t.mute,s=t.option,c=new kL(e._room.audioManager),u={},l={muted:!0},s&&(bw(s.microphoneId)?bw(s.audioTrack)||(u.customSource=s.audioTrack):u.deviceId=s.microphoneId,s&&Aw(s.captureVolume)&&c.setCaptureVolume(s.captureVolume),bw(s.profile)||(Iw(s.profile)?ZR[s.profile]&&c.setProfile(ZR[s.profile]):c.setProfile(s.profile)),Aw(s.earMonitorVolume)&&(l.muted=!(s.earMonitorVolume>0),l.volume=s.earMonitorVolume),bw(s.echoCancellation)||(c.profile.echoCancellation=s.echoCancellation),bw(s.noiseSuppression)||(c.profile.noiseSuppression=s.noiseSuppression),bw(s.autoGainControl)||(c.profile.autoGainControl=s.autoGainControl)),c.on("5",(function(t){e.emit(YF.ERROR,new CF({code:SF.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),c.on("2",(function(t){e.emit(YF.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),c.on("4",(function(t){var n;t.error&&(n=CF.convertFrom(t.error)),e.emit(YF.PUBLISH_STATE_CHANGED,$A(QA({},t),{error:n}))})),e._listenOutputTrackChanged(c),e._speakerId&&c.setAudioOutput(e._speakerId),n.next=11,c.capture(u);case 11:return bw(o)||c.setMute(o),FP(c,c).add("player-state-changed",(function(t){e.emit(YF.AUDIO_PLAY_STATE_CHANGED,$A(QA({},t),{userId:""}))})),e.listeners(YF.AUDIO_FRAME).length>0&&(e._getPCMAbortCtrl=e._room.audioManager.getPCM((function(t){e.emit(i.EVENT.AUDIO_FRAME,{data:t})}))),e._getPCMAbortCtrl&&c.on("input-media-track-changed",(function(){e._getPCMAbortCtrl&&(e._getPCMAbortCtrl.abort("inputMediaTrackChanged"),e._getPCMAbortCtrl=e._room.audioManager.getPCM((function(t){e.emit(i.EVENT.AUDIO_FRAME,{data:t})})))})),a&&e._room.isJoined&&e._room.publish(c).catch((function(){})),e._localAudioTrack=c,e._localAudioConfig=$A(QA({},t),{publish:a}),n.next=20,e._updateAudioPlayOption({playOption:l,track:c});case 20:case"end":return n.stop()}}),n)}))()}))}},{key:"updateLocalAudio",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localAudioTrack&&this._localAudioConfig){t.next=2;break}return t.abrupt("return");case 2:if(n=e.publish,r=e.mute,i=e.option,a={},t.t0=i,!t.t0){t.next=18;break}if(!i.microphoneId){t.next=10;break}return t.next=8,this._localAudioTrack.switchDevice(i.microphoneId);case 8:t.next=14;break;case 10:if(t.t1=bw(i.audioTrack),t.t1){t.next=14;break}return t.next=14,this._localAudioTrack.setInputMediaStreamTrack(i.audioTrack);case 14:return bw(i.captureVolume)||this._localAudioTrack.setCaptureVolume(i.captureVolume),bw(i.earMonitorVolume)||(a.muted=!(i.earMonitorVolume>0),a.volume=i.earMonitorVolume),t.next=18,this._localAudioTrack.update3A(i);case 18:return this._room.isJoined&&!bw(n)&&(n&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((function(){})),this._localAudioConfig.publish&&!n&&this._room.unpublish(this._localAudioTrack).catch((function(){}))),bw(r)||this._localAudioTrack.setMute(r),t.next=22,this._updateAudioPlayOption({playOption:a,track:this._localAudioTrack,prevConfig:this._localAudioConfig});case 22:Ww(this._localAudioConfig,e);case 23:case"end":return t.stop()}}),t,this)})))}},{key:"stopLocalAudio",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._localAudioTrack,!e.t0){e.next=13;break}if(e.t1=this._room.isJoined,!e.t1){e.next=6;break}return e.next=6,this._room.unpublish(this._localAudioTrack).catch((function(){}));case 6:this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),BP(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null,this._getPCMAbortCtrl&&(this._getPCMAbortCtrl.abort("stopLocalAudio"),delete this._getPCMAbortCtrl);case 13:case"end":return e.stop()}}),e,this)})))}},{key:"startLocalVideo",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return f().mark((function n(){var r,i,a,o,s,c,u,l;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e._localVideoTrack){n.next=2;break}return n.abrupt("return",void e._log.warn("local video is already started"));case 2:return r=t.view,i=t.publish,a=void 0===i||i,o=t.mute,s=t.option,c=new AL(e._room.videoManager),u={},l={},Rw(null==s?void 0:s.avoidCropping)&&(c.avoidCropping=s.avoidCropping),s&&(s.cameraId?u.deviceId=s.cameraId:bw(s.useFrontCamera)?bw(s.videoTrack)||(u.customSource=s.videoTrack):u.facingMode=s.useFrontCamera?nC.FACING_MODE_USER:nC.FACING_MODE_ENVIRONMENT,s.qosPreference&&(u.contentHint=$F(s.qosPreference)),bw(s.profile)||(Iw(s.profile)?eC[s.profile]&&c.setProfile(eC[s.profile]):c.setProfile(s.profile)),bw(s.fillMode)||(l.objectFit=s.fillMode),bw(s.mirror)||(l.mirror=s.mirror),bw(s.small)||(JN()?Iw(s.small)?c.small=eC[s.small]:!0===s.small?c.small=eC["120p"]:c.small=s.small:e._log.warn("small stream is not supported"))),c.once("first-video-frame",(function(t){e.emit(YF.FIRST_VIDEO_FRAME,$A(QA({},t),{streamType:QF(t.streamType)}))})),c.on("5",(function(t){e.emit(YF.ERROR,new CF({code:SF.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),c.on("2",(function(t){e.emit(YF.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),c.on("4",(function(t){var n;t.error&&(n=CF.convertFrom(t.error)),e.emit(YF.PUBLISH_STATE_CHANGED,$A(QA({},t),{error:n}))})),e._listenOutputTrackChanged(c),n.next=12,c.capture(u);case 12:if(n.t0=bw(o),n.t0){n.next=16;break}return n.next=16,c.setMute(o);case 16:return FP(c,c).add("player-state-changed",(function(t){e.emit(YF.VIDEO_PLAY_STATE_CHANGED,$A(QA({},t),{userId:"",streamType:"main"}))})),a&&e._room.isJoined&&e._room.publish(c).catch((function(){})),e._localVideoTrack=c,e._localVideoConfig=$A(QA({},t),{view:r,publish:a}),n.next=22,e._updateVideoPlayOption({view:r,playOption:l,track:c});case 22:case"end":return n.stop()}}),n)}))()}))}},{key:"updateLocalVideo",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localVideoTrack&&this._localVideoConfig){t.next=2;break}return t.abrupt("return");case 2:if(n=e.view,r=e.publish,i=e.mute,a=e.option,o={},!a){t.next=28;break}if(bw(a.profile)||(Iw(a.profile)?eC[a.profile]&&this._localVideoTrack.setProfile(eC[a.profile]):this._localVideoTrack.setProfile(a.profile),(!a.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(a.cameraId))&&bw(a.useFrontCamera)&&this._localVideoTrack.applyProfile()),!a.cameraId){t.next=10;break}return t.next=8,this._localVideoTrack.switchDevice(a.cameraId);case 8:t.next=19;break;case 10:if(!bw(a.useFrontCamera)){t.next=17;break}if(t.t0=bw(a.videoTrack),t.t0){t.next=15;break}return t.next=15,this._localVideoTrack.setInputMediaStreamTrack(a.videoTrack);case 15:t.next=19;break;case 17:return t.next=19,this._localVideoTrack.switchDevice(a.useFrontCamera?nC.FACING_MODE_USER:nC.FACING_MODE_ENVIRONMENT);case 19:if(bw(a.fillMode)||(o.objectFit=a.fillMode),bw(a.mirror)||(o.mirror=a.mirror),a.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint($F(a.qosPreference)),!a.small){t.next=27;break}s=!this._localVideoTrack.small,JN()?(!0===a.small?this._localVideoTrack.small=eC["120p"]:Iw(a.small)?this._localVideoTrack.small=eC[a.small]:this._localVideoTrack.small=a.small,this._room.videoManager.update(),s&&this._room.enableSmall(!0)):this._log.warn("small stream is not supported"),t.next=28;break;case 27:!1===a.small&&this._localVideoTrack.small&&(delete this._localVideoTrack.small,this._room.videoManager.update(),this._room.enableSmall(!1));case 28:if(this._room.isJoined&&!bw(r)&&(r&&!this._localVideoConfig.publish&&this._room.publish(this._localVideoTrack).catch((function(){})),this._localVideoConfig.publish&&!r&&this._room.unpublish(this._localVideoTrack).catch((function(){}))),t.t1=bw(i),t.t1){t.next=33;break}return t.next=33,this._localVideoTrack.setMute(i);case 33:return t.next=35,this._updateVideoPlayOption({view:n,playOption:o,track:this._localVideoTrack,prevConfig:this._localVideoConfig});case 35:Ww(this._localVideoConfig,e);case 36:case"end":return t.stop()}}),t,this)})))}},{key:"stopLocalVideo",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._localVideoTrack,!e.t0){e.next=11;break}if(e.t1=this._room.isJoined,!e.t1){e.next=6;break}return e.next=6,this._room.unpublish(this._localVideoTrack).catch((function(){}));case 6:this._localVideoTrack.stop(),this._localVideoTrack.close(),BP(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null;case 11:case"end":return e.stop()}}),e,this)})))}},{key:"startScreenShare",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return f().mark((function n(){var r,i,a,o,s,c,u,l,d,h,p,m;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e._localScreenTrack){n.next=2;break}return n.abrupt("return",void e._log.warn("screen share is already started"));case 2:return r=t.view,i=void 0===r?null:r,a=t.publish,o=void 0===a||a,s=t.option,(c=new wL(e._room.videoManager)).on("4",(function(t){var n;t.error&&(n=CF.convertFrom(t.error)),e.emit(YF.PUBLISH_STATE_CHANGED,$A(QA({},t),{error:n}))})),c.once("first-video-frame",(function(t){e.emit(YF.FIRST_VIDEO_FRAME,$A(QA({},t),{streamType:QF(t.streamType)}))})),e._listenOutputTrackChanged(c),"main"===t.streamType&&(c.mediaType=4),u=null,l={},d={},s&&(bw(s.profile)||(Iw(s.profile)?tC[s.profile]&&c.setProfile(tC[s.profile]):c.setProfile(s.profile)),s.systemAudio&&(l.systemAudio=!0,l.echoCancellation=s.echoCancellation,l.noiseSuppression=s.noiseSuppression,l.autoGainControl=s.autoGainControl),bw(s.fillMode)||(d.objectFit=s.fillMode),s.videoTrack&&(l.videoTrack=s.videoTrack),s.audioTrack&&(l.audioTrack=s.audioTrack),s.captureElement&&(l.captureElement=s.captureElement),s.preferDisplaySurface&&(l.preferDisplaySurface=s.preferDisplaySurface),s.qosPreference&&(l.contentHint=$F(s.qosPreference))),n.next=8,c.capture(l);case 8:if(h=n.sent,c.mediaTrack.addEventListener(nC.ENDED,(function(){e._stopScreenShare(),e.emit(YF.SCREEN_SHARE_STOPPED)})),n.t0=h.getAudioTracks()[0],!n.t0){n.next=16;break}return u=new xL(e._room.audioManager),n.next=15,u.setInputMediaStreamTrack(h.getAudioTracks()[0]);case 15:e._speakerId&&u.setAudioOutput(e._speakerId);case 16:if(FP(c,c).add("player-state-changed",(function(t){e.emit(YF.VIDEO_PLAY_STATE_CHANGED,$A(QA({},t),{userId:"",streamType:"sub"}))})),!o||!e._room.isJoined){n.next=20;break}m=[c],u&&m.push(u),(p=e._room).publish.apply(p,m).catch((function(){}));case 20:return e._localScreenTrack=c,e._localScreenAudioTrack=u,e._localScreenConfig=$A(QA({},t),{view:i,publish:o}),n.next=25,e._updateVideoPlayOption({view:i,playOption:d,track:c});case 25:case"end":return n.stop()}}),n)}))()}))}},{key:"updateScreenShare",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localScreenTrack&&this._localScreenConfig){t.next=2;break}return t.abrupt("return");case 2:return n=e.view,r=e.publish,i=e.option,a={},i&&(bw(i.fillMode)||(a.objectFit=i.fillMode),i.qosPreference)&&(o=$F(i.qosPreference),this._localScreenTrack.setContentHint(o)),this._room.isJoined&&!bw(r)&&(r&&!this._localScreenConfig.publish&&(this._room.publish(this._localScreenTrack).catch((function(){})),this._localScreenAudioTrack&&this._room.publish(this._localScreenAudioTrack).catch((function(){}))),this._localScreenConfig.publish&&!r&&(this._room.unpublish(this._localScreenTrack).catch((function(){})),this._localScreenAudioTrack&&this._room.unpublish(this._localScreenAudioTrack).catch((function(){})))),t.next=7,this._updateVideoPlayOption({view:n,playOption:a,track:this._localScreenTrack,prevConfig:this._localScreenConfig});case 7:Ww(this._localScreenConfig,e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"stopScreenShare",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._stopScreenShare();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"startRemoteVideo",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.view,r=e.userId,i=e.streamType,a=e.option,o="".concat(r,"_").concat(i),!this._remoteVideoConfigMap.has(o)){t.next=3;break}return t.abrupt("return",void this._log.warn("remote video has already started. userId:".concat(r,", streamType:").concat(i)));case 3:if(s=this._room.remotePublishedUserMap.get(r)){t.next=6;break}return t.abrupt("return");case 6:return c={},u="main"===i?s.remoteVideoTrack:s.remoteAuxiliaryTrack,this._listenOutputTrackChanged(u),a&&(bw(a.fillMode)||(c.objectFit=a.fillMode),bw(a.mirror)||(c.mirror=a.mirror),bw(a.poster)||(c.poster=a.poster),c.canvasRender=a.canvasRender,"main"===i&&!bw(a.small)&&(!s.remoteVideoTrack.isSubscribing&&!s.remoteVideoTrack.isSubscribed&&s.remoteVideoTrack.setMediaType(a.small?8:4),this._room.changeType(a.small,u.user))),t.next=11,this._room.subscribe(u);case 11:return t.next=13,this._enableVideoDecodeFallback(u,i);case 13:return t.next=15,this._updateVideoPlayOption({view:n,playOption:c,track:u});case 15:this._emitTrackEvent(u),this._remoteVideoConfigMap.set(o,{config:e}),a&&!bw(a.receiveWhenViewVisible)&&this._observeView({remoteTrack:u,view:n,receiveWhenViewVisible:a.receiveWhenViewVisible,viewRoot:null==a?void 0:a.viewRoot});case 18:case"end":return t.stop()}}),t,this)})))}},{key:"updateRemoteVideo",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d,h,p,m,v,_;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.view,a=e.userId,o=e.streamType,s=e.option,c="".concat(a,"_").concat(o),(u=this._remoteVideoConfigMap.get(c))&&this._room.remotePublishedUserMap.has(a)){t.next=3;break}return t.abrupt("return");case 3:if(l={},s&&(bw(s.fillMode)||(l.objectFit=s.fillMode),bw(s.mirror)||(l.mirror=s.mirror)),d=null,h=this._room.remotePublishedUserMap.get(a),"main"===o&&null!=h&&h.muteState.hasVideo&&(d=h.remoteVideoTrack),"sub"===o&&null!=h&&h.muteState.hasAuxiliary&&(d=h.remoteAuxiliaryTrack),d){t.next=8;break}return t.abrupt("return");case 8:return p=u.config,"main"===o&&s&&!bw(s.small)&&this._room.changeType(s.small,d.user),t.next=12,this._updateVideoPlayOption({view:i,playOption:l,track:d,prevConfig:p});case 12:Ww(p,e),m=bw(null==s?void 0:s.receiveWhenViewVisible)?null==(n=p.option)?void 0:n.receiveWhenViewVisible:s.receiveWhenViewVisible,v=bw(i)?p.view:i,_=bw(null==s?void 0:s.viewRoot)?null==(r=p.option)?void 0:r.viewRoot:s.viewRoot,this._observeView({remoteTrack:d,view:v,receiveWhenViewVisible:m,viewRoot:_});case 15:case"end":return t.stop()}}),t,this)})))}},{key:"stopRemoteVideo",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._stopRemoteVideo(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"_stopRemoteVideo",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return aR(this,null,f().mark((function n(){var r,i,a,o,s,c,u,l,d;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],(i=this._room.remotePublishedUserMap.get(e.userId))&&(a=i.muteState,o=i.remoteVideoTrack,s=i.remoteAuxiliaryTrack,"main"===e.streamType&&(o.stop(),a.hasVideo&&r.push(o)),"sub"===e.streamType&&(s.stop(),a.hasAuxiliary&&r.push(s))),c=0,u=r;case 3:if(!(c<u.length)){n.next=13;break}if(l=u[c],n.t0=t,!n.t0){n.next=10;break}return n.next=9,this._room.unsubscribe(l);case 9:this._mediaTrackMap.delete(l.outMediaTrack);case 10:c++,n.next=3;break;case 13:(d=this._remoteVideoConfigMap.get("".concat(e.userId,"_").concat(e.streamType)))&&d.observer&&d.observer.disconnect(),this._remoteVideoConfigMap.delete("".concat(e.userId,"_").concat(e.streamType));case 15:case"end":return n.stop()}}),n,this)})))}},{key:"muteRemoteAudio",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._remoteAudioMuteMap.set(e,t),n.prev=1,"*"!==e){n.next=30;break}if(!t){n.next=8;break}return n.next=6,this._stopRemoteAudio({userId:e});case 6:n.next=28;break;case 8:r=E(this._room.remotePublishedUserMap.values()),i=s(r),n.prev=10,i.s();case 12:if((a=i.n()).done){n.next=20;break}if(o=a.value,n.t0=o.muteState.hasAudio&&!this._remoteAudioConfigMap.has(o.userId),!n.t0){n.next=18;break}return n.next=18,this._startRemoteAudio({userId:o.userId});case 18:n.next=12;break;case 20:n.next=25;break;case 22:n.prev=22,n.t1=n.catch(10),i.e(n.t1);case 25:return n.prev=25,i.f(),n.finish(25);case 28:n.next=39;break;case 30:if(!t){n.next=35;break}return n.next=33,this._stopRemoteAudio({userId:e});case 33:n.next=39;break;case 35:if(n.t2=this._remoteAudioConfigMap.has(e),n.t2){n.next=39;break}return n.next=39,this._startRemoteAudio({userId:e});case 39:n.next=44;break;case 41:throw n.prev=41,n.t3=n.catch(1),this._remoteAudioMuteMap.delete(e),n.t3;case 44:case"end":return n.stop()}}),n,this,[[1,41],[10,22,25,28]])})))}},{key:"setRemoteAudioVolume",value:function(e,t){if("*"===e){var n,r=s(E(this._room.remotePublishedUserMap.values()));try{for(r.s();!(n=r.n()).done;){var i=n.value;this._remoteAudioVolumeMap.set(i.userId,t),i.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}}catch(o){r.e(o)}finally{r.f()}}else if(e){var a=this._room.remotePublishedUserMap.get(e);this._remoteAudioVolumeMap.set(e,t),a&&a.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:a.remoteAudioTrack})}}},{key:"startPlugin",value:function(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.start(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"updatePlugin",value:function(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.update(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"stopPlugin",value:function(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.stop(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"enableAudioVolumeEvaluation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}},{key:"on",value:function(e,t,n){var r=this;return this.listeners(e).includes(t)||(this._log.debug("on",e),g(i,"on",this,3)([e,t,n]),this._eventListened.add(e),e===i.EVENT.AUDIO_FRAME&&!this._getPCMAbortCtrl&&(this._getPCMAbortCtrl=this._room.audioManager.getPCM((function(e){r.emit(i.EVENT.AUDIO_FRAME,{data:e})})),this._localAudioTrack&&this._localAudioTrack.on("input-media-track-changed",(function(){r._getPCMAbortCtrl&&(r._getPCMAbortCtrl.abort("inputMediaTrackChanged"),r._getPCMAbortCtrl=r._room.audioManager.getPCM((function(e){r.emit(i.EVENT.AUDIO_FRAME,{data:e})})))})))),this}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];try{XF.has(e)&&this._log.debug("emit ".concat(e," ").concat(JSON.stringify(n)))}catch(vO){}return g(i,"emit",this,3)([e].concat(n))}},{key:"off",value:function(e,t,n){var r,a;return this._log.debug("off",e),"*"===e?(this._eventListened.clear(),this.removeAllListeners(),null==(r=this._getPCMAbortCtrl)||r.abort("off"),delete this._getPCMAbortCtrl):(g(i,"off",this,3)([e,t,n]),e===i.EVENT.AUDIO_FRAME&&(null==(a=this._getPCMAbortCtrl)||a.abort("off"),delete this._getPCMAbortCtrl)),this}},{key:"getAudioTrack",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},n=null,r="main",i=!1;if(Iw(t)?e=t:(e=t.userId,i=!0===t.processed,t.streamType&&(r=t.streamType)),e){var a=this._room.remotePublishedUserMap.get(e);a&&(n=a.remoteAudioTrack)}else n="sub"===r?this._localScreenAudioTrack:this._localAudioTrack;return n?i&&n.outMediaTrack&&n.outMediaTrack!==n.mediaTrack?n.outMediaTrack.clone():n.mediaTrack:null}},{key:"getVideoTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},t=e.userId,n=void 0===t?"":t,r=e.streamType,i=void 0===r?"main":r,a=e.processed,o=void 0!==a&&a,s=null;if(""===n)"main"===i&&this._localVideoTrack&&(s=this._localVideoTrack),"sub"===i&&this._localScreenTrack&&(s=this._localScreenTrack);else{var c=this._room.remotePublishedUserMap.get(n);c&&(s="main"===i?c.remoteVideoTrack:c.remoteAuxiliaryTrack)}return s?o&&s.outMediaTrack&&s.outMediaTrack!==s.mediaTrack?s.outMediaTrack.clone():s.mediaTrack:null}},{key:"getVideoSnapshot",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.userId,n=e.streamType,r=void 0===n?"main":n;if(t){var i=this._room.remotePublishedUserMap.get(t);if("main"===r&&null!=i&&i.muteState.hasVideo)return i.remoteVideoTrack.getVideoFrame();if("sub"===r&&null!=i&&i.muteState.hasAuxiliary)return i.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===r&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===r&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}},{key:"_setCurrentSpeaker",value:function(e){var t,n;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(n=this._localScreenAudioTrack)||n.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((function(t){return t.remoteAudioTrack.setAudioOutput(e)}))}},{key:"setCurrentSpeaker",value:function(e){return aR(this,null,f().mark((function t(){var n=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,GM();case 2:t.sent.forEach((function(t){t.deviceId===e&&(n._setCurrentSpeaker(e),n.emit(YF.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}),nq=t)})),this._log.warn('the "setCurrentSpeaker" method of the instance will be deprecated in the future, please use "TRTC.setCurrentSpeaker" instead. For more information, please visit: https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/TRTC.html#.setCurrentSpeaker');case 4:case"end":return t.stop()}}),t,this)})))}},{key:"_startRemoteAudio",value:function(e){return this._doStartRemoteAudio(e)}},{key:"_doStartRemoteAudio",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.userId,!this._remoteAudioConfigMap.has(n)){t.next=3;break}return t.abrupt("return",void this._log.warn("remote audio has already started. userId:".concat(n)));case 3:if(r=this._room.remotePublishedUserMap.get(n)){t.next=6;break}return t.abrupt("return");case 6:return i={},a=r.remoteAudioTrack,this._listenOutputTrackChanged(a),this._speakerId&&a.setAudioOutput(this._speakerId),t.prev=8,o=this._remoteAudioVolumeMap.get(n),s=Aw(o)?o:100,i.volume=s,this._remoteAudioConfigMap.set(n,e),t.next=14,this._room.subscribe(a);case 14:return zL(SU(a,"decode-failed"),WU(SU(a,wP.INIT)),GV((function(){c.startPlugin(ZB.Name,{track:a,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})}))),t.next=17,this._updateAudioPlayOption({playOption:i,track:a});case 17:t.next=22;break;case 19:throw t.prev=19,t.t0=t.catch(8),this._remoteAudioConfigMap.delete(n),t.t0;case 22:this._emitTrackEvent(a);case 23:case"end":return t.stop()}}),t,this,[[8,19]])})))}},{key:"_stopRemoteAudio",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._room.remotePublishedUserMap.get(e.userId),n.t0=r,!n.t0){n.next=9;break}if(r.remoteAudioTrack.stop(),n.t1=r.muteState.hasAudio&&t,!n.t1){n.next=8;break}return n.next=8,this._room.unsubscribe(r.remoteAudioTrack);case 8:this._mediaTrackMap.delete(r.remoteAudioTrack.outMediaTrack);case 9:this._remoteAudioConfigMap.delete("".concat(e.userId));case 10:case"end":return n.stop()}}),n,this)})))}},{key:"_enableVideoDecodeFallback",value:function(e,t){var n,r=this,i=this._room.videoDecodeFallbackType;i&&this._plugins.has("TRTCVideoDecoder")&&(e.log.debug("remote video will fall back when decode failed",e.id),zL(SU(e,"decode-failed"),WU(SU(e,wP.INIT)),WV((function(){r.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:i})})),bV(SU(e,"decode-downgrade-state-changed")),GV((function(i){n=i.state,r.emit(YF.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,$A(QA({},i),{streamType:t,userId:e.userId}))}),(function(t){e.log.error("fallback",t)}),(function(){"STARTED"===n&&e.log.info("fallback complete")}))))}},{key:"_updateVideoPlayOption",value:function(e){return aR(this,arguments,(function(e){var t=e.view,n=e.playOption,r=e.track,i=e.prevConfig;return f().mark((function e(){var a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.setMirror(n.mirror),!(bw(t)&&i&&i.view)||qw(n)){e.next=6;break}if(a=Jw(i.view),e.t0=a.length>0,!e.t0){e.next=6;break}return e.next=6,r.play(a,n);case 6:if(bw(t)){e.next=14;break}if(!((o=Jw(t)).length>0)){e.next=13;break}return e.next=11,r.play(o,n);case 11:e.next=14;break;case 13:r.stop();case 14:case"end":return e.stop()}}),e)}))()}))}},{key:"_updateAudioPlayOption",value:function(e){return aR(this,arguments,(function(e){var t=e.playOption,n=void 0===t?{}:t,r=e.track;return e.prevConfig,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.isPlayCalled){e.next=8;break}return e.prev=1,e.next=4,r.play(null,n);case 4:e.next=8;break;case 6:e.prev=6,e.t0=e.catch(1);case 8:bw(n.muted)||r.setPlayerMute(n.muted),bw(n.volume)||r.setAudioVolume(n.volume/100);case 9:case"end":return e.stop()}}),e,null,[[1,6]])}))()}))}},{key:"_listenOutputTrackChanged",value:function(e){var t=this;0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(function(){return t._emitTrackEvent(e,!1)}))}},{key:"_emitTrackEvent",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.isRemote?e.userId:"";e.outMediaTrack&&(t&&this._mediaTrackMap.get(e.outMediaTrack)===n||(this._mediaTrackMap.set(e.outMediaTrack,n),this.emit(YF.TRACK,{userId:n,streamType:QF(e.streamType),track:e.outMediaTrack,sourceTrack:e.mediaTrack})))}},{key:"_checkTrackToPublish",value:function(){var e,t,n,r,i=[];if(null!=(t=this._localAudioConfig)&&t.publish&&this._localAudioTrack&&i.push(this._localAudioTrack),null!=(n=this._localVideoConfig)&&n.publish&&this._localVideoTrack&&i.push(this._localVideoTrack),null!=(r=this._localScreenConfig)&&r.publish&&(this._localScreenTrack&&i.push(this._localScreenTrack),this._localScreenAudioTrack&&i.push(this._localScreenAudioTrack)),0!==i.length)return(e=this._room).publish.apply(e,i).catch((function(){}))}},{key:"_observeView",value:function(e){var t=this,n=e.remoteTrack,r=e.view,i=e.receiveWhenViewVisible,a=void 0!==i&&i,o=e.viewRoot;if(!bw(r)){var s=this._remoteVideoConfigMap.get("".concat(n.userId,"_").concat(QF(n.streamType)));if(s){var c=s.observer||void 0;if(null===r||ww(r)&&0===r.length||!a)return null==c||c.disconnect(),void(n.isSubscribed||this._room.subscribe(n).catch((function(){})));var u=s.visibleViewMap||new Map,l=-1;(!c||c.root!==o)&&(null==c||c.disconnect(),u.clear(),c=new IntersectionObserver((function(e){e.forEach((function(e){u.set(e.target,e.isIntersecting)})),clearTimeout(l),l=window.setTimeout((function(){var e=E(u.values()).find((function(e){return e}));n.log.info("view is".concat(e?"":" not"," visible")),e?n.isSubscribed||t._room.subscribe(n).catch((function(){})):n.isSubscribed&&t._room.unsubscribe(n).catch((function(){}))}),200)}),{root:o}));var d=new Set(Jw(r));u.forEach((function(e,t){d.has(t)||(c.unobserve(t),u.delete(t))})),d.forEach((function(e){u.set(e,!0),c.observe(e)})),c.takeRecords().forEach((function(e){u.set(e.target,e.isIntersecting)})),s.visibleViewMap=u,s.observer=c}}}},{key:"_exitRoom",value:function(){return aR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._room.isJoined,!e.t0){e.next=4;break}return e.next=4,this._room.leave();case 4:new Set([].concat(E(this._remoteAudioConfigMap.keys()),E(this._remoteAudioMuteMap.keys()))).forEach((function(e){t._stopRemoteAudio({userId:e}).catch()})),E(this._remoteVideoConfigMap.keys()).forEach((function(e){var n=e.includes("main")?"main":"sub",r=e.split("_".concat(n))[0];r&&t._stopRemoteVideo({userId:r,streamType:n}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._remoteAudioVolumeMap.clear(),function(e){var t=vB.get(e);t&&(t.forEach((function(e){return clearTimeout(e)})),vB.delete(e))}(this),this._room.remotePublishedUserMap.forEach((function(e){BP(e.remoteAudioTrack),BP(e.remoteVideoTrack),BP(e.remoteAuxiliaryTrack)}));case 12:case"end":return e.stop()}}),e,this)})))}},{key:"_stopScreenShare",value:function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._localScreenTrack){e.next=7;break}if(!this._room.isJoined){e.next=6;break}return r=[this._localScreenTrack],this._localScreenAudioTrack&&r.push(this._localScreenAudioTrack),e.next=6,null==(t=this._room)?void 0:(n=t).unpublish.apply(n,r).catch((function(){}));case 6:this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),BP(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null;case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_onLocalTrackCaptured",value:function(e){"audio"===e.track.kind&&(!nq||FM(nq))&&(this._initActiveSpeaker(),rO.off("102",this._onLocalTrackCaptured,this))}},{key:"_initActiveSpeaker",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!nq||FM(nq)){e.next=4;break}this.emit(YF.DEVICE_CHANGED,{type:"speaker",action:"active",device:nq}),e.next=8;break;case 4:return e.next=6,GM();case 6:(t=e.sent)[0]&&!FM(t[0])?(nq=t[0],this.emit(YF.DEVICE_CHANGED,{type:"speaker",action:"active",device:t[0]})):rO.on("102",this._onLocalTrackCaptured,this);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"_onAudioAvailable",value:function(e){var t=e.userId,n=this._remoteAudioMuteMap.has(t)?this._remoteAudioMuteMap.get(t):this._remoteAudioMuteMap.get("*");(!1===n||this._room.autoReceiveAudio&&!n)&&this._doStartRemoteAudio({userId:t}).catch((function(){}))}},{key:"_onVideoAvailable",value:function(e){var t=this,n=e.userId,r=e.streamType;if(this._room.autoReceiveVideo){var i=this._room.remotePublishedUserMap.get(n);if(i){var a,o="main"===r?i.remoteVideoTrack:i.remoteAuxiliaryTrack,s=[o];this._room.autoReceiveAudio&&i.remoteAudioTrack.isAvailable&&s.push(i.remoteAudioTrack),(a=this._room).subscribe.apply(a,s).then((function(){t._emitTrackEvent(o)})).catch((function(){}))}}}},{key:"_onAudioUnavailable",value:function(e){var t=e.userId,n=e.muteState;n.hasAudio&&n.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((function(){}))}},{key:"_onVideoUnavailable",value:function(e){var t=e.userId,n=e.streamType;this._stopRemoteVideo({userId:t,streamType:n},!1).catch((function(){}))}},{key:"sendSEIMessage",value:function(e,t){var n,r=this._plugins.get("SEI");r&&(r.update({buffer:e,options:$A(QA({seiPayloadType:243},t),{small:!(null==(n=this._localVideoTrack)||!n.small)})}),IN.addCount({key:5e5,useUV:!0}))}},{key:"sendCustomMessage",value:function(e){var t,n;null==(n=(t=this._room).sendCustomMessage)||n.call(t,e),IN.addCount({key:500001,useUV:!0})}}],[{key:"create",value:function(e){}},{key:"_create",value:function(e,t){var n;TF&&(TF=!1,5!==sO.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(BR,"/en/index.html")),console.info("* Changelog: ".concat(BR,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),sO.info("TRTC Web SDK Version:",RR),qx||sO.debug("Build Time:","2025-04-21 21:08:11"),sO.info("UA:",navigator.userAgent),sO.info("URL: ".concat(location.href).concat("IFRAME"===(null==(n=self.frameElement)?void 0:n.tagName)?" in iframe":"")),Kx().then((function(e){e&&sO.info(Jx)})));var r=new i(e,t||{});return tq.add(r),r}},{key:"setLogLevel",value:function(e,t){sO.setLogLevel(e),bw(t)||(t?sO.enableUploadLog():sO.disableUploadLog())}},{key:"isSupported",value:function(){return UN()}},{key:"getCameraList",value:function(){return jM(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"getMicrophoneList",value:function(){return qM(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"getSpeakerList",value:function(){return GM(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"setCurrentSpeaker",value:function(e){return aR(this,null,f().mark((function t(){var n,r,a=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ID&&(e===kF.SPEAKER||e===kF.HEADSET)){t.next=6;break}return t.next=3,GM();case 3:t.sent.forEach((function(t){t.deviceId===e&&(tq.forEach((function(n){n._setCurrentSpeaker(e),n.emit(YF.DEVICE_CHANGED,{type:"speaker",action:"active",device:t})})),nq=t)})),t.next=13;break;case 6:return t.next=8,i.getMicrophoneList();case 8:if(n=t.sent,r="",n.forEach((function(t){t.label===e&&(r=t.deviceId)})),r){t.next=12;break}return t.abrupt("return");case 12:tq.forEach((function(e){return aR(a,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=e._localAudioTrack,!t.t0){t.next=4;break}return t.next=4,e.updateLocalAudio({option:{microphoneId:r}});case 4:case"end":return t.stop()}}),t)})))}));case 13:case"end":return t.stop()}}),t)})))}},{key:"_addKVStat",value:function(e){var t=e.type,n=e.key,r=e.value,i=e.base,a=e.useUV,o=e.version;switch(o&&(bN.version=o),t){case"count":bN.addCount({key:n,useUV:a});break;case"enum":bN.addEnum({key:n,value:r,useUV:a});break;case"number":bN.addNumber({key:n,value:r,split:i})}}}])}(mR.EventEmitter);rR(iq,"_loggerManager",sO),rR(iq,"EVENT",YF),rR(iq,"ERROR_CODE",SF),rR(iq,"TYPE",kF),rR(iq,"frameWorkType",30),nR([TB({replaceArg:function(e){return{argIndex:0,value:{name:"plugin"in e?e.plugin.Name:e.Name,assetsPath:"assetsPath"in e?null==e?void 0:e.assetsPath:"default"}}}})],iq.prototype,"use",1),nR([_B(UF.TRTC.enterRoom),zF("room",(function(e,t){var n=v(e,1)[0],r=v(t,1)[0];return(n.roomId||n.strRoomId)===(r.roomId||r.strRoomId)&&n.userId===r.userId&&n.sdkAppId===r.sdkAppId})),uL((function(e){return function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)}})),TB()],iq.prototype,"enterRoom",1),nR([TB()],iq.prototype,"exitRoom",1),nR([_B(UF.TRTC.switchRole),JF("room",{merge:function(e,t){return t}}),TB()],iq.prototype,"switchRole",1),nR([TB()],iq.prototype,"destroy",1),nR([_B(UF.TRTC.startLocalAudio),zF("audio",(function(e,t){var n,r,i=v(e,1)[0],a=v(t,1)[0];return(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)===(null==(r=null==a?void 0:a.option)?void 0:r.microphoneId)})),TB()],iq.prototype,"startLocalAudio",1),nR([_B(UF.TRTC.updateLocalAudio),JF("audio",{debounce:{delay:200,getKey:function(){return"".concat(eq,"-localAudio")},isNeedToDebounce:function(e){var t;return!bw(null==(t=e.option)?void 0:t.captureVolume)}}}),TB()],iq.prototype,"updateLocalAudio",1),nR([KF("audio"),TB()],iq.prototype,"stopLocalAudio",1),nR([_B(UF.TRTC.startLocalVideo),zF("video",(function(e,t){var n,r,i=v(e,1)[0],a=v(t,1)[0];return(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)===(null==(r=null==a?void 0:a.option)?void 0:r.cameraId)})),TB()],iq.prototype,"startLocalVideo",1),nR([_B(UF.TRTC.updateLocalVideo),JF("video"),TB()],iq.prototype,"updateLocalVideo",1),nR([KF("video"),TB()],iq.prototype,"stopLocalVideo",1),nR([_B(UF.TRTC.startScreenShare),zF("screen",(function(){return!0})),TB()],iq.prototype,"startScreenShare",1),nR([_B(UF.TRTC.updateScreenShare),JF("screen"),TB()],iq.prototype,"updateScreenShare",1),nR([TB()],iq.prototype,"stopScreenShare",1),nR([_B(UF.TRTC.startRemoteVideo),zF((function(e){return"v".concat(e.userId).concat(e.streamType)}),(function(){return!0})),TB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],iq.prototype,"startRemoteVideo",1),nR([_B(UF.TRTC.updateRemoteVideo),JF((function(e){return"v".concat(e.userId).concat(e.streamType)})),TB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],iq.prototype,"updateRemoteVideo",1),nR([_B(UF.TRTC.stopRemoteVideo),uL((function(e){return function(t){return aR(this,null,f().mark((function n(){var r,i=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("*"!==t.userId){n.next=3;break}return r=[],n.abrupt("return",(this._room.remotePublishedUserMap.forEach((function(e){i._remoteVideoConfigMap.has("".concat(e.userId,"_main"))&&r.push(i.stopRemoteVideo({streamType:"main",userId:e.userId}).catch((function(){}))),i._remoteVideoConfigMap.has("".concat(e.userId,"_sub"))&&r.push(i.stopRemoteVideo({streamType:"sub",userId:e.userId}).catch((function(){})))})),Promise.all(r)));case 3:return n.abrupt("return",e.call(this,t));case 4:case"end":return n.stop()}}),n,this)})))}})),TB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],iq.prototype,"stopRemoteVideo",1),nR([KF((function(e){return"v".concat(e.userId).concat(e.streamType)}))],iq.prototype,"_stopRemoteVideo",1),nR([_B.apply(void 0,E(UF.TRTC.muteRemoteAudio)),TB({getRemoteId:function(e){return e}})],iq.prototype,"muteRemoteAudio",1),nR([gB.apply(void 0,E(UF.TRTC.setRemoteAudioVolume)),function(e,t){return uL((function(e,n){return function(){for(var n=this,r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];var o=vB.get(this);o||(o=new Map,vB.set(this,o));var s=t.apply(void 0,i),c=o.get(s);if(!c||c<=0){e.apply(this,i);var u=setTimeout((function(){var e;null==(e=vB.get(n))||e.delete(s)}),200);o.set(s,u)}else{clearTimeout(c);var l=window.setTimeout((function(){var t;e.apply(n,i),null==(t=vB.get(n))||t.delete(s)}),200);o.set(s,l)}}}))}(0,(function(e){return e})),TB({getRemoteId:function(e){return e}})],iq.prototype,"setRemoteAudioVolume",1),nR([kB("start"),sL((function(e){var t;return null==(t=e.afterStart)?void 0:t.call(e)})),zF((function(e,t){return e.disableRandomCall?null:e.getAlias()+e.getGroup(t)})),TB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return EN[e.getName()]},ignoreLog:function(e){return"Debug"===e.getName()}})],iq.prototype,"startPlugin",1),nR([kB("update"),JF((function(e,t){return e.disableRandomCall?null:e.getAlias()+e.getGroup(t)})),TB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return TN[e.getName()]}})],iq.prototype,"updatePlugin",1),nR([kB("stop"),KF((function(e,t){if(e.disableRandomCall)return null;var n=e.getGroup(t),r=e.getAlias();return"*"===n?new RegExp("".concat(r,".*")):r+n})),TB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return kN[e.getName()]}})],iq.prototype,"stopPlugin",1),nR([gB.apply(void 0,E(UF.TRTC.enableAudioVolumeEvaluation))],iq.prototype,"enableAudioVolumeEvaluation",1),nR([TB()],iq.prototype,"getVideoSnapshot",1),nR([TB()],iq.prototype,"_setCurrentSpeaker",1),nR([zF((function(e){return"a".concat(e.userId)}),(function(){return!0}))],iq.prototype,"_startRemoteAudio",1),nR([uL((function(e){return function(t){return aR(this,null,f().mark((function n(){var r=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return","*"===t.userId?Promise.all(E(this._room.remotePublishedUserMap.values()).map((function(e){return r._stopRemoteAudio($A(QA({},t),{userId:e.userId})).catch((function(){}))}))):e.call(this,t));case 1:case"end":return n.stop()}}),n,this)})))}})),KF((function(e){return"a".concat(e.userId)}))],iq.prototype,"_stopRemoteAudio",1),nR([KF("room")],iq.prototype,"_exitRoom",1),nR([KF("screen")],iq.prototype,"_stopScreenShare",1),nR([_B.apply(void 0,E(UF.TRTC.sendSEIMessage)),yF({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].byteLength}})],iq.prototype,"sendSEIMessage",1),nR([_B(UF.TRTC.sendCustomMessage),yF({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(e){return e.data.byteLength}})],iq.prototype,"sendCustomMessage",1),nR([_B(UF.TRTC.create)],iq,"_create",1);var aq=iq,oq=function(){return o((function e(){r(this,e),rR(this,"_set",new Set),rO.on(aO.LEAVE_SUCCESS,this.delete,this)}),[{key:"add",value:function(e){var t=e.room,n=e.roomId;if("rtc"!==t.scene){var r=this.getKey(t.userId,n||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(r)}}},{key:"delete",value:function(e){var t=e.room,n=e.roomId;if("rtc"!==t.scene){var r=this.getKey(t.userId,t.roomId||n,t.sdkAppId,t.useStringRoomId);this._set.delete(r)}}},{key:"getKey",value:function(e,t,n,r){return"".concat(n,"_").concat(t,"_").concat(e,"_").concat(r)}},{key:"isJoined",value:function(e){var t=e.userId,n=e.roomId,r=e.sdkAppId,i=e.room;return"rtc"!==i.scene&&this._set.has(this.getKey(t,n,r,i.useStringRoomId))}}])}();function sq(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u,l,d,h,p,m;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,qM();case 3:r=e.sent,t=r&&r.length,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(0);case 9:return e.prev=9,e.next=12,jM();case 12:i=e.sent,n=i&&i.length,e.next=18;break;case 16:e.prev=16,e.t1=e.catch(9);case 18:a={microphone:t,camera:n},o=this.checkSystemResult.detail,s=o.isH264EncodeSupported,c=o.isVp8EncodeSupported,u=o.isH264DecodeSupported,l=o.isVp8DecodeSupported,d=lO.basis(),h={webRTC:d.isWebRTCSupported,getUserMedia:d.isGetUserMediaSupported,webSocket:d.isWebSocketsSupported,screenShare:d.isScreenShareSupported,webAudio:d.isWebAudioSupported,h264Encode:s,h264Decode:u,vp8Encode:c,vp8Decode:l},p={browser:d.browser,os:d.os,trtc:h,devices:a},m={isWebCodecSupported:d.isWebCodecSupported,isMediaSessionSupported:d.isMediaSessionSupported,isWebTransportSupported:d.isWebTransportSupported},qP.uploadEvent({log:"trtcstats-".concat(JSON.stringify(p)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(p))),qP.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(m)),userId:this.userId});case 20:case"end":return e.stop()}}),e,this,[[0,7],[9,16]])})))}var cq=tR(oR()),uq="3",lq="5",dq={CLIENT_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,PUBLISH_STATE_CHANGE_RESULT:4112,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,START_PUBLISH_CDN_STREAM_RES:8196,UPDATE_PUBLISH_CDN_STREAM_RES:8198,STOP_PUBLISH_CDN_STREAM_RES:8200,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,REBUILD_PEER_CONNECTION_RES:4150,SPC_PUBLISH_RESULT:4146,SPC_SUBSCRIBE_RESULT:4156,ABILITY_STATUS_REPORT_RESULT:4158,SERVER_FIRST_PACKAGE_RECEIVED:5e3,RECEIVE_CUSTOM_MSG:4140},hq=[dq.UPDATE_REMOTE_MUTE_STAT,dq.UPLINK_NETWORK_STATS,dq.USER_LIST_RES,dq.MUTE_RESULT,dq.SERVER_FIRST_PACKAGE_RECEIVED,dq.RECEIVE_CUSTOM_MSG],fq={CLIENT_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",START_PUBLISH_CDN_STREAM_RES:"start-publish-cdn-stream-res",UPDATE_PUBLISH_CDN_STREAM_RES:"update-publish-cdn-stream-res",STOP_PUBLISH_CDN_STREAM_RES:"stop-publish-cdn-stream-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",REBUILD_PEER_CONNECTION_RES:"rebuild-pc-res",SPC_PUBLISH_RESULT:"spc-publish-result",SPC_SUBSCRIBE_RESULT:"spc-subscribe-result",ABILITY_STATUS_REPORT_RESULT:"ability-status-report",SERVER_FIRST_PACKAGE_RECEIVED:"first-pkg-received",RECEIVE_CUSTOM_MSG:"receive-custom-msg"},pq="mute_uplink",mq="publish_state_change",vq="unpublish",_q="unsubscribe",gq="subscribe_change",yq="update_constraint_config",Eq=new Set,Tq=function(e){function i(e){var a,o,s,c;r(this,i),a=n(this,i),rR(t(a),"room"),rR(t(a),"sdkAppId"),rR(t(a),"userId"),rR(t(a),"userSig"),rR(t(a),"url"),rR(t(a),"backupUrl"),rR(t(a),"race"),rR(t(a),"destroyed",!1),rR(t(a),"_socketInUse"),rR(t(a),"_socket"),rR(t(a),"_backupSocket"),rR(t(a),"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0,bakRelayIps:[]}),rR(t(a),"_currentState","DISCONNECTED"),rR(t(a),"_isReconnecting",!1),rR(t(a),"_seq",0),rR(t(a),"_log"),rR(t(a),"_lastMessageTime",-1),rR(t(a),"_connectStartTime",-1),rR(t(a),"_stopConnectRetry"),rR(t(a),"bytesSent",0),rR(t(a),"bytesReceived",0),rR(t(a),"keepAlive",!1),rR(t(a),"signalDomainWhenUnifiedProxy"),rR(t(a),"stopKeepAliveTimeout"),rR(t(a),"rtt",0),a.room=e.room,a.sdkAppId=e.sdkAppId,a.userId=e.userId,a.userSig=e.userSig,a.race=!!bw(e.race)||e.race,a.signalDomainWhenUnifiedProxy=e.signalDomainWhenUnifiedProxy;var u=(null==(s=null==(o=a.room.scheduleResult)?void 0:o.config)?void 0:s.keepAliveClient)||0;return null!=(c=a.room.joinParams)&&c.keepAlive&&!u&&(u=1),u-Eq.size>0&&a.room.enableSPC&&(a.keepAlive=!0,Eq.add(a)),a.url=e.url,a.backupUrl=e.backupUrl,a._seq=0,a._log=sO.createLogger({id:"ws",userId:a.userId,sdkAppId:a.sdkAppId}),a.onmessage=a.onmessage.bind(a),a.onerror=a.onerror.bind(a),a.onclose=a.onclose.bind(a),a}return d(i,e),o(i,[{key:"urlParam",get:function(){var e="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId),"&userId=").concat(encodeURIComponent(this.userId),"&userSig=").concat(encodeURIComponent(this.userSig),"&keepAlive=").concat(encodeURIComponent(Number(this.keepAlive)));this.signalDomainWhenUnifiedProxy&&(e+="&signalDomain=".concat(encodeURIComponent(this.signalDomainWhenUnifiedProxy)));var t=new URLSearchParams(location.search).get("clientIp");return t&&(e+="&clientIp=".concat(t)),this.race?"".concat(e,"&race=1"):e}},{key:"_urlWithParam",get:function(){return"".concat(this.url).concat(this.race?"/v2/ws":"").concat(this.urlParam)}},{key:"_backupUrlWithParam",get:function(){return"".concat(this.backupUrl).concat(this.race?"/v2/ws":"").concat(this.urlParam)}},{key:"isConnected",get:function(){return"CONNECTED"===this._currentState}},{key:"isConnecting",get:function(){return"CONNECTING"===this._currentState}},{key:"isOnline",get:function(){return"CONNECTED"===this._currentState&&Date.now()-this._lastMessageTime<12e3}},{key:"connect",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;return f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e.isConnected){n.next=2;break}return n.abrupt("return",Promise.resolve());case 2:return e._log.info("connect to [".concat(e.url,", ").concat(e.backupUrl,"]").concat(t?" timeout: ".concat(t):""," keepAlive: ").concat(Number(e.keepAlive))),e.emitConnectionStateChanged("CONNECTING"),e._connectStartTime=Uw(),r=[e.connectWS({url:e._urlWithParam,isMain:!0,timeout:t})],e.race&&e._backupUrlWithParam!==e._urlWithParam&&r.push(e.connectWS({url:e._backupUrlWithParam,isMain:!1,timeout:t})),n.next=7,Lw(r);case 7:e._socketInUse=n.sent,e.unbindAndCloseSocket(e._socketInUse===e._socket?nC.BACKUP:nC.MAIN),e.emitConnectionStateChanged("CONNECTED");case 10:case"end":return n.stop()}}),n)}))()}))}},{key:"connectWS",value:function(e){var t=this,n=e.url,r=e.timeout,i=e.isMain,a=new WebSocket(n);this.bindSocket(a),i?this._socket=a:this._backupSocket=a;var o=-1;return new Promise((function(e,n){a.onclose=n,a.onerror=n,a.onopen=function(){return e(a)},r&&(o=setTimeout((function(){t.unbindAndCloseSocket(i?nC.MAIN:nC.BACKUP),n(new yR({code:_R.SIGNAL_CHANNEL_SETUP_FAILED,message:"ws connect timeout"}))}),r))})).finally((function(){a.onclose=null,a.onerror=null,a.onopen=null,clearTimeout(o)}))}},{key:"bindSocket",value:function(e){e.addEventListener("close",this.onclose),e.addEventListener("error",this.onerror),e.addEventListener("message",this.onmessage)}},{key:"unbindSocket",value:function(e){e.removeEventListener("close",this.onclose),e.removeEventListener("error",this.onerror),e.removeEventListener("message",this.onmessage)}},{key:"unbindAndCloseSocket",value:function(e){if(e===nC.MAIN){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(DC){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(DC){}this._backupSocket=null}}},{key:"onclose",value:function(e){e.target===this._socketInUse&&(this._log.warn("".concat(e.target===this._socket?"main":"backup"," is closed code:").concat(e.code," ").concat(e.reason)),this.emitConnectionStateChanged("DISCONNECTED"),(!e.wasClean||1e3!==e.code)&&this.startReconnection(),this.room.isJoining&&this.emit(lq,new yR({code:_R.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onclose"})))}},{key:"onerror",value:function(e){this._log.error("".concat(e.target===this._socket?"main":"backup"," error observed")),this.emitConnectionStateChanged("DISCONNECTED"),e.target===this._socketInUse&&(this.unbindAndCloseSocket(nC.MAIN),this.unbindAndCloseSocket(nC.BACKUP),this._socketInUse=null,this.reconnect()),this.room.isJoining&&this.emit(lq,new yR({code:_R.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onerror"}))}},{key:"onmessage",value:function(e){if(this.isConnected){this._lastMessageTime=Date.now(),this.bytesReceived+=$w(e.data);var t=JSON.parse(e.data),n=t.cmd,r=t.data,i=Object.values(dq),a=Object.keys(dq)[i.indexOf(n)],o=fq[a]||n;switch(hq.includes(n)||(this._log.debug("received ".concat(n," msg: ").concat(e.data)),o&&this._log.info("Received event: [ ".concat(o," ]"))),n){case dq.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=r.clientIp,this._signalInfo.signalIp=r.signalInnerIp,r.svrTime&&function(e){ER=e-(new Date).getTime();var t=new Date;t.setTime(e),sO.info("baseTime from server: ".concat(t," offset: ").concat(ER))}(r.svrTime),this._log.info("ChannelSetup Success ".concat(Uw()-this._connectStartTime)),IN.addSuccessEvent({key:521701,cost:Uw()-this._connectStartTime}),this._connectStartTime=-1,this.emit("1",{signalInfo:this._signalInfo});else{var s=new yR({code:_R.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:mN({key:dN.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),IN.addFailedEvent({key:521701,error:s}),this.emit(lq,s)}break;case dq.JOIN_ROOM_RESULT:0===t.code&&(this._signalInfo.relayIp=r.relayOuterIp,this._signalInfo.relayInnerIp=r.relayInnerIp,this._signalInfo.bakRelayIps=r.bakRelayIps,this._signalInfo.relayPort=r.relayPort,this._signalInfo.tinyId=t.tinyId,this._signalInfo.endReportExtend=r.endReportExtend,this._log.info("signalIp:".concat(this._signalInfo.signalIp," clientIp:").concat(this._signalInfo.clientIp," relayIp: ").concat(this._signalInfo.relayIp))),this.emit(o,{data:t});break;default:this.emit(String(o),{data:t})}}}},{key:"reGetSignalChannelUrl",value:function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.room.joinParams){e.next=3;break}return e.abrupt("return");case 3:return rB(!0),e.next=6,this.room.schedule(this.room.joinParams);case 6:t=this.room.getSignalChannelUrl(),n=t.mainUrl,r=t.backupUrl,this.url=n,this.backupUrl=r,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(0);case 12:case"end":return e.stop()}}),e,this,[[0,10]])})))}},{key:"startReconnection",value:function(){if(this._socketInUse){this._socketInUse.onclose=null,this._socketInUse.close(4011);var e=this._socketInUse===this._socket;this.unbindAndCloseSocket(e?nC.MAIN:nC.BACKUP),this._socketInUse=null,this.emitConnectionStateChanged("DISCONNECTED"),this.reconnect()}}},{key:"reconnect",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isReconnecting){e.next=25;break}if(this.room.isJoined||!this.keepAlive){e.next=3;break}return e.abrupt("return",void this.close());case 3:return this._isReconnecting=!0,e.prev=4,this._log.warn("reconnect"),e.next=8,this.connect();case 8:return t=this.room,n=t.roomId,r=t.useStringRoomId,i=this._signalInfo,a=i.relayIp,o=i.relayInnerIp,s=i.relayPort,e.next=17,this.sendWaitForResponse({command:"reconnect",data:{roomId:n,useStringRoomId:r,relayInnerIp:o,relayOuterIp:a,relayPort:s},responseCommand:fq.CHANNEL_RECONNECT_RESULT});case 17:c=e.sent,0===(u=c.data).code?(this._log.warn("reconnect success"),this.stopReconnection(),IN.addSuccessEvent({key:521702,cost:Uw()-this._connectStartTime}),this._connectStartTime=-1,this.room.syncUserList(),this.room.checkConnectionsToReconnect()):(IN.addFailedEvent({key:521702,error:u.code}),this._log.warn("reconnect failed, ".concat(u.code," ").concat(u.message)),this.room.reJoin()),e.next=25;break;case 22:e.prev=22,e.t0=e.catch(4),this._log.error(e.t0),this.room.reJoin();case 25:case"end":return e.stop()}}),e,this,[[4,22]])})))}},{key:"send",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected&&!this.room.isLeft){var n={cmd:e,data:t,userId:this.userId,tinyId:this._signalInfo.tinyId,seq:++this._seq},r=JSON.stringify(n);return this._socketInUse.send(r),this.bytesSent+=$w(r),n.seq}}},{key:"sendWaitForResponse",value:function(e){var t=this,n=e.command,r=e.data,i=e.timeout,a=void 0===i?5e3:i,o=e.responseCommand,s=e.commandDesc,c=e.enableLog,u=void 0===c||c,l=e.addReceiveTime,d=void 0!==l&&l;return new Promise((function(e,i){var c=setTimeout((function(){t.off(o,l);var e=new yR({code:_R.API_CALL_TIMEOUT,message:mN({key:dN.API_CALL_TIMEOUT,data:{commandDesc:s,command:n}})});u&&t._log.warn(e),i(e)}),a),l=function(n){n.data.seq===h&&(clearTimeout(c),t.off(o,l),d&&(n.data.receiveTime=Date.now()),e(n))};t.on(o,l);var h=t.send(n,r)}))}},{key:"sendWaitForResponseWithRetry",value:function(e){var t=this,n=e.commandDesc,r=e.command,i=e.retries,a=void 0===i?0:i,o=e.retryTimeout,s=void 0===o?0:o;return dD({retryFunction:this.sendWaitForResponse,onError:function(e){var n=e.retry;t.isOnline?n():(t._log.warn("retry ".concat(r," when connected")),t.once(uq,n))},onRetrying:function(e){t._log.warn("".concat(n||r," timeout observed, retrying [").concat(e,"/").concat(a,"]"))},settings:{retries:a,timeout:s},context:this})(e)}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"getSignalInfo",value:function(){return this._signalInfo}},{key:"stopReconnection",value:function(){this._isReconnecting=!1,this._stopConnectRetry&&this._stopConnectRetry()}},{key:"close",value:function(){this._log.info("closed"),clearTimeout(this.stopKeepAliveTimeout),Eq.delete(this),this.stopReconnection(),this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,bakRelayIps:[],endReportExtend:void 0},this._socketInUse=null,this.bytesSent=0,this.bytesReceived=0,this._stopConnectRetry&&this._stopConnectRetry(),this.unbindAndCloseSocket(nC.MAIN),this.unbindAndCloseSocket(nC.BACKUP),this.emitConnectionStateChanged("DISCONNECTED")}},{key:"destroy",value:function(){this.close(),this.destroyed=!0}},{key:"getBackupRelayIpPair",value:function(){var e,t=null==(e=this._signalInfo.bakRelayIps)?void 0:e.shift();return t&&(t.relayPort=t.relayPort||this._signalInfo.relayPort),t}},{key:"clearBakRelayIps",value:function(){this._signalInfo.bakRelayIps=[]}},{key:"stopKeepAliveIn",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3600;if(this.keepAlive){this._log.info("stopKeepAlive in ".concat(t,"s")),this.stopKeepAliveTimeout=setTimeout((function(){e.keepAlive=!1,e._log.info("close due to not used ".concat(t,"s")),e.close(),e.off(fq.JOIN_ROOM_RESULT,n)}),1e3*t);var n=function(t){0===t.data.code&&(e._log.info("stopKeepAlive clear timeout"),clearTimeout(e.stopKeepAliveTimeout),e.off(fq.JOIN_ROOM_RESULT,n))};this.on(fq.JOIN_ROOM_RESULT,n)}}},{key:"emitConnectionStateChanged",value:function(e){e!==this._currentState&&(this._log.info("".concat(this._currentState," -> ").concat(e)),this.emit("2",{prevState:this._currentState,state:e}),this._currentState=e,"CONNECTED"===e?this.emit(uq):"DISCONNECTED"===e&&this.emit("6"))}}])}(cq.default);nR([HP({settings:{retries:1/0,timeout:2e3},onError:function(e,t){!this.room.isDestroyed&&!this.destroyed&&t()},onRetrying:function(e,t){this._log.warn("retrying to connect ".concat(e)),e>=3&&e%3==0&&this.reGetSignalChannelUrl(),t&&(this._stopConnectRetry=t,(this.room.isDestroyed||this.destroyed)&&t())}})],Tq.prototype,"connect",1);var kq=tR(oR()),Sq=0,bq=!1,Iq=new Set,Aq=!1,Rq=function(){return o((function e(t){r(this,e),rR(this,"userId"),rR(this,"tinyId"),rR(this,"_sdpSemantics"),rR(this,"_isUplink"),rR(this,"_room"),rR(this,"_log"),rR(this,"_signalChannel"),rR(this,"_isErrorObserved",!1),rR(this,"_waitForPeerConnectionConnectedPromise"),rR(this,"_waitForPeerConnectionConnectedPromiseReject",null),rR(this,"_peerConnection",null),rR(this,"_emitter",new kq.default),rR(this,"_currentState","DISCONNECTED"),rR(this,"_isReconnecting",!1),rR(this,"_reconnectionCount",0),rR(this,"_reconnectionTimer",-1),rR(this,"_isFirstConnection",!0),rR(this,"_prevTime",-1),rR(this,"_localAddress"),rR(this,"_remoteAddress"),this.userId=t.userId,this.tinyId=t.tinyId,this._room=t.room,this._sdpSemantics=t.room.sdpSemantics,this._isUplink=t.isUplink,this._log=sO.createLogger({id:"n-mpc",userId:this._room.userId,remoteUserId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=t.signalChannel}),[{key:"beforeConnect",value:function(){this._prevTime<0&&(this._prevTime=Uw())}},{key:"afterConnect",value:function(){try{this._isFirstConnection?(this._isFirstConnection=!1,IN.addSuccessEvent({key:521705,cost:Math.min(Uw()-this._prevTime,3e4)})):this._isReconnecting&&IN.addSuccessEvent({key:521706,cost:Uw()-this._prevTime}),this._prevTime=-1}catch(mO){throw this._isFirstConnection?(this._isFirstConnection=!1,IN.addFailedEvent({key:521705,error:mO})):this._isReconnecting&&this._reconnectionCount>=3&&IN.addFailedEvent({key:521706,error:mO}),mO}}},{key:"initialize",value:function(){var e={iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this._peerConnection=new RTCPeerConnection(e),this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(e){this._log.info("close connection"),this._emitter.emit("closed",e),this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),Iq.delete(this)}},{key:"closePeerConnection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._peerConnection&&(this._log.info("close pc"),this._peerConnection.onconnectionstatechange=null,this._peerConnection.close(),this._peerConnection=null,e&&this.emitConnectionStateChangedEvent("DISCONNECTED")),this._waitForPeerConnectionConnectedPromiseReject&&this._waitForPeerConnectionConnectedPromiseReject(new yR({code:_R.API_CALL_ABORTED,message:"connection closed"}))}},{key:"getDTLSTransportState",value:function(){if(!this._peerConnection)return IC;var e=null;if(this._isUplink){if(!XN()||0===this._peerConnection.getSenders().length)return IC;e=this._peerConnection.getSenders()[0].transport}else{if(!YN()||0===this._peerConnection.getReceivers().length)return IC;e=this._peerConnection.getReceivers()[0].transport}return e?e.state:IC}},{key:"onConnectionStateChange",value:function(e){var t=this._peerConnection.iceConnectionState,n=this.getDTLSTransportState();if(this._log.info("connectionState: ".concat(e.target.connectionState,", ICE: ").concat(t,", DTLS: ").concat(n)),e.target.connectionState===AC.CONNECTING&&this.emitConnectionStateChangedEvent("CONNECTING"),e.target.connectionState===AC.FAILED||e.target.connectionState===AC.CLOSED){var r="connection ".concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(n),i=new yR({message:r,code:_R.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",i)}(e.target.connectionState===AC.CONNECTED||e.target.connectionState===AC.COMPLETED)&&(this.logSelectedCandidate(),qP.logSuccessEvent({userId:this._room.userId,eventType:OC.ICE_CONNECTION_STATE}),this.emitConnectionStateChangedEvent("CONNECTED"))}},{key:"emitConnectionStateChangedEvent",value:function(e){return e!==this._currentState&&("CONNECTED"===e?(Sq=0,bq=!1,Aq=!0,Iq.add(this)):Iq.delete(this),rO.emit(aO.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this._emitter.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"getRoom",value:function(){return this._room}},{key:"getUserId",value:function(){return this.userId}},{key:"getTinyId",value:function(){return this.tinyId}},{key:"logSelectedCandidate",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this._peerConnection.getStats();case 4:t=e.sent,n=s(t),e.prev=6,n.s();case 8:if((r=n.n()).done){e.next=16;break}if(i=v(r.value,2),a=i[1],!jN(a)){e.next=14;break}return o=t.get(a.localCandidateId),c=t.get(a.remoteCandidateId),o&&(this._log.info("local candidate: ".concat(o.candidateType," ").concat(o.protocol,":").concat(o.ip||o.address,":").concat(o.port," ").concat(o.networkType||""," ").concat("relay"===o.candidateType?"relayProtocol:".concat(o.relayProtocol):"")),this._localAddress="".concat(o.ip||o.address,":").concat(o.port)),c&&(this._log.info("remote candidate: ".concat(c.candidateType," ").concat(c.protocol,":").concat(c.ip||c.address,":").concat(c.port)),this._remoteAddress="".concat(c.protocol,":").concat(c.ip||c.address)),e.abrupt("break",16);case 14:e.next=8;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(6),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[6,18,21,24]])})))}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"waitForPeerConnectionConnected",value:function(){var e=this;return this._waitForPeerConnectionConnectedPromise||(this._waitForPeerConnectionConnectedPromise=new Promise((function(t,n){if("CONNECTED"===e._currentState)return t();e._waitForPeerConnectionConnectedPromiseReject=n;var r=function(e){"CONNECTED"===e.state&&(clearTimeout(o),a(),t())},i=function(t){t.room===e._room&&(clearTimeout(o),a(),n(new yR({code:_R.API_CALL_ABORTED,message:mN({key:dN.CONNECTION_ABORTED,data:"leave room"})})))},a=function(){rO.off(aO.LEAVE_SUCCESS,i,e),e._emitter.off("connection-state-changed",r,e)},o=setTimeout((function(){a();var t,r=new yR({code:_R.API_CALL_TIMEOUT,message:"connection timeout"});Sq+=1,t=e._signalChannel.isConnected,Sq>2&&!bq&&0===Iq.size&&t&&(e._log.warn("firewall restriction"),bq=!0,e._emitter.emit("firewall-restriction")),n(r)}),GC);rO.on(aO.LEAVE_SUCCESS,i,e),e._emitter.on("connection-state-changed",r,e)})),this._waitForPeerConnectionConnectedPromise=this._waitForPeerConnectionConnectedPromise.finally((function(){e._waitForPeerConnectionConnectedPromise=null,e._waitForPeerConnectionConnectedPromiseReject=null}))),this._waitForPeerConnectionConnectedPromise}},{key:"getReconnectionCount",value:function(){return this._reconnectionCount}},{key:"startReconnection",value:function(){this._isReconnecting=!0,this.reconnect()}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"stopReconnection",value:function(){this._log.info("stop reconnection"),this._isReconnecting=!1,this._reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(uq,this.reconnect,this)}},{key:"beforeReconnect",value:function(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=wC()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();var e=new yR({code:this._isUplink?_R.UPLINK_RECONNECTION_FAILED:_R.DOWNLINK_RECONNECTION_FAILED,message:mN({key:this._isUplink?dN.UPLINK_RECONNECTION_FAILED:dN.DOWNLINK_RECONNECTION_FAILED})});return this.emitConnectionStateChangedEvent("DISCONNECTED"),this._emitter.emit("error",e),-1}return this._signalChannel.isConnected?(this._reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this._reconnectionCount,"]")),1):(this._log.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this._signalChannel.once(uq,this.reconnect,this),-1)}},{key:"on",value:function(e,t,n){this._emitter.on(e,t,n)}},{key:"off",value:function(e,t,n){this._emitter.off(e,t,n)}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"isH264",get:function(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},{key:"setOffer",value:function(e){var t;return null==(t=this._peerConnection)?void 0:t.setLocalDescription(e)}},{key:"setAnswer",value:function(e){var t;return null==(t=this._peerConnection)?void 0:t.setRemoteDescription(e)}}])}();nR([gL(521712,!1)],Rq.prototype,"setOffer",1),nR([gL(521713,!1)],Rq.prototype,"setAnswer",1);var Cq=tR(pR()),wq=function(e){return Cq.default.parse(e)},Dq=function(e){return Cq.default.write(e)};function xq(e){return Object.keys(e).filter((function(t){return e[t]}))}var Oq=function(e){function i(e){var a;return r(this,i),a=n(this,i,[$A(QA({},e),{isUplink:!1})]),rR(t(a),"_flag",0),rR(t(a),"isRobot",!1),rR(t(a),"role","anchor"),rR(t(a),"remoteAudioTrack"),rR(t(a),"remoteVideoTrack"),rR(t(a),"remoteAuxiliaryTrack"),rR(t(a),"ssrc",{audio:0,video:0,auxiliary:0}),rR(t(a),"_isSDPExchanging",!1),a.flag=e.flag,a.isRobot=e.isRobot||!1,a.remoteAudioTrack=e.remoteAudioTrack||new XV(a._room,t(a)),a.remoteVideoTrack=e.remoteVideoTrack||new pF(a._room,t(a)),a.remoteAuxiliaryTrack=e.remoteAuxiliaryTrack||new mF(a._room,t(a)),a}return d(i,e),o(i,[{key:"videoCodec",get:function(){var e,t,n=null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)?void 0:t.sdp;return n?n.includes("H264")?"h264":"vp8":"h264"}},{key:"subscribeState",get:function(){var e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}},{key:"muteState",get:function(){return jw(this.flag,this.userId)}},{key:"flag",get:function(){return this._flag},set:function(e){var t,n,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(n=this.remoteVideoTrack)||n.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}},{key:"hasMainStream",get:function(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}},{key:"hasAuxStream",get:function(){return this.muteState.hasAuxiliary}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState.video&&this.muteState.hasVideo}},{key:"isStreamUnpublished",value:function(e){return e===nC.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}},{key:"initialize",value:function(){g(i,"initialize",this,3)([]),this.installEvents(),this._peerConnection.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(e){g(i,"close",this,3)([e]),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents()}},{key:"installEvents",value:function(){}},{key:"uninstallEvents",value:function(){this._emitter.removeAllListeners()}},{key:"emitConnectionStateChangedEvent",value:function(e){var t,n,r=this._currentState,a=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return a&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(n=this.remoteAuxiliaryTrack)||n.emit("connection-state-changed",{prevState:r,state:e})),a}},{key:"onTrack",value:function(e){var t=e.streams[0],n=e.track,r=t.id===pC?nC.MAIN:nC.AUXILIARY;this._log.debug("ontrack ".concat(r," ").concat(n.kind));var i=nC.AUDIO;n.kind===nC.VIDEO&&(i=r===nC.MAIN?nC.VIDEO:nC.AUXILIARY);var a=this.remoteAudioTrack;i===nC.VIDEO?a=this.remoteVideoTrack:i===nC.AUXILIARY&&(a=this.remoteAuxiliaryTrack),a.setInputMediaStreamTrack(n)}},{key:"addRRTRLine",value:function(e){var t=e.split("\r\n"),n=new Map;t.forEach((function(e,r){/^a=rtcp-fb:/.test(e)&&t[r+1]&&!/^a=rtcp-fb:/.test(t[r+1])&&n.set(r+1,"".concat(e.match(/^a=rtcp-fb:\d+/)[0]," rrtr"))}));for(var r=E(n),i=0;i<r.length;i++){var a=v(r[i],2),o=a[0],s=a[1];t.splice(o+i,0,s)}return t.join("\r\n")}},{key:"addSPSDescription",value:function(e){var t=wq(e);return t.media.forEach((function(e){e.type===nC.VIDEO&&e.fmtp.forEach((function(e){e.config+=";sps-pps-idr-in-keyframe=1"}))})),Dq(t)}},{key:"removeSDESDescription",value:function(e){var t=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],n=wq(e);return n.media.forEach((function(e){e.ext&&(e.ext=e.ext.filter((function(e){return!t.includes(e.uri)})))})),Dq(n)}},{key:"isSubscriptionStateNotChanged",value:function(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}},{key:"subscribe",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,n.t0=(null==(r=this._peerConnection)?void 0:r.connectionState)===AC.NEW||(null==(i=this._peerConnection)?void 0:i.connectionState)===AC.CONNECTING,!n.t0){n.next=5;break}return n.next=5,this.waitForPeerConnectionConnected();case 5:if(!this.isSubscriptionStateNotChanged(e)){n.next=13;break}if(n.t1=this._peerConnection,n.t1){n.next=12;break}return this.initialize(),n.next=11,this.connect(e);case 11:n.t1=n.sent;case 12:return n.abrupt("return",void n.t1);case 13:if(this._log.info("subscribe ".concat(t," ").concat(JSON.stringify(e))),!this._peerConnection&&!this._isSDPExchanging){n.next=20;break}return a="subscribe_change",Object.values(e).find((function(e){return!0===e}))||(a="unsubscribe"),n.next=18,this.sendSubscription(a,e);case 18:n.next=23;break;case 20:return this.initialize(),n.next=23,this.connect(e);case 23:n.next=28;break;case 25:throw n.prev=25,n.t2=n.catch(0),this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(n.t2.message," ").concat(JSON.stringify(this.muteState))),new yR({code:_R.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):n.t2;case 28:case"end":return n.stop()}}),n,this,[[0,25]])})))}},{key:"unsubscribe",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.remoteTracks,r=e.streamType;return f().mark((function e(){var i,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("CONNECTED"!==t._currentState||("main"!==r||t.isMainStreamSubscribed)&&("auxiliary"!==r||t.isAuxStreamSubscribed)){e.next=2;break}return e.abrupt("return",void t._log.info("".concat(r," stream already unsubscribed")));case 2:return i=QA({},t.subscribeState),n.forEach((function(e){switch(e.mediaType){case 1:i.audio=!1;break;case 4:i.video=!1;break;case 8:i.smallVideo=!1;break;case 2:i.auxiliary=!1}})),a="subscribe_change",Object.values(i).find((function(e){return!0===e}))||(a="unsubscribe"),t._log.info("".concat("unsubscribe"===a?a:"subscribe"," ").concat(r," [").concat(xq(i),"]")),e.next=9,t.sendSubscription(a,i);case 9:"unsubscribe"===a&&(t.closePeerConnection(),t.emitConnectionStateChangedEvent("DISCONNECTED"));case 10:case"end":return e.stop()}}),e)}))()}))}},{key:"sendSubscription",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,r={srcTinyId:this.tinyId,srcUserId:this.userId},i=_q,a=fq.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(r={audio:n.audio,bigVideo:n.video,auxVideo:n.auxiliary,smallVideo:n.smallVideo,srcTinyId:this.tinyId},i=gq,a=fq.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:i,data:r,responseCommand:a,timeout:1e4}).then((function(n){var r=n.data;if(0!==r.code){var i=new yR({code:r.code,message:mN({key:dN.ERROR_MESSAGE,data:{type:e,message:r.message}})});throw t._log.error(i),i}}))}},{key:"connect",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState;return f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.exchangeSDP(t);case 3:return n.next=5,e.waitForPeerConnectionConnected();case 5:n.next=10;break;case 7:throw n.prev=7,n.t0=n.catch(0),e.closePeerConnection(!0),n.t0;case 10:case"end":return n.stop()}}),n,null,[[0,7]])}))()}))}},{key:"exchangeSDP",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,this._isSDPExchanging=!0,t.next=4,this.createOffer();case 4:return this._log.info("createOffer success, sending offer"),n=this._peerConnection.localDescription,r=n.type,i=n.sdp,a={type:r,sdp:i,srcUserId:this.userId,srcTinyId:this.tinyId,audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo},t.next=11,this._signalChannel.sendWaitForResponse({command:"subscribe",commandDesc:"exchange sdp",data:a,responseCommand:fq.SUBSCRIBE_RESULT,timeout:MC});case 11:if(o=t.sent,this._peerConnection){t.next=15;break}throw s=new yR({code:_R.INVALID_OPERATION,message:mN({key:dN.CONNECTION_CLOSED})}),this._log.warn(s),s;case 15:return t.next=17,this.onSubscribeResult(o);case 17:this._isSDPExchanging=!1,t.next=23;break;case 20:throw t.prev=20,t.t0=t.catch(0),this._isSDPExchanging=!1,t.t0;case 23:case"end":return t.stop()}}),t,this,[[0,20]])})))}},{key:"createOffer",value:function(){return aR(this,null,f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={voiceActivityDetection:!1},$N()&&this._sdpSemantics===LC?(this._peerConnection.addTransceiver(nC.AUDIO,{direction:rC.RECVONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:rC.RECVONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:rC.RECVONLY})):(t.offerToReceiveAudio=!0,t.offerToReceiveVideo=!0),e.next=4,this._peerConnection.createOffer(t);case 4:if(!(n=e.sent).sdp){e.next=11;break}return e.next=8,LN();case 8:e.sent.isH264DecodeSupported||(this._log.warn("remove h264 desc from sdp"),n.sdp=function(e){var t=wq(e);return t.media.forEach((function(e){var t,n;if(e.type===nC.VIDEO){var r=new Set;e.rtp.forEach((function(e){var t=e.payload;return"H264"===e.codec&&r.add(t)})),e.fmtp.forEach((function(e){var t=e.payload,n=e.config.match(/apt=(\d+)/);n&&n[1]&&r.has(Number(n[1]))&&r.add(t)}));var i=function(e){var t=e.payload;return!r.has(t)};e.rtp=e.rtp.filter(i),e.rtcpFb=null==(t=e.rtcpFb)?void 0:t.filter(i),e.fmtp=e.fmtp.filter(i),e.payloads=null==(n=e.payloads)?void 0:n.split(" ").filter((function(e){return!r.has(Number(e))})).join(" ")}})),Dq(t)}(n.sdp)),n.sdp=this.addRRTRLine(n.sdp),n.sdp=this.addSPSDescription(n.sdp),n.sdp=function(e){var t=wq(e);return t.media.forEach((function(e){e.type===nC.AUDIO&&e.fmtp.forEach((function(e){e.config+=";sprop-stereo=1;stereo=1"}))})),Dq(t)}(n.sdp),this._sdpSemantics===LC&&(n.sdp=this.removeSDESDescription(n.sdp));case 11:return e.next=13,this.setOffer(n);case 13:case"end":return e.stop()}}),e,this)})))}},{key:"onSubscribeResult",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e&&e.data||{},r=n.code,i=n.message,a=void 0===i?"":i,o=e&&e.data&&e.data.data||{},s=o.type,c=o.sdp,r!==VC){t.next=3;break}throw new yR({code:_R.NOT_SUPPORTED_H264,message:mN({key:dN.NOT_SUPPORTED_H264DECODE})});case 3:if(t.prev=3,0===r){t.next=6;break}throw new yR({code:r,message:mN({key:dN.EXCHANGE_SDP_FAILED,data:{errMsg:a}})});case 6:return this._log.debug("accept remote answer: ".concat(c)),t.next=9,this.setAnswer({type:s,sdp:c});case 9:this.updateSSRC(c),t.next=15;break;case 12:throw t.prev=12,t.t0=t.catch(3),this._log.error(t.t0),t.t0;case 15:case"end":return t.stop()}}),t,this,[[3,12]])})))}},{key:"updateSSRC",value:function(e){var t=this;try{wq(e).media.forEach((function(e){if(e.ssrcs)if(e.type===nC.AUDIO){var n=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(pC)}));n&&(t.ssrc.audio=Number(n.id))}else{var r=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(pC)})),i=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(mC)}));r&&(t.ssrc.video=Number(r.id)),i&&(t.ssrc.auxiliary=Number(i.id))}}))}catch(DC){}}},{key:"getMainStreamVideoTrackId",value:function(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}},{key:"getAuxStreamVideoTrackId",value:function(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}},{key:"reconnect",value:function(){return aR(this,null,f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(iR(i.prototype,this,"beforeReconnect").call(this)<0){e.next=14;break}return e.prev=1,this.closePeerConnection(),this.initialize(),e.next=6,this.connect();case 6:this.stopReconnection(),this._log.warn("reconnect() success"),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),t=Tw(this._reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((function(){n.clearReconnectionTimer(),n.reconnect()}),t);case 14:case"end":return e.stop()}}),e,this,[[1,10]])})))}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"setDelay",value:function(e){var t=e.audioDelay,n=e.videoDelay;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=n}},{key:"audioReceiver",get:function(){var e;return(null==(e=this._peerConnection)?void 0:e.getReceivers()[0])||null}}])}(Rq);nR([uL((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var a=function(e){t._emitter.off("closed",a),i(new yR({code:_R.API_CALL_ABORTED,message:mN({key:dN.CONNECTION_ABORTED,data:e})}))};t._emitter.on("closed",a),e.apply(t,r).then(n,i).finally((function(){t._emitter.off("closed",a)}))}))}}))],Oq.prototype,"subscribe",1),nR([gL(521717,!1)],Oq.prototype,"unsubscribe",1),nR([sL(Rq.prototype.afterConnect),oL(Rq.prototype.beforeConnect)],Oq.prototype,"connect",1);var Nq=Oq,Pq={voiceActivityDetection:!1},Mq=function(e){function i(e){var a;return r(this,i),a=n(this,i,[$A(QA({},e),{isUplink:!0})]),rR(t(a),"localMainAudioTrack",null),rR(t(a),"localMainVideoTrack",null),rR(t(a),"localAuxAudioTrack",null),rR(t(a),"localAuxVideoTrack",null),rR(t(a),"ssrc",{audio:0,video:0,small:0,auxiliary:0}),rR(t(a),"_isPublishingAux",!1),rR(t(a),"_publishingLocalAudioTrack"),rR(t(a),"_publishingLocalVideoTrack"),rR(t(a),"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),rR(t(a),"flag",0),a}return d(i,e),o(i,[{key:"videoCodec",get:function(){return this._mediaSettings.videoCodec.toLowerCase()||"h264"}},{key:"isMainStreamPublished",get:function(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}},{key:"isAuxStreamPublished",get:function(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}},{key:"publishState",get:function(){var e,t,n,r,i=this,a={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){var o=this._peerConnection.getSenders();o&&(QN()?(a.audio=!(null==(e=o[0])||!e.track),a.bigVideo=!(null==(t=o[1])||!t.track),a.smallVideo=!(null==(n=o[2])||!n.track),a.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((function(e){e.track&&(e.track.kind===nC.AUDIO?a.audio=!0:(a.bigVideo=!0,i._room.videoManager.hasSmall&&(a.smallVideo=!0)))})))}return a}},{key:"initialize",value:function(){g(i,"initialize",this,3)([]),this.installEvents()}},{key:"reset",value:function(){this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents()}},{key:"close",value:function(e){g(i,"close",this,3)([e]),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}},{key:"installEvents",value:function(){this._emitter.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this._emitter.on("connection-state-changed",this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this._emitter.off("connection-state-changed",this.handleConnectionStateChange,this)}},{key:"emitConnectionStateChangedEvent",value:function(e,t){var n,r,a,o=this._currentState,s=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(n=this.localMainVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(a=this._publishingLocalVideoTrack)||a.emit("connection-state-changed",{prevState:o,state:e}))),s}},{key:"publish",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.isAuxiliary;return f().mark((function e(){var a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._peerConnection||t.initialize(),n&&(t._publishingLocalAudioTrack=n),r&&(t._publishingLocalVideoTrack=r),t._isPublishingAux=i,r&&!i&&r.small&&(a=t._room.videoManager.smallTrack),t.sendMediaSettings(),!$N()){e.next=11;break}return e.next=9,t.publishByTransceiver({localAudioTrack:n,localVideoTrack:r,smallTrack:a,isAuxiliary:i});case 9:e.next=13;break;case 11:return e.next=13,t.publishByAddTrack({localAudioTrack:n,localVideoTrack:r,smallTrack:a});case 13:t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,i?(r&&(t.localAuxVideoTrack=r),n&&(t.localAuxAudioTrack=n)):(r&&(t.localMainVideoTrack=r),n&&(t.localMainAudioTrack=n)),t.installTrackMuteEvents(n,r),t.sendMutedFlag();case 19:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByTransceiver",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack,a=e.isAuxiliary;return f().mark((function e(){var o,s,c,u,l,d;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._log.info("publish by transceiver"),o=new MediaStream,s=null==r?void 0:r.outMediaTrack,(c=null==n?void 0:n.outMediaTrack)&&o.addTrack(c),s&&o.addTrack(s),0!==(u=t._peerConnection.getTransceivers()).length){e.next=13;break}return t._peerConnection.addTransceiver(c||nC.AUDIO,{direction:rC.SENDONLY,streams:[o]}),t._peerConnection.addTransceiver(a?nC.VIDEO:s||nC.VIDEO,{direction:rC.SENDONLY,streams:[o]}),t._peerConnection.addTransceiver(i||nC.VIDEO,{direction:rC.SENDONLY,streams:[o]}),t._peerConnection.addTransceiver(a&&s||nC.VIDEO,{direction:rC.SENDONLY,streams:[o]}),e.next=11,t.connect();case 11:e.next=41;break;case 13:if(l=[],e.t0=c,!e.t0){e.next=21;break}return u[0].sender.track||l.push(0),e.next=19,u[0].sender.replaceTrack(c);case 19:return e.next=21,t.setBandwidth({bandwidth:(null==n?void 0:n.profile.bitrate)||40,type:nC.AUDIO});case 21:if(!s){e.next=35;break}return d=a?3:1,e.next=25,u[d].sender.replaceTrack(s);case 25:return e.next=27,t.setBandwidth({bandwidth:r.profile.bitrate,type:nC.VIDEO,videoType:a?nC.AUXILIARY:nC.BIG});case 27:if(l.push(d),e.t1=i,!e.t1){e.next=35;break}return e.next=32,u[2].sender.replaceTrack(i);case 32:return e.next=34,t.setBandwidth({bandwidth:r.small.bitrate,type:nC.VIDEO,videoType:nC.SMALL});case 34:l.push(2);case 35:return e.next=37,t.setTransceiverDirection(rC.SENDONLY,l);case 37:return e.next=39,t.doPublishChange();case 39:null==r||r.emit("connection-state-changed",{prevState:"DISCONNECTED",state:"CONNECTING"}),null==r||r.emit("connection-state-changed",{prevState:"CONNECTING",state:"CONNECTED"});case 41:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByAddTrack",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack;return f().mark((function e(){var a,o,s,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._log.info("publish by addtrack"),a=null==r?void 0:r.outMediaTrack,o=null==n?void 0:n.outMediaTrack,!t._peerConnection||"new"===t._peerConnection.connectionState){e.next=13;break}if(e.t0=n&&o,!e.t0){e.next=7;break}return e.next=7,t.addTrack(n);case 7:if(e.t1=a,!e.t1){e.next=12;break}return e.next=11,t.addTrack(r);case 11:e.t1=e.sent;case 12:return e.abrupt("return",void e.t1);case 13:return s=new MediaStream,o&&s.addTrack(o),a&&s.addTrack(a),o&&t._peerConnection.addTrack(o,s),a&&(t._peerConnection.addTrack(a,s),i)&&((c=new MediaStream).addTrack(i),t._peerConnection.addTrack(i,c)),e.next=17,t.connect();case 17:case"end":return e.stop()}}),e)}))()}))}},{key:"enableSmall",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._peerConnection.getTransceivers(),!e){t.next=10;break}if(t.t0=this._room.videoManager.smallTrack,!t.t0){t.next=8;break}return t.next=6,n[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 6:return t.next=8,this.setTransceiverDirection(rC.SENDONLY,[2]);case 8:t.next=14;break;case 10:return t.next=12,n[2].sender.replaceTrack(null);case 12:return t.next=14,this.setTransceiverDirection(rC.INACTIVE,[2]);case 14:return this.updateMediaSettings(),t.next=17,this.doPublishChange();case 17:case"end":return t.stop()}}),t,this)})))}},{key:"installTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.on("mute",e.sendMutedFlag,e),null==t||t.on("unmute",e.sendMutedFlag,e))}))}},{key:"uninstallTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.off("mute",e.sendMutedFlag,e),null==t||t.off("unmute",e.sendMutedFlag,e))}))}},{key:"unpublish",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack;return f().mark((function e(){var i,a,o,s;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(QN()){e.next=19;break}if(!n||!n.outMediaTrack||r||!t.localMainVideoTrack){e.next=7;break}return e.next=4,t.removeTrack(n);case 4:e.t0=void(t.localMainAudioTrack=null),e.next=18;break;case 7:if(!r||!r.outMediaTrack||n||!t.localMainAudioTrack){e.next=13;break}return e.next=10,t.removeTrack(r);case 10:e.t1=void(t.localMainVideoTrack=null),e.next=17;break;case 13:return e.next=15,t.doUnpublish();case 15:t.uninstallTrackMuteEvents(n,r),e.t1=void t.emitConnectionStateChangedEvent("DISCONNECTED",r);case 17:e.t0=e.t1;case 18:return e.abrupt("return",e.t0);case 19:if(i=r&&r===t.localAuxVideoTrack,a=null==r?void 0:r.outMediaTrack,o=t._peerConnection.getSenders(),s=[],e.t2=n,!e.t2){e.next=28;break}if(i?t.localAuxAudioTrack=null:t.localMainAudioTrack=null,e.t3=!t.localAuxAudioTrack&&!t.localMainAudioTrack,!e.t3){e.next=28;break}return e.next=27,o[0].replaceTrack(null);case 27:s.push(0);case 28:if(e.t4=a,!e.t4){e.next=45;break}if(!i){e.next=38;break}return e.next=33,o[3].replaceTrack(null);case 33:t.localAuxVideoTrack=null,t._mediaSettings=$A(QA({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3),e.next=45;break;case 38:return e.next=40,o[1].replaceTrack(null);case 40:return e.next=42,o[2].replaceTrack(null);case 42:t.localMainVideoTrack=null,t._mediaSettings=$A(QA({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2);case 45:if(!t.isMainStreamPublished&&!t.isAuxStreamPublished){e.next=52;break}return e.next=48,t.setTransceiverDirection(rC.INACTIVE,s);case 48:return e.next=50,t.doPublishChange(!1);case 50:e.next=54;break;case 52:return e.next=54,t.doUnpublish();case 54:t.uninstallTrackMuteEvents(n,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"});case 56:case"end":return e.stop()}}),e)}))()}))}},{key:"doPublishChange",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={state:this.publishState,constraintConfig:this._mediaSettings},t.next=3,this._signalChannel.sendWaitForResponse({command:mq,data:n,responseCommand:fq.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});case 3:r=t.sent,this.checkPublishResultCode(r.data.code,r.data.message);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doUnpublish",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:vq,commandDesc:"unpublish",responseCommand:fq.UNPUBLISH_RESULT,enableLog:e}).catch((function(e){if(e.getCode()===_R.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}},{key:"updateMediaSettings",value:function(){var e=this._room.checkSystemResult.detail,t=e.isH264EncodeSupported,n=e.isVp8EncodeSupported;t?this._mediaSettings.videoCodec="H264":n&&(this._mediaSettings.videoCodec="VP8");var r=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,i=this.localMainVideoTrack,a=this.localAuxVideoTrack;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?a=this._publishingLocalVideoTrack:i=this._publishingLocalVideoTrack),aP){if(r&&r.outMediaTrack){var o=r.outMediaTrack.getSettings();this._mediaSettings.audioChannel=o.channelCount||1,this._mediaSettings.audioBps=1e3*r.profile.bitrate,this._mediaSettings.audioFs=o.sampleRate||0}if(i&&i.outMediaTrack){var s=i.outMediaTrack.getSettings();this._mediaSettings.videoWidth=s.width||0,this._mediaSettings.videoHeight=s.height||0,this._mediaSettings.videoFps=s.frameRate||0,this._mediaSettings.videoBps=1e3*i.profile.bitrate,i.small&&(this._mediaSettings.smallVideoWidth=i.small.width,this._mediaSettings.smallVideoHeight=i.small.height,this._mediaSettings.smallVideoFps=i.small.frameRate,this._mediaSettings.smallVideoBps=1e3*i.small.bitrate)}if(a&&a.outMediaTrack){var c=a.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=c.width||0,this._mediaSettings.auxVideoHeight=c.height||0,this._mediaSettings.auxVideoFps=c.frameRate||0,this._mediaSettings.auxVideoBps=1e3*a.profile.bitrate}}else r&&r.outMediaTrack&&(this._mediaSettings.audioChannel=r.profile.channelCount,this._mediaSettings.audioBps=1e3*r.profile.bitrate,this._mediaSettings.audioFs=r.profile.sampleRate),i&&i.outMediaTrack&&(this._mediaSettings.videoWidth=i.profile.width,this._mediaSettings.videoHeight=i.profile.height,this._mediaSettings.videoFps=i.profile.frameRate,this._mediaSettings.videoBps=1e3*i.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}},{key:"sendMediaSettings",value:function(){var e=this;this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:yq,data:this._mediaSettings,responseCommand:fq.UPDATE_CONSTRAINT_CONFIG_RES}).then((function(t){0!==t.data.code&&e._log.warn(t.data.message)})).catch((function(){}))}},{key:"addTrack",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._peerConnection){t.next=2;break}return t.abrupt("return");case 2:if(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is adding ".concat(e.kind," track to current published local ").concat(n?nC.AUXILIARY:nC.MAIN," stream")),!$N()){t.next=9;break}return t.next=7,this.addTrackByTransceiver(e,n);case 7:t.next=11;break;case 9:return t.next=11,this.addTrackBySender(e);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"addTrackByTransceiver",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(i=this._peerConnection.getTransceivers(),e.kind!==nC.AUDIO){n.next=8;break}return n.next=6,i[0].sender.replaceTrack(e.outMediaTrack);case 6:n.next=19;break;case 8:return a=t?3:1,n.next=11,i[a].sender.replaceTrack(e.outMediaTrack);case 11:if(n.t0=1===a&&null!=(r=this.localMainVideoTrack)&&r.small,!n.t0){n.next=15;break}return n.next=15,i[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 15:if(n.t1=i[a].direction===rC.INACTIVE,!n.t1){n.next=19;break}return n.next=19,this.setTransceiverDirection(rC.SENDONLY,[a]);case 19:return this.updateMediaSettings(),n.next=22,this.doPublishChange();case 22:case"end":return n.stop()}}),n,this)})))}},{key:"addTrackBySender",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.outMediaTrack){t.next=2;break}return t.abrupt("return");case 2:if(n=e.outMediaTrack,t.t0=QN()&&this._peerConnection.getTransceivers().findIndex((function(e){return"stopped"===e.direction}))>=0,!t.t0){t.next=8;break}return this._log.warn("transceiver is stopping, negotiate sdp first"),t.next=8,this.updateOffer("remove",n);case 8:if(r=this._peerConnection.getSenders().find((function(e){return e.track&&e.track.kind===n.kind})),!r||!r.track){t.next=15;break}return this._log.warn("sender already exists, remove sender first"),i=r.track,this.removeSender(r),t.next=15,this.updateOffer("remove",i);case 15:return n&&this._peerConnection.addTrack(n,new MediaStream([n])),n.kind===nC.VIDEO&&e instanceof AL&&e.small&&(a=new MediaStream,o=this._room.videoManager.smallTrack,a.addTrack(o),this._peerConnection.addTrack(o,a)),t.next=18,this.updateOffer("add",n);case 18:case"end":return t.stop()}}),t,this)})))}},{key:"isNeedToResetOfferOrder",value:function(){if(this._sdpSemantics===UC||!this._peerConnection||!this._peerConnection.localDescription)return!1;for(var e=this._peerConnection.localDescription.sdp,t=wq(e),n=0;n<t.media.length;n++)if(0===Number(t.media[n].mid)&&t.media[n].type===nC.VIDEO)return!0;return!1}},{key:"removeSender",value:function(e){var t=null;QN()&&(t=this._peerConnection.getTransceivers().find((function(t){return t.sender&&t.sender.track===e.track}))),this._peerConnection.removeTrack(e),t&&Sw(t.stop)&&(this._log.info("stop transceiver"),t.stop())}},{key:"removeTrack",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._peerConnection){t.next=2;break}return t.abrupt("return");case 2:if(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is removing ".concat(e.kind," track from current published local ").concat(n?nC.AUXILIARY:nC.MAIN," stream")),!$N()){t.next=9;break}return t.next=7,this.removeTrackByTransceiver(e,n);case 7:t.next=11;break;case 9:return t.next=11,this.removeTrackBySender(e);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrackByTransceiver",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.outMediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),e.kind!==nC.AUDIO){n.next=8;break}return n.next=6,r[0].sender.replaceTrack(null);case 6:n.next=17;break;case 8:return i=t?3:1,n.next=11,r[i].sender.replaceTrack(null);case 11:if(n.t0=1===i&&e.small,!n.t0){n.next=15;break}return n.next=15,r[2].sender.replaceTrack(null);case 15:return n.next=17,this.setTransceiverDirection(rC.INACTIVE,[i]);case 17:return this.updateMediaSettings(),n.next=20,this.doPublishChange();case 20:case"end":return n.stop()}}),n,this)})))}},{key:"setTransceiverDirection",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(wD){n.next=2;break}return n.abrupt("return");case 2:if(r=!1,i=!1,this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e)),a=this._peerConnection.getTransceivers(),t.forEach((function(t){a[t].direction!==e&&(a[t].direction=e,r=!0)})),!r){n.next=12;break}return this._log.info("updating offer"),n.next=9,this._peerConnection.createOffer();case 9:return o=n.sent,n.next=12,this.setOffer(o);case 12:if(s=-1,c=this._peerConnection.remoteDescription.sdp.split("\r\n").map((function(n){if(n.match(new RegExp("a=(".concat(rC.INACTIVE,"|").concat(rC.RECVONLY,"|").concat(rC.SENDONLY,")")))&&s++,t.includes(s)){if(e===rC.INACTIVE&&n.includes("a=".concat(rC.RECVONLY)))return i=!0,"a=".concat(e);if(e===rC.SENDONLY&&n.includes("a=".concat(rC.INACTIVE)))return i=!0,"a=".concat(rC.RECVONLY)}return n})).join("\r\n"),n.t0=i,!n.t0){n.next=18;break}return this._log.info("updating answer"),n.next=18,this.setAnswer({type:"answer",sdp:c});case 18:case"end":return n.stop()}}),n,this)})))}},{key:"removeTrackBySender",value:function(e){return aR(this,null,f().mark((function t(){var n,r=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.outMediaTrack){t.next=2;break}return t.abrupt("return");case 2:if(e.kind!==nC.VIDEO||!this.isNeedToResetOfferOrder()||!this.localMainAudioTrack){t.next=8;break}return this.reset(),this.initialize(),t.next=7,this.publish({localAudioTrack:this.localMainAudioTrack,isAuxiliary:!1});case 7:return t.abrupt("return",void t.sent);case 8:return(n=this._peerConnection.getSenders().find((function(t){return t.track===e.outMediaTrack})))&&(this.removeSender(n),e.kind===nC.VIDEO&&e.small&&this._peerConnection.getSenders().forEach((function(e){e.track&&e.track.kind===nC.VIDEO&&r.removeSender(e)}))),t.next=12,this.updateOffer("remove",e.outMediaTrack);case 12:case"end":return t.stop()}}),t,this)})))}},{key:"replaceTrack",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((i=null==(n=this._peerConnection)?void 0:n.getSenders())&&0!==i.length&&e.mediaTrack){t.next=3;break}return t.abrupt("return",!1);case 3:if(r=$N()?e.kind===nC.AUDIO?i[0]:i[1]:i.find((function(t){return t.track&&t.track.kind===e.kind})),r){t.next=5;break}return t.abrupt("return",!1);case 5:if(a=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is replacing ".concat(e.kind," track on ").concat(a?nC.AUXILIARY:nC.MAIN," stream")),e.kind!==nC.AUDIO){t.next=12;break}return t.next=10,r.replaceTrack(e.outMediaTrack);case 10:case 19:t.next=23;break;case 12:if(t.t0=e.kind===nC.VIDEO,!t.t0){t.next=23;break}if(!a){t.next=21;break}if(t.t1=i[3],!t.t1){t.next=19;break}return t.next=19,i[3].replaceTrack(e.outMediaTrack);case 21:return t.next=23,r.replaceTrack(e.outMediaTrack);case 23:return t.abrupt("return",!0);case 24:case"end":return t.stop()}}),t,this)})))}},{key:"updateOffer",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,this._peerConnection.createOffer(Pq);case 3:return r=n.sent,wD&&r.sdp&&(r.sdp=this.setSDPDirection(r.sdp,"sendrecv")),n.next=7,this.setOffer(r);case 7:return i=this.updateMediaSettings(),a={action:e,trackId:t.id,kind:t.kind===nC.VIDEO?"bigVideo":t.kind,type:"offer",sdp:this._peerConnection.localDescription.sdp,constraintConfig:i,state:this.publishState},this._log.info("createOffer success, sending updated offer to remote server"),this._log.debug("updatedOffer: ".concat(a.sdp)),n.next=11,this._signalChannel.sendWaitForResponse({command:"publish_change",data:a,responseCommand:fq.UPDATE_OFFER_RESULT,timeout:PC,commandDesc:"update offer"});case 11:return o=n.sent,s=o.data,c=s.code,u=s.message,0!==c&&this.checkPublishResultCode(c,u),n.next=18,this.acceptAnswer(o.data.data);case 18:r.sdp&&this.updateSSRC(r.sdp),n.next=24;break;case 21:throw n.prev=21,n.t0=n.catch(0),this._log.error(n.t0),n.t0;case 24:case"end":return n.stop()}}),n,this,[[0,21]])})))}},{key:"setBandwidth",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.bandwidth,r=e.type,i=e.videoType,a=e.sdp;return f().mark((function e(){var o,s,c,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rP()){e.next=2;break}return e.abrupt("return",a?r===nC.VIDEO?t.updateVideoBandwidthRestriction(a,n,i):t.updateAudioBandwidthRestriction(a,n):void 0);case 2:if(s=t._peerConnection.getSenders(),$N()?(c=0,r===nC.VIDEO&&(c=i===nC.SMALL?2:i===nC.AUXILIARY?3:1),o=s[c]):o=s.find((function(e){return e.track&&e.track.kind===r})),!o){e.next=18;break}return(!(u=o.getParameters()).encodings||0===u.encodings.length)&&(u.encodings=[{}]),u.encodings[0].maxBitrate=1e3*n,e.prev=7,e.next=10,o.setParameters(u);case 10:return t._log.info("".concat(i||"").concat(r," bandwidth ").concat(n," kbps")),e.abrupt("return",a);case 14:if(e.prev=14,e.t0=e.catch(7),t._log.info("failed to set bandwidth by setting maxBitrate: ".concat(e.t0)),!a){e.next=18;break}return e.abrupt("return",r===nC.VIDEO?t.updateVideoBandwidthRestriction(a,n,i):t.updateAudioBandwidthRestriction(a,n));case 18:return e.abrupt("return",a);case 19:case"end":return e.stop()}}),e,null,[[7,14]])}))()}))}},{key:"updateVideoBandwidthRestriction",value:function(e,t,n){var r="AS";wD&&(r="TIAS",t*=1e3);var i=0,a=-1;return n===nC.SMALL?i=1:n===nC.AUXILIARY&&(i=2),e.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,(function(e){return(a+=1)===i?"".concat(e,"b=").concat(r,":").concat(t,"\r\n"):e}))}},{key:"updateAudioBandwidthRestriction",value:function(e,t){var n="AS";return wD&&(n="TIAS",t*=1e3),e.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb=".concat(n,":").concat(t,"\r\n"))}},{key:"removeBandwidthRestriction",value:function(e){return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(e){return e.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.exchangeSDP();case 3:return e.next=5,this.waitForPeerConnectionConnected();case 5:e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(0),this.closePeerConnection(!0),this.uninstallEvents(),e.t0;case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))}},{key:"exchangeSDP",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.createOffer();case 3:return this._log.info("createOffer success, sending offer to remote server"),e.next=6,this.doExchangeSDP();case 6:e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(0),e.t0;case 11:case"end":return e.stop()}}),e,this,[[0,8]])})))}},{key:"createOffer",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._peerConnection.createOffer(Pq);case 3:return t=e.sent,e.next=6,this.setOffer(t);case 6:t.sdp&&this.updateSSRC(t.sdp),e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,9]])})))}},{key:"doExchangeSDP",value:function(){var e=this,t={command:"publish",responseCommand:fq.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof wL||this.localAuxVideoTrack instanceof wL,state:this.publishState,constraintConfig:this._mediaSettings},enableLog:!1};return this._log.debug("sending sdp offer: ".concat(t.data.sdp)),this._signalChannel.sendWaitForResponse(t).then((function(t){var n=t.data,r=n.code,i=n.message,a=n.data;return 0===r?e.acceptAnswer(a):e.checkPublishResultCode(r,i)}))}},{key:"setSDPDirection",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=wq(e);return r.media.forEach((function(e){("all"===n||e.type===n)&&(e.direction=t)})),Dq(r)}},{key:"acceptAnswer",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d,h;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,!(this._publishingLocalAudioTrack||this._publishingLocalVideoTrack||this.isMainStreamPublished)){t.next=13;break}if(c=(null==(n=this._publishingLocalVideoTrack)?void 0:n.profile.bitrate)||(null==(r=this.localMainVideoTrack)?void 0:r.profile.bitrate),u=(null==(i=this._publishingLocalAudioTrack)?void 0:i.profile.bitrate)||(null==(a=this.localMainAudioTrack)?void 0:a.profile.bitrate),!c){t.next=8;break}return l=this._isPublishingAux?nC.AUXILIARY:nC.BIG,t.next=7,this.setBandwidth({bandwidth:c,type:nC.VIDEO,sdp:s,videoType:l});case 7:s=t.sent;case 8:if(t.t0=u,!t.t0){t.next=13;break}return t.next=12,this.setBandwidth({bandwidth:u,type:nC.AUDIO,sdp:s});case 12:s=t.sent;case 13:if(s=this.removeVideoOrientation(e.sdp),null==(o=this._publishingLocalVideoTrack)||!o.small){t.next=18;break}return d=this._room.smallStreamConfig,t.next=17,this.setBandwidth({bandwidth:this._publishingLocalVideoTrack.small.bitrate||d.bitrate,type:nC.VIDEO,videoType:nC.SMALL,sdp:s});case 17:s=t.sent;case 18:return h={type:e.type,sdp:s},t.next=21,this.setAnswer(h);case 21:this._log.debug("accepted answer: ".concat(s)),t.next=27;break;case 24:throw t.prev=24,t.t1=t.catch(0),this._log.error("failed to accept remote answer ".concat(t.t1)),t.t1;case 27:case"end":return t.stop()}}),t,this,[[0,24]])})))}},{key:"sendMutedFlag",value:function(e){var t,n,r;if(e!==this.localAuxAudioTrack&&e!==this.localAuxVideoTrack){var i={audio:!(null==(t=this.localMainAudioTrack)||!t.muted),bigVideo:!(null==(n=this.localMainVideoTrack)||!n.muted),auxVideo:!(null==(r=this.localAuxVideoTrack)||!r.muted)};this._log.info("send muted state: ".concat(JSON.stringify(i))),this._signalChannel.send(pq,i)}}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"reconnect",value:function(){return aR(this,null,f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(iR(i.prototype,this,"beforeReconnect").call(this)<0){e.next=22;break}return e.prev=1,e.next=4,this._signalChannel.sendWaitForResponse({command:vq,responseCommand:fq.UNPUBLISH_RESULT,enableLog:!1});case 4:if(this.closePeerConnection(),this.initialize(),e.t0=this.isMainStreamPublished,!e.t0){e.next=10;break}return e.next=10,this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1});case 10:if(e.t1=this.isAuxStreamPublished,!e.t1){e.next=14;break}return e.next=14,this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0});case 14:this._log.warn("reconnect() uplink reconnect successfully"),this.stopReconnection(),e.next=22;break;case 18:e.prev=18,e.t2=e.catch(1),t=Tw(this._reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((function(){n.clearReconnectionTimer(),n.reconnect()}),t);case 22:case"end":return e.stop()}}),e,this,[[1,18]])})))}},{key:"handleConnectionStateChange",value:function(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&rO.emit(aO.SEND_FIRST_VIDEO_FRAME,{room:this._room})}},{key:"updateSSRC",value:function(e){var t=this;try{wq(e).media.forEach((function(e,n){if(e.type===nC.AUDIO){var r=e.ssrcs&&e.ssrcs[0];r&&(t.ssrc.audio=Number(r.id))}else{if(t._sdpSemantics===UC&&e.ssrcGroups)return void e.ssrcGroups.forEach((function(e,n){var r=Number(e.ssrcs.split(" ")[0]);0===n?t.ssrc.video=r:1===n&&(t.ssrc.small=r)}));var i=e.ssrcs&&e.ssrcs[0];if(!i)return;switch(n){case 1:t.ssrc.video=Number(i.id);break;case 2:t.ssrc.small=Number(i.id);break;case 3:t.ssrc.auxiliary=Number(i.id)}}}))}catch(DC){}}},{key:"getVideoTrackId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nC.VIDEO;if(this._peerConnection){var t=this._peerConnection.getSenders();if(e===nC.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===nC.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===nC.VIDEO){var n=this.localMainVideoTrack.mediaTrack;if(n)return n.id}if(this.localAuxVideoTrack&&e===nC.AUXILIARY){var r=this.localAuxVideoTrack.mediaTrack;if(r)return r.id}return""}},{key:"getSSRC",value:function(){return this.ssrc}},{key:"checkPublishResultCode",value:function(e,t){if(0!==e)throw e===VC?(this._log.error(hN.NOT_SUPPORTED_H264ENCODE),new yR({code:_R.NOT_SUPPORTED_H264,message:mN({key:dN.NOT_SUPPORTED_H264ENCODE})})):new yR({code:_R.UNKNOWN,message:mN({key:dN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:fq.PUBLISH_RESULT,code:e,message:t}})})}}])}(Rq);nR([uL((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var a=function(e){t._emitter.off("closed",a),i(new yR({code:_R.API_CALL_ABORTED,message:mN({key:dN.CONNECTION_ABORTED,data:e})}))};t._emitter.on("closed",a),e.apply(t,r).then(n,i).finally((function(){t._emitter.off("closed",a)}))}))}}))],Mq.prototype,"publish",1),nR([gL(521715,!1)],Mq.prototype,"unpublish",1),nR([sL(Rq.prototype.afterConnect),oL(Rq.prototype.beforeConnect)],Mq.prototype,"connect",1);var Lq=Mq,Uq=function(){return o((function e(t,n){r(this,e),this.room=t,rR(this,"_log"),rR(this,"_prevReportTime",0),rR(this,"_prevReport",{}),rR(this,"_prevStats",null),rR(this,"_prevEncoderImplementation",""),rR(this,"_prevAuxEncoderImpl",""),rR(this,"_prevQualityLimitationReason",""),rR(this,"_prevAuxQualityLimitationReason",""),rR(this,"_prevDecoderImplementationMap",new Map),rR(this,"totalBytesSent",0),rR(this,"totalBytesReceived",0),rR(this,"_spcStats",null),this._log=n}),[{key:"statInterval",get:function(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}},{key:"getSenderStats",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},i=e.getPeerConnection(),a=e.getSSRC(),!i){t.next=18;break}if(t.prev=2,t.t0=this._spcStats,t.t0){t.next=8;break}return t.next=7,i.getStats();case 7:t.t0=t.sent;case 8:if(t.t0.forEach((function(t){var n,i,o,c;if("outbound-rtp"===t.type)if((t.mediaType||t.kind)===nC.VIDEO){if(t.ssrc===a.video?(c=nC.VIDEO,e.localMainVideoTrack):t.ssrc===a.small?c=nC.SMALL:t.ssrc===a.auxiliary&&(e.localAuxVideoTrack,c=nC.AUXILIARY),!c)return;if(r[c].bytesSent=t.bytesSent,r[c].packetsSent=t.packetsSent,r[c].framesEncoded=t.framesEncoded,bw(t.keyFramesEncoded)||(r[c].keyFramesEncoded=t.keyFramesEncoded),bw(t.nackCount)||(r[c].nackCount=t.nackCount),bw(t.pliCount)||(r[c].pliCount=t.pliCount),bw(t.retransmittedPacketsSent)||(r[c].retransmittedPacketsSent=t.retransmittedPacketsSent),bw(t.totalEncodeTime)||(r[c].totalEncodeTime=t.totalEncodeTime),bw(t.totalPacketSendDelay)||(r[c].totalPacketSendDelay=t.totalPacketSendDelay),!bw(t.encoderImplementation)&&(c===nC.VIDEO&&s._prevEncoderImplementation!==t.encoderImplementation||c===nC.AUXILIARY&&s._prevAuxEncoderImpl!==t.encoderImplementation)){var u=2,l=s._prevEncoderImplementation;c===nC.AUXILIARY&&(u=7,l=s._prevAuxEncoderImpl),rO.emit("262",{userId:e.userId,streamType:u,prevImplementation:l,implementation:t.encoderImplementation,codec:e.videoCodec,isHWCodec:t.powerEfficientEncoder}),s[c===nC.VIDEO?"_prevEncoderImplementation":"_prevAuxEncoderImpl"]=t.encoderImplementation,s._log.info("".concat(c===nC.AUXILIARY?"aux ":"","encoderImplementation change to ").concat(t.encoderImplementation,"(").concat(e.videoCodec,") HWEncoder: ").concat(t.powerEfficientEncoder))}t.ssrc===a.video?!bw(t.qualityLimitationReason)&&0!==t.bytesSent&&s._prevQualityLimitationReason!==t.qualityLimitationReason&&(s._log.info("qualityLimitationReason change to ".concat(t.qualityLimitationReason)),rO.emit("263",{userId:e.userId,reason:t.qualityLimitationReason,prevReason:s._prevQualityLimitationReason,streamType:2,isQosClearFirst:null==(n=e.localMainVideoTrack)?void 0:n.isQosClearFirst}),s._prevQualityLimitationReason=t.qualityLimitationReason):t.ssrc===a.auxiliary&&!bw(t.qualityLimitationReason)&&0!==t.bytesSent&&s._prevAuxQualityLimitationReason!==t.qualityLimitationReason&&(s._log.info("aux qualityLimitationReason change to ".concat(t.qualityLimitationReason)),rO.emit("263",{userId:e.userId,reason:t.qualityLimitationReason,prevReason:s._prevAuxQualityLimitationReason,streamType:7,isQosClearFirst:null==(i=e.localAuxVideoTrack)?void 0:i.isQosClearFirst}),s._prevAuxQualityLimitationReason=t.qualityLimitationReason)}else r.audio.bytesSent=t.bytesSent,r.audio.packetsSent=t.packetsSent;else"candidate-pair"===t.type?jN(t)&&(s.totalBytesSent=t.bytesSent,Aw(t.currentRoundTripTime)&&(r.rtt=Math.floor(1e3*t.currentRoundTripTime))):"media-source"===t.type&&(t.kind===nC.AUDIO?(r.audio.audioLevel=t.audioLevel||0,r.audio.totalAudioEnergy=t.totalAudioEnergy||0,t.echoReturnLoss,t.totalSamplesDuration&&(r.audio.totalSamplesDuration=t.totalSamplesDuration)):t.kind===nC.VIDEO&&(t.trackIdentifier===e.getVideoTrackId(nC.VIDEO)?r.video.fpsCapture=t.framesPerSecond:t.trackIdentifier===e.getVideoTrackId(nC.AUXILIARY)?r.auxiliary.fpsCapture=t.framesPerSecond:r.small.fpsCapture=t.framesPerSecond));if(!bw(t.audioLevel)&&null!=(o=e.localMainAudioTrack)&&o.mediaTrack&&t.trackIdentifier===e.localMainAudioTrack.mediaTrack.id&&(r.audio.audioLevel=t.audioLevel||0),!bw(t.frameWidth)){var d=nC.SMALL;t.trackIdentifier===e.getVideoTrackId(nC.VIDEO)||t.ssrc===a.video?d=nC.VIDEO:(t.trackIdentifier===e.getVideoTrackId(nC.AUXILIARY)||t.ssrc===a.auxiliary)&&(d=nC.AUXILIARY),r[d].frameWidth=t.frameWidth,r[d].frameHeight=t.frameHeight,r[d].framesSent=t.framesSent}})),!e.localMainAudioTrack){t.next=12;break}o=e.localMainAudioTrack.getInternalAudioLevel(),r.audio.micAudioLevel=o,0===r.audio.audioLevel&&(r.audio.audioLevel=o);case 12:this.totalBytesSent||(this.totalBytesSent+=r.audio.bytesSent+r.video.bytesSent+r.auxiliary.bytesSent),Object.keys(r).forEach((function(t){t===nC.AUDIO?(e.localMainAudioTrack&&(e.localMainAudioTrack.stat=r[t]),e.localAuxAudioTrack&&(e.localAuxAudioTrack.stat=r[t])):t===nC.VIDEO?e.localMainVideoTrack&&(e.localMainVideoTrack.stat=r[t]):t===nC.AUXILIARY&&e.localAuxVideoTrack&&(e.localAuxVideoTrack.stat=r[t])})),t.next=18;break;case 15:t.prev=15,t.t1=t.catch(2),this._log.warn("failed to getStats on sender connection ".concat(t.t1));case 18:return t.abrupt("return",(0===r.rtt&&(r.rtt=(null==(n=this.room.networkQuality)?void 0:n.uplinkRTT)||0),r));case 19:case"end":return t.stop()}}),t,this,[[2,15]])})))}},{key:"getReceiverStats",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a={tinyId:e.tinyId,userId:e.userId,rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,isSmallSubscribed:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,p2pDelay:0,totalJitter:0,totalJitterCount:0,audioLevel:0,totalAudioEnergy:0,insertedSamplesForDeceleration:0,removedSamplesForAcceleration:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0,freezeCount:0,totalFreezesDuration:0,totalJitter:0,totalJitterCount:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0,totalJitter:0,totalJitterCount:0}},!(o=e.getPeerConnection())){t.next=19;break}if(t.prev=2,s=e.ssrc,c=e.muteState,u=e.subscribeState,t.t0=this._spcStats,t.t0){t.next=9;break}return t.next=8,o.getStats();case 8:t.t0=t.sent;case 9:t.t0.forEach((function(t){if("inbound-rtp"===t.type){var n=(t.mediaType||t.kind)===nC.AUDIO;if(n){if(t.ssrc!==s.audio||!c.hasAudio)return;a.audio.packetsReceived=t.packetsReceived,a.audio.bytesReceived=t.bytesReceived,a.audio.packetsLost=t.packetsLost,t.insertedSamplesForDeceleration&&(a.audio.insertedSamplesForDeceleration=t.insertedSamplesForDeceleration),t.removedSamplesForAcceleration&&(a.audio.removedSamplesForAcceleration=t.removedSamplesForAcceleration),t.totalSamplesDuration&&(a.audio.totalSamplesDuration=t.totalSamplesDuration),t.totalSamplesReceived&&(a.audio.totalSamplesReceived=t.totalSamplesReceived),t.concealedSamples&&(a.audio.concealedSamples=t.concealedSamples);var r=e.remoteAudioTrack;r.stat.packetsReceived=t.packetsReceived,r.stat.bytesReceived=t.bytesReceived,r.stat.packetsLost=t.packetsLost,a.audio.p2pDelay=r.stat.end2EndDelay,a.hasAudio=!0}else{if(wD&&0===t.bytesReceived)return;var i;t.ssrc===s.video&&c.hasVideo&&(a.video.packetsReceived=t.packetsReceived,a.video.bytesReceived=t.bytesReceived,a.video.packetsLost=t.packetsLost,a.video.framesReceived=t.framesReceived,a.video.framesDecoded=t.framesDecoded,a.video.fpsDecoded=t.framesPerSecond,a.hasVideo=!0,i=e.remoteVideoTrack,c.hasSmall&&u.smallVideo&&(a.isSmallSubscribed=!0),t.decoderImplementation&&(!l._prevDecoderImplementationMap.has(a.userId)||l._prevDecoderImplementationMap.get(a.userId)!==t.decoderImplementation)&&(l._log.info("".concat(a.userId," decoderImplementation change to ").concat(t.decoderImplementation," HWDecoder: ").concat(t.powerEfficientDecoder)),rO.emit("262",{userId:l.room.userId,remoteUserId:a.userId,prevImplementation:l._prevDecoderImplementationMap.get(a.userId),implementation:t.decoderImplementation,codec:e.videoCodec,isHWCodec:t.powerEfficientDecoder}),l._prevDecoderImplementationMap.set(a.userId,t.decoderImplementation))),t.ssrc===s.auxiliary&&c.hasAuxiliary&&(a.auxiliary.packetsReceived=t.packetsReceived,a.auxiliary.bytesReceived=t.bytesReceived,a.auxiliary.packetsLost=t.packetsLost,a.auxiliary.framesReceived=t.framesReceived,a.auxiliary.framesDecoded=t.framesDecoded,a.auxiliary.fpsDecoded=t.framesPerSecond,i=e.remoteAuxiliaryTrack,a.hasAuxiliary=!0),i&&(i.stat.packetsReceived=t.packetsReceived,i.stat.bytesReceived=t.bytesReceived,i.stat.packetsLost=t.packetsLost,i.stat.framesReceived=t.framesReceived,i.stat.framesDecoded=t.framesDecoded,t.jitterBufferDelay&&(i.stat.jitterBufferDelay=Math.floor(t.jitterBufferDelay/t.jitterBufferEmittedCount*1e3)))}t.jitterBufferDelay&&(n?(a.audio.totalJitter=t.jitterBufferDelay,a.audio.totalJitterCount=t.jitterBufferEmittedCount):t.ssrc===s.video&&c.hasVideo?(a.video.totalJitter=t.jitterBufferDelay,a.video.totalJitterCount=t.jitterBufferEmittedCount):t.ssrc===s.auxiliary&&c.hasAuxiliary&&(a.auxiliary.totalJitter=t.jitterBufferDelay,a.auxiliary.totalJitterCount=t.jitterBufferEmittedCount))}else"candidate-pair"===t.type&&jN(t)&&(l.totalBytesReceived=t.bytesReceived,Aw(t.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*t.currentRoundTripTime)));bw(t.frameWidth)||((t.trackIdentifier===e.getMainStreamVideoTrackId()||t.ssrc===s.video)&&(a.video.frameWidth=t.frameWidth,a.video.frameHeight=t.frameHeight,e.remoteVideoTrack.stat.frameWidth=t.frameWidth,e.remoteVideoTrack.stat.frameHeight=t.frameHeight),(t.trackIdentifier===e.getAuxStreamVideoTrackId()||t.ssrc===s.auxiliary)&&(a.auxiliary.frameWidth=t.frameWidth,a.auxiliary.frameHeight=t.frameHeight,e.remoteAuxiliaryTrack.stat.frameWidth=t.frameWidth,e.remoteAuxiliaryTrack.stat.frameHeight=t.frameHeight)),!bw(t.audioLevel)&&e.muteState.audioAvailable&&e.remoteAudioTrack.mediaTrack&&t.trackIdentifier===e.remoteAudioTrack.mediaTrack.id&&(a.audio.audioLevel=t.audioLevel||0,a.audio.totalAudioEnergy=t.totalAudioEnergy||0)})),0===a.audio.audioLevel&&e.muteState.audioAvailable&&(a.audio.audioLevel=e.remoteAudioTrack.getInternalAudioLevel()||0),this.totalBytesReceived||(this.totalBytesReceived+=a.audio.bytesReceived+a.video.bytesReceived+a.auxiliary.bytesReceived),bw(null==(n=e.remoteVideoTrack.player.stat)?void 0:n.fps)||(a.video.fpsRender=e.remoteVideoTrack.player.stat.fps),bw(null==(r=e.remoteAuxiliaryTrack.player.stat)?void 0:r.fps)||(a.auxiliary.fpsRender=e.remoteAuxiliaryTrack.player.stat.fps),t.next=19;break;case 16:t.prev=16,t.t1=t.catch(2),this._log.warn("failed to getStats on receiver connection ".concat(t.t1));case 19:return t.abrupt("return",(0===a.rtt&&(a.rtt=(null==(i=this.room.networkQuality)?void 0:i.uplinkRTT)||0),a));case 20:case"end":return t.stop()}}),t,this,[[2,16]])})))}},{key:"getStats",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,c,u,l,d,h,p,m,_,g;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r={},i=[],!this.room.singlePC){n.next=13;break}if(a=this.room.singlePC.getPeerConnection()){n.next=5;break}return n.abrupt("return",{senderStats:r,receiverStats:i});case 5:return o=Uw(),n.next=8,a.getStats();case 8:c=n.sent,(u=Uw())-o>2e3&&this._log.warn("getStats cost ".concat(u-o,"ms")),l=[],d=new Set(["inbound-rtp","outbound-rtp","track","candidate-pair","media-source"]),c.forEach((function(e){return d.has(e.type)&&l.push(e)})),this._spcStats=l;case 13:if(n.t0=e,!n.t0){n.next=18;break}return n.next=17,this.getSenderStats(e);case 17:r=n.sent;case 18:h=s(t),n.prev=19,h.s();case 21:if((p=h.n()).done){n.next=29;break}return(m=v(p.value,2))[0],_=m[1],n.next=25,this.getReceiverStats(_);case 25:g=n.sent,i.push(g);case 27:n.next=21;break;case 29:n.next=34;break;case 31:n.prev=31,n.t1=n.catch(19),h.e(n.t1);case 34:return n.prev=34,h.f(),n.finish(34);case 37:return n.abrupt("return",{senderStats:r,receiverStats:i});case 38:case"end":return n.stop()}}),n,this,[[19,31,34,37]])})))}},{key:"getDifferenceValue",value:function(e,t){if(eL(e))return t;var n=t-e;return n<0?0:n}},{key:"prepareReport",value:function(e){var t,n=this,r=e.stats,i=e.report,a=e.freezeMap;if(!eL(r.senderStats)){var o={uint32_audio_level:r.senderStats.audio.audioLevel*tN,uint32_audio_energy:1e6*(r.senderStats.audio.totalAudioEnergy||0),uint32_audio_codec_bitrate:r.senderStats.audio.bytesSent};r.senderStats.audio.micAudioLevel&&(o.uint32_mic_audio_level=r.senderStats.audio.micAudioLevel*tN),r.senderStats.audio.totalSamplesDuration&&(i.msg_device_info.uint32_audio_capture_cost=r.senderStats.audio.totalSamplesDuration);var s=[];if(r.senderStats.video.bytesSent){var c={uint32_video_stream_type:2,uint32_video_codec_fps:r.senderStats.video.framesSent,uint32_video_capture_fps:r.senderStats.video.fpsCapture,uint32_video_width:r.senderStats.video.frameWidth,uint32_video_height:r.senderStats.video.frameHeight,uint32_video_codec_bitrate:r.senderStats.video.bytesSent,uint32_video_enc_fps:r.senderStats.video.framesEncoded,uint32_key_frame_count:r.senderStats.video.keyFramesEncoded,uint32_nack_count:r.senderStats.video.nackCount,uint32_pli_count:r.senderStats.video.pliCount,uint32_encode_cost:1e3*(r.senderStats.video.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.video.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.video.retransmittedPacketsSent};s.push(c)}if(r.senderStats.small.bytesSent){var u={uint32_video_stream_type:3,uint32_video_codec_fps:r.senderStats.small.framesSent||0,uint32_video_capture_fps:r.senderStats.small.fpsCapture||0,uint32_video_width:r.senderStats.small.frameWidth||0,uint32_video_height:r.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:r.senderStats.small.bytesSent,uint32_video_enc_fps:r.senderStats.small.framesEncoded||0,uint32_key_frame_count:r.senderStats.small.keyFramesEncoded,uint32_nack_count:r.senderStats.small.nackCount,uint32_pli_count:r.senderStats.small.pliCount,uint32_encode_cost:1e3*(r.senderStats.small.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.small.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.small.retransmittedPacketsSent};s.push(u)}if(r.senderStats.auxiliary.bytesSent){var l={uint32_video_stream_type:7,uint32_video_codec_fps:r.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:r.senderStats.auxiliary.fpsCapture||0,uint32_video_width:r.senderStats.auxiliary.frameWidth||0,uint32_video_height:r.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:r.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:r.senderStats.auxiliary.framesEncoded||0,uint32_key_frame_count:r.senderStats.auxiliary.keyFramesEncoded,uint32_nack_count:r.senderStats.auxiliary.nackCount,uint32_pli_count:r.senderStats.auxiliary.pliCount,uint32_encode_cost:1e3*(r.senderStats.auxiliary.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.auxiliary.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.auxiliary.retransmittedPacketsSent};s.push(l)}var d={uint32_bitrate:0,uint32_lost:0,uint32_rtt:r.senderStats.rtt};i.msg_up_stream_info={msg_audio_status:o,msg_video_status:s,msg_network_status:d}}var h=this.statInterval;i.msg_down_stream_info=[],r.receiverStats.forEach((function(e){var t={msg_user_info:{str_identifier:e.userId,uint64_tinyid:e.tinyId},msg_network_status:{uint32_rtt:e.rtt,uint32_bitrate:0,uint32_lost:0},msg_audio_status:{},msg_video_status:[]};if(e.hasAudio){var n={uint32_audio_p2p_delay:e.audio.p2pDelay,uint32_audio_cache_ms:e.audio.totalJitter,uint32_audio_cache_ms_count:e.audio.totalJitterCount,uint32_audio_codec_bitrate:e.audio.bytesReceived,uint32_audio_total_bitrate:e.audio.bytesReceived,uint32_audio_level:1e8*e.audio.audioLevel,uint32_audio_energy:1e6*e.audio.totalAudioEnergy,uint32_audio_receive:e.audio.packetsReceived,uint32_audio_origin_lost:e.audio.packetsLost};t.msg_audio_status=n}if(e.hasVideo){var r=a.get("".concat(e.userId,"_").concat(vC)),o=r?r.duration:0,s={uint32_video_stream_type:e.isSmallSubscribed?3:2,uint32_video_receive_fps:e.video.framesReceived,uint32_video_width:e.video.frameWidth,uint32_video_height:e.video.frameHeight,uint32_video_codec_bitrate:e.video.bytesReceived,uint32_video_receive:e.video.packetsReceived,uint32_video_origin_lost:e.video.packetsLost,uint32_video_block_time:o,uint32_video_dec_fps:e.video.framesDecoded,uint32_video_codec_fps:e.video.fpsRender,uint32_video_cache_ms:e.video.totalJitter,uint32_video_cache_ms_count:e.video.totalJitterCount};t.msg_video_status.push(s)}if(e.hasAuxiliary){var c=a.get("".concat(e.userId,"_").concat(_C)),u=c?c.duration:0,l={uint32_video_stream_type:7,uint32_video_receive_fps:e.auxiliary.framesReceived,uint32_video_width:e.auxiliary.frameWidth,uint32_video_height:e.auxiliary.frameHeight,uint32_video_codec_bitrate:e.auxiliary.bytesReceived,uint32_video_receive:e.auxiliary.packetsReceived+e.auxiliary.packetsLost,uint32_video_origin_lost:e.auxiliary.packetsLost,uint32_video_block_time:u,uint32_video_dec_fps:e.auxiliary.framesDecoded,uint32_video_codec_fps:e.video.fpsRender,uint32_video_cache_ms:e.auxiliary.totalJitter,uint32_video_cache_ms_count:e.auxiliary.totalJitterCount};t.msg_video_status.push(l)}i.msg_down_stream_info.push(t)}));var f=this._prevReport,p=this._prevStats;if(this._prevReport=JSON.parse(JSON.stringify(i)),this._prevStats=JSON.parse(JSON.stringify(r)),i.msg_up_stream_info.msg_audio_status&&f.msg_up_stream_info.msg_audio_status){var m=f.msg_up_stream_info.msg_audio_status,v=i.msg_up_stream_info.msg_audio_status;if(0===m.uint32_audio_codec_bitrate)v.uint32_audio_codec_bitrate=0;else{var _=this.getDifferenceValue(m.uint32_audio_codec_bitrate,v.uint32_audio_codec_bitrate);v.uint32_audio_codec_bitrate=Math.round(8*_/h),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=v.uint32_audio_codec_bitrate}null!=(t=f.msg_device_info)&&t.uint32_audio_capture_cost?i.msg_device_info.uint32_audio_capture_cost=2*Math.floor(1e3*this.getDifferenceValue(f.msg_device_info.uint32_audio_capture_cost,i.msg_device_info.uint32_audio_capture_cost)/h):delete i.msg_device_info.uint32_audio_capture_cost}var g=f.msg_up_stream_info.msg_video_status;i.msg_up_stream_info.msg_video_status.forEach((function(e){var t=g.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type}));if(!t||0===t.uint32_video_codec_bitrate)return e.uint32_video_codec_bitrate=0,e.uint32_video_enc_fps=0,void(e.uint32_video_codec_fps=0);var r=0,a=0,o=0;t&&e.uint32_video_codec_bitrate>=t.uint32_video_codec_bitrate&&(r=t.uint32_video_codec_bitrate,a=t.uint32_video_enc_fps,o=t.uint32_video_codec_fps);var s=n.getDifferenceValue(r,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*s/h),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=e.uint32_video_codec_bitrate,e.uint32_video_enc_fps=Math.round(n.getDifferenceValue(a,e.uint32_video_enc_fps)/h),e.uint32_video_codec_fps=Math.round(n.getDifferenceValue(o,e.uint32_video_codec_fps)/h),0===t.uint32_video_width&&0===t.uint32_video_height&&0===t.uint32_video_codec_fps&&(e.uint32_video_codec_fps=e.uint32_video_enc_fps),bw(t.uint32_key_frame_count)||(e.uint32_key_frame_count=Math.round(n.getDifferenceValue(t.uint32_key_frame_count,e.uint32_key_frame_count))),bw(t.uint32_nack_count)||(e.uint32_nack_count=Math.round(n.getDifferenceValue(t.uint32_nack_count,e.uint32_nack_count))),bw(t.uint32_pli_count)||(e.uint32_pli_count=Math.round(n.getDifferenceValue(t.uint32_pli_count,e.uint32_pli_count))),bw(t.uint32_video_arq_packets)||(e.uint32_video_arq_packets=Math.round(n.getDifferenceValue(t.uint32_video_arq_packets,e.uint32_video_arq_packets))),bw(t.uint32_encode_cost)||(e.uint32_encode_cost=Math.round(n.getDifferenceValue(t.uint32_encode_cost,e.uint32_encode_cost)/h)),bw(t.uint32_send_packet_cost)||(e.uint32_send_packet_cost=Math.round(n.getDifferenceValue(t.uint32_send_packet_cost,e.uint32_send_packet_cost)/h))}));var y=f.msg_down_stream_info;i.msg_down_stream_info=i.msg_down_stream_info.filter((function(e){return y.find((function(t){return t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid}))}));var E=i.msg_down_stream_info;return E.forEach((function(e){var t=y.find((function(t){return t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid}));if(eL(e.msg_audio_status)||eL(t.msg_audio_status))e.msg_audio_status={};else{var r=e.msg_audio_status,i=t.msg_audio_status,a=n.getDifferenceValue(i.uint32_audio_cache_ms_count,r.uint32_audio_cache_ms_count);delete r.uint32_audio_cache_ms_count,r.uint32_audio_cache_ms=Math.floor(1e3*n.getDifferenceValue(i.uint32_audio_cache_ms,r.uint32_audio_cache_ms)/a)||0;var o=n.room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);o&&(o.remoteAudioTrack.stat.jitterBufferDelay=r.uint32_audio_cache_ms),r.uint32_audio_origin_lost=n.getDifferenceValue(i.uint32_audio_origin_lost,r.uint32_audio_origin_lost),r.uint32_audio_receive=n.getDifferenceValue(i.uint32_audio_receive,r.uint32_audio_receive),r.uint32_audio_receive+=r.uint32_audio_origin_lost;var s=n.getDifferenceValue(i.uint32_audio_codec_bitrate,r.uint32_audio_codec_bitrate);r.uint32_audio_codec_bitrate=Math.round(8*s/h),r.uint32_audio_total_bitrate=Math.round(8*s/h)}if(e.msg_video_status&&t.msg_video_status){var c=t.msg_video_status;e.msg_video_status=e.msg_video_status.filter((function(e){return c.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type}))})),e.msg_video_status.forEach((function(e){var t=c.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type})),r=t.uint32_video_receive,i=t.uint32_video_origin_lost,a=t.uint32_video_codec_bitrate,o=t.uint32_video_receive_fps,s=t.uint32_video_dec_fps;e.uint32_video_origin_lost=n.getDifferenceValue(i,e.uint32_video_origin_lost),e.uint32_video_receive=n.getDifferenceValue(r,e.uint32_video_receive)+e.uint32_video_origin_lost;var u=n.getDifferenceValue(a,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*u/h);var l=n.getDifferenceValue(o,e.uint32_video_receive_fps);e.uint32_video_receive_fps=Math.round(l/h),e.uint32_video_dec_fps=Math.round(n.getDifferenceValue(s,e.uint32_video_dec_fps)/h);var d=n.getDifferenceValue(t.uint32_video_cache_ms_count,e.uint32_video_cache_ms_count);delete e.uint32_video_cache_ms_count,e.uint32_video_cache_ms=Math.floor(1e3*n.getDifferenceValue(t.uint32_video_cache_ms,e.uint32_video_cache_ms)/d)||0}))}})),p&&r.receiverStats.forEach((function(e){if(e.audio.concealedSamples&&e.audio.totalSamplesReceived){var t=p.receiverStats.find((function(t){return t.userId===e.userId}));if(t&&t.audio.concealedSamples&&t.audio.totalSamplesReceived){var n=e.audio.concealedSamples-t.audio.concealedSamples,r=e.audio.totalSamplesReceived-t.audio.totalSamplesReceived,i=Math.floor(n/r*1e3*h);if(i>1e3*h/5){var a=E.find((function(t){return t.msg_user_info.str_identifier===e.userId}));a&&(a.msg_audio_status.uint32_audio_block_time=i)}}}})),i}},{key:"getStatsReport",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.uplinkConnection,r=e.downlinkConnections,i=e.freezeMap;return f().mark((function e(){var a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a={msg_device_info:{},msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0},msg_video_status:[],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_audio_status:{uint32_audio_cache_ms:0,uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0},msg_video_status:[{uint32_video_cache_ms:0,uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}}]},e.next=3,t.getStats(n,r);case 3:return o=e.sent,e.abrupt("return",("{}"===JSON.stringify(t._prevReport)&&(t._prevReport=JSON.parse(JSON.stringify(a))),t.prepareReport({stats:o,report:a,freezeMap:i}),t._prevReportTime=Date.now(),a));case 5:case"end":return e.stop()}}),e)}))()}))}},{key:"reset",value:function(){this._prevReportTime=0,this._prevReport={},this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevDecoderImplementationMap=new Map}}])}(),Vq=function(e){function i(e){var a;r(this,i);var o=e.signalChannel,s=e.room;return a=n(this,i),rR(t(a),"_room"),rR(t(a),"_signalChannel"),rR(t(a),"_log"),rR(t(a),"uplinkRTT",0),rR(t(a),"uplinkLoss",0),rR(t(a),"downlinkRTT",0),rR(t(a),"downlinkLoss",0),rR(t(a),"pingResults",{}),rR(t(a),"_downlinkPrevStatMap",new Map),rR(t(a),"_downlinkLossAndRTTMap",new Map),rR(t(a),"_interval",-1),rR(t(a),"_uplinkNetworkQuality",0),rR(t(a),"_downlinkNetworkQuality",0),a._room=s,a._signalChannel=o,a._log=sO.createLogger({id:"q",userId:a._room.userId,sdkAppId:a._room.sdkAppId}),a.initialize(),a}return d(i,e),o(i,[{key:"uplinkNetworkQuality",get:function(){return this._uplinkNetworkQuality},set:function(e){e!==this._uplinkNetworkQuality&&this._log.info("uplink ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this.uplinkRTT,", loss: ").concat(this.uplinkLoss," ws-rtt: ").concat(this._signalChannel.rtt)),this._uplinkNetworkQuality=e}},{key:"downlinkNetworkQuality",get:function(){return this._downlinkNetworkQuality},set:function(e){if(e!==this._downlinkNetworkQuality){var t=this.getAverageLossAndRTT(E(this._downlinkLossAndRTTMap.values())),n=t.rtt,r=t.loss;this._log.info("downlink ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(n,", loss: ").concat(r," ws-rtt: ").concat(this._signalChannel.rtt))}this._downlinkNetworkQuality=e}},{key:"initialize",value:function(){var e=this;this._signalChannel.on(fq.UPLINK_NETWORK_STATS,(function(t){e.handleUplinkNetworkQuality(t)})),this._signalChannel.on("2",this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(e){var t,n;if(0===e.data.code){var r=e.data.data;if(r.delay&&this.updateDelay(r.delay),this._room.signalChannel&&r.wsRtt&&(this._room.signalChannel.rtt=r.wsRtt),!this._room.uplinkConnection)return this.uplinkNetworkQuality=0,this.uplinkLoss=0,void(this.uplinkRTT=0);var i=null==(n=null==(t=this._room)?void 0:t.uplinkConnection)?void 0:n.getPeerConnection();if(i&&this.isPeerConnectionDisconnected(i))return this.uplinkNetworkQuality=6,this.uplinkLoss=0,void(this.uplinkRTT=0);var a=r.expectAudPkg+r.expectVidPkg,o=r.recvAudPkg+r.recvVidPkg,s=a-o;0===a&&0===o||(this.uplinkLoss=s<=0?0:Math.round(s/a*100),this.uplinkRTT=r.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss,this.uplinkRTT))}}},{key:"handleDownlinkNetworkQuality",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u,l,d,h,p,m,v,_=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._room.remotePublishedUserMap.size){e.next=2;break}return e.abrupt("return",void(this.downlinkNetworkQuality=0));case 2:if(t=E(this._room.remotePublishedUserMap.values()),n=t.filter((function(e){var t;return(null==(t=e.getPeerConnection())?void 0:t.connectionState)===AC.CONNECTED})),t.filter((function(e){return _.isPeerConnectionDisconnected(e.getPeerConnection())})).length!==t.length){e.next=5;break}return e.abrupt("return",void(this.downlinkNetworkQuality=6));case 5:r=0;case 6:if(!(r<n.length)){e.next=24;break}if(i=n[r].getPeerConnection()){e.next=10;break}return e.abrupt("return");case 10:return e.next=12,this.getStat(i);case 12:if(a=e.sent,o=a.rtt,s=a.totalPacketsLost,c=a.totalPacketsReceived,this._downlinkPrevStatMap.has(i)){e.next=19;break}return this._downlinkPrevStatMap.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),e.abrupt("continue",21);case 19:l=this._downlinkPrevStatMap.get(i),d=s-l.totalPacketsLost,h=c-l.totalPacketsReceived,u=d<=0||h<0?0:Math.round(d/(d+h)*100),this._downlinkPrevStatMap.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),this._downlinkLossAndRTTMap.set(i,{rtt:o,loss:u,userId:n[r].getUserId(),audioDelay:n[r].remoteAudioTrack.stat.end2EndDelay,videoDelay:n[r].remoteVideoTrack.stat.end2EndDelay});case 21:r++,e.next=6;break;case 24:if(E(this._downlinkPrevStatMap.keys()).forEach((function(e){_.isPeerConnectionDisconnected(e)&&(_._downlinkPrevStatMap.delete(e),_._downlinkLossAndRTTMap.delete(e))})),0!==this._downlinkLossAndRTTMap.size){e.next=26;break}return e.abrupt("return",(this.downlinkRTT=0,this.downlinkLoss=0,void(this.downlinkNetworkQuality=0)));case 26:p=this.getAverageLossAndRTT(E(this._downlinkLossAndRTTMap.values())),m=p.rtt,v=p.loss,this.downlinkRTT=m,this.downlinkLoss=v,this.downlinkNetworkQuality=this.getNetworkQuality(v,m);case 28:case"end":return e.stop()}}),e,this)})))}},{key:"getStat",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},e&&YN()){t.next=3;break}return t.abrupt("return",n);case 3:r=e.getReceivers(),t.prev=4,i=0;case 6:if(!(i<r.length)){t.next=13;break}return t.next=9,r[i].getStats();case 9:t.sent.forEach((function(e){"candidate-pair"===e.type&&Aw(e.currentRoundTripTime)&&(n.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"===e.type&&(e.mediaType===nC.AUDIO||e.mediaType===nC.VIDEO)&&(n.totalPacketsLost+=e.packetsLost,n.totalPacketsReceived+=e.packetsReceived)}));case 10:i++,t.next=6;break;case 13:return t.abrupt("return",(0===n.rtt&&(n.rtt=this.uplinkRTT),n));case 16:return t.prev=16,t.t0=t.catch(4),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this,[[4,16]])})))}},{key:"getAverageLossAndRTT",value:function(e){var t={rtt:0,loss:0};return Array.isArray(e)&&e.length>0&&(e.forEach((function(e){t.rtt+=e.rtt,t.loss+=e.loss})),Object.keys(t).forEach((function(n){t[n]=Math.round(t[n]/e.length)}))),t}},{key:"getNetworkQuality",value:function(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(e){"DISCONNECTED"===e.state?(this.uplinkRTT=0,this.uplinkLoss=0,this.uplinkNetworkQuality=6):"CONNECTED"===e.state&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(e){var t=e.state;"DISCONNECTED"===t?(this.uplinkLoss=0,this.uplinkRTT=0,this.uplinkNetworkQuality=6):"CONNECTED"===t&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(e){return!(!e||e.connectionState!==AC.DISCONNECTED&&e.connectionState!==AC.FAILED&&e.connectionState!==AC.CLOSED)}},{key:"setUplinkConnection",value:function(e){this._room.uplinkConnection=e,this._room.uplinkConnection?this._room.uplinkConnection.on("connection-state-changed",this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT=0,this.uplinkLoss=0)}},{key:"start",value:function(){var e=this;-1===this._interval?(this._log.debug("start network quality calculating"),this._interval=MP.run("ric",(function(){var t;e.handleDownlinkNetworkQuality();var n=E(e._downlinkLossAndRTTMap.values());rO.emit(aO.NETWORK_QUALITY,{room:e._room,uplink:{rtt:e.uplinkRTT,loss:e.uplinkLoss},downlinks:n});var r=null==(t=e._room.scheduleResult.config)?void 0:t.pingDomainInfo,a={uplinkNetworkQuality:e.uplinkNetworkQuality,downlinkNetworkQuality:e.downlinkNetworkQuality,uplinkRTT:e.uplinkRTT,uplinkLoss:e.uplinkLoss,downlinkRTT:e.downlinkRTT,downlinkLoss:e.downlinkLoss};r&&(a=$A(QA({},a),{pingResults:e.uplinkRTT>r.rttThreshold||e.downlinkRTT>r.rttThreshold?e.pingResults:{}})),e.emit(i.EVENT_NETWORK_QUALITY,a);var o=Date.now();if(r&&(e.uplinkRTT>r.rttThreshold||e.downlinkRTT>r.rttThreshold)&&o-i.lastPingTime>1e3*r.interval){i.lastPingTime=Date.now();var c=r.domain.map((function(e){return function(e){var t=this;return new Promise((function(n){return aR(t,null,f().mark((function t(){var r,i,a,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=setTimeout((function(){n({totalCost:1e4,local:0,dns:0,tcp:0,tls:0,request:0,response:0})}),1e4),i=Date.now(),a="https://".concat(e,"/?t=").concat(i),t.prev=1,t.next=4,fetch(a);case 4:t.next=8;break;case 6:t.prev=6,t.t0=t.catch(1);case 8:clearTimeout(r),o=function(e){var t={totalCost:0,local:0,redirect:0,httpCache:0,dns:0,tcp:0,tls:0,request:0,response:0};try{var n,i=s(performance.getEntriesByType("resource").reverse());try{for(i.s();!(n=i.n()).done;){var a=n.value;if(a.name===e){var o=Math.round(a.duration),c=Math.max(Math.round(a.domainLookupStart-a.startTime),0),u=a.redirectStart>0?Math.max(Math.round(a.redirectEnd-a.redirectStart),0):0,l=a.fetchStart>0?Math.max(Math.round(a.domainLookupStart-a.fetchStart),0):0,d=Math.round(a.domainLookupEnd-a.domainLookupStart),h=Math.round(a.requestStart-a.secureConnectionStart),f=Math.round(a.secureConnectionStart-a.connectStart),p=Math.round(a.responseStart-a.requestStart),m=Math.round(a.responseEnd-(a.responseStart||a.startTime));t=$A(QA({},t),{totalCost:o,local:c,redirect:u,httpCache:l,dns:d,tcp:f,tls:h,request:p,response:m});break}}}catch(v){i.e(v)}finally{i.f()}}catch(r){}return t}(a),0===o.totalCost&&(o.totalCost=Date.now()-i),n(o);case 11:case"end":return t.stop()}}),t,null,[[1,6]])})))}))}(e).then((function(t){return{domain:e,cost:t.totalCost}}))}));Promise.all(c).then((function(t){e.pingResults.isPoorNetwork=t.some((function(e){return e.cost>700})),e.pingResults.timestamp=o,e.pingResults.data=t,t.forEach((function(e){IN.addSuccessEvent({key:521718,cost:e.cost})})),e._log.warn("All ping results: ".concat(JSON.stringify(t)))})).catch((function(t){e._log.warn("Error during pinging domains: ".concat(t))}))}}),{delay:2e3})):this._log.info("network quality calculating is already started")}},{key:"stop",value:function(){this._log.debug("stopped"),-1!==this._interval&&(MP.clearTask(this._interval),this._interval=-1),this._downlinkLossAndRTTMap.clear(),this._downlinkPrevStatMap.clear()}},{key:"updateDelay",value:function(e){var t=this,n=this._room.tinyIdToUserIdMap;e.forEach((function(e){var r=e.srcTinyId,i=e.videoDelay,a=e.audioDelay,o=n.get(r);if(o){var s=t._room.remotePublishedUserMap.get(o);null==s||s.setDelay({videoDelay:i,audioDelay:a})}}))}}])}(tR(oR()).default);rR(Vq,"EVENT_NETWORK_QUALITY","0"),rR(Vq,"lastPingTime",0);var Fq=Vq,Bq=function(){return o((function e(t){var n=this;r(this,e),rR(this,"_frameWorkType"),rR(this,"_component"),rR(this,"_language"),rR(this,"connectionType"),rR(this,"_room"),rR(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0}),rR(this,"_keyPrefix"),rR(this,"_log"),rR(this,"_intervalId"),rR(this,"_firstPublishedUserList"),rR(this,"_networkQuality"),rR(this,"_basicInfo"),rR(this,"_pathJoinRoom"),rR(this,"_pathLeaveRoom"),rR(this,"_pathMainVideoMap"),rR(this,"_pathMainAudioMap"),rR(this,"_pathAuxiliaryMap"),rR(this,"_remoteStreamStatMap"),rR(this,"_localStreamStat"),rR(this,"_eventMap",new Map),rR(this,"_captureCostSum",0),rR(this,"_captureCostCount",0),rR(this,"isDestroyed",!1),this._frameWorkType=t.frameWorkType||30,this._component=t.component||0,this.connectionType=t.connectionType||1,this._language=t.language||0,this._room=t.room,this._keyPrefix="key_point",this._log=sO.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((function(e){e.startsWith("handle")&&Sw(n[e])&&(n[e]=function(e){var t=e.fn,n=e.context;return function(){try{for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var a=t.apply(n,r);return Ow(a)?a.catch((function(e){return sO.error("".concat(t.name,"() error observed ").concat(e))})):a}catch(DC){sO.error("".concat(t.name,"() error observed ").concat(DC))}}}({fn:n[e],context:n}))})),this.initData(),this.installEvents()}),[{key:"initData",value:function(){var e=this;this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:RR,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,Kx().then((function(t){e._basicInfo.string_os_version=Zx(),e._basicInfo.string_device_name=t&&t.mobile?t.model:e._basicInfo.string_os_version}))}},{key:"addEvent",value:function(e,t){return this._eventMap.set(e,t),rO.on(e,t),this}},{key:"installEvents",value:function(){var e=this;this.handleUnload=this.handleUnload.bind(this),window.addEventListener("pagehide",this.handleUnload),this._room.once("banned",(function(){return e.handleLeaveSuccess({room:e._room,roomId:e._room.roomId})})),this.addEvent(aO.JOIN_START,this.handleJoinStart).addEvent(aO.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(aO.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(aO.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(aO.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(aO.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(aO.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(aO.JOIN_FAILED,this.handleJoinFailed).addEvent(aO.LEAVE_START,this.handleLeaveStart).addEvent(aO.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(aO.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(aO.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(aO.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(aO.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(aO.PUBLISH_START,this.handlePublishStart).addEvent(aO.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(aO.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(aO.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(aO.PLAY_TRACK_START,this.handlePlayStart).addEvent(aO.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(aO.PLAYER_STATE_CHANGED,(function(t){var n=t.track,r=t.state,i=t.type;!n.isRemote||!e.hitTest(n.room)||"PLAYING"===r&&(i===nC.AUDIO?e.handleAudioPlaying(n):e.handleVideoPlaying(n))})).addEvent(aO.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(aO.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(aO.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(aO.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n=t.room,r=t.prevMuteState,i=t.muteState;if(e.hitTest(n)){var a=r.hasAudio||r.hasVideo||r.hasSmall,o=r.hasAuxiliary,s=i.hasAudio||i.hasVideo||i.hasSmall,c=i.hasAuxiliary;!a&&s&&e.handleRemoteStreamAdded(i.userId,"main"),!o&&c&&e.handleRemoteStreamAdded(i.userId,"auxiliary")}})).addEvent(aO.SINGLE_CONNECTION_STAT,(function(t){var n=t.room,r=t.stat;e.hitTest(n)&&(e._pathJoinRoom.int32_ice_cost=r.ice,e._pathJoinRoom.int32_dtls_cost=r.dtls,e._pathJoinRoom.int32_peer_connection_cost=r.peerConnection)}))}},{key:"uninstallEvents",value:function(){window.removeEventListener("pagehide",this.handleUnload),this._eventMap.forEach((function(e,t){return rO.off(t,e)})),this._eventMap.clear()}},{key:"destroy",value:function(){this.uninstallEvents(),MP.clearTask(this._intervalId),0===this._pathJoinRoom.uint64_start_time&&(this._room=null),this.isDestroyed=!0}},{key:"handleUnload",value:function(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}},{key:"handleJoinStart",value:function(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now()),e.params&&(bw(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),bw(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),bw(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}},{key:"handleJoinScheduleSuccess",value:function(e){var t=e.room,n=e.detailCost;if(this.hitTest(t)&&n){var r=n.totalCost,i=n.local,a=n.dns,o=n.tcp,s=n.tls,c=n.request,u=n.response;this._pathJoinRoom.int32_schedule_cost=r,this._pathJoinRoom.int32_schedule_local=i,this._pathJoinRoom.int32_schedule_dns=a,this._pathJoinRoom.int32_schedule_tcp=o,this._pathJoinRoom.int32_schedule_tls=s,this._pathJoinRoom.int32_schedule_request=c,this._pathJoinRoom.int32_schedule_response=u}}},{key:"handleSignalConnectionStart",value:function(e){var t=e.room;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleSignalConnectionEnd",value:function(e){var t=e.room,n=e.error;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),n&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=n instanceof yR?Number(n.getExtraCode()||n.getCode()):_R.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}},{key:"handleJoinSendCMD",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}},{key:"handleJoinSuccess",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}},{key:"handleJoinFailed",value:function(e){var t=this,n=e.room,r=e.error;this.hitTest(n)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=r.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((function(){t.report()})))}},{key:"handleReceivedPublishUserList",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}},{key:"handleSendFirstVideoFrame",value:function(e){var t=e.room;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}},{key:"handleLeaveStart",value:function(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}},{key:"handleLeaveSendCMD",value:function(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}},{key:"handleRemoteStreamAdded",value:function(e,t){var n,r="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(r)){var i={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:$A(QA({},jq),{msg_user_info:new Hq({userId:e,tinyId:null==(n=this._room.remotePublishedUserMap.get(e))?void 0:n.tinyId,role:20})})};i.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(r,i)}}},{key:"handleSubscribeStart",value:function(e){var t=e.room,n=e.remotePublishedUser,r=e.streamType,i=e.subscribeState;if(this.hitTest(t)){var a=n.userId,o=n.tinyId,s=n.role,c=new Hq({userId:a,tinyId:o,role:"anchor"===s?20:21}),u=Date.now(),l="".concat(a,"_").concat(r),d=this._remoteStreamStatMap.get(l);d&&0===d.subscribeStartTime&&(d.subscribeStartTime=u),"main"===r?(n.muteState.hasVideo&&(i.video||i.smallVideo)&&!this._pathMainVideoMap.has(l)&&this._pathMainVideoMap.set(l,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:a,sendSubscribeCMDTime:u}),n.muteState.hasAudio&&i.audio&&!this._pathMainAudioMap.has(l)&&this._pathMainAudioMap.set(l,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:a,sendSubscribeCMDTime:u})):n.muteState.hasAuxiliary&&i.auxiliary&&!this._pathAuxiliaryMap.has(l)&&this._pathAuxiliaryMap.set(l,{sendSubscribeCMDTime:u})}}},{key:"handleSubscribed",value:function(e){var t=e.room,n=e.remotePublishedUser,r=e.streamType;if(this.hitTest(t)){var i="".concat(n.userId,"_").concat(r),a=this._remoteStreamStatMap.get(i);a&&0===a.subscribedTime&&(a.subscribedTime=Date.now())}}},{key:"handlePlayStart",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)){var n="".concat(t.userId,"_").concat(t.streamType),r=this._remoteStreamStatMap.get(n);0===(null==r?void 0:r.playStreamTime)&&(r.playStreamTime=Date.now())}}},{key:"handleVideoLoadedData",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)){var n="".concat(t.userId,"_").concat(t.streamType),r=this._pathMainVideoMap.get(n);r&&0===r.statsToReport.uint64_combine_first_frame_time&&(r.statsToReport.uint64_combine_first_frame_time=Date.now())}}},{key:"handleVideoPlaying",value:function(e){var t="".concat(e.userId,"_").concat(e.streamType),n=Date.now(),r=this._pathMainVideoMap.get(t),i=this._remoteStreamStatMap.get(t);if(i){var a=i.statsToReport;if(a.uint32_video_render_first||"main"!==e.streamType?this.hasAuxFlag(e.userId):this.hasVideoFlag(e.userId)){var o=n-this._pathJoinRoom.uint64_start_time;a.uint32_video_render_first=o,IN.addNumber({key:516820,value:o})}}0===(null==r?void 0:r.statsToReport.uint64_render_first_frame_time)&&(r.statsToReport.uint64_render_first_frame_time=n)}},{key:"handleAudioPlaying",value:function(e){var t="".concat(e.userId,"_").concat(e.streamType),n=this._pathMainAudioMap.get(t);n&&0===n.statsToReport.uint64_play_first_frame_time&&(n.statsToReport.uint64_play_first_frame_time=Date.now())}},{key:"handleNetworkQuality",value:function(e){var t=this;this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((function(e){var n,r,i,a,o=e.rtt,s=e.loss,c=e.userId,u=e.videoDelay,l=e.audioDelay,d=t._networkQuality.totalDownlinkRTTAndLossMap.get(c);d?(d.totalRTT+=o,d.totalLoss+=s,u&&(d.totalVideoDelay=(d.totalVideoDelay||0)+u,d.videoDelayCount=(d.videoDelayCount||0)+1),l&&(d.totalAudioDelay=(d.totalAudioDelay||0)+l,d.audioDelayCount=(d.audioDelayCount||0)+1),d.count++):(u&&(r=u,i=1),l&&(n=l,a=1),t._networkQuality.totalDownlinkRTTAndLossMap.set(c,{totalRTT:o,totalLoss:s,count:1,totalAudioDelay:n,totalVideoDelay:r,audioDelayCount:a,videoDelayCount:i}))})))}},{key:"handleHeartbeatStats",value:function(e){var t=this;if(this.hitTest(e.room)){var n=e.report,r=n.msg_device_info,i=n.msg_up_stream_info,a=n.msg_down_stream_info;if(i.msg_video_status[0]){var o=i.msg_video_status[0],s=o.uint32_video_codec_bitrate,c=o.uint32_video_enc_fps,u=o.uint32_video_width,l=o.uint32_video_height;this._localStreamStat.totalVideoBitrate+=s,this._localStreamStat.totalVideoFPS+=c,this._localStreamStat.totalVideoWidth+=u,this._localStreamStat.totalVideoHeight+=l,this._localStreamStat.videoCount++}if(i.msg_audio_status){var d=i.msg_audio_status.uint32_audio_level;Math.floor(d/tN*100)>0&&(this._localStreamStat.totalAudioLevel+=d/tN,this._localStreamStat.audioLevelCount++)}a.forEach((function(e){var n=e.msg_user_info,r=e.msg_audio_status,i=e.msg_video_status,a=n.str_identifier,o=t._room.remotePublishedUserMap.get(a);if(i.forEach((function(e){var n=2===e.uint32_video_stream_type,r=7===e.uint32_video_stream_type,i="".concat(a,"_").concat(n?"main":"auxiliary"),s=t._remoteStreamStatMap.get(i);if(s&&(n&&null!=o&&o.remoteVideoTrack.isSubscribed||r&&null!=o&&o.remoteAuxiliaryTrack)){s.totalVideoFPS+=e.uint32_video_receive_fps,s.totalVideoBitrate+=e.uint32_video_codec_bitrate,s.videoCount++,0===s.statsToReport.uint32_video_width&&(s.statsToReport.uint32_video_width=e.uint32_video_width),0===s.statsToReport.uint32_video_height&&(s.statsToReport.uint32_video_height=e.uint32_video_height);var c=n?o.remoteVideoTrack:o.remoteAuxiliaryTrack;c.stat.jitterBufferDelay&&(s.videoJitterBufferDelay=c.stat.jitterBufferDelay),c.stat.framesReceived&&(s.statsToReport.uint32_video_consume_render_rate=Math.floor(c.stat.framesDecoded/c.stat.framesReceived*YA(10,6)))}})),!qw(r)){var s="".concat(a,"_main"),c=t._remoteStreamStatMap.get(s);t._remoteStreamStatMap.has(s)&&c&&null!=o&&o.remoteAudioTrack.isSubscribed&&(c.totalAudioBitrate+=r.uint32_audio_codec_bitrate,c.audioCount++,o.remoteAudioTrack.stat.jitterBufferDelay&&(c.audioJitterBufferDelay=o.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(r.uint32_audio_level/tN*100)>0&&(c.totalAudioLevel+=r.uint32_audio_level/tN,c.audioLevelCount++))}})),r.uint32_audio_capture_cost&&(this._captureCostSum+=r.uint32_audio_capture_cost,this._captureCostCount+=1,this._captureCostCount>=100&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0))}}},{key:"handlePublishStart",value:function(e){var t=e.room;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}},{key:"handleTrackCaptureStart",value:function(e){var t=e.track;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}},{key:"handleTrackCaptureSuccess",value:function(e){var t=e.track;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}},{key:"handleTrackCaptureFailed",value:function(e){var t=e.track,n=e.error,r={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[n.name]||(n instanceof yR?n.getExtraCode()||n.getCode():_R.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=r,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=r,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&oC}))>=0}},{key:"hasAudioFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&uC}))>=0}},{key:"hasAuxFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&cC}))>=0}},{key:"hitTest",value:function(e){return e===this._room}},{key:"prepareReport",value:function(){var e=this;if(this._captureCostCount>0&&!this._basicInfo.uint32_audio_capture_cost&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0),this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);var t=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),n=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=t<<16|n}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach((function(t,n){var r=t.userId,i=e._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(i){var a=i.totalLoss,o=i.count,s=i.audioDelayCount,c=i.videoDelayCount,u=i.totalAudioDelay,l=i.totalVideoDelay;t.statsToReport.uint32_avg_down_loss=Math.floor(a/o),s&&u&&(t.statsToReport.uint32_audio_network_p2p_delay=Math.floor(u/s),t.audioJitterBufferDelay&&(t.statsToReport.uint32_p2p_delay=Math.floor(t.statsToReport.uint32_audio_network_p2p_delay+t.audioJitterBufferDelay))),c&&l&&(t.statsToReport.uint32_video_network_p2p_delay=Math.floor(l/c))}t.videoCount>0&&(t.statsToReport.uint32_video_avg_fps=Math.floor(t.totalVideoFPS/t.videoCount),t.statsToReport.uint32_video_avg_bitrate=Math.floor(t.totalVideoBitrate/t.videoCount)),t.audioCount>0&&(t.statsToReport.uint32_audio_recv_bitrate=t.statsToReport.uint32_audio_bitrate=Math.floor(t.totalAudioBitrate/t.audioCount)),t.audioLevelCount>0&&(t.statsToReport.uint32_audio_play_db=Math.floor(t.totalAudioLevel/t.audioLevelCount*100));var d=e._room.callDurationCalculator;d&&(t.statsToReport.uint32_audio_play_time=d.getDuration(n,nC.AUDIO),t.statsToReport.uint32_video_play_time=d.getDuration(n,nC.VIDEO)),t.statsToReport.uint32_video_render_first&&(t.statsToReport.uint32_video_render_first=Math.min(t.statsToReport.uint32_video_render_first,qq));var h=e._room.badCaseDetector,f=h.getDataFreezeDuration(n),p=f.dataFreeze,m=f.count,v=h.getRenderFreezeDuration(n).renderFreeze;t.statsToReport.uint32_video_block_count=m,t.statsToReport.uint32_video_block_time=Math.min(p,t.statsToReport.uint32_video_play_time),t.statsToReport.uint32_video_external_block_time=Math.min(v,t.statsToReport.uint32_video_play_time),h.isBlackStream(n)&&0===t.statsToReport.uint32_video_avg_fps?t.statsToReport.uint32_video_black_screen_subjective=1:t.statsToReport.uint32_video_black_screen_subjective=0})),this._pathMainAudioMap.forEach((function(t,n){e.hasAudioFlag(t.userId)?t.statsToReport.uint64_play_first_frame_time-t.statsToReport.uint64_start_enter_time>qq&&(t.statsToReport.uint64_play_first_frame_time=t.statsToReport.uint64_start_enter_time+qq):e._pathMainAudioMap.delete(n)})),this._pathMainVideoMap.forEach((function(t,n){e.hasVideoFlag(t.userId)?t.statsToReport.uint64_render_first_frame_time-t.statsToReport.uint64_start_enter_time>qq&&(t.statsToReport.uint64_render_first_frame_time=t.statsToReport.uint64_start_enter_time+qq):e._pathMainVideoMap.delete(n)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>qq&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+qq)}},{key:"getReportData",value:function(){this._basicInfo.uint32_networkType=dw();var e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new Hq({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:Gw(this._signalInfo.relayIp),uint32_client_ip:Gw(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*YA(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:E(this._pathMainVideoMap.values()).map((function(e){return e.statsToReport})),msg_quality_statistics:E(this._remoteStreamStatMap.values()).map((function(e){return e.statsToReport})),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:E(this._pathMainAudioMap.values()).map((function(e){return e.statsToReport})),uint32_info_client_ip:Gw(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend};return nD(e),e}},{key:"report",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.prepareReport(),t=this.getReportData(),e.next=5,this.upload(t);case 5:this.initData(),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),this._log.warn(e.t0);case 11:return e.prev=11,this.isDestroyed&&(this._room=null),e.finish(11);case 14:case"end":return e.stop()}}),e,this,[[0,8,11,14]])})))}},{key:"upload",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==e.msg_path_enter_room.uint64_start_time){t.next=2;break}return t.abrupt("return");case 2:return n=Number(this._room.sdkAppId),t.next=5,oD(e);case 5:return r=t.sent,i=r instanceof ArrayBuffer,a="".concat(ow(n,zR.KEY_POINT),"&gzip=").concat(+i),o=!1,navigator.sendBeacon&&(o=navigator.sendBeacon(a,r)),s=[this.uploadKVStat(IN),this.uploadKVStat(bN)],o||s.push(aD({url:a,body:r,priority:"low"})),t.next=14,Promise.all(s);case 14:case"end":return t.stop()}}),t,this)})))}},{key:"setConnectionType",value:function(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}},{key:"uploadKVStat",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(n=e.getReportData()).stats_count.length||0!==n.stats_distribution.length){t.next=3;break}return t.abrupt("return");case 3:return n.msg_sdk_basic_info=$A(QA({},n.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(n),t.next=6,oD(n);case 6:r=t.sent,i="".concat(ow(+this._room.sdkAppId,zR.KV_STAT),"&gzip=").concat(+(r instanceof ArrayBuffer)),a=!1,navigator.sendBeacon&&(a=navigator.sendBeacon(i,r)),a||aD({url:i,body:r});case 10:case"end":return t.stop()}}),t,this)})))}}])}();nR([HP({settings:{timeout:500,retries:3}})],Bq.prototype,"upload",1);var qq=5e3,jq={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},Hq=o((function e(t){r(this,e),rR(this,"str_identifier"),rR(this,"str_tinyid"),rR(this,"uint32_role"),this.str_identifier=String(t.userId),this.str_tinyid=String(t.tinyId||0),this.uint32_role=t.role})),Gq=Bq,Wq=function(){return o((function e(){r(this,e),rR(this,"_startTime"),rR(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}),[{key:"start",value:function(){0===this._startTime&&(this._startTime=Uw())}},{key:"stop",value:function(){0===this._endTime&&(this._endTime=Uw())}},{key:"getDuration",value:function(){return 0===this._endTime?Uw()-this._startTime:this._endTime-this._startTime}},{key:"startTime",get:function(){return this._startTime}},{key:"endTime",get:function(){return this._endTime}}])}(),zq=function(){return o((function e(t){r(this,e),rR(this,"_room",null),rR(this,"_durationMap"),rR(this,"_eventMap",new Map),this._room=t.room,this._durationMap=new Map,this.installEvents()}),[{key:"installEvents",value:function(){var e=this;this._eventMap.set(aO.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(aO.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(aO.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n,r=t.room,i=t.prevMuteState,a=t.muteState,o=a.userId;if(e.hitTest(r)){i.hasAudio&&!a.hasAudio&&e.stopDurationItem("".concat(o,"_main"),nC.AUDIO),i.hasVideo&&!a.hasVideo&&e.stopDurationItem("".concat(o,"_main"),nC.VIDEO),i.hasAuxiliary&&!a.hasAuxiliary&&e.stopDurationItem("".concat(o,"_auxiliary"),nC.VIDEO);var s=null==(n=e._room)?void 0:n.remotePublishedUserMap.get(o);s&&(!i.hasAudio&&a.hasAudio&&s.remoteAudioTrack.isSubscribed&&e.addDuractionItem(o,nC.AUDIO,"main"),!i.hasVideo&&a.hasVideo&&s.remoteVideoTrack.isSubscribed&&e.addDuractionItem(o,nC.VIDEO,"main"),!i.hasAuxiliary&&a.hasAuxiliary&&s.remoteAuxiliaryTrack.isSubscribed&&e.addDuractionItem(o,nC.VIDEO,"auxiliary"))}})),this._eventMap.forEach((function(t,n){return rO.on(n,t,e)}))}},{key:"uninstallEvents",value:function(){var e=this;this._eventMap.forEach((function(t,n){return rO.off(n,t,e)})),this._eventMap.clear()}},{key:"handleSubscribed",value:function(e){var t=e.track;if(this.hitTest(t.room)){var n=t.userId,r=t.streamType,i=t.kind;t.isSubscribed?this.addDuractionItem(n,i,r):this.stopDurationItem("".concat(n,"_").concat(r),i)}}},{key:"handleUnsubscribed",value:function(e){var t=e.track;this.hitTest(t.room)&&this.stopDurationItem("".concat(t.userId,"_").concat(t.streamType),t.kind)}},{key:"isRecording",value:function(e){return e.findIndex((function(e){return 0===e.endTime}))>=0}},{key:"addDuractionItem",value:function(e,t,n){var r="".concat(e,"_").concat(n),i=new Wq,a=this._durationMap.get(r);a?this.isRecording(a[t])||a[t].push(i):this._durationMap.set(r,{userId:e,type:n,audio:t===nC.AUDIO?[i]:[],video:t===nC.AUDIO?[]:[i]})}},{key:"stopDurationItem",value:function(e,t){if(this._durationMap.has(e)){var n=this._durationMap.get(e)[t].find((function(e){return 0===e.endTime}));n&&n.stop()}}},{key:"hitTest",value:function(e){return this._room===e}},{key:"getDuration",value:function(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce((function(e,t){return e+t.getDuration()}),0):0}},{key:"getDurationMap",value:function(){return this._durationMap}},{key:"reset",value:function(){this._durationMap.clear()}},{key:"destroy",value:function(){this._room=null,this.uninstallEvents()}}])}(),Jq=function(){return o((function e(t){r(this,e),rR(this,"_room"),rR(this,"_renderFreezeMap",new Map),rR(this,"_isVideoPlayingEventFiredMap",new Map),rR(this,"_dataFreezeMap",new Map),rR(this,"_monitorFreezeData",new Map),rR(this,"_eventMap",new Map),this._room=t.room,this.installEvents()}),[{key:"getRenderFreezeMap",value:function(){return this._renderFreezeMap}},{key:"getDataFreezeMap",value:function(){return this._dataFreezeMap}},{key:"installEvents",value:function(){var e=this;this._eventMap.set(aO.LEAVE_SUCCESS,(function(t){var n=t.room;e.hitTest(n)&&e.stop()})).set(aO.PLAY_TRACK_START,this.onPlayTrackStart).set(aO.UNSUBSCRIBE_SUCCESS,(function(t){var n=t.room,r=t.streamType,i=t.remotePublishedUser;if(e.hitTest(n)){var a=i.userId,o="".concat(a,"_").concat(r);e.stopDataFreeze({key:o,userId:a,type:r})}})).set(aO.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n=t.room,r=t.prevMuteState,i=t.muteState;if(e.hitTest(n)){var a=i.userId;if(r.hasVideo&&!i.hasVideo){var o="main",s="".concat(i.userId,"_").concat(o);e.stopDataFreeze({key:s,userId:a,type:o})}if(r.hasAuxiliary&&!i.hasAuxiliary){var c="auxiliary",u="".concat(i.userId,"_").concat(c);e.stopDataFreeze({key:u,userId:a,type:c})}}})).set(aO.PLAYER_STATE_CHANGED,(function(t){var n=t.track,r=t.state,i=t.reason,a=t.type;if(n.isRemote&&n.room&&e.hitTest(n.room)&&a===nC.VIDEO){if("PLAYING"===r){var o="".concat(n.userId,"_").concat(n.streamType);e._isVideoPlayingEventFiredMap.set(o,!0)}i===nC.MUTE?e.onVideoTrackMuted(n):i===nC.UNMUTE&&e.onVideoTrackUnmuted(n)}})).set(aO.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach((function(t,n){return rO.on(n,t,e)}))}},{key:"uninstallEvents",value:function(){var e=this;this._eventMap.forEach((function(t,n){return rO.off(n,t,e)})),this._eventMap.clear()}},{key:"stop",value:function(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}},{key:"onVideoTrackMuted",value:function(e){if(e.isSubscribed){var t=e.userId,n=e.streamType,r="".concat(t,"_").concat(n),i=this._dataFreezeMap.get(r),a=new Wq;i?i.durationItemList.push(a):this._dataFreezeMap.set(r,{userId:t,type:n,durationItemList:[a],isFreezing:function(){var e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}}},{key:"onVideoTrackUnmuted",value:function(e){if(e.isSubscribed){var t=e.userId,n=e.streamType,r="".concat(t,"_").concat(n);this.stopDataFreeze({key:r,userId:t,type:n})}}},{key:"onHearBeatReport",value:function(e){var t=this,n=e.room,r=e.report;this.hitTest(n)&&r.msg_down_stream_info.forEach((function(e){var n=t._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(n){var r=n.userId,i=n.muteState;e.msg_video_status.forEach((function(e){2===e.uint32_video_stream_type&&i.hasVideo&&!i.videoMuted&&n.remoteVideoTrack.isSubscribed&&t.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&i.hasAuxiliary&&n.remoteAuxiliaryTrack.isSubscribed&&t.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}}))}},{key:"stopDataFreeze",value:function(e){var t=e.key,n=e.userId,r=e.type,i=this._dataFreezeMap.get(t);if(i&&i.isFreezing()){var a=i.durationItemList[i.durationItemList.length-1];a.stop();var o=a.getDuration();o>BC?this._monitorFreezeData.set(t,{userId:n,type:r,duration:o}):i.durationItemList.pop()}}},{key:"getTotalDuration",value:function(e){return e.reduce((function(e,t){var n=t.getDuration();return e+Math.min(n,5e3)}),0)}},{key:"handleRenderFreeze",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.userId,r=e.fps,i=e.type;return f().mark((function e(){var a,o,s,c,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a="".concat(n,"_").concat(i),o=t._renderFreezeMap.get(a),r<=2?(s=Uw(),o&&!o.isFreeze&&(o.freezeTimeline.push({startTime:s,endTime:0}),o.isFreeze=!0),o||t._renderFreezeMap.set(a,{userId:n,type:i,isFreeze:!0,freezeTimeline:[{startTime:s,endTime:0}],renderFreezeTotal:0})):o&&o.isFreeze&&(o.isFreeze=!1,(c=o.freezeTimeline.pop())&&(c.endTime=Uw(),u=c.endTime-c.startTime,o.freezeTimeline.push(c),o.renderFreezeTotal+=Math.min(5e3,u)));case 2:case"end":return e.stop()}}),e)}))()}))}},{key:"onPlayTrackStart",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)&&t.kind===nC.VIDEO&&t.isRemotePublished){var n="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(n)||this._isVideoPlayingEventFiredMap.set(n,!1)}}},{key:"getDataFreezeDuration",value:function(e){var t={dataFreeze:0,count:0},n=this._dataFreezeMap.get(e);if(n){if(n.isFreezing()){var r=n.durationItemList[n.durationItemList.length-1];r.stop(),r.getDuration()<BC&&n.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(n.durationItemList),t.count=n.durationItemList.length}return t}},{key:"getRenderFreezeDuration",value:function(e){var t=this._renderFreezeMap.get(e),n=0,r=0;if(t)if(t.isFreeze){var i=Uw()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;n=t.renderFreezeTotal+Math.min(i,5e3),r=t.freezeTimeline.length}else n=t.renderFreezeTotal;return{renderFreeze:n,count:r}}},{key:"getMonitorFreeze",value:function(){return this._monitorFreezeData}},{key:"isBlackStream",value:function(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}},{key:"resetMonitor",value:function(){this._monitorFreezeData.clear()}},{key:"hitTest",value:function(e){return e===this._room}},{key:"destroy",value:function(){this.uninstallEvents()}}])}(),Kq=tR(oR(),1),Yq=[1,0,0,0,1,1,0,1],Xq=function(e){function t(e,i){var a;if(r(this,t),a=n(this,t,[e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"mirror",logger:i}]),e instanceof hF)try{a.setTexBuffer(Yq)}catch(DC){e.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(a.name," error ").concat(DC.message||DC)}))}return a}return d(t,e),o(t,[{key:"draw2d",value:function(e,n,r,i,a){if(this.ctx2d){this.ctx2d.save(),this.ctx2d.scale(-1,1),this.ctx2d.translate(-this.width,0);var o=g(t,"draw2d",this,3)([e,n,r,i,a]);return this.ctx2d.restore(),o}return!1}},{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}}])}(ZV),Qq=function(){return o((function e(t,n){r(this,e),this.node=t,this.layout=n,rR(this,"positionBuffer")}),[{key:"x",get:function(){return this.layout.x||this.node.x}},{key:"y",get:function(){return this.layout.y||this.node.y}},{key:"width",get:function(){return this.layout.width||this.node.width}},{key:"height",get:function(){return this.layout.height||this.node.height}},{key:"right",get:function(){return this.x+this.width}},{key:"bottom",get:function(){return this.y+this.height}}])}(),$q=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,logger:a}]),rR(t(o),"inputs",[]),o}return d(i,e),o(i,[{key:"addInput",value:function(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");var n=new Qq(e,t);this.inputs[t.zIndex]=n}},{key:"resize",value:function(e,t){var n=this,r=this.inputs.reduce((function(e,t){return t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e}),{width:0,height:0});g(i,"resize",this,3)([r.width,r.height]),this.context instanceof hF&&this.inputs.forEach((function(e){if(e){var t=n.layout2texCoords(e);e.positionBuffer?n.changeBufferData(e.positionBuffer,t):e.positionBuffer=n.createBuffer(t)}}))}},{key:"connect",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return g(i,"connect",this,3)([e].concat(n)),this.resize(0,0),e}},{key:"removeInput",value:function(e){this.inputs[this.inputs.findIndex((function(t){return(null==t?void 0:t.node)===e}))]=void 0}},{key:"render",value:function(e){var t=this.context.ctx;if(t.clearColor(0,0,0,0),!this.inputs.reduce((function(t,n){return(!n||!n.node.requestFrame(e))&&t}),!0)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(var n=0;n<this.inputs.length;n++){var r=this.inputs[n];r&&(r.node.useTexture(),this.draw(r.positionBuffer))}return!0}return!1}},{key:"render2d",value:function(e){if(!this.inputs.reduce((function(t,n){return(!n||!n.node.requestFrame(e))&&t}),!0)&&this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height);for(var t=0;t<this.inputs.length;t++){var n=this.inputs[t];n&&this.draw2d(n.node.image,n.x,n.y,n.width,n.height)}return!0}return!1}},{key:"getInfo",value:function(){var e=this.totalFrames,t=this.x,n=this.y,r=this.width,i=this.height,a=this.name,o=Date.now(),s=(e-this.lastInfo.totalFrames)/((o-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:n,width:r,height:i,timestamp:o,fps:s,name:a},QA({parent:this.inputs.filter((function(e){return e})).map((function(e){return e.node.getInfo()}))},this.lastInfo)}},{key:"close",value:function(){var e=this;g(i,"close",this,3)([]),this.inputs.forEach((function(t){var n,r;if(t&&(null==(n=t.node)||n.disconnect(),t.positionBuffer&&e.context instanceof hF))try{null==(r=e.context.ctx)||r.deleteBuffer(t.positionBuffer)}catch(yO){}}))}}])}(ZV),Zq=function(e){function i(e,a){var o;r(this,i),o=n(this,i,[e,a.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0,logger:e.log}]),rR(t(o),"_bgTexture"),rR(t(o),"_waterMarkTexture"),rR(t(o),"_lastMaskTexture"),rR(t(o),"_lastMaskFbo"),rR(t(o),"_textureValid",!1),rR(t(o),"_selfieTextureValid",!1),rR(t(o),"_selfieSegmentation"),rR(t(o),"wasm"),rR(t(o),"_prePrograme"),rR(t(o),"_segmentationMask"),rR(t(o),"_weixin",!1),a.selfieSegmentation&&(o._selfieSegmentation=a.selfieSegmentation,o._selfieSegmentation.onResults=o.onPredict.bind(t(o)));try{o.init(a)}catch(vO){e.log.error(vO),e.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(vO.message||vO)}))}return o}return d(i,e),o(i,[{key:"init",value:function(e){var t=e.Wasm,n=this.context.ctx;if(this.wasm=new t.AllIn1(n),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"green"===e.bg?3:0,e.waterMark){var r=e.waterMark,i=r.x,a=r.y,o=r.width,s=r.height;this.wasm.setWaterMark(i,a,o,s)}if(e.beautyParams){var c=e.beautyParams,u=c.beauty,l=c.brightness,d=c.ruddy;this.wasm.setBeauty(u,l,d,null==e?void 0:e.width,null==e?void 0:e.height)}if(this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(n.uniform1i(n.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(n.uniform1i(n.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image)),n.uniform1i(n.getUniformLocation(this.program,"lastMask"),4),this._weixin){var h=this.context.createShader(n.FRAGMENT_SHADER,"#version 300 es\nprecision highp float;\nuniform sampler2D u_texture;\nuniform sampler2D mask;\n\nin vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {\n outColor = vec4(texture(u_texture, v_texCoord).rgb, texture(mask, v_texCoord).a);\n}"),f=this.context.createShader(n.VERTEX_SHADER,"#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}");this._prePrograme=this.context.createProgram(f,h),n.useProgram(this._prePrograme),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this._prePrograme,"mask"),1)}}},{key:"onPredict",value:function(e){var t,n=this.context.ctx;this._weixin&&(this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image),this._lastMaskFbo=this.createFramebuffer(this._lastMaskTexture))),this.useProgram(),this._weixin?this.useTexture():null==this||this._selfieSegmentation.bindTexture(),n.activeTexture(n.TEXTURE1),null==(t=this._selfieSegmentation)||t.bindTexture2d(e),n.activeTexture(n.TEXTURE2),n.bindTexture(n.TEXTURE_2D,this._bgTexture||null),n.activeTexture(n.TEXTURE3),n.bindTexture(n.TEXTURE_2D,this._waterMarkTexture||null),this.useBufferFrame(),n.drawArrays(n.TRIANGLE_STRIP,0,4),this._segmentationMask=e,this.totalFrames++}},{key:"render",value:function(e){var t,n,r,i,a=this.context.ctx,o=this.image;this.tryVideoFrameCallback(o);var s=o.videoWidth,c=o.videoHeight;if(0===s||0===c)return!1;o.width=s,o.height=c;var u=!1;if(this.totalFrames)this._weixin?this.useTexture():null==(t=this._selfieSegmentation)||t.bindTexture(),u=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),u=this._textureValid,this._textureValid=!0}return this.width===s&&this.height===c&&u?a.texSubImage2D(a.TEXTURE_2D,0,0,0,a.RGBA,a.UNSIGNED_BYTE,o):(this.resize(s,c),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,o)),this._weixin&&(a.useProgram(this._prePrograme),this.useTexture(),this._segmentationMask&&(a.activeTexture(a.TEXTURE1),null==(n=this._selfieSegmentation)||n.bindTexture2d(this._segmentationMask),a.bindFramebuffer(a.FRAMEBUFFER,this._lastMaskFbo||null)),a.drawArrays(a.TRIANGLE_STRIP,0,4),null==(r=this._selfieSegmentation)||r.bindTexture(),this._segmentationMask?a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,s,c):a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,s,c,0)),null==(i=this._selfieSegmentation)||i.send(s,c),this.totalFrames||(a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,this._bgTexture||null),a.activeTexture(a.TEXTURE3),a.bindTexture(a.TEXTURE_2D,this._waterMarkTexture||null),a.drawArrays(a.TRIANGLE_STRIP,0,4)),!1}},{key:"close",value:function(){var e;g(i,"close",this,3)([]);var t=this.context.ctx;this._bgTexture&&t.deleteTexture(this._bgTexture),this._waterMarkTexture&&t.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&t.deleteTexture(this._lastMaskTexture),this._lastMaskFbo&&t.deleteFramebuffer(this._lastMaskFbo),this._prePrograme&&t.deleteProgram(this._prePrograme),null==(e=this.wasm)||e.close()}}])}(cF),ej=function(e){function i(e){var a;r(this,i),a=n(this,i,[e,{name:"yuv-source",useDefaultProgram:!1,create2d:!1,useFbo:!1,createTexture:!1,logger:e.log,fragmentShaderSource:"\n precision highp float;\n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n varying highp vec2 textureCoord;\n const mat4 YUV2RGB = mat4(\n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n void main() {\n vec3 yuv;\n yuv.r = texture2D(ySampler, textureCoord).r;\n yuv.g = texture2D(uSampler, textureCoord).r;\n yuv.b = texture2D(vSampler, textureCoord).r;\n gl_FragColor = vec4(yuv,1) * YUV2RGB;\n }\n ",vertexShaderSource:"\n attribute vec4 vertexPos;\n attribute vec2 texturePos;\n varying vec2 textureCoord;\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos;\n }"}]),rR(t(a),"yTextureRef"),rR(t(a),"uTextureRef"),rR(t(a),"vTextureRef"),rR(t(a),"Y"),rR(t(a),"U"),rR(t(a),"V"),a.useProgram();var o=a.context.ctx;return o.pixelStorei(o.PACK_ALIGNMENT,1),o.pixelStorei(o.UNPACK_ALIGNMENT,1),a.setTexBuffer([0,1,1,1,0,0,1,0]),a.yTextureRef=a._initTexture("ySampler",0),a.uTextureRef=a._initTexture("uSampler",1),a.vTextureRef=a._initTexture("vSampler",2),a._canvas=e._canvas,a}return d(i,e),o(i,[{key:"_initTexture",value:function(e,t){var n=this.context.ctx,r=n.createTexture();return n.bindTexture(n.TEXTURE_2D,r),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.bindTexture(n.TEXTURE_2D,null),n.uniform1i(n.getUniformLocation(this.program,e),t),r}},{key:"render",value:function(e){var t=this.context.ctx,n=this.width,r=this.height;return this.useProgram(),t.viewport(0,0,n,r),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.yTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n,r,t.LUMINANCE,t.UNSIGNED_BYTE,this.Y),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.uTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n/2,r/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.U),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.vTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n/2,r/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.V),this.draw(),!0}},{key:"resize",value:function(e,t){g(i,"resize",this,3)([e,t]);var n=this.context.ctx;n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,this.yTextureRef),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e,t,0,n.LUMINANCE,n.UNSIGNED_BYTE,null),n.activeTexture(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this.uTextureRef),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e/2,t/2,0,n.LUMINANCE,n.UNSIGNED_BYTE,null),n.activeTexture(n.TEXTURE2),n.bindTexture(n.TEXTURE_2D,this.vTextureRef),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e/2,t/2,0,n.LUMINANCE,n.UNSIGNED_BYTE,null)}}])}(ZV),tj=[function(e){e.codec="avc1.420028"},function(e){delete e.hardwareAcceleration}],nj=function(e,t){switch(e){case"webCodecs":return"videoFrame"===t?514705:514706;case"wasm":return"webgl"===t?514707:"videoFrame"===t?514708:514709}throw new Error("decoder type not supported")},rj=0,ij=function(){return o((function e(t){var n=this;r(this,e),rR(this,"id",rj++),rR(this,"trackDoneOB"),rR(this,"startOB"),rR(this,"stopOB"),rR(this,"decoder"),rR(this,"videoContext"),rR(this,"gop",0),rR(this,"gop_helper",0),rR(this,"waitFirstKeyFrame",!0),rR(this,"startTimestamp",0),rR(this,"startTime",0),rR(this,"startPerformanceTime",0),rR(this,"inputFrameCount",0),rR(this,"decodedFrameCount",0),rR(this,"decodeFrameCount",0),rR(this,"downgradeLevel",0),rR(this,"lastDowngradeTime",0),rR(this,"lastFrameDiff",0),rR(this,"lastDecodeFrameTimestamp",0),rR(this,"config"),rR(this,"gop_before_configure",[]),rR(this,"videoElement"),rR(this,"type","wasm"),rR(this,"goodType"),rR(this,"renderer","2d"),rR(this,"wasmOption"),rR(this,"createDecoder"),rR(this,"_decodeSink"),rR(this,"isReported",!1),rR(this,"track"),rR(this,"stateChangeOB"),rR(this,"failedReason");var i=t.track,a=t.createDecoder;if(this.stateChangeOB=fU(),this.track=i,this.createDecoder=a,this.wasmOption={yuvMode:"webgl"===t.renderer,wasmPath:t.wasmPath,workerMode:t.workerMode,canvas:t.canvas},this.config=t.config,this.videoElement=t.videoElement,this.renderer=t.renderer,this.trackDoneOB=SU(i.availableState,wP.OFF),this.stopOB=fU(this.trackDoneOB),"auto"===t.type){switch(t.fallback){case"wasm":this.type="wasm",this.renderer="webgl";break;case"wasm_2d":this.type="wasm",this.renderer="2d";break;case"wasm_video":this.type="wasm",this.renderer="videoFrame";break;default:this.type="webCodecs"}this.wasmOption.yuvMode="webgl"===this.renderer}else this.type=t.type;this.changeRenderer(this.renderer),zL(this.stateChangeOB,fV((function(e,t){return e!==t&&i.onDecodeDowngradeStateChanged({type:n.type,renderer:n.renderer,reason:n.failedReason,prevState:e,state:t}),t}),"INITIALIZED"),WU(this.stopOB),GV()),this.start()}),[{key:"start",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.waitFirstKeyFrame=!0,this.stateChangeOB.next("STARTING");var n=zL(this.pipe(this.track),WU(this.stopOB),eU());zL(n,GV((function(){e.track.stat.framesDecoded++}),(function(n){if(e.track.log.error("".concat(e.id," play failed: ").concat(n," retryCount: ").concat(t)),IN.addFailedEvent({key:nj(e.type,e.renderer),error:n}),t>4)e.failedReason=n,e.stateChangeOB.next("FAILED");else{if(e.goodType)return void e.start(t);switch(e.type){case"webCodecs":e.type="wasm",e.changeRenderer("webgl");break;case"wasm":"webgl"===e.renderer&&e.changeRenderer("videoFrame")}e.start(t+1)}}),(function(){e.track.log.warn("".concat(e.id," decoderOB completed")),IN.addSuccessEvent({key:nj(e.type,e.renderer)}),IN.addSuccessEvent({key:514704})}))),zL(n,GU(1),GV((function(){e.track.player.handlePlaying("canvas"),e.goodType=e.type,e.stateChangeOB.next("STARTED")})))}},{key:"mock",value:function(e){this._decodeSink?this._decodeSink.error(e):this.start()}},{key:"close",value:function(e){this.stopOB.next(e)}},{key:"changeRenderer",value:function(e){this.renderer=e,"videoFrame"===this.renderer&&!PN()&&(this.renderer="2d"),this.wasmOption.yuvMode="webgl"===this.renderer}},{key:"decode",value:function(e){var t,n,r=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.failedReason){this.inputFrameCount++;var a,o=new Uint8Array(e.data);if(0!==(a=o)[0]||0!==a[1]||0!==a[2]||1!==a[3]||o.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(o.subarray(0,5))),e;var s=!1;switch(31&o[4]){case 5:case 7:s=!0}if("configured"!==(null==(t=this.decoder)?void 0:t.state))return this.track.log.debug("not configured ".concat(this.inputFrameCount)),s&&(this.gop_before_configure=[]),this.gop_before_configure.push({data:e.data,timestamp:e.timestamp,type:e.type}),e;this.gop_before_configure.length>0&&!i&&(this.gop_before_configure.forEach((function(e){return r.decode(e,!0)})),this.gop_before_configure=[]);var c=e.timestamp;if(s?(this.gop=this.gop_helper,this.gop_helper=0):this.gop_helper++,this.decoder){if(this.waitFirstKeyFrame){if(!s)return void this.track.log.debug("wait first key frame ".concat(this.inputFrameCount," ").concat(o.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=c,this.startTime=Date.now(),this.startPerformanceTime=Uw()}switch(this.downgradeLevel){case 0:case 1:break;case 2:if(this.gop_helper>this.gop>>1)return;break;case 3:if(this.gop_helper>0)return;break;default:return}return(this.decodeFrameCount<10||this.decodeFrameCount%500==0)&&this.track.log.debug("decode ".concat(this.decodeFrameCount," gop: ").concat(this.gop," ").concat(c," ").concat(null==(n=e.getMetadata)?void 0:n.call(e).rtpTimestamp)),this.decodeFrameCount++,this.lastDecodeFrameTimestamp=c,void this.decoder.decode({data:e.data,type:e.type,timestamp:this.lastDecodeFrameTimestamp})}return e}}},{key:"checkDowngradeByFrameDiff",value:function(){var e=this.downgradeLevel,t=this.decodeFrameCount-this.decodedFrameCount;t>this.lastFrameDiff?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):t<=this.lastFrameDiff&&this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==e&&this.track.log.debug("downgrade level ".concat(e," to ").concat(this.downgradeLevel," ").concat(this.decodeFrameCount," frameDiff: ").concat(t,", lastFrameDiff: ").concat(this.lastFrameDiff)),this.lastFrameDiff=t,this.lastDowngradeTime=Date.now()}},{key:"checkDowngradeByTimestampDiff",value:function(e){var t=this.downgradeLevel;this.lastDecodeFrameTimestamp-e>9e4?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==t&&this.track.log.debug("downgrade level ".concat(t," to ").concat(this.downgradeLevel))}},{key:"pipe",value:function(e){var t=this;return function(n){return aR(t,null,f().mark((function t(){var r,i,a,o,s,c,u,l,d,h,p,m=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._decodeSink=n,i=e.mediaTrack,n.defer((function(){var t;e.player.setCanvas(),e.setInputMediaStreamTrack(i),null==r||r.close(),null==(t=m.videoContext)||t.destroy(),delete m._decodeSink})),a=this.renderer,o=this.type,e.log.info("decoder type: ".concat(this.type," renderer: ").concat(this.renderer)),t.prev=5,t.t0=o,t.next="wasm"===t.t0?9:"webCodecs"===t.t0?11:27;break;case 9:return r=this.createDecoder(o,this.wasmOption),t.abrupt("break",28);case 11:s=0;case 12:if(!(s<=tj.length)){t.next=25;break}return t.next=15,VideoDecoder.isConfigSupported(this.config);case 15:if(!t.sent.supported){t.next=19;break}return t.abrupt("break",25);case 19:if(s!==tj.length){t.next=21;break}return t.abrupt("return",void n.error(3));case 21:tj[s](this.config);case 22:s++,t.next=12;break;case 25:return r=this.createDecoder(o),t.abrupt("break",28);case 27:throw new Error("not supported yet");case 28:return c=0,r.on("videoFrame",(function(t){m.decodedFrameCount++,(++c<=10||c%500==0)&&e.log.debug("frame ".concat(c," ").concat(m.decodedFrameCount,"/").concat(m.decodeFrameCount," decoded ").concat(t.timestamp)),Date.now()-m.lastDowngradeTime>5e3&&("webCodecs"===m.type?m.checkDowngradeByFrameDiff():"wasm"===m.type&&m.checkDowngradeByTimestampDiff(t.timestamp)),n.next(t)})),r.on("error",(function(t){e.log.error(t),n.error("webCodecs"===o?4:8)})),t.next=33,r.initialize(this.videoElement);case 33:if(this._decodeSink){t.next=35;break}return t.abrupt("return");case 35:r.configure(this.config),"wasm"===o&&"webgl"===a?(this.videoContext=new hF({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create(),this.videoContext.on(hF.UNAVAILABLE,(function(t){e.log.error(t),n.error(7)})),u=new ej(this.videoContext),r.on("videoCodecInfo",(function(e){return u.resize(e.width,e.height)})),r.on("videoFrame",(function(e){u.Y=e.y,u.U=e.u,u.V=e.v,1===m.downgradeLevel?m.decodedFrameCount%2==0&&u.render(m.decodedFrameCount):u.render(m.decodedFrameCount)})),e.source=u,e.player.setCanvas(this.videoContext._canvas,2)):"videoFrame"===a?(e.player.setCanvas(),l=new MediaStreamTrackGenerator({kind:"video"}),d=l.writable.getWriter(),e.setInputMediaStreamTrack(l),r.on("videoFrame",(function(e){return d.write(e)}))):(this.videoContext=new fF({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create({alpha:!1}),h=this.videoContext.createVideoImageSource(),r.on("videoFrame",(function(e){h.image=e,h.update()})),p=new nF(this.videoContext,{name:"remotePlayer",logger:e.log}),h.connect(p),e.source=h,e.player.setCanvas(this.videoContext._canvas,2)),this.decoder=r,t.next=42;break;case 39:t.prev=39,t.t1=t.catch(5),e.log.error(t.t1),n.error("webCodecs"===o?2:6);case 42:case"end":return t.stop()}}),t,this,[[5,39]])})))}}}])}(),aj=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).room=e,rR(t(a),"videoContext"),rR(t(a),"_glVideoContext"),rR(t(a),"_2dVideoContext"),rR(t(a),"destination"),rR(t(a),"smallVideoContext"),rR(t(a),"smallDestination"),rR(t(a),"smallTrackSource"),rR(t(a),"smallImageSource"),rR(t(a),"_isMirror",!1),rR(t(a),"cameraTrack"),rR(t(a),"cameraNode"),rR(t(a),"mirrorNode"),rR(t(a),"mixNode"),rR(t(a),"screenTrack"),rR(t(a),"screenNode"),rR(t(a),"selfModel",!1),rR(t(a),"blurRadius",3),rR(t(a),"arTrack"),rR(t(a),"Wasm"),rR(t(a),"waterMarkNode"),rR(t(a),"_waterMarkOption"),rR(t(a),"watermarkImageList",[]),rR(t(a),"_beautyParams"),rR(t(a),"isUsingArTrack",!1),rR(t(a),"_isMixScreen",!1),rR(t(a),"_virtualBackground"),rR(t(a),"_virtualBackgroundAbortCallback"),rR(t(a),"virtualBackgroundInstance"),rR(t(a),"_bgAssetPath"),rR(t(a),"log",sO.createLogger({id:"vm"})),rR(t(a),"_checkId",0),rR(t(a),"_use2d",!1),rR(t(a),"_autoSwitchRenderMode",!0),rR(t(a),"_selfieSegmentation"),rR(t(a),"encodePipeline",[]),rR(t(a),"decodePipeline",[]),e&&(a.log.setUserId(e.userId),a.log.setSdkAppId(e.sdkAppId)),a.smallVideoContext=new fF({frameRate:15,logger:a.log,name:"s"}),a.enablePrintDetail(),a}return d(i,e),o(i,[{key:"_hasVirtualBg",get:function(){return!!this._virtualBackground}},{key:"_hasWaterMark",get:function(){return this.watermarkImageList.length>0}},{key:"renderMode",get:function(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"},set:function(e){if(this._autoSwitchRenderMode="auto"===e,!this._autoSwitchRenderMode){var t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}}},{key:"get2dVideoContext",value:function(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new fF({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this._2dVideoContext}},{key:"getGlVideoContext",value:function(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new hF({frameRate:15,logger:this.log,name:"m"});return this.initializeGlVideoContext(),this._glVideoContext}},{key:"initializeGlVideoContext",value:function(){var e=this;try{this._glVideoContext.create(),this._glVideoContext.on(hF.UNAVAILABLE,(function(t){var n;e.emit("error",t),e.log.warn("video context unavailable",t),null==(n=e._virtualBackgroundAbortCallback)||n.call(e,t),e.update().catch((function(t){e.log.error(t)}))}))}catch(wR){this.emit("error",wR)}}},{key:"enablePrintDetail",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=MP.run("interval",(function(){e.destination&&e.log.debug(e.destination.getInfo())}),{delay:t})}},{key:"destroy",value:function(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),MP.clearTask(this._checkId)}},{key:"needAlpha",get:function(){return this._hasWaterMark||this._hasVirtualBg}},{key:"active",get:function(){return(Nx||this._isMixScreen||this._isMirror||this._hasWaterMark||this._hasVirtualBg||this._beautyParams)&&this.checkOrCreateVideoContext()}},{key:"sendCreateResult",value:function(){var e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?IN.addFailedEvent({key:t,error:e}):IN.addSuccessEvent({key:t})}},{key:"checkOrCreateVideoContext",value:function(){var e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){var t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else{if(this._glVideoContext=new hF({frameRate:15,logger:this.log,name:"m"}),this.initializeGlVideoContext(),this._glVideoContext.available)return this.videoContext=this._glVideoContext,this.videoContext.available;this.log.warn("webgl is still not available"),this.clear(),this._use2d=!0}return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}},{key:"smallTrack",get:function(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}},{key:"hasSmall",get:function(){return!!this.smallTrack}},{key:"initialTrack",get:function(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}},{key:"initVirtualBackground",value:function(e){return this._selfieSegmentation=e,this._selfieSegmentation.changeModel()}},{key:"setSmallVideo",value:function(e,t){var n=this;if(e){if(!this.smallVideoContext.available){if(this.smallVideoContext.create({alpha:!1}),!this.smallVideoContext.available)return;this.smallDestination=new aF(this.smallVideoContext,e,this.log),this.smallVideoContext.on(hF.UNAVAILABLE,(function(e){n.log.warn("small video context lost",e)}))}this.smallVideoContext.frameRate=e.frameRate,this.smallDestination.resolution=e,t?(this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=t:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(t),this.smallImageSource.connect(this.smallDestination))):(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource?this.smallTrackSource.replaceTrack(this.initialTrack):(this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack,"smallTrackSource"),this.smallTrackSource.connect(this.smallDestination)))}else this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource)}},{key:"_setMainOutput",value:function(e){var t;try{var n=this.cameraTrack,r=n.small,i=n.player;this.setSmallVideo(r,e),Nx&&i.setCanvas(e);var a=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),a=this.arTrack),this._selfieSegmentation&&e&&!this._use2d&&(this._selfieSegmentation._glName||this._selfieSegmentation.setCanvas(e)),this.log.info("set main output ".concat(a?a.label:"no output track")),n.setOutputMediaStreamTrack(a)}catch(vO){this.log.error("set main output failed",vO)}}},{key:"update",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cameraTrack&&this.cameraTrack.mediaTrack){e.next=2;break}return e.abrupt("return");case 2:if(this.active){e.next=4;break}return e.abrupt("return",(this.cameraNode&&this.clear(),this._setMainOutput()));case 4:return r=this.cameraTrack,i=r.settings,a=r.profile,this._use2d||!this._virtualBackground&&!this._beautyParams?(this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log})),16===Ux?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof cF?(this.cameraNode.close(),delete this.cameraNode):this.cameraNode.image=this.initialTrack.canvas),this.cameraNode||(this.cameraNode=this.videoContext.createVideoImageSource(this.initialTrack.canvas,{name:"cameraCanvasSource",logger:this.log}))):(this.cameraNode&&(this.cameraNode instanceof cF?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode.close(),delete this.cameraNode)),this.cameraNode||(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraTrackSource"))):this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraNodeSource"),this.cameraNode.resize(i.width,i.height)):(this.cameraNode&&this.cameraNode.close(),this.destination?this.destination.disableCheckMute():this.destination=new iF(this.videoContext,{name:"mainDestination",logger:this.log}),this.cameraNode=new Zq(this.videoContext,{input:this.cameraTrack.mediaTrack,width:i.width,height:i.height,mirror:this._isMirror,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,beautyParams:this._beautyParams,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,selfieSegmentation:this._selfieSegmentation,Wasm:this.Wasm}),this.cameraNode.connect(this.destination),this.destination.enableCheckMute()),this.videoContext.frameRate=a.frameRate,this._use2d&&((o=this.cameraNode).disconnect(),this._isMirror&&(this.mirrorNode||(this.mirrorNode=new Xq(this.videoContext,this.log)),(o=o.connect(this.mirrorNode)).disconnect(),this.log.info("start mirror")),this.mixNode&&this.mixNode.close(),delete this.mixNode,(this._isMixScreen||this._hasWaterMark)&&(this.mixNode=new $q(this.videoContext,this.log),o.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption&&(this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1,logger:this.log}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y),null==(t=this.waterMarkNode)||t.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&!this.screenNode&&(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource")),null==(n=this.screenNode)||n.connect(this.mixNode,{zIndex:0}),o=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))),o.connect(this.destination)),e.abrupt("return",(this.log.info("update ".concat(this._use2d?"2d":"webgl")),this._setMainOutput(this.videoContext._canvas)));case 7:case"end":return e.stop()}}),e,this)})))}},{key:"changeInput",value:function(e){var t,n,r,i;if(e instanceof wL)return this.log.info("change screen input",null==(t=e.mediaTrack)?void 0:t.label),this.setScreenTrack(e);if(e instanceof AL)return this.log.info("change video input",null==(n=e.mediaTrack)?void 0:n.label),this.setCameraTrack(e);if(e instanceof pF){this.log.info("change remote input",null==(r=e.mediaTrack)?void 0:r.label);var a=e.mediaTrack;return e.setOutputMediaStreamTrack(a)}this.log.warn("change unknown input",null==(i=e.mediaTrack)?void 0:i.label)}},{key:"removeInput",value:function(e){var t;e instanceof wL?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof AL?(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):e instanceof pF&&e.source&&e.source.context.destroy()}},{key:"setCameraTrack",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.cameraTrack=e,this.update();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"setScreenTrack",value:function(e){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}},{key:"getWatermarkImage",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=document.createElement("canvas"),t&&e&&(r.height=t,r.width=e),i=r.getContext("2d")){n.next=5;break}throw new yR({code:_R.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});case 5:return n.abrupt("return",(this.watermarkImageList.sort((function(e,t){return e.zIndex-t.zIndex})),this.watermarkImageList.forEach((function(e){var t=e.image,n=e.x,r=e.y,a=e.width,o=e.height;i.drawImage(t,n,r,a,o)})),eD(r.toDataURL())));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"pushWaterMarkImageList",value:function(e){var t=e.type;this.watermarkImageList.some((function(t){return t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex}))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((function(e){return e.type!==t}))),this.watermarkImageList.push(e))}},{key:"setBeautyParams",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._beautyParams=e,this.update();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"stopBeauty",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._beautyParams=void 0,this.update();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"setWatermark",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d,h,p,m,v,_;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,eD((null==e?void 0:e.imageElement)||e.imageUrl);case 3:i=t.sent,t.next=9;break;case 6:throw t.prev=6,t.t0=t.catch(0),new yR({code:_R.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)});case 9:if(a=e.x,o=void 0===a?0:a,s=e.y,c=void 0===s?0:s,u=e.width,l=void 0===u?i.width:u,d=e.height,h=void 0===d?i.height:d,p=e.type,m=void 0===p?"watermark":p,v=e.zIndex,_=void 0===v?2:v,!this.watermarkImageList.some((function(e){return e.type===m}))){t.next=20;break}return this.watermarkImageList=this.watermarkImageList.filter((function(e){return e.type!==m})),this.pushWaterMarkImageList({x:o,y:c,width:l,height:h,image:i,zIndex:_,type:m,imageUrl:e.imageUrl}),t.next=15,this.getWatermarkImage(null==(n=this.cameraTrack)?void 0:n.settings.width,null==(r=this.cameraTrack)?void 0:r.settings.height);case 15:i=t.sent,this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.waterMarkNode?(this.waterMarkNode.x=0,this.waterMarkNode.y=0,this.waterMarkNode.resize(i.width,i.height),this.waterMarkNode.image=i):this.update(),t.next=23;break;case 20:return this.pushWaterMarkImageList({x:o,y:c,width:l,height:h,image:i,zIndex:_,type:m,imageUrl:e.imageUrl}),t.next=23,this.freshWatermark();case 23:this.log.info("set watermark",JSON.stringify(this.watermarkImageList,(function(e,t){return"imageUrl"===e?void 0:t})));case 24:case"end":return t.stop()}}),t,this,[[0,6]])})))}},{key:"deleteWatermark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.watermarkImageList=this.watermarkImageList.filter((function(t){return t.type!==e})),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList,(function(e,t){return"imageUrl"===e?void 0:t}))),t.next=4,this.freshWatermark();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"freshWatermark",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==(t=this.waterMarkNode)||t.close(),delete this.waterMarkNode,delete this._waterMarkOption,e.next=3,this.getWatermarkImage(null==(n=this.cameraTrack)?void 0:n.settings.width,null==(r=this.cameraTrack)?void 0:r.settings.height);case 3:i=e.sent,this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.update();case 5:case"end":return e.stop()}}),e,this)})))}},{key:"setVirtualBackground",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=13;break}if(e.onAbort&&(this._virtualBackgroundAbortCallback=e.onAbort),!this._use2d||this._autoSwitchRenderMode){t.next=3;break}return t.abrupt("return",Promise.reject(new Error("not support virtual background in 2d mode")));case 3:if(this._bgAssetPath=e.assetPath,"image"!==e.type){t.next=10;break}return t.next=7,eD(e.imageUrl);case 7:this._virtualBackground=t.sent,t.next=11;break;case 10:this.blurRadius=e.blurLevel||this.blurRadius||3,this._virtualBackground=e.type;case 11:t.next=14;break;case 13:delete this._virtualBackground,delete this._virtualBackgroundAbortCallback;case 14:return this.log.info("".concat(this._virtualBackground?"start":"stop"," virtual background, ").concat((null==e?void 0:e.type)||"",", ").concat(this.blurRadius||"")),t.next=17,this.update();case 17:if(!this._virtualBackground||this._glVideoContext.available){t.next=19;break}throw new yR({code:_R.INVALID_OPERATION,message:"webgl context create failed, ".concat(this._glVideoContext.error)});case 19:case"end":return t.stop()}}),t,this)})))}},{key:"mixScreen",get:function(){return this._isMixScreen},set:function(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}},{key:"mirror",get:function(){return this._isMirror},set:function(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isMirror||(null==(t=this.mirrorNode)||t.close(),delete this.mirrorNode),this.update())}},{key:"enableAr",value:function(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}},{key:"updateAr",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=null!=(t=this.cameraTrack)&&t.mediaTrack,!e.t0){e.next=4;break}return e.next=4,this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone());case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disableAr",value:function(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}},{key:"createDecodeContext",value:function(e){return new ij(e)}},{key:"clear",value:function(){var e;null==(e=this.videoContext)||e.disconnect(),delete this.destination,delete this.cameraNode,delete this.mirrorNode,delete this.screenNode,delete this.waterMarkNode}},{key:"addEncodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.encodePipeline.includes(n)||(this.encodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"addDecodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.decodePipeline.includes(n)||(this.decodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"removeEncodeProcessor",value:function(e){var t=e.type;this.encodePipeline[t]=void 0}},{key:"removeDecodeProcessor",value:function(e){var t=e.type;this.decodePipeline[t]=void 0}}])}(Kq.EventEmitter);nR([cL((function(e){this.log.error("update failed",e)}))],aj.prototype,"update",1);var oj=0,sj=function(e){function i(e){var a;return r(this,i),a=n(this,i,["room"]),rR(t(a),"seq",++oj),rR(t(a),"sdkAppId"),rR(t(a),"userId"),rR(t(a),"userSig"),rR(t(a),"privateMapKey"),rR(t(a),"latencyLevel"),rR(t(a),"tinyId"),rR(t(a),"scene"),rR(t(a),"roomId"),rR(t(a),"useStringRoomId"),rR(t(a),"role","anchor"),rR(t(a),"joinParams",null),rR(t(a),"localTracks",new Set),rR(t(a),"enableAutoPlayDialog",!0),rR(t(a),"autoReceiveAudio",!0),rR(t(a),"autoReceiveVideo",!0),rR(t(a),"proxy_ws"),rR(t(a),"proxy_wt"),rR(t(a),"proxy_unified"),rR(t(a),"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0}}),rR(t(a),"keyPointManager"),rR(t(a),"audioManager"),rR(t(a),"videoManager"),rR(t(a),"callDurationCalculator"),rR(t(a),"badCaseDetector"),rR(t(a),"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),rR(t(a),"videoDecodeFallbackType"),rR(t(a),"_isUsingCachedSchedule",!1),rR(t(a),"_log",sO.createLogger({id:"r".concat(a.seq)})),rR(t(a),"_joinedTimestamp",0),rR(t(a),"_sdkType"),rR(t(a),"heartbeatReport"),rR(t(a),"quality"),rR(t(a),"enableSEI"),rR(t(a),"isDestroyed",!1),a.useStringRoomId=!!e.useStringRoomId,Rw(e.autoReceiveAudio)&&(a.autoReceiveAudio=e.autoReceiveAudio),Rw(e.autoReceiveVideo)&&(a.autoReceiveVideo=e.autoReceiveVideo),Rw(e.enableAutoPlayDialog)&&(a.enableAutoPlayDialog=e.enableAutoPlayDialog),a._sdkType=e.sdkType,a.keyPointManager=new Gq({room:t(a),frameWorkType:e.frameWorkType,component:e.component,language:e.language}),a.callDurationCalculator=new zq({room:t(a)}),a.badCaseDetector=new Jq({room:t(a)}),a.audioManager=new NL(t(a)),a.videoManager=new aj(t(a)),a}return d(i,e),o(i,[{key:"scriptTransformWorker",get:function(){}},{key:"isMainStreamPublished",get:function(){var e,t=s(this.localTracks);try{for(t.s();!(e=t.n()).done;)if(4&e.value.mediaType)return!0}catch(n){t.e(n)}finally{t.f()}return!1}},{key:"isAuxStreamPublished",get:function(){var e,t=s(this.localTracks);try{for(t.s();!(e=t.n()).done;)if(2&e.value.mediaType)return!0}catch(n){t.e(n)}finally{t.f()}return!1}},{key:"hasAuxStream",get:function(){var e,t=s(this.remotePublishedUserMap.values());try{for(t.s();!(e=t.n()).done;)if(e.value.muteState.hasAuxiliary)return!0}catch(n){t.e(n)}finally{t.f()}return this.isAuxStreamPublished}},{key:"localMainVideoTrack",get:function(){var e,t=s(this.localTracks);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(4&n.mediaType)return n}}catch(r){t.e(r)}finally{t.f()}return null}},{key:"localAuxVideoTrack",get:function(){var e,t=s(this.localTracks);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(2&n.mediaType)return n}}catch(r){t.e(r)}finally{t.f()}return null}},{key:"getLogger",value:function(){return this._log}},{key:"isJoining",get:function(){return"joining"===this.state.toString()}},{key:"isJoined",get:function(){return"joined"===this.state}},{key:"isLeft",get:function(){return"left"===this.state}},{key:"addTrack",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.publish(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrack",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unpublish(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"replaceTrack",value:function(e){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"setEncodedDataProcessingListener",value:function(e){throw new Error("Method not implemented.")}},{key:"enableAIVoice",value:function(e){throw new Error("Method not implemented.")}},{key:"setProxyServer",value:function(e){var t=this;if(Iw(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(yw(e)){var n=e.websocketProxy,r=e.webtransportProxy,i=e.loggerProxy,a=e.scheduleProxy,o=e.unifiedProxy;this.proxy_ws=n,this.proxy_wt=r,this.proxy_unified=o,o?(oB([o,o]),MR("https://".concat(o))):(i&&MR(i),a&&oB(a))}rO.once(aO.JOIN_RECEIVED_CMD_RES,(function(){return t.sendAbilityStatus({sched_domain:aB.main,sched_back_domain:aB.backup,signal_domain:t.proxy_ws||t.proxy_wt||""})}))}},{key:"getRemoteAudioStats",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={},e.abrupt("return",(this.remotePublishedUserMap.forEach((function(e){t[e.userId]=e.remoteAudioTrack.stat})),t));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getTransportStats",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={rtt:(null==(t=this.quality)?void 0:t.uplinkRTT)||0,downlinksRTT:{}},this.quality){r=s(this.quality.downlinkInfo);try{for(r.s();!(i=r.n()).done;)a=i.value,n.downlinksRTT[a.userId]=a.rtt}catch(o){r.e(o)}finally{r.f()}}return e.abrupt("return",n);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getRemoteVideoStats",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r={},n.abrupt("return",(e.remotePublishedUserMap.forEach((function(e){var n="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;r[e.userId]=n.stat})),r));case 2:case"end":return n.stop()}}),n)}))()}))}},{key:"checkDestroy",value:function(){if(this.isDestroyed)throw new yR({code:_R.INVALID_OPERATION,message:mN({key:dN.CLIENT_DESTROYED,data:{funName:"join"}})})}},{key:"destroy",value:function(){if(this.isJoined)throw this._log.warn(hN.INVALID_DESTROY),new yR({code:_R.INVALID_OPERATION,message:mN({key:dN.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,rO.emit(aO.ROOM_DESTROY,{room:this})}},{key:"schedule",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s,c,u,l,d=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=Uw(),n.prev=1,n.next=4,iB({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?e.strRoomId:e.roomId,useStringRoomId:this.useStringRoomId,version:RR,userSig:this.userSig,role:"live"===this.scene?e.role:void 0,frameWorkType:t,latencyLevel:e.latencyLevel});case 4:s=n.sent,c=s.isCached,u=s.result,l=s.detailCost,this._isUsingCachedSchedule=c,this._log.info("schedule cache:".concat(+c," ").concat(Xw(u,{keysToExclude:["username","credential"]}))),c&&rO.once(aO.JOIN_RECEIVED_CMD_RES,(function(){return d.sendAbilityStatus({scheduleCache:1})})),this.scheduleResult=QA(QA({},this.scheduleResult),u),Aw(null==(r=u.config)?void 0:r.retryCount)&&CC(u.config.retryCount),Iw(null==(i=u.config)?void 0:i.loggerDomain)&&MR(u.config.loggerDomain),this.videoDecodeFallbackType=(null==(a=u.config)?void 0:a.videoDecodeFallback)||this.videoDecodeFallbackType,rO.emit(aO.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:l}),IN.addSuccessEvent({key:521700,cost:Uw()-o,split:50}),n.next=14;break;case 11:throw n.prev=11,n.t0=n.catch(1),IN.addFailedEvent({key:521700,error:n.t0}),n.t0;case 14:case"end":return n.stop()}}),n,this,[[1,11]])})))}},{key:"sendAbilityStatus",value:function(e){}},{key:"enableInsertableStreams",value:function(){return Promise.resolve()}}])}(wP),cj=tR(oR()),uj=tR(pR());function lj(e){for(var t,n=[],r=function(r){if(["rtx","red","ulpfec"].includes(e.rtp[r].codec))return 1;var i=e.fmtp.filter((function(t){return t.payload===e.rtp[r].payload}))[0];n.push({payload:e.rtp[r].payload,codec:e.rtp[r].codec,fmtp:i?i.config:"",rate:e.rtp[r].rate,rtx:"rtx"===(null==(t=e.rtp[r+1])?void 0:t.codec)?e.rtp[r+1].payload:0,rtcpfb:((null==e?void 0:e.rtcpFb)||[]).filter((function(t){return t.payload===e.rtp[r].payload})).map((function(e){var t=e.type,n=e.subtype;return{id:t,params:n?[n]:[]}}))})},i=0;i<e.rtp.length;i++)r(i);return n}var dj=function(e,t){return aR(void 0,null,f().mark((function n(){var r,i,a,o,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=wq(e),(a={ice:{ufrag:"",password:""},dtls:{hash:"",fingerprint:"",setup:""},audio:{codecs:[],extensions:[]},video:{codecs:[],decoders:[],extensions:[]},useDataChannel:!1}).ice.ufrag=String(i.media[0].iceUfrag),a.ice.password=i.media[0].icePwd||"",i.fingerprint&&(a.dtls.hash=i.fingerprint.type,a.dtls.fingerprint=i.fingerprint.hash,a.dtls.setup=i.setup||""),i.media[0].fingerprint&&(a.dtls.hash=i.media[0].fingerprint.type,a.dtls.fingerprint=i.media[0].fingerprint.hash),a.dtls.setup=i.media[0].setup||"",o=i.media[0],s=i.media[1],o.ext&&(a.audio.extensions=o.ext.map((function(e){return{id:e.value,uri:e.uri}}))),s.ext&&(a.video.extensions=s.ext.map((function(e){return{id:e.value,uri:e.uri}}))),c={codec:o.rtp[0].codec,fmtp:o.fmtp[0].config,payload:o.fmtp[0].payload,rate:o.rtp[0].rate,channels:o.rtp[0].encoding,rtcpfb:[],rtx:0},null==(r=o.rtcpFb)||r.forEach((function(e){var t=e.payload,n=e.type,r=e.subtype;if(t===c.payload){var i={id:n,params:[]};r&&i.params.push(r),c.rtcpfb.push(i)}})),a.audio.codecs.push(c),u=["h264","vp8"],t&&u.shift(),a.video.codecs=E(lj(s)).filter((function(e){return u.includes(e.codec.toLocaleLowerCase())})),n.next=11,function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=new RTCPeerConnection).addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_RECVONLY}),e.next=4,t.createOffer();case 4:if((n=e.sent).sdp){e.next=7;break}return e.abrupt("return",[]);case 7:return r=lj(wq(n.sdp).media[0]),e.abrupt("return",(t.close(),r));case 9:case"end":return e.stop()}}),e)})))}();case 11:return a.video.decoders=n.sent.filter((function(e){return["h264","vp8"].includes(e.codec.toLocaleLowerCase())})),n.abrupt("return",a);case 13:case"end":return n.stop()}}),n)})))},hj=function(e){var t=e.serverAbility,n=e.clientAbility,r=e.offerSDP,i=e.enableCustomMessage,a=wq(r),o={extmapAllowMixed:"extmap-allow-mixed",groups:a.groups,icelite:"ice-lite",media:[],msidSemantic:{semantic:"",token:"WMS"},name:"-",origin:{address:"127.0.0.1",username:"-",sessionId:String(Date.now()),sessionVersion:1,netType:"IN",ipVer:4},timing:{start:0,stop:0},version:0},s={candidates:t.candidates.map((function(e){return{component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}})),connection:{version:4,ip:"0.0.0.0"},direction:nC.TRANSCEIVER_DIRECTION_RECVONLY,ext:t.audio.extensions.map((function(e){return{value:e.id,uri:e.uri}})),fingerprint:{type:t.dtls.hash,hash:t.dtls.fingerprint},fmtp:[{payload:t.audio.codecs[0].payload,config:t.audio.codecs[0].fmtp}],icePwd:t.ice.password,iceUfrag:t.ice.ufrag,mid:"0",payloads:String(t.audio.codecs[0].payload),port:a.media[0].port,protocol:a.media[0].protocol,type:nC.AUDIO,setup:t.dtls.setup,rtcpFb:t.audio.codecs[0].rtcpfb.map((function(e){return{payload:t.audio.codecs[0].payload,type:e.id,subtype:e.params[0]}})),rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[{payload:t.audio.codecs[0].payload,codec:t.audio.codecs[0].codec,rate:t.audio.codecs[0].rate,encoding:t.audio.codecs[0].channels}]};return o.media.push(s),[1,2,3].forEach((function(e){o.media.push(fj({mid:e,serverAbility:t,clientAbility:n,parsedOffer:a}))})),i&&o.media.push(a.media.find((function(e){return"dc"===e.mid}))),Dq(o)},fj=function(e){var t=e.mid,n=e.serverAbility,r=e.clientAbility,i=e.parsedOffer,a=e.isDownlink,o=void 0!==a&&a,s={candidates:n.candidates.map((function(e){return{component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}})),connection:{version:4,ip:"0.0.0.0"},direction:nC.TRANSCEIVER_DIRECTION_RECVONLY,ext:n.video.extensions.map((function(e){return{value:e.id,uri:e.uri}})),fingerprint:{type:n.dtls.hash,hash:n.dtls.fingerprint},fmtp:[],icePwd:n.ice.password,iceUfrag:n.ice.ufrag,mid:String(t),payloads:"",port:i.media[0].port,protocol:i.media[0].protocol,type:nC.VIDEO,setup:n.dtls.setup,rtcpFb:[],rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[]};if(o){var c=n.video.decoders;(!c||0===c.length)&&(c=n.video.codecs),(!c||0===c.length)&&(c=r.video.decoders),c.forEach((function(e){pj(s,e)}))}else{var u=n.video.codecs.findIndex((function(e){return e.codec.toLowerCase()===(n.useVp8?"vp8":"h264")})),l=n.video.codecs[u]||r.video.codecs[0];pj(s,l)}return s},pj=function(e,t){e.payloads="".concat(e.payloads," ").concat(t.payload).trim(),e.fmtp.push({payload:t.payload,config:t.fmtp}),e.rtcpFb=[].concat(E(e.rtcpFb||[]),E(t.rtcpfb.map((function(e){return{payload:t.payload,type:e.id,subtype:e.params[0]}})))),e.rtp.push({payload:t.payload,codec:t.codec.toUpperCase(),rate:t.rate}),t.rtx&&(e.payloads="".concat(e.payloads," ").concat(t.rtx),e.fmtp.push({payload:t.rtx,config:"apt=".concat(t.payload)}),e.rtp.push({payload:t.rtx,codec:"rtx",rate:t.rate}))},mj=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).room=e,rR(t(a),"mainFpsHealth",1),rR(t(a),"mainBitrateHealth",1),rR(t(a),"badMainBitrateHealthCount",0),rR(t(a),"lastEmitBadHealthTime",0),rR(t(a),"log"),!ID&&Rx&&rO.on("262",a.onVideoCodecChanged,t(a)),a.log=e.getLogger().createChild({id:"h-d"}),a}return d(i,e),o(i,[{key:"onVideoCodecChanged",value:function(e){var t=e.remoteUserId,n=e.streamType,r=e.isHWCodec,i=e.codec;if(!t&&7!==n&&"h264"===i){if(!r)return void this.room.off("heartbeat-report",this.onHeartbeatReport,this);this.room.listeners("heartbeat-report").includes(this.onHeartbeatReport)||this.room.on("heartbeat-report",this.onHeartbeatReport,this)}}},{key:"onHeartbeatReport",value:function(e){var t=this;Date.now()-this.lastEmitBadHealthTime<3e4||(e.msg_up_stream_info.msg_video_status.forEach((function(e){if(e.uint32_video_enc_fps&&e.uint32_video_capture_fps){var n=e.uint32_video_enc_fps/e.uint32_video_capture_fps;2===e.uint32_video_stream_type&&(t.mainFpsHealth=n)}if(e.uint32_video_codec_bitrate&&2===e.uint32_video_stream_type){var r=t.room.localMainVideoTrack;r&&(t.mainBitrateHealth=e.uint32_video_codec_bitrate/1e3/r.profile.bitrate)}})),this.log.debug("mainBitrateHealth: ".concat(this.mainBitrateHealth," mainFpsHealth: ").concat(this.mainFpsHealth)),this.mainBitrateHealth>.5&&(this.badMainBitrateHealthCount=0),this.mainFpsHealth>.9&&this.mainBitrateHealth<.5&&(this.badMainBitrateHealthCount++,this.badMainBitrateHealthCount>3&&(this.badMainBitrateHealthCount=0,this.lastEmitBadHealthTime=Date.now(),this.log.warn("bad main bitrate health: ".concat(this.mainBitrateHealth)),this.emit("1",{isAux:!1}))))}},{key:"destroy",value:function(){rO.off("262",this.onVideoCodecChanged,this),this.room.off("heartbeat-report",this.onHeartbeatReport,this)}}])}(tR(oR()).EventEmitter);rR(mj,"EVENT_BAD_HEALTH","bad_health");var vj=mj;function _j(e){var t=e.seiMessageList,n=e.isAudio,r=e.isMain;return new TransformStream({transform:function(e,i){var a=e;n?audioEncodePipeline.forEach((function(e){a=e({frame:a})})):videoEncodePipeline.forEach((function(e){a=e({frame:a,seiMessageList:t,onDump:function(){self.postMessage({type:"dump",isAudio:n,data:a.data,userId:"",streamType:r?"main":"auxiliary"})}})})),i.enqueue(a)}})}function gj(e,t,n){return new TransformStream({transform:function(r,i){var a=r;videoDecodePipeline.forEach((function(r){a=r({frame:a,onSEI:function(n){n.forEach((function(n){self.postMessage({type:"sei",seiPayloadType:n.seiPayloadType,data:n.seiPayload.buffer,userId:e,streamType:t})}))},onDump:function(){self.postMessage({type:"dump",isAudio:n,data:a.data,userId:e,streamType:t})}})})),i.enqueue(a)}})}var yj=function(e){return e.TRACK="track",e.DATA_CHANNEL_MESSAGE="data_channel_msg",e[e.CONNECTION_STATE_CHANGED="connection-state-changed"]="CONNECTION_STATE_CHANGED",e[e.FIREWALL_RESTRICTION="firewall-restriction"]="FIREWALL_RESTRICTION",e.RECONNECTED="spc-reconnected",e.RECONNECT_FAILED="spc-reconnect-failed",e.ERROR="error",e.SEI_MESSAGE="sei-message",e.DUMP="dump",e}(yj||{}),Ej=0,Tj=!1,kj=new Set,Sj=1,bj=function(e){function i(e){var a;r(this,i);var o=e.signalChannel,s=e.room,c=e.enableCustomMessage;return a=n(this,i),rR(t(a),"stat",{iceStartTime:0,iceEndTime:0,dtlsStartTime:0,dtlsEndTime:0,peerConnectionStartTime:0,peerConnectionEndTime:0}),rR(t(a),"currentState","DISCONNECTED"),rR(t(a),"_room"),rR(t(a),"_signalChannel"),rR(t(a),"_peerConnection",null),rR(t(a),"_datachannel",null),rR(t(a),"_enableCustomMessage"),rR(t(a),"_log"),rR(t(a),"_downlinkMIDMap",new Map),rR(t(a),"_downlinkMIDUserIDMap",new Map),rR(t(a),"_reconnectionTimer",-1),rR(t(a),"reconnectionCount",0),rR(t(a),"clientAbility"),rR(t(a),"_serverAbility",null),rR(t(a),"addDownlinkQueue",new Set),rR(t(a),"removeDownlinkQueue",new Set),rR(t(a),"_parsedAnswer",null),rR(t(a),"_updateSDPPromise",null),rR(t(a),"_waitForPCConnectedPromise"),rR(t(a),"clearConnectTimeout"),rR(t(a),"_isSDPLogged",!1),rR(t(a),"enableInsertableStreams",!1),rR(t(a),"insertableStreamsAbortMap",new Map),rR(t(a),"receiverRemoteTrackMap",new WeakMap),rR(t(a),"scriptTransformWorker"),rR(t(a),"_isRelayTried",!1),rR(t(a),"_rttOverCount",0),rR(t(a),"originOffer",null),a._room=s,a._enableCustomMessage=c,a._signalChannel=o,a._log=sO.createLogger({id:"spc".concat(Sj++),userId:a._room.userId,sdkAppId:a._room.sdkAppId}),a._room.enableCodecPipeline&&(sP?a.enableInsertableStreams=!0:a.initScriptTransformWorker()),a._room.healthDetector.on("1",a.onBadHealth,t(a)),a}return d(i,e),o(i,[{key:"isH264EncodeSupported",get:function(){var e=this._room.checkSystemResult.detail.isH264EncodeSupported;return this._serverAbility&&(e=e&&!!this._serverAbility.video.codecs.find((function(e){return"h264"===e.codec.toLowerCase()}))),e}},{key:"addAbortController",value:function(e,t){var n;null==(n=this.insertableStreamsAbortMap.get(e))||n.abort("destory"),this.insertableStreamsAbortMap.set(e,t)}},{key:"isVP8EncodeSupported",get:function(){var e=this._room.checkSystemResult.detail.isVp8EncodeSupported;return this._serverAbility&&(e=e&&this._serverAbility.video.codecs.find((function(e){return"vp8"===e.codec.toLowerCase()}))),e}},{key:"videoCodec",get:function(){var e,t,n=null==(e=this._parsedAnswer)?void 0:e.media[1].rtp.find((function(e){return["h264","vp8"].includes(e.codec.toLowerCase())}));return n?n.codec.toLowerCase():null!=(t=this._serverAbility)&&t.useVp8?"vp8":"h264"}},{key:"downlinkVideoCodec",get:function(){var e;return null!=(e=this._serverAbility)&&e.video.decoders.find((function(e){return"h264"===e.codec.toLowerCase()}))?"h264":"vp8"}},{key:"isUsingH264",get:function(){return"h264"===this.videoCodec}},{key:"is42001fSupported",get:function(){return!!this.clientAbility&&!!this.clientAbility.video.codecs.find((function(e){return e.fmtp.includes("42001f")}))}},{key:"uplinkSSRC",get:function(){return this._peerConnection&&this._peerConnection.localDescription?function(e){var t=wq(e),n={audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0};return t.media.forEach((function(e,t){var r;if(e.ssrcs&&!bw(e.ssrcs[0].id)){var i=Number(e.ssrcs[0].id),a=Number(null==(r=e.ssrcs.filter((function(e){return"cname"===e.attribute}))[1])?void 0:r.id);switch(t){case 0:n.audioSsrc=i;break;case 1:n.bigVideoSsrc=i,n.bigVideoRtxSsrc=a;break;case 2:n.smallVideoSsrc=i,n.smallVideoRtxSsrc=a;break;case 3:n.auxVideoSsrc=i,n.auxVideoRtxSsrc=a}}})),n}(this._peerConnection.localDescription.sdp):{audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0}}},{key:"onBadHealth",value:function(e){var t=e.isAux;this.useHWEncoder(!1,t?7:2)}},{key:"initScriptTransformWorker",value:function(){var e=this;cP&&(this.scriptTransformWorker=function(e){var t=[SL],n=[UB,MB,LB,PB,_j,gj],r="const videoEncodePipeline=[".concat(e.videoEncodePipeline.toString(),"];\n const videoDecodePipeline=[").concat(e.videoDecodePipeline.toString(),"];\n const audioEncodePipeline = [").concat(e.audioEncodePipeline.toString(),"];\n const audioDecodePipeline = [").concat(e.audioDecodePipeline.toString(),"];"),i="(()=>{".concat(t.map((function(e){return"const ".concat(e.name,"=(()=>").concat(e.toString(),")()")})).join("\n"),"\n").concat(n.map((function(e){return e.toString()})).join("\n"),";(").concat((function(){var e=[],t=[],n=[];self.onmessage=function(r){"sei"===r.data.type&&(r.data.isMain?(e.push(r.data.data),r.data.small&&n.push(r.data.data)):t.push(r.data.data))},self.onrtctransform=function(r){var i=r.transformer.options,a=i.isReceiver?gj(i.userId,i.streamType,i.isAudio):_j({isAudio:i.isAudio,seiMessageList:i.isMain?i.small?n:e:t,isMain:i.isMain});r.transformer.readable.pipeThrough(a).pipeTo(r.transformer.writable)}}),")();").concat(r,"})()"),a=new Blob([i],{type:"text/javascript"}),o=URL.createObjectURL(a),s=new Worker(o);return URL.revokeObjectURL(o),s}({videoEncodePipeline:this._room.videoManager.encodePipeline,videoDecodePipeline:this._room.videoManager.decodePipeline,audioEncodePipeline:this._room.audioManager.encodePipeline,audioDecodePipeline:this._room.audioManager.decodePipeline}),this.scriptTransformWorker.onmessage=function(t){"sei"===t.data.type&&e.emit("sei-message",t.data),"dump"===t.data.type&&e.emit("dump",t.data)},this.scriptTransformWorker.onerror=function(t){e._log.error("scriptTransformWorker error: ",t)})}},{key:"isReconnecting",get:function(){return"RECONNECTING"===this.currentState||this._reconnectionTimer>0||this.reconnectionCount>0}},{key:"dtlsTransport",get:function(){if(!this._peerConnection)return null;var e=this._peerConnection.getSenders();return 0===e.length?null:e[0].transport}},{key:"getPeerConnectionConfig",value:function(e){var t={encodedInsertableStreams:this.enableInsertableStreams,offerExtmapAllowMixed:!0,iceServers:e,iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._room.sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};return this._log.debug("getPeerConnectionConfig",JSON.stringify(t)),t}},{key:"initialize",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,this._peerConnection=new RTCPeerConnection(this.getPeerConnectionConfig(e)),this._peerConnection.oniceconnectionstatechange=function(){if(i._peerConnection){var e=i._peerConnection.iceConnectionState;i._log.debug("ice state: ".concat(e)),"checking"===e&&0===i.stat.iceStartTime?i.stat.iceStartTime=Date.now():"connected"===e&&0===i.stat.iceEndTime?(i.stat.iceEndTime=Date.now(),i._signalChannel.clearBakRelayIps(),IN.addSuccessEvent({key:521711,cost:i.stat.iceEndTime-i.stat.iceStartTime})):"failed"===e&&IN.addFailedEvent({key:521711})}},this._peerConnection.onsignalingstatechange=function(){var e,t=(null==(e=i._peerConnection)?void 0:e.signalingState)||"";i._log["closed"===t?"debug":"info"]("signaling state: ".concat(t))},this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this._peerConnection.ontrack=function(e){return i.emit("track",e)},this._enableCustomMessage&&(this._datachannel=this._peerConnection.createDataChannel("".concat(this._room.userId,"dc")),this._datachannel.binaryType="arraybuffer",this._datachannel.onopen=function(){i._log.info("datachannel open")},this._datachannel.onclose=function(){i._log.warn("datachannel close")},this._datachannel.onmessage=function(e){var t=new Aj(e.data);i.emit("data_channel_msg",{data:t})},this._datachannel.onerror=function(e){i._log.warn("datachannel error",e)}),this._peerConnection.addTransceiver(nC.AUDIO,{direction:nC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_SENDONLY}),t.next=13,this._peerConnection.createOffer();case 13:return r=t.sent,t.next=16,dj(r.sdp,(null==(n=this._room.scheduleResult.config)?void 0:n.remove264FromSDP)||!1);case 16:return this.clientAbility=t.sent,this.originOffer=r,this.dtlsTransport&&(this.dtlsTransport.onstatechange=function(){var e=i.dtlsTransport;e&&(i._log.debug("dtls state: ".concat(e.state)),"connecting"===e.state&&0===i.stat.dtlsStartTime?i.stat.dtlsStartTime=Date.now():"connected"===e.state&&0===i.stat.dtlsEndTime&&(i.stat.dtlsEndTime=Date.now()))}),IN.addSuccessEvent({key:521707}),t.abrupt("return",this.clientAbility);case 23:throw t.prev=23,t.t0=t.catch(0),IN.addFailedEvent({key:521707,error:t.t0}),this._log.error("initialize failed ".concat(t.t0," \noffer: ").concat(null==r?void 0:r.sdp)),t.t0;case 26:case"end":return t.stop()}}),t,this,[[0,23]])})))}},{key:"setIceServers",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._peerConnection){t.next=5;break}if(this._log.info("setIceServers",JSON.stringify(e)),this._peerConnection.setConfiguration(this.getPeerConnectionConfig(e)),(null==(n=this._peerConnection)||!n.localDescription)&&this.originOffer){t.next=3;break}return t.abrupt("return",void this._log.warn("setIceServers warning, already has localDescription or no origin Offer"));case 3:return t.next=5,this.setOffer(this.originOffer);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"setPriority",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"high";if(this._peerConnection)try{this._peerConnection.getSenders().forEach((function(n){var r=n.getParameters();r.encodings[0]&&(r.encodings[0].priority=t,r.encodings[0].networkPriority=t,n.setParameters(r).catch((function(t){e._log.warn("setPriority error ",t)})))}))}catch(DC){this._log.warn("setPriority error ",DC)}}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return aR(this,null,f().mark((function n(){var r,i,a,o,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,"CONNECTED"!==this.currentState){n.next=3;break}return n.abrupt("return");case 3:if(n.t0=(null==(r=this._peerConnection)||!r.localDescription)&&this.originOffer,!n.t0){n.next=7;break}return n.next=7,this.setOffer(this.originOffer);case 7:return o=Uw(),s={type:"answer",sdp:hj({serverAbility:e,clientAbility:this.clientAbility,offerSDP:this._peerConnection.localDescription.sdp,enableCustomMessage:this._enableCustomMessage})},this._serverAbility=e,n.next=11,this.setAnswer(s);case 11:return n.next=13,this.waitForPeerConnectionConnected();case 13:(c=(null==(i=this._room.scheduleResult.config)?void 0:i.priority)||(null==(a=this._room.joinParams)?void 0:a.priority)||new URLSearchParams(location.search).get("priority"))&&this.setPriority(c),t||IN.addSuccessEvent({key:521703,cost:Uw()-o}),n.next=21;break;case 17:throw n.prev=17,n.t1=n.catch(0),(u=n.t1 instanceof yR&&n.t1.code===_R.API_CALL_ABORTED)||this._log.error("connect failed: ".concat(n.t1),e),this.reset(),!u&&!this.isReconnecting&&(IN.addFailedEvent({key:521703,error:n.t1}),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),n.t1;case 21:case"end":return n.stop()}}),n,this,[[0,17]])})))}},{key:"reconnect",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1!==this._reconnectionTimer){e.next=41;break}if(this._signalChannel.isConnected){e.next=3;break}return e.abrupt("return",(this._log.warn("reconnect() wait signal channel is connected"),void this._signalChannel.once(uq,this.reconnect,this)));case 3:return e.prev=3,this.reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this.reconnectionCount,"]")),this.reset(),t=this._signalChannel.getBackupRelayIpPair(),e.next=8,this.initialize(this._room.getIceServers(null!=t&&t.iceServer?[t.iceServer]:[]));case 8:return n=e.sent,r=QA({ability:n},t),e.next=12,this._signalChannel.sendWaitForResponse({command:"rebuild_pc",responseCommand:fq.REBUILD_PEER_CONNECTION_RES,data:r,enableLog:!1});case 12:if(0===(i=e.sent).data.code){e.next=15;break}throw new yR({code:i.data.code,message:i.data.message});case 15:return e.next=17,this.connect(i.data.data.ability,!0);case 17:IN.addSuccessEvent({key:521704}),this._log.warn("reconnect() success"),this.stopReconnection(),rO.emit(aO.SPC_RECONNECTED,{room:this._room}),this.emit("spc-reconnected"),e.next=39;break;case 24:if(e.prev=24,e.t0=e.catch(3),this.isReconnecting){e.next=28;break}return e.abrupt("return");case 28:if(null==e.t0||!e.t0.message.includes("timeout")){e.next=38;break}return a=Tw(this.reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(a/1e3,"s")),e.next=33,rD(a,(function(e){o._reconnectionTimer=e}));case 33:return this.clearReconnectionTimer(),e.next=36,this.reconnect();case 36:e.next=39;break;case 38:this._log.error("reconnect() failed ".concat(null==e.t0?void 0:e.t0.code," ").concat(e.t0)),IN.addFailedEvent({key:521704,error:e.t0}),this.reconnectionCount>=wC()&&this._log.warn("SDK has tried reconnect for ".concat(wC()," times, but all failed, please check your network")),this.stopReconnection(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.emit("error");case 39:e.next=42;break;case 41:this._log.warn("reconnect() is reconnecting, ignore current reconnection");case 42:case"end":return e.stop()}}),e,this,[[3,24]])})))}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"startReconnection",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isReconnecting,e.t0){e.next=7;break}return this._log.warn("start reconnect"),this._updateSDPPromise=null,this.emitConnectionStateChangedEvent("RECONNECTING"),e.next=7,this.reconnect();case 7:case"end":return e.stop()}}),e,this)})))}},{key:"stopReconnection",value:function(){var e;this.isReconnecting&&(this._log.info("stop reconnect"),this.reconnectionCount=0,this.clearReconnectionTimer(),null==(e=this.clearConnectTimeout)||e.call(this),this._signalChannel.off(uq,this.reconnect,this),"RECONNECTING"===this.currentState&&this.emitConnectionStateChangedEvent("DISCONNECTED"))}},{key:"checkPeerConnectionToReconnect",value:function(){var e;!this.isReconnecting&&(null==(e=this._peerConnection)?void 0:e.connectionState)===AC.CLOSED&&this.startReconnection()}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"onConnectionStateChange",value:function(e){var t,n=(null==(t=this._peerConnection)?void 0:t.iceConnectionState)||"closed",r=this.getDTLSTransportState();this._log.info("connectionState: ".concat(e.target.connectionState," ICE: ").concat(n," DTLS: ").concat(r)),e.target.connectionState===AC.CONNECTING&&(0===this.stat.peerConnectionStartTime&&(this.stat.peerConnectionStartTime=Date.now()),this.emitConnectionStateChangedEvent("CONNECTING")),(e.target.connectionState===AC.FAILED||e.target.connectionState===AC.CLOSED)&&(this.emitConnectionStateChangedEvent("DISCONNECTED"),this._room.forceRelay?this.switchRelay(!1):this.startReconnection()),(e.target.connectionState===AC.CONNECTED||e.target.connectionState===AC.COMPLETED)&&(0===this.stat.peerConnectionEndTime&&(this.stat.peerConnectionEndTime=Date.now()),rO.emit(aO.SINGLE_CONNECTION_STAT,{room:this._room,stat:{ice:this.stat.iceEndTime-this.stat.iceStartTime,dtls:this.stat.dtlsEndTime-this.stat.dtlsStartTime,peerConnection:this.stat.peerConnectionEndTime-this.stat.peerConnectionStartTime}}),this.logSelectedCandidate(),this.emitConnectionStateChangedEvent("CONNECTED"))}},{key:"getDTLSTransportState",value:function(){if(!this._peerConnection)return IC;var e=null;return XN()&&0!==this._peerConnection.getSenders().length?(e=this._peerConnection.getSenders()[0].transport,YN()&&0!==this._peerConnection.getReceivers().length&&e?e.state:IC):IC}},{key:"emitConnectionStateChangedEvent",value:function(e){e!==this.currentState&&("RECONNECTING"===this.currentState&&"CONNECTING"===e||(this.emit(yj.CONNECTION_STATE_CHANGED,{prevState:this.currentState,state:e}),this.currentState=e))}},{key:"logSelectedCandidate",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this._peerConnection.getStats();case 4:t=e.sent,n=s(t),e.prev=6,n.s();case 8:if((r=n.n()).done){e.next=16;break}if((i=v(r.value,2))[0],a=i[1],!jN(a)){e.next=14;break}return o=t.get(a.localCandidateId),c=t.get(a.remoteCandidateId),o&&(this._log.info("local candidate: ".concat(o.candidateType," ").concat(o.protocol,":").concat(o.ip||o.address,":").concat(o.port," ").concat(o.networkType||""," ").concat("relay"===o.candidateType?"relayProtocol:".concat(o.relayProtocol):"")),o.networkType&&lw(o.networkType)),c&&this._log.info("remote candidate: ".concat(c.candidateType," ").concat(c.protocol,":").concat(c.ip||c.address,":").concat(c.port)),e.abrupt("break",16);case 14:e.next=8;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(6),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[6,18,21,24]])})))}},{key:"waitForPeerConnectionConnected",value:function(){var e=this;return this._waitForPCConnectedPromise||(this._waitForPCConnectedPromise=new Promise((function(t,n){if("CONNECTED"===e.currentState)return t();var r=function(e){"CONNECTED"===e.state&&(clearTimeout(o),a(),t())},i=function(t){t.room===e._room&&(clearTimeout(o),a(),n(new yR({code:_R.API_CALL_ABORTED,message:mN({key:dN.CONNECTION_ABORTED,data:"leave room"})})))},a=function(){rO.off(aO.LEAVE_SUCCESS,i,e),e.off(yj.CONNECTION_STATE_CHANGED,r,e)},o=setTimeout((function(){a();var t,r=new yR({code:_R.API_CALL_TIMEOUT,message:"connection timeout"});Ej+=1,t=e._signalChannel.isConnected,Ej>2&&!Tj&&0===kj.size&&t&&(e._log.warn("firewall restriction"),Tj=!0,e.emit(yj.FIREWALL_RESTRICTION)),n(r)}),GC);e.clearConnectTimeout=function(){a(),clearTimeout(o),delete e.clearConnectTimeout},rO.on(aO.LEAVE_SUCCESS,i,e),e.on(yj.CONNECTION_STATE_CHANGED,r,e)})),this._waitForPCConnectedPromise=this._waitForPCConnectedPromise.finally((function(){e._waitForPCConnectedPromise=null,delete e.clearConnectTimeout}))),this._waitForPCConnectedPromise}},{key:"waitForReconnected",value:function(){var e=this;return this.isReconnecting?new Promise((function(t,n){e.once("spc-reconnected",t),e.once("error",n)})):Promise.resolve()}},{key:"addDownlink",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("addDownlink(".concat(e.userId,") trying")),t.t0=this.isReconnecting,!t.t0){t.next=5;break}return t.next=5,this.waitForReconnected();case 5:if(t.t1=this._updateSDPPromise,!t.t1){t.next=9;break}return t.next=9,this._updateSDPPromise;case 9:if(this.updateLocalAndRemoteSDPConfig(e),0!==this.addDownlinkQueue.size){t.next=22;break}return t.prev=11,t.next=14,this.updateSDP();case 14:this._log.info("addDownlink(".concat(e.userId,") done")),t.next=22;break;case 17:return t.prev=17,t.t2=t.catch(11),this._log.error("addDownlink(".concat(e.userId,") failed ").concat(t.t2)),t.next=22,this.startReconnection();case 22:case"end":return t.stop()}}),t,this,[[11,17]])})))}},{key:"updateLocalAndRemoteSDPConfig",value:function(e){var t=e.ssrc,n=e.userId,r=e.tinyId;if(this._peerConnection){this._log.info("updateLocalAndRemoteSDPConfig ".concat(n," ").concat(JSON.stringify(t)));var i=this._peerConnection.getTransceivers().slice(4).filter((function(e){return"inactive"===e.direction})).slice(0,3).map((function(e){return e.direction=nC.TRANSCEIVER_DIRECTION_RECVONLY,Number(e.mid)}));this._parsedAnswer||(this._parsedAnswer=wq(this._peerConnection.remoteDescription.sdp));var a,o,s,c=this._parsedAnswer.media.filter((function(e){var t;return null==(t=e.ssrcs)?void 0:t.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(r)}))}));if(3===c.length)a=c[0],o=c[1],s=c[2];else if(3===i.length)a=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[0])})),o=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[1])})),s=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[2])}));else if(0===i.length){this._peerConnection.addTransceiver(nC.AUDIO,{direction:nC.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_RECVONLY}),a=JSON.parse(JSON.stringify(this._parsedAnswer.media[0]));var u=fj({mid:1,serverAbility:this._serverAbility,clientAbility:this.clientAbility,parsedOffer:wq(this._peerConnection.localDescription.sdp),isDownlink:!0});o=JSON.parse(JSON.stringify(u)),s=JSON.parse(JSON.stringify(u)),a.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(a),o.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(o),s.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(s)}a.direction=nC.TRANSCEIVER_DIRECTION_SENDONLY;var l="".concat(r,"-").concat(t.audio);a.ssrcs=[{id:t.audio,attribute:"cname",value:"".concat(l)},{id:t.audio,attribute:"msid",value:"".concat(l,"-").concat(nC.MAIN," ").concat(l,"-audio")}],o.direction=nC.TRANSCEIVER_DIRECTION_SENDONLY,o.ssrcs=[{id:t.video,attribute:"cname",value:"".concat(l)},{id:t.video,attribute:"msid",value:"".concat(l,"-").concat(nC.MAIN," ").concat(l,"-bigvideo")},{id:t.videoRtx,attribute:"cname",value:"".concat(l)},{id:t.videoRtx,attribute:"msid",value:"".concat(l,"-").concat(nC.MAIN," ").concat(l,"-bigvideo")}],o.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.video," ").concat(t.videoRtx)}],s.direction=nC.TRANSCEIVER_DIRECTION_SENDONLY;var d="".concat(l,"-aux");s.ssrcs=[{id:t.auxiliary,attribute:"cname",value:d},{id:t.auxiliary,attribute:"msid",value:"".concat(d," ").concat(l,"-aux").concat(nC.VIDEO)},{id:t.auxiliaryRtx,attribute:"cname",value:"".concat(d," ").concat(l,"-aux").concat(nC.VIDEO)},{id:t.auxiliaryRtx,attribute:"msid",value:"".concat(d," ").concat(l,"-aux").concat(nC.VIDEO)}],s.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.auxiliary," ").concat(t.auxiliaryRtx)}],this._parsedAnswer.groups&&(this._parsedAnswer.groups[0].mids=this._parsedAnswer.media.map((function(e){return e.mid})).join(" ")),this._downlinkMIDMap.set(n,[a.mid,o.mid,s.mid]),this._downlinkMIDUserIDMap.set(a.mid,n),this._downlinkMIDUserIDMap.set(o.mid,n),this._downlinkMIDUserIDMap.set(s.mid,n)}}},{key:"removeDownlink",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._downlinkMIDMap.has(e)&&this._peerConnection){t.next=2;break}return t.abrupt("return");case 2:if(this._log.info("removeDownlink(".concat(e,") trying")),t.t0=this.isReconnecting,!t.t0){t.next=7;break}return t.next=7,this.waitForReconnected();case 7:if(t.t1=this._updateSDPPromise,!t.t1){t.next=11;break}return t.next=11,this._updateSDPPromise;case 11:if(n=this._downlinkMIDMap.get(e),r=!1,this._peerConnection.getTransceivers().forEach((function(e){null!=n&&n.includes(Number(e.mid))&&(r=!0,e.direction="inactive")})),this._parsedAnswer||(this._parsedAnswer=wq(this._peerConnection.remoteDescription.sdp)),this._parsedAnswer.media.forEach((function(e){null!=n&&n.includes(Number(e.mid))&&(r=!0,e.direction="inactive",e.ssrcs=[],e.ssrcGroups=[])})),t.t2=0===this.removeDownlinkQueue.size&&r,!t.t2){t.next=19;break}return t.next=19,this.updateSDP();case 19:this._downlinkMIDMap.delete(e),null==n||n.forEach((function(e){return i._downlinkMIDUserIDMap.delete(e)})),this._log.info("removeDownlink(".concat(e,") done"));case 22:case"end":return t.stop()}}),t,this)})))}},{key:"setBandwidth",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._peerConnection){t.next=2;break}return t.abrupt("return");case 2:if(n=e.audio,r=e.bigVideo,i=e.smallVideo,a=e.auxVideo,t.prev=3,!rP()){t.next=26;break}o=this._peerConnection.getSenders().slice(0,4),s=0;case 7:if(!(s<o.length)){t.next=17;break}if(c=void 0,u=o[s],0===s&&n?c=n:1===s&&r?c=r:2===s&&i?c=i:3===s&&a&&(c=a),t.t0=c,!t.t0){t.next=14;break}return t.next=14,this.setSenderMaxBitrate(u,c);case 14:s++,t.next=7;break;case 17:if(l=!1,r&&o[1].track&&(l=this.setStartBitrate(1,r)),a&&o[3].track&&(l=this.setStartBitrate(3,a)||l),t.t1=l,!t.t1){t.next=24;break}return t.next=24,this.updateSDP();case 24:t.next=28;break;case 26:return t.next=28,this.setBandwidthBySDP(e);case 28:this._log.info("setBandwidth ".concat(JSON.stringify(e))),t.next=34;break;case 31:t.prev=31,t.t2=t.catch(3),this._log.error("failed to set bandwidth: ".concat(t.t2));case 34:case"end":return t.stop()}}),t,this,[[3,31]])})))}},{key:"setStartBitrate",value:function(e,t){var n,r;return!(null==(n=this._peerConnection)||!n.remoteDescription||(this._parsedAnswer||(this._parsedAnswer=wq(this._peerConnection.remoteDescription.sdp)),null==(r=this._parsedAnswer.media[e])||!r.fmtp[0])||(this._parsedAnswer.media[e].fmtp[0].config+=";x-google-start-bitrate=".concat(t>5e3?5e3:t),0))}},{key:"setSenderMaxBitrate",value:function(e,t){var n=e.getParameters();return(!n.encodings||0===n.encodings.length)&&(n.encodings=[{}]),"unlimited"===t?delete n.encodings[0].maxBitrate:n.encodings[0].maxBitrate=1e3*t,e.setParameters(n)}},{key:"setBandwidthBySDP",value:function(e){var t=e.audio,n=e.bigVideo,r=e.smallVideo,i=e.auxVideo;if(this._peerConnection&&this._peerConnection.localDescription){var a=wq(this._peerConnection.localDescription.sdp);this._parsedAnswer||(this._parsedAnswer=wq(this._peerConnection.remoteDescription.sdp));var o=wD?"TIAS":"AS";t&&(a.media[0].bandwidth=[{type:o,limit:wD?1e3*t:t}],this._parsedAnswer.media[0].bandwidth=[{type:o,limit:wD?1e3*t:t}]),n&&(a.media[1].bandwidth=[{type:o,limit:wD?1e3*n:n}],this._parsedAnswer.media[1].bandwidth=[{type:o,limit:wD?1e3*n:n}]),r&&(a.media[2].bandwidth=[{type:o,limit:wD?1e3*r:r}],this._parsedAnswer.media[2].bandwidth=[{type:o,limit:wD?1e3*r:r}]),i&&(a.media[3].bandwidth=[{type:o,limit:wD?1e3*i:i}],this._parsedAnswer.media[3].bandwidth=[{type:o,limit:wD?1e3*i:i}]);var s={type:"offer",sdp:Dq(a)};return this.updateSDP({localDescription:s})}}},{key:"setScaleResolutionDownBy",value:function(e,t,n){var r=e.getParameters();(!r.encodings||0===r.encodings.length)&&(r.encodings=[{}]);var i=r.encodings[0].scaleResolutionDownBy;if(bw(i)?1!==t:t!==i){var a="setScaleResolutionDownBy ".concat(n," ").concat(t);return i&&(a+=" prevScale: ".concat(i)),this._log.warn(a),r.encodings[0].scaleResolutionDownBy=t,e.setParameters(r)}}},{key:"updateSDP",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).localDescription;if(!this._parsedAnswer)return Promise.resolve();var n=Dq(this._parsedAnswer);return this._updateSDPPromise=new Promise((function(r,i){return aR(e,null,f().mark((function e(){var a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,e.t0=!t&&this._peerConnection,!e.t0){e.next=7;break}return this._log.info("creating offer"),e.next=6,this._peerConnection.createOffer();case 6:t=e.sent;case 7:if(e.t1=t,!e.t1){e.next=11;break}return e.next=11,this.setOffer(t);case 11:return e.next=13,this.setAnswer({type:"answer",sdp:n});case 13:this._updateSDPPromise=null,r(),e.next=20;break;case 17:e.prev=17,e.t2=e.catch(0),this._log.error(e.t2),!this._isSDPLogged&&this._peerConnection&&(this._log.warn("current offer: ".concat(this.filterSDPDirection(null==(a=this._peerConnection.localDescription)?void 0:a.sdp)," \nnext offer: ").concat(this.filterSDPDirection(null==t?void 0:t.sdp))),this._log.warn("current answer: ".concat(this.filterSDPDirection(null==(o=this._peerConnection.remoteDescription)?void 0:o.sdp)," \nnext answer: ").concat(this.filterSDPDirection(n))),this._log.warn("offer: ".concat(null==t?void 0:t.sdp)),this._log.warn("answer: ".concat(n)),this._log.warn("transceivers: ".concat(JSON.stringify(this._peerConnection.getTransceivers().map((function(e){return{mid:e.mid,currentDirection:e.currentDirection,direction:e.direction,stopped:e.stopped}}))))),this._log.warn("parsedAnswer: ".concat(JSON.stringify(this._parsedAnswer))),this._isSDPLogged=!0),this._updateSDPPromise=null,i(e.t2);case 20:case"end":return e.stop()}}),e,this,[[0,17]])})))})),this._updateSDPPromise}},{key:"setTransceiverDirection",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(wD&&this._peerConnection&&this._parsedAnswer){n.next=2;break}return n.abrupt("return");case 2:this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e)),r=this._peerConnection.getTransceivers(),t.forEach((function(t){r[t].direction!==e&&(r[t].direction=e)})),i=s(t);try{for(i.s();!(a=i.n()).done;)o=a.value,c=this._parsedAnswer.media[o].direction,e===rC.INACTIVE&&c===rC.RECVONLY&&(this._parsedAnswer.media[o].direction=e),e===rC.SENDONLY&&c===rC.INACTIVE&&(this._parsedAnswer.media[o].direction=rC.RECVONLY)}catch(u){i.e(u)}finally{i.f()}return n.next=9,this.updateSDP();case 9:case"end":return n.stop()}}),n,this)})))}},{key:"filterSDPDirection",value:function(){return wq(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").media.map((function(e){return e.direction}))}},{key:"setOffer",value:function(e){this._log.info("setting offer");var t=function(e,t,n){var r=uj.default.parse(e);return r.media.forEach((function(e,i){var a;if((e.type===nC.AUDIO||e.type===nC.VIDEO)&&(function(e){if(e.rtcpFb){var t=[];e.rtcpFb.forEach((function(n,r){var i;t.push(n),e.rtcpFb&&(null==(i=e.rtcpFb[r+1])?void 0:i.payload)!==n.payload&&"rrtr"!==n.type&&t.push({payload:n.payload,type:"rrtr"})})),e.rtcpFb=t}}(e),function(e){e.type===nC.VIDEO&&e.fmtp&&e.fmtp.forEach((function(e){e.config.includes("apt")||(e.config+=";sps-pps-idr-in-keyframe=1")}))}(e),function(e){e.type===nC.AUDIO&&e.fmtp&&e.fmtp.forEach((function(e){e.config+=";sprop-stereo=1;stereo=1"}))}(e),function(e){var t=new Set(["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"]);e.ext&&(e.ext=e.ext.filter((function(e){return!t.has(e.uri)})))}(e),e.type===nC.VIDEO))if(i<4)e.payloads="",e.fmtp=[],e.rtp=[],e.rtcpFb=[],t.video.codecs.forEach((function(t){return pj(e,t)}));else if(n){e.payloads="",e.fmtp=[],e.rtp=[],e.rtcpFb=[];var o=n.video.decoders;(!o||0===o.length)&&(o=n.video.codecs),(!o||0===o.length)&&(o=t.video.decoders),o.forEach((function(t){return pj(e,t)}))}null!=(a=e.payloads)&&a.includes("datachannel")&&r.groups&&e.mid&&(r.groups[0].mids=r.groups[0].mids.replace(e.mid,"dc"),e.mid="dc")})),uj.default.write(r)}(e.sdp,this.clientAbility,this._serverAbility);return this._log.debug(t),this._peerConnection.setLocalDescription({type:"offer",sdp:t})}},{key:"setAnswer",value:function(e){return this._log.info("setting answer"),this._log.debug(e.sdp),this._peerConnection.setRemoteDescription(e)}},{key:"switchVideoEncoder",value:function(e){return aR(this,null,f().mark((function t(){var n,r=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._peerConnection&&this._parsedAnswer&&this._serverAbility){t.next=2;break}return t.abrupt("return");case 2:if(n=!1,this._parsedAnswer.media.forEach((function(t){var i;if(t.type===nC.VIDEO){var a=r._serverAbility.video.codecs.find((function(t){return t.codec.toLowerCase()===e}));a&&(null==(i=t.payloads)||!i.includes(String(a.payload)))&&(t.fmtp=[],t.payloads="",t.rtp=[],t.rtcpFb=[],pj(t,a),n=!0)}})),t.t0=n,!t.t0){t.next=9;break}return this._log.warn("switch video encoder to ".concat(e)),t.next=9,this.updateSDP();case 9:case"end":return t.stop()}}),t,this)})))}},{key:"useHWEncoder",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1?arguments[1]:void 0;return aR(this,null,f().mark((function n(){var r,i,a=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._peerConnection&&this._parsedAnswer&&this._serverAbility){n.next=2;break}return n.abrupt("return");case 2:if(r=!1,i=[],bw(t)?i=this._parsedAnswer.media.slice(1,4):2===t?i.push(this._parsedAnswer.media[1]):3===t?i.push(this._parsedAnswer.media[2]):7===t&&i.push(this._parsedAnswer.media[3]),i.forEach((function(t){var n,i;t.type===nC.VIDEO&&(e&&a.is42001fSupported?i=a.clientAbility.video.codecs.find((function(e){return e.fmtp.includes("42001f")})):e||(i=a._serverAbility.video.codecs.find((function(e){return e.codec.toLowerCase()===(a._serverAbility.useVp8?"vp8":"h264")}))),i&&(null==(n=t.payloads)||!n.includes(String(i.payload)))&&(t.fmtp=[],t.payloads="",t.rtp=[],t.rtcpFb=[],pj(t,i),r=!0))})),n.t0=r,!n.t0){n.next=10;break}return this._log.warn("use ".concat(e?"hw":"sw"," encoder")),n.next=10,this.updateSDP();case 10:case"end":return n.stop()}}),n,this)})))}},{key:"sendDataChannelMessage",value:function(e){var t;null==(t=this._datachannel)||t.send(e)}},{key:"reset",value:function(){this._peerConnection&&(this._peerConnection.close(),this._peerConnection.removeEventListener("track",this._peerConnection._onaddstreampoly,this),this._peerConnection._onaddstreampoly=null,this._peerConnection=null),this._waitForPCConnectedPromise=null,this._parsedAnswer=null,this.originOffer=null}},{key:"close",value:function(){this._log.info("close pc"),this.removeRTCListener(),this.insertableStreamsAbortMap.forEach((function(e){return cD(e.abort)&&e.abort("destroy")})),this.insertableStreamsAbortMap.clear(),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this._downlinkMIDMap.clear(),this.stopReconnection(),this.removeAllListeners(),this._room.healthDetector.off("1",this.onBadHealth,this)}},{key:"getReceiversByUserId",value:function(e){if(!this._peerConnection)return[];var t=this._peerConnection.getReceivers();return(this._downlinkMIDMap.get(e)||[]).map((function(e){return t[e]}))}},{key:"isUsingRelay",get:function(){return"relay"===this._room.getIceTransportPolicy()}},{key:"detectTCPAndUDP",value:function(e){var t,n=e.uplinkRTT,r=e.downlinkRTT;if("CONNECTED"===this.currentState&&(!this._isRelayTried||this._room.forceRelay)&&0!==this._room.getIceServers().length){var i=this._signalChannel.rtt,a=Math.max(n,r),o=(null==(t=this._room.scheduleResult.config)?void 0:t.useTurnTcpInfo)||{},s=o.rttRatioThreshold,c=o.rttThreshold;if(s&&c&&i&&a){var u=Math.floor(a/i),l=(this._isRelayTried||u>s)&&a>c;l?++this._rttOverCount<5||(this._log.warn("detectTCPAndUDP ws-rtt: ".concat(i," upRTT: ").concat(n," downRTT: ").concat(r," ratio: ").concat(u," over-count: ").concat(this._rttOverCount," isOver: ").concat(l," isRelayTried: ").concat(this._isRelayTried," force-relay: ").concat(this._room.forceRelay)),this.isUsingRelay||this._isRelayTried?this._room.forceRelay&&this.switchRelay(!1):(this._isRelayTried=!0,this._rttOverCount=0,this.switchRelay(!0))):this._rttOverCount=0}}}},{key:"switchRelay",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return aR(this,null,f().mark((function n(){var r,i,a;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.isUsingRelay!==e){n.next=2;break}return n.abrupt("return");case 2:return r=e?"relay":"udp",i=e?521709:521710,n.prev=3,this._room.forceRelay=e,this._log.warn("switchRelay ".concat(r)),a=Date.now(),n.next=8,this.doSwitchRelay(r);case 8:this._log.warn("switchRelay ".concat(r," success")),IN.addSuccessEvent({key:i,cost:Date.now()-a}),n.next=22;break;case 12:if(n.prev=12,n.t0=n.catch(3),this._log.warn("switchRelay ".concat(r," failed"),n.t0),IN.addFailedEvent({key:i,error:n.t0}),!t){n.next=20;break}this._room.reJoin(),n.next=22;break;case 20:return n.next=22,this.switchRelay(!e,!0);case 22:case"end":return n.stop()}}),n,this,[[3,12]])})))}},{key:"doSwitchRelay",value:function(e){var t=this;return new Promise((function(n,r){var i=setTimeout((function(){t.stopReconnection(),r(new Error("switch ".concat(e," timeout")))}),1e4);t.startReconnection().then(n,r).finally((function(){return clearTimeout(i)}))}))}},{key:"removeRTCListener",value:function(){this._peerConnection&&(this._peerConnection.oniceconnectionstatechange=null,this._peerConnection.onconnectionstatechange=null,this._peerConnection.onsignalingstatechange=null,this._peerConnection.ontrack=null),this.dtlsTransport&&(this.dtlsTransport.onstatechange=null)}}])}(cj.default);nR([vL("reconnect")],bj.prototype,"startReconnection",1),nR([_L((function(e){return e.userId}))],bj.prototype,"addDownlink",1),nR([_L((function(e){return e}))],bj.prototype,"removeDownlink",1),nR([mL(!0)],bj.prototype,"updateSDP",1),nR([gL(521712,!1)],bj.prototype,"setOffer",1),nR([gL(521713,!1)],bj.prototype,"setAnswer",1);var Ij=o((function e(t){r(this,e),rR(this,"tag"),rR(this,"len"),rR(this,"data");var n=new DataView(t);this.tag=n.getUint16(),this.len=n.getUint16(2),this.data=new Uint8Array(t).slice(4,4+this.len).buffer})),Aj=o((function e(t){var n=this;r(this,e),rR(this,"tinyId"),rR(this,"data");for(var i=new DataView(t),a=0,o=[];a<i.byteLength;){var s=i.getUint16(a+2),c=new Ij(new Uint8Array(t).slice(a,a+2+2+s).buffer);o.push(c),a+=4+s}o.forEach((function(e){1===e.tag?n.tinyId=(new TextDecoder).decode(e.data):2===e.tag&&(n.data=e.data)}))})),Rj=new Set;function Cj(){var e=Math.floor(4294967296*Math.random());return Rj.has(e)?Cj():(Rj.add(e),e)}var wj=function(e){function i(e){var a;return r(this,i),a=n(this,i),rR(t(a),"userId"),rR(t(a),"tinyId"),rR(t(a),"_sdpSemantics"),rR(t(a),"_isUplink"),rR(t(a),"_room"),rR(t(a),"_log"),rR(t(a),"_currentState","DISCONNECTED"),rR(t(a),"_prevTime",-1),a.userId=e.userId,a.tinyId=e.tinyId,a._room=e.room,a._sdpSemantics=e.room.sdpSemantics,a._isUplink=e.isUplink,a._log=sO.createLogger({id:"n",userId:a._room.userId,remoteUserId:a._isUplink?void 0:a.userId,sdkAppId:a._room.sdkAppId,isLocal:a._isUplink}),a}return d(i,e),o(i,[{key:"_peerConnection",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.getPeerConnection())||null}},{key:"singlePC",get:function(){return this._room.singlePC}},{key:"_signalChannel",get:function(){return this._room.signalChannel}},{key:"close",value:function(e){this._log.info("close connection"),this.emit("closed",e)}},{key:"emitConnectionStateChangedEvent",value:function(e){return e!==this._currentState&&(rO.emit(aO.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"getRoom",value:function(){return this._room}},{key:"getUserId",value:function(){return this.userId}},{key:"getTinyId",value:function(){return this.tinyId}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"isH264",get:function(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}}])}(tR(oR()).default),Dj=function(e){function i(e){var a;return r(this,i),a=n(this,i,[$A(QA({},e),{isUplink:!0})]),rR(t(a),"localMainAudioTrack",null),rR(t(a),"localMainVideoTrack",null),rR(t(a),"localAuxAudioTrack",null),rR(t(a),"localAuxVideoTrack",null),rR(t(a),"_isPublishingAux",!1),rR(t(a),"_publishingLocalAudioTrack"),rR(t(a),"_publishingLocalVideoTrack"),rR(t(a),"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),rR(t(a),"_flag",0),rR(t(a),"_checkPublishStateTimeoutId",-1),a.initialize(),a}return d(i,e),o(i,[{key:"videoCodec",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.videoCodec)||"h264"}},{key:"ssrc",get:function(){if(!this.singlePC)return{audio:0,video:0,videoRtx:0,small:0,smallRtx:0,auxiliary:0,auxiliaryRtx:0};var e=this.singlePC.uplinkSSRC;return{audio:e.audioSsrc||0,video:e.bigVideoSsrc||0,videoRtx:e.bigVideoRtxSsrc||0,small:e.smallVideoSsrc||0,smallRtx:e.smallVideoRtxSsrc||0,auxiliary:e.auxVideoSsrc||0,auxiliaryRtx:e.auxVideoRtxSsrc||0}}},{key:"flag",get:function(){return this._flag},set:function(e){this._flag!==e&&(this._flag=e,this.checkPublishState())}},{key:"checkPublishState",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(t||!(this._checkPublishStateTimeoutId>0)){var n=this.publishState,r=this.serverPublishState,i=Object.keys(n).find((function(e){return n[e]!==r[e]}));if(i){if(!t)return void(this._checkPublishStateTimeoutId=MP.run("timeout",(function(){return e.checkPublishState(!0)}),{delay:1e4,count:1}));this._log.warn("publish state not matched, ".concat(i," local:").concat(n[i]," server:").concat(r[i]," ").concat(Zx()," ").concat(Yx())),IN.addCount({key:521e3})}MP.clearTask(this._checkPublishStateTimeoutId),this._checkPublishStateTimeoutId=-1}}},{key:"isMainStreamPublished",get:function(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}},{key:"isAuxStreamPublished",get:function(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}},{key:"publishState",get:function(){var e,t,n,r,i=this,a={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){var o=this._peerConnection.getSenders();o&&(QN()?(a.audio=!(null==(e=o[0])||!e.track),a.bigVideo=!(null==(t=o[1])||!t.track),a.smallVideo=!(null==(n=o[2])||!n.track),a.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((function(e){e.track&&(e.track.kind===nC.AUDIO?a.audio=!0:(a.bigVideo=!0,i._room.videoManager.hasSmall&&(a.smallVideo=!0)))})))}return a}},{key:"publishingState",get:function(){var e=this.publishState,t=QA({},e);return this._publishingLocalAudioTrack&&(t.audio=!0),this._publishingLocalVideoTrack&&(this._isPublishingAux?t.auxVideo=!0:(t.bigVideo=!0,this._publishingLocalVideoTrack.small&&(t.smallVideo=!0))),t}},{key:"serverPublishState",get:function(){return{audio:!!(this.flag&uC),bigVideo:!!(this.flag&oC),smallVideo:!!(this.flag&sC),auxVideo:!!(this.flag&cC)}}},{key:"muteState",get:function(){var e,t,n;return{audio:!(null==(e=this.localMainAudioTrack)||!e.muted),bigVideo:!(null==(t=this.localMainVideoTrack)||!t.muted),auxVideo:!(null==(n=this.localAuxVideoTrack)||!n.muted)}}},{key:"initialize",value:function(){this.installEvents()}},{key:"close",value:function(e){var t,n,r=s((null==(t=this._peerConnection)?void 0:t.getSenders())||[]);try{for(r.s();!(n=r.n()).done;)n.value.replaceTrack(null)}catch(a){r.e(a)}finally{r.f()}g(i,"close",this,3)([e]),this.uninstallEvents(),this.uninstallTrackMuteEvents(this.localMainAudioTrack,this.localMainVideoTrack,this.localAuxVideoTrack),this.emitConnectionStateChangedEvent("DISCONNECTED")}},{key:"installEvents",value:function(){this.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this.on("connection-state-changed",this.handleConnectionStateChange,this),this.installSPCEvents()}},{key:"installSPCEvents",value:function(){var e,t;null!=(e=this.singlePC)&&e.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||null==(t=this.singlePC)||t.on("spc-reconnected",this.onSinglePCReconnected,this)}},{key:"uninstallSPCEvents",value:function(){var e;null==(e=this.singlePC)||e.off("spc-reconnected",this.onSinglePCReconnected,this)}},{key:"uninstallEvents",value:function(){this.off("connection-state-changed",this.handleConnectionStateChange,this),this.uninstallSPCEvents()}},{key:"emitConnectionStateChangedEvent",value:function(e,t){var n,r,a,o=this._currentState,s=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(n=this.localMainVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(a=this._publishingLocalVideoTrack)||a.emit("connection-state-changed",{prevState:o,state:e}))),s}},{key:"onVideoEncodeFailed",value:function(e){var t;e&&e.isMediaTrackActive&&"h264"===this.videoCodec&&(this._log.warn("h264 encoder not working"),null!=(t=this.singlePC)&&t.isVP8EncodeSupported&&(this._log.warn("switch to vp8"),this.singlePC.switchVideoEncoder("vp8")))}},{key:"publish",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.isAuxiliary;return f().mark((function e(){var a,o,s,c,u,l,d,h,p,m,v;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.singlePC){e.next=2;break}return e.abrupt("return");case 2:return t.installEvents(),e.next=5,t.singlePC.waitForPeerConnectionConnected();case 5:if(p=t.publishState,m=t.muteState,n&&(t._publishingLocalAudioTrack=n,p.audio=!0,m.audio=n.muted),!r){e.next=22;break}if(t.singlePC.isH264EncodeSupported||t.singlePC.isVP8EncodeSupported){e.next=9;break}throw new yR({code:_R.NOT_SUPPORTED_H264,message:mN({key:dN.NOT_SUPPORTED_H264ENCODE})});case 9:if(e.t0=t.singlePC.isUsingH264&&!t.singlePC.isH264EncodeSupported&&t.singlePC.isVP8EncodeSupported,!e.t0){e.next=14;break}return t._log.warn("h264 encoder not supported"),e.next=14,t.singlePC.switchVideoEncoder("vp8");case 14:if(e.t1=ID&&115===Ax()&&r.profile.width*r.profile.height<=230400,!e.t1){e.next=20;break}return t._log.warn("fallback video to 480p"),r.setProfile(eC["480p_2"]),e.next=20,r.applyProfile();case 20:t._publishingLocalVideoTrack=r,i?(p.auxVideo=!0,m.auxVideo=r.muted):(p.bigVideo=!0,m.bigVideo=r.muted);case 22:return t._isPublishingAux=i,r&&!i&&r.small&&(h=t._room.videoManager.smallTrack,p.smallVideo=!0),e.next=26,t._signalChannel.sendWaitForResponseWithRetry({command:"publish/v2",responseCommand:fq.SPC_PUBLISH_RESULT,data:$A(QA({},t.singlePC.uplinkSSRC),{state:p,muteState:m}),retries:3});case 26:return e.next=28,t.publishByTransceiver({localAudioTrack:n,localVideoTrack:r,smallTrack:h,isAuxiliary:i});case 28:if(t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,!r){e.next=36;break}return t[i?"localAuxVideoTrack":"localMainVideoTrack"]=r,v=r.scaleResolutionDownBy,e.next=36,t.singlePC.setScaleResolutionDownBy(t._peerConnection.getSenders()[i?3:1],v,r.streamType);case 36:return n&&(t[i?"localAuxAudioTrack":"localMainAudioTrack"]=n),e.next=39,t.singlePC.setBandwidth({audio:(null==(a=t.localMainAudioTrack)?void 0:a.profile.bitrate)||(null==(o=t.localAuxAudioTrack)?void 0:o.profile.bitrate),bigVideo:null==(s=t.localMainVideoTrack)?void 0:s.profile.bitrate,smallVideo:null==(u=null==(c=t.localMainVideoTrack)?void 0:c.small)?void 0:u.bitrate,auxVideo:null==(l=t.localAuxVideoTrack)?void 0:l.profile.bitrate});case 39:t.sendMediaSettings(),t.installTrackMuteEvents(n,r),(t._room.preferHW||null!=(d=t._room.scheduleResult.config)&&d.preferHW)&&r&&r.profile.width*r.profile.height>=921600&&t.singlePC.useHWEncoder(!0,i?7:2);case 42:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByTransceiver",value:function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack,a=e.isAuxiliary;if($N()){this._log.info("publish by transceiver");var o=null==r?void 0:r.outMediaTrack,s=null==n?void 0:n.outMediaTrack,c=this._peerConnection.getTransceivers(),u=[],l=[],d=function(e,n,r){var i,a,o=c[n].sender.replaceTrack(r);l.push(n),null!=(i=t.singlePC)&&i.enableInsertableStreams&&o.then((function(){return t.createEncodedStreams(c[n].sender,e)})),null!=(a=t.singlePC)&&a.scriptTransformWorker&&t.initSenderTransfrom(c[n].sender,e),u.push(o)};s&&d(n.mediaType,0,s),o&&d(r.mediaType,a?3:1,o),i&&d(8,2,i);var h=this.singlePC.setTransceiverDirection(rC.SENDONLY,l);return u.push(h),Promise.all(u)}}},{key:"getTrackByMediaType",value:function(e){switch(e){case 1:return this.localMainAudioTrack||this._publishingLocalAudioTrack;case 4:case 8:return this.localMainVideoTrack||this._publishingLocalVideoTrack;case 2:return this.localAuxVideoTrack||this._publishingLocalVideoTrack;default:return null}}},{key:"createEncodedStreams",value:function(e,t){var n,r,i=this;if(!this.singlePC.insertableStreamsAbortMap.has(e)){var a=e.createEncodedStreams(),o=new AbortController;null==(n=this.singlePC)||n.addAbortController(e,o),(null!=(r=this.getTrackByMediaType(t))&&r.enableEncodeFrame?a.readable.pipeThrough(new TransformStream({transform:function(e,n){var r,a=i.getTrackByMediaType(t);n.enqueue(null!=(r=i.singlePC)&&r.isUsingH264&&a?a.encodeFrame(e,8===t):e)}}),o):a.readable).pipeTo(a.writable,o).catch((function(e){i._log.debug("encoded stream error",e),"destory"!==e&&i._log.warn(e)}))}}},{key:"initSenderTransfrom",value:function(e,t){if(this._peerConnection&&this.singlePC&&this.singlePC.scriptTransformWorker){var n=2!==t,r=8===t;e.transform||(e.transform=new RTCRtpScriptTransform(this.singlePC.scriptTransformWorker,{isReceiver:!1,isAudio:1===t,isMain:n,isSmall:r}))}}},{key:"enableSmall",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.singlePC){t.next=2;break}return t.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),!e){t.next=13;break}if(!this._room.videoManager.smallTrack){t.next=11;break}return i=r[2].sender,null!=(n=this.singlePC)&&n.enableInsertableStreams&&this.createEncodedStreams(i,8),t.next=9,i.replaceTrack(this._room.videoManager.smallTrack);case 9:return t.next=11,this.singlePC.setTransceiverDirection(rC.SENDONLY,[2]);case 11:t.next=17;break;case 13:return t.next=15,r[2].sender.replaceTrack(null);case 15:return t.next=17,this.singlePC.setTransceiverDirection(rC.INACTIVE,[2]);case 17:return this.updateMediaSettings(),t.next=20,this.doPublishChange();case 20:case"end":return t.stop()}}),t,this)})))}},{key:"installTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.on("mute",e.sendMutedFlag,e),null==t||t.on("unmute",e.sendMutedFlag,e))}))}},{key:"uninstallTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.off("mute",e.sendMutedFlag,e),null==t||t.off("unmute",e.sendMutedFlag,e))}))}},{key:"unpublish",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack;return f().mark((function e(){var i,a,o,s;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r&&r===t.localAuxVideoTrack,a=null==r?void 0:r.outMediaTrack,o=t._peerConnection.getSenders(),s=[],e.t0=n,!e.t0){e.next=9;break}if(i?t.localAuxAudioTrack=null:t.localMainAudioTrack=null,e.t1=!t.localMainAudioTrack&&!t.localAuxAudioTrack,!e.t1){e.next=9;break}return e.next=8,o[0].replaceTrack(null);case 8:s.push(0);case 9:if(e.t2=a,!e.t2){e.next=26;break}if(!i){e.next=19;break}return e.next=14,o[3].replaceTrack(null);case 14:t.localAuxVideoTrack=null,t._mediaSettings=$A(QA({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3),e.next=26;break;case 19:return e.next=21,o[1].replaceTrack(null);case 21:return e.next=23,o[2].replaceTrack(null);case 23:t.localMainVideoTrack=null,t._mediaSettings=$A(QA({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2);case 26:if(!t.isMainStreamPublished&&!t.isAuxStreamPublished){e.next=33;break}return e.next=29,t.singlePC.setTransceiverDirection(rC.INACTIVE,s);case 29:return e.next=31,t.doPublishChange(!1);case 31:e.next=35;break;case 33:return e.next=35,t.doUnpublish();case 35:t.uninstallTrackMuteEvents(n,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"});case 37:case"end":return e.stop()}}),e)}))()}))}},{key:"doPublishChange",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={state:this.publishingState,constraintConfig:this._mediaSettings},t.next=3,this._signalChannel.sendWaitForResponseWithRetry({command:mq,data:n,responseCommand:fq.PUBLISH_STATE_CHANGE_RESULT,enableLog:e,retries:3});case 3:r=t.sent,this.checkPublishResultCode(r.data.code,r.data.message);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doUnpublish",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:vq,commandDesc:"unpublish",responseCommand:fq.UNPUBLISH_RESULT,enableLog:e}).catch((function(e){if(e.getCode()===_R.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}},{key:"updateMediaSettings",value:function(){var e;this._mediaSettings.videoCodec=(null==(e=this.singlePC)?void 0:e.videoCodec)||"h264";var t=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,n=this.localMainVideoTrack,r=this.localAuxVideoTrack;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?r=this._publishingLocalVideoTrack:n=this._publishingLocalVideoTrack),aP){if(t&&t.outMediaTrack){var i=t.outMediaTrack.getSettings();this._mediaSettings.audioChannel=i.channelCount||1,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=i.sampleRate||0}if(n&&n.outMediaTrack){var a=n.outMediaTrack.getSettings(),o=n.scaleResolutionDownBy;this._mediaSettings.videoWidth=a.width/o||0,this._mediaSettings.videoHeight=a.height/o||0,this._mediaSettings.videoFps=a.frameRate||0,this._mediaSettings.videoBps=1e3*n.profile.bitrate,n.small&&(this._mediaSettings.smallVideoWidth=n.small.width,this._mediaSettings.smallVideoHeight=n.small.height,this._mediaSettings.smallVideoFps=n.small.frameRate,this._mediaSettings.smallVideoBps=1e3*n.small.bitrate)}if(r&&r.outMediaTrack){var s=r.outMediaTrack.getSettings(),c=r.scaleResolutionDownBy;this._mediaSettings.auxVideoWidth=s.width/c||0,this._mediaSettings.auxVideoHeight=s.height/c||0,this._mediaSettings.auxVideoFps=s.frameRate||0,this._mediaSettings.auxVideoBps=1e3*r.profile.bitrate}}else t&&t.outMediaTrack&&(this._mediaSettings.audioChannel=t.profile.channelCount,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=t.profile.sampleRate),n&&n.outMediaTrack&&(this._mediaSettings.videoWidth=n.profile.width,this._mediaSettings.videoHeight=n.profile.height,this._mediaSettings.videoFps=n.profile.frameRate,this._mediaSettings.videoBps=1e3*n.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}},{key:"sendMediaSettings",value:function(){var e=this;this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:yq,data:this._mediaSettings,responseCommand:fq.UPDATE_CONSTRAINT_CONFIG_RES}).then((function(t){0!==t.data.code&&e._log.warn(t.data.message)})).catch((function(){}))}},{key:"addTrack",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._peerConnection){t.next=2;break}return t.abrupt("return");case 2:if(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is adding ".concat(e.kind," track to current published local ").concat(n?nC.AUXILIARY:nC.MAIN," stream")),t.t0=QN(),!t.t0){t.next=8;break}return t.next=8,this.addTrackByTransceiver(e,n);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"addTrackByTransceiver",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(i=this._peerConnection.getTransceivers(),e.kind!==nC.AUDIO){n.next=8;break}return n.next=6,i[0].sender.replaceTrack(e.outMediaTrack);case 6:n.next=19;break;case 8:return a=t?3:1,n.next=11,i[a].sender.replaceTrack(e.outMediaTrack);case 11:if(n.t0=1===a&&null!=(r=this.localMainVideoTrack)&&r.small,!n.t0){n.next=15;break}return n.next=15,i[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 15:if(n.t1=i[a].direction===rC.INACTIVE,!n.t1){n.next=19;break}return n.next=19,this.singlePC.setTransceiverDirection(rC.SENDONLY,[a]);case 19:return this.updateMediaSettings(),n.next=22,this.doPublishChange();case 22:case"end":return n.stop()}}),n,this)})))}},{key:"removeTrack",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._peerConnection){t.next=2;break}return t.abrupt("return");case 2:if(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is removing ".concat(e.kind," track from current published local ").concat(n?nC.AUXILIARY:nC.MAIN," stream")),t.t0=QN(),!t.t0){t.next=8;break}return t.next=8,this.removeTrackByTransceiver(e,n);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrackByTransceiver",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),e.kind!==nC.AUDIO){n.next=8;break}return n.next=6,r[0].sender.replaceTrack(null);case 6:n.next=17;break;case 8:return i=t?3:1,n.next=11,r[i].sender.replaceTrack(null);case 11:if(n.t0=1===i&&this._room.videoManager.hasSmall,!n.t0){n.next=15;break}return n.next=15,r[2].sender.replaceTrack(null);case 15:return n.next=17,this.singlePC.setTransceiverDirection(rC.INACTIVE,[i]);case 17:return this.updateMediaSettings(),n.next=20,this.doPublishChange();case 20:case"end":return n.stop()}}),n,this)})))}},{key:"replaceTrack",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=null==(n=this._peerConnection)?void 0:n.getSenders(),i=e.outMediaTrack||e.mediaTrack,r&&0!==r.length&&i&&!r.find((function(e){return e.track===i}))){t.next=3;break}return t.abrupt("return",!1);case 3:if(a=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is replacing ".concat(i.kind," track ").concat(i.id," ").concat(i.label," on ").concat(a?nC.AUXILIARY:nC.MAIN," stream")),t.t0=i.kind===nC.AUDIO&&r[0],!t.t0){t.next=9;break}return t.next=9,r[0].replaceTrack(i);case 9:if(t.t1=i.kind===nC.VIDEO,!t.t1){t.next=19;break}if(t.t2=!a&&r[1],!t.t2){t.next=15;break}return t.next=15,r[1].replaceTrack(i);case 15:if(t.t3=a&&r[3],!t.t3){t.next=19;break}return t.next=19,r[3].replaceTrack(i);case 19:return t.abrupt("return",!0);case 20:case"end":return t.stop()}}),t,this)})))}},{key:"setBandwidth",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.bandwidth,r=e.type,i=e.videoType;return f().mark((function e(){var a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.singlePC){e.next=5;break}return a={},r===nC.AUDIO?a.audio=n:"big"===i?a.bigVideo=n:"small"===i?a.smallVideo=n:a.auxVideo=n,e.next=5,t.singlePC.setBandwidth(a);case 5:case"end":return e.stop()}}),e)}))()}))}},{key:"sendMutedFlag",value:function(e){e===this.localAuxAudioTrack||e===this.localAuxVideoTrack||(this._log.info("send muted state: ".concat(JSON.stringify(this.muteState))),this._signalChannel.sendWaitForResponseWithRetry({command:pq,responseCommand:fq.MUTE_RESULT,data:this.muteState,retries:3}).catch((function(){})))}},{key:"handleConnectionStateChange",value:function(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&rO.emit(aO.SEND_FIRST_VIDEO_FRAME,{room:this._room})}},{key:"getVideoTrackId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nC.VIDEO;if(this._peerConnection){var t=this._peerConnection.getSenders();if(e===nC.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===nC.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===nC.VIDEO){var n=this.localMainVideoTrack.mediaTrack;if(n)return n.id}if(this.localAuxVideoTrack&&e===nC.AUXILIARY){var r=this.localAuxVideoTrack.mediaTrack;if(r)return r.id}return""}},{key:"getSSRC",value:function(){return this.ssrc}},{key:"checkPublishResultCode",value:function(e,t){if(0!==e)throw e===VC?(this._log.error(hN.NOT_SUPPORTED_H264ENCODE),new yR({code:_R.NOT_SUPPORTED_H264,message:mN({key:dN.NOT_SUPPORTED_H264ENCODE})})):new yR({code:_R.UNKNOWN,message:mN({key:dN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:fq.PUBLISH_RESULT,code:e,message:t}})})}},{key:"onSinglePCReconnected",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isMainStreamPublished,!e.t0){e.next=5;break}return this._log.warn("republish main stream"),e.next=5,this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1});case 5:if(e.t1=this.isAuxStreamPublished,!e.t1){e.next=10;break}return this._log.warn("republish aux stream"),e.next=10,this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0});case 10:case"end":return e.stop()}}),e,this)})))}}])}(wj);nR([sL((function(e){var t=e.localVideoTrack;null==t||t.once("6",this.onVideoEncodeFailed,this)}))],Dj.prototype,"publish",1),nR([sL((function(e){var t=e.localVideoTrack;null==t||t.off("6",this.onVideoEncodeFailed,this)}))],Dj.prototype,"unpublish",1);var xj=Dj;function Oj(e){return Object.keys(e).filter((function(t){return e[t]}))}var Nj=function(e){function i(e){var a;return r(this,i),a=n(this,i,[$A(QA({},e),{isUplink:!1})]),rR(t(a),"_flag",0),rR(t(a),"isRobot",!1),rR(t(a),"role","anchor"),rR(t(a),"remoteAudioTrack"),rR(t(a),"remoteVideoTrack"),rR(t(a),"remoteAuxiliaryTrack"),rR(t(a),"ssrc",{audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0}),rR(t(a),"jitterBufferTimeoutId",-1),a.flag=e.flag,a.isRobot=e.isRobot||!1,a.remoteAudioTrack=new XV(a._room,t(a)),a.remoteVideoTrack=new pF(a._room,t(a)),a.remoteAuxiliaryTrack=new mF(a._room,t(a)),a.initialize(),a}return d(i,e),o(i,[{key:"videoCodec",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.downlinkVideoCodec)||"h264"}},{key:"subscribeState",get:function(){return{audio:this.remoteAudioTrack.isSubscribed||this.remoteAudioTrack.isSubscribing,video:this.remoteVideoTrack.isBig&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),smallVideo:this.remoteVideoTrack.isSmall&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),auxiliary:this.remoteAuxiliaryTrack.isSubscribed||this.remoteAuxiliaryTrack.isSubscribing}}},{key:"muteState",get:function(){return jw(this.flag,this.userId)}},{key:"flag",get:function(){return this._flag},set:function(e){var t,n,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(n=this.remoteVideoTrack)||n.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}},{key:"hasMainStream",get:function(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}},{key:"hasAuxStream",get:function(){return this.muteState.hasAuxiliary}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState.video&&this.muteState.hasVideo}},{key:"isStreamUnpublished",value:function(e){return e===nC.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}},{key:"initialize",value:function(){this.installEvents()}},{key:"close",value:function(e){clearTimeout(this.jitterBufferTimeoutId),g(i,"close",this,3)([e]),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents(),this.removeDownlink()}},{key:"installEvents",value:function(){this.singlePC&&(this.listeners("track").includes(this.onTrack)||this.singlePC.on("track",this.onTrack,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||this.singlePC.on("spc-reconnected",this.onSinglePCReconnected,this))}},{key:"uninstallEvents",value:function(){this.singlePC&&(this.singlePC.off("track",this.onTrack,this),this.singlePC.off("spc-reconnected",this.onSinglePCReconnected,this))}},{key:"emitConnectionStateChangedEvent",value:function(e){var t,n,r=this._currentState,a=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return a&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(n=this.remoteAuxiliaryTrack)||n.emit("connection-state-changed",{prevState:r,state:e})),a}},{key:"onTrack",value:function(e){var t,n,r=e.streams[0],i=e.track,a=e.receiver;if(r.id.includes(this.tinyId)){var o=r.id.includes("aux")?"auxiliary":"main";this._log.debug("ontrack ".concat(o," ").concat(i.kind));var s=nC.AUDIO;i.kind===nC.VIDEO&&(s=o===nC.MAIN?nC.VIDEO:nC.AUXILIARY);var c=this.remoteAudioTrack;s===nC.VIDEO?c=this.remoteVideoTrack:s===nC.AUXILIARY&&(c=this.remoteAuxiliaryTrack),null==(t=this.singlePC)||t.receiverRemoteTrackMap.set(a,c),null!=(n=this.singlePC)&&n.scriptTransformWorker&&this.initReceiverTransform(a,o,i.kind===nC.AUDIO),this.singlePC.enableInsertableStreams&&this.createEncodedStreams(a),c.setInputMediaStreamTrack(i)}}},{key:"createEncodedStreams",value:function(e){var t=this;if(!this.singlePC.insertableStreamsAbortMap.has(e)){var n=e.createEncodedStreams(),r=new AbortController,i={abortController:r,enqueue:function(n){var r,i,a=null==(r=t.singlePC)?void 0:r.receiverRemoteTrackMap.get(e);return a&&("video"!==a.kind||null!=(i=t.singlePC)&&i.isUsingH264)?a.decodeFrame(n):n}};n.readable.pipeThrough(new TransformStream({transform:function(e,t){var n=i.enqueue(e);n&&t.enqueue(n)}})).pipeTo(n.writable,r).catch((function(e){"destory"!==e&&t._log.warn(e)})),this.singlePC.addAbortController(e,r)}}},{key:"initReceiverTransform",value:function(e,t,n){!this._peerConnection||!this.singlePC||!this.singlePC.scriptTransformWorker||e.transform||(e.transform=new RTCRtpScriptTransform(this.singlePC.scriptTransformWorker,{isReceiver:!0,isAudio:n,userId:this.userId,streamType:t}))}},{key:"subscribe",value:function(e,t){return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,this._log.info("subscribe ".concat(t," ").concat(Oj(e))),!this.hasSSRC){n.next=8;break}return r="subscribe_change",Object.values(e).find((function(e){return!0===e}))||(r="unsubscribe"),n.next=6,this.sendSubscription(r,e);case 6:n.next=11;break;case 8:return n.next=10,this.doSubscribe(e);case 10:this.checkTrackEnded(e);case 11:n.next=16;break;case 13:throw n.prev=13,n.t0=n.catch(0),this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(n.t0.message," ").concat(JSON.stringify(this.muteState))),new yR({code:_R.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):n.t0;case 16:case"end":return n.stop()}}),n,this,[[0,13]])})))}},{key:"checkTrackEnded",value:function(e){var t,n,r;if((e.audio&&"ended"===(null==(t=this.remoteAudioTrack.mediaTrack)?void 0:t.readyState)||e.video&&"ended"===(null==(n=this.remoteVideoTrack.mediaTrack)?void 0:n.readyState)||e.auxiliary&&"ended"===(null==(r=this.remoteAuxiliaryTrack.mediaTrack)?void 0:r.readState))&&this.singlePC&&!this.singlePC.isReconnecting){if(this._log.warn("remote track ended start spc reconnect"),Rx&&Dx<92)return;this.singlePC.startReconnection()}}},{key:"unsubscribe",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.remoteTracks,r=e.streamType;return f().mark((function e(){var i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(("main"!==r||t.isMainStreamSubscribed)&&("auxiliary"!==r||t.isAuxStreamSubscribed)){e.next=2;break}return e.abrupt("return",void t._log.info("".concat(r," stream already unsubscribed")));case 2:return a=QA({},t.subscribeState),n.forEach((function(e){switch(e.mediaType){case 1:a.audio=!1;break;case 4:a.video=!1;break;case 8:a.smallVideo=!1;break;case 2:a.auxiliary=!1}})),o="subscribe_change",Object.values(a).find((function(e){return!0===e}))||(o="unsubscribe"),t._log.info("".concat("unsubscribe"===o?o:"subscribe"," ").concat(r," [").concat(Oj(a),"]")),"unsubscribe"===o&&(null==(i=t.singlePC)||i.removeDownlinkQueue.add(t.tinyId)),e.next=10,t.sendSubscription(o,a);case 10:if(e.t0="unsubscribe"===o,!e.t0){e.next=14;break}return e.next=14,t.removeDownlink();case 14:case"end":return e.stop()}}),e)}))()}))}},{key:"sendSubscription",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,r={srcTinyId:this.tinyId,srcUserId:this.userId},i=_q,a=fq.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(r={audio:n.audio,bigVideo:n.video,auxVideo:n.auxiliary,smallVideo:n.smallVideo,srcTinyId:this.tinyId},i=gq,a=fq.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponseWithRetry({command:i,data:r,responseCommand:a,timeout:1e4,retries:3}).then((function(n){var r=n.data;if(0!==r.code){var i=new yR({code:r.code,message:mN({key:dN.ERROR_MESSAGE,data:{type:e,message:r.message}})});throw t._log.error(i),i}}))}},{key:"getMainStreamVideoTrackId",value:function(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}},{key:"getAuxStreamVideoTrackId",value:function(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}},{key:"setDelay",value:function(e){var t=e.audioDelay,n=e.videoDelay;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=n}},{key:"onSinglePCReconnected",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.ssrc.audio||this.ssrc.video||this.ssrc.auxiliary,!e.t0){e.next=8;break}return this._log.warn("resubscribe ".concat(JSON.stringify(this.subscribeState))),e.next=5,this.doSubscribe(this.subscribeState);case 5:this.remoteAudioTrack.checkDecodeResult(),this.remoteVideoTrack.checkDecodeResult(),this.remoteAuxiliaryTrack.checkDecodeResult();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"hasSSRC",get:function(){return this.ssrc.audio&&this.ssrc.video&&this.ssrc.auxiliary}},{key:"doSubscribe",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return f().mark((function r(){var i,a,o,s,c,u,l,d,h,p,m,v,_,g,y;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!e.singlePC){r.next=34;break}return e.singlePC.addDownlinkQueue.add(e.tinyId),r.next=4,e.singlePC.waitForPeerConnectionConnected();case 4:if(r.prev=4,!n&&e.hasSSRC){r.next=25;break}return i={audioSsrc:Cj(),bigVideoSsrc:Cj(),bigVideoRtxSsrc:Cj(),auxVideoSsrc:Cj(),auxVideoRtxSsrc:Cj()},a=i.audioSsrc,o=i.bigVideoSsrc,s=i.bigVideoRtxSsrc,c=i.auxVideoSsrc,u=i.auxVideoRtxSsrc,e.ssrc={audio:a,video:o,videoRtx:s,auxiliary:c,auxiliaryRtx:u},e.singlePC.addDownlinkQueue.delete(e.tinyId),r.next=11,e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});case 11:return r.prev=11,r.next=14,e._signalChannel.sendWaitForResponseWithRetry({command:"subscribe/v3",responseCommand:fq.SPC_SUBSCRIBE_RESULT,data:{srcUserId:e.userId,srcTinyId:e.tinyId,audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,customData:!1,ssrc:i},retries:3,retryTimeout:0});case 14:if(0===(l=r.sent).data.code){r.next=17;break}throw new yR({code:l.data.code,message:l.data.message});case 17:r.next=24;break;case 19:return r.prev=19,r.t0=r.catch(11),r.next=23,e.removeDownlink();case 23:throw r.t0;case 24:return r.abrupt("return");case 25:return e.singlePC.addDownlinkQueue.delete(e.tinyId),r.next=28,e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});case 28:if(r.prev=28,yP){r.next=31;break}return r.abrupt("return");case 31:return d=e._room.jitterBufferDelay||{},h=d.main,p=d.aux,m=e._room.scheduleResult.config||{},v=m.jitterDelay,_=void 0===v?h:v,g=m.jitterDelayAux,y=void 0===g?p:g,(Aw(_)||Aw(y))&&e.setJitterBufferDelay({mainDelay:_,auxDelay:y}),r.finish(28);case 34:case"end":return r.stop()}}),r,null,[[4,,28,34],[11,19]])}))()}))}},{key:"removeDownlink",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.singlePC){e.next=2;break}return e.abrupt("return");case 2:return this.ssrc={audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0},this.singlePC.removeDownlinkQueue.delete(this.tinyId),(null!=(t=this._room.scheduleResult.config)&&t.jitterDelay||null!=t&&t.jitterDelayAux)&&this.setJitterBufferDelay({mainDelay:0,auxDelay:0}),e.next=7,this.singlePC.removeDownlink(this.userId);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setJitterBufferDelay",value:function(e){var t=this,n=e.mainDelay,r=e.auxDelay;if(!yP||!this.singlePC||!this._peerConnection||uD(n)&&uD(r))return Promise.resolve();this._log.info("set jitterBuffer main: ".concat(n," aux: ").concat(r));var i=this.singlePC.getReceiversByUserId(this.userId);return Aw(n)&&(this.remoteAudioTrack.jitterBufferDelay=n,this.remoteVideoTrack.jitterBufferDelay=n),Aw(r)&&(this.remoteAuxiliaryTrack.jitterBufferDelay=r,uD(n)&&(this.remoteAudioTrack.jitterBufferDelay=r)),new Promise((function(e){t.doSetJitterBufferDelay({mainDelay:n,auxDelay:r,receivers:i,resolve:e})}))}},{key:"doSetJitterBufferDelay",value:function(e){var t=this,n=e.mainDelay,r=e.auxDelay,i=e.receivers,a=e.resolve;try{if(0===n&&0===r)return i.forEach((function(e){return e.jitterBufferTarget=0})),a();if(i.forEach((function(e){var i,a=e.track===t.remoteAuxiliaryTrack.outMediaTrack||uD(n)&&e.track===t.remoteAudioTrack.outMediaTrack;if(!(a&&uD(r)||!a&&uD(n))){var o=a?r||0:n,s=(e.jitterBufferTarget||0)+100;s>o||(e.jitterBufferTarget=s,t._log.debug("set ".concat(a?"aux ":"").concat(null==(i=null==e?void 0:e.track)?void 0:i.kind," jitterBuffer delay ").concat(s," -> ").concat(o)))}})),!i.find((function(e){var i=e.track===t.remoteAuxiliaryTrack.outMediaTrack?r||0:n;return e.jitterBufferTarget<i})))return this._log.info("set jitterBuffer main: ".concat(n," aux: ").concat(r," done")),a();this.jitterBufferTimeoutId=setTimeout((function(){t.doSetJitterBufferDelay({mainDelay:n,auxDelay:r,receivers:i,resolve:a})}),1e3)}catch(DR){this._log.warn("set jitterBuffer delay error: ".concat(DR)),clearTimeout(this.jitterBufferTimeoutId),a()}}},{key:"audioReceiver",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.getReceiversByUserId(this.userId)[0])||null}}])}(wj);nR([mL(),uL((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var a=function(e){t.off("closed",a),i(new yR({code:_R.API_CALL_ABORTED,message:mN({key:dN.CONNECTION_ABORTED,data:e})}))};t.on("closed",a),e.apply(t,r).then(n,i).finally((function(){t.off("closed",a)}))}))}}))],Nj.prototype,"subscribe",1),nR([mL()],Nj.prototype,"unsubscribe",1),nR([_L((function(){return"jitter"}))],Nj.prototype,"setJitterBufferDelay",1);var Pj=Nj,Mj=function(e){function i(e,a){var o;return r(this,i),(o=n(this,i)).room=e,o.signalChannel=a,rR(t(o),"log"),rR(t(o),"cmdIdSeqMap",new Map),rR(t(o),"messageMap",new Map),o.log=sO.createLogger({id:"cmm",userId:e.userId}),o.onReceiveMsg=o.onReceiveMsg.bind(t(o)),a.on(fq.RECEIVE_CUSTOM_MSG,o.onReceiveMsg),o.room.on("peer-leave",(function(e){E(o.messageMap.keys()).forEach((function(t){t.split("_").slice(0,-1).join("_")===e&&o.messageMap.delete(t)}))})),o}return d(i,e),o(i,[{key:"send",value:function(e){var t=e.cmdId,n=e.data,r=this.cmdIdSeqMap.get(t)||Math.floor(16383*Math.random()),i={cmdId:t,msg:btoa(String.fromCharCode.apply(String,E(new Uint8Array(n)))),ordered:!0,reliable:!0,streamSeq:r};this.cmdIdSeqMap.set(t,r+1),this.signalChannel.send("channel_msg",i),this.log.debug("send custom msg: ".concat(JSON.stringify(i)))}},{key:"onReceiveMsg",value:function(e){var t=this,n=e.data.data,r=this.room.tinyIdToUserIdMap.get(n.srcTinyId);if(r){var a={userId:r,cmdId:n.cmdId,seq:n.streamSeq,data:Uint8Array.from(atob(n.msg),(function(e){return e.charCodeAt(0)})).buffer};if(n.ordered){var o="".concat(r,"_").concat(a.cmdId),s=this.messageMap.get(o);if(s&&0!==s.lastSeq)if(Math.abs(s.lastSeq-a.seq)>i.SEQ_INTERVAL)this.messageMap.set(o,{lastSeq:a.seq,cachedMessageMap:new Map}),this.emitMessage(a);else if(a.seq>s.lastSeq){if(a.seq===s.lastSeq+1)this.emitMessage(a);else if(!s.cachedMessageMap.has(a.seq)){var c=setTimeout((function(){return t.emitMessage(a,!0)}),5e3);s.cachedMessageMap.set(a.seq,{message:a,timeoutId:c})}}else this.log.debug("drop message ".concat(a.userId,"-").concat(a.cmdId,"-").concat(a.seq));else s||(s={lastSeq:0,cachedMessageMap:new Map},this.messageMap.set(o,s),setTimeout((function(){return t.emitMessage(a,!0)}),100)),s.cachedMessageMap.set(a.seq,{message:a})}else this.emit("message",a)}else{this.log.warn("receive msg from unknown user, wait peer-join tinyId: ".concat(n.srcTinyId));var u=function(r){r.tinyId===n.srcTinyId&&(t.room.off("peer-join",u),t.onReceiveMsg(e))};this.room.on("peer-join",u),rD(2e3).then((function(){return t.room.off("peer-join",u)}))}}},{key:"emitMessage",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.messageMap.get("".concat(e.userId,"_").concat(e.cmdId)),i=e;if(r){if(n){var a=E(r.cachedMessageMap.values()).sort((function(e,t){return e.message.seq-t.message.seq}));a[0]&&(i=a[0].message)}0!==r.lastSeq&&i.seq-r.lastSeq>1&&this.log.debug("msg lost userId: ".concat(i.userId," seq: ").concat(r.lastSeq," -> ").concat(i.seq)),r.lastSeq=i.seq,clearTimeout(null==(t=r.cachedMessageMap.get(i.seq))?void 0:t.timeoutId),r.cachedMessageMap.delete(i.seq)}this.log.debug("receive custom msg: ".concat(JSON.stringify(i))),this.emit("message",i);var o=null==r?void 0:r.cachedMessageMap.get(i.seq+1);o&&this.emitMessage(o.message)}}])}(tR(oR()).EventEmitter);rR(Mj,"SEQ_INTERVAL",300);var Lj=Mj,Uj=bR.isString,Vj=bR.isUndefined,Fj=bR.getNetworkType,Bj=bR.isEmpty,qj=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e]),rR(t(a),"_businessInfo"),rR(t(a),"userManager"),rR(t(a),"_version"),rR(t(a),"_heartbeat",-1),rR(t(a),"_lastHeartBeatTime",-1),rR(t(a),"_stats"),rR(t(a),"_joinTimeout",-1),rR(t(a),"_firstPublishedList",null),rR(t(a),"_joinReject",null),rR(t(a),"_isRelayChanged",!1),rR(t(a),"sdpSemantics"),rR(t(a),"signalChannel",null),rR(t(a),"uplinkConnection",null),rR(t(a),"singlePC",null),rR(t(a),"enableSPC",ZN),rR(t(a),"_changeBigSmallRecords",new Map),rR(t(a),"networkQuality"),rR(t(a),"_iceTransportPolicy"),rR(t(a),"forceRelay",!1),rR(t(a),"_turnServers",[]),rR(t(a),"_iceServersFromJoin"),rR(t(a),"_syncUserListInterval",-1),rR(t(a),"_smallStreamConfig",{bitrate:100,frameRate:15,height:120,width:160}),rR(t(a),"enableSEI",!1),rR(t(a),"_enableAudioVolumeEvaluation",!1),rR(t(a),"_audioVolumeIntervalId",0),rR(t(a),"_enableMultiAuxStream",!1),rR(t(a),"_pureAudioPushMode",!1),rR(t(a),"_customMessageManager"),rR(t(a),"preferHW",!1),rR(t(a),"healthDetector"),rR(t(a),"playoutDelay"),rR(t(a),"jitterBufferDelay"),rR(t(a),"_updateAudioLevelTaskId",-1),a._stats=new Uq(t(a),a._log),a.userManager=new gF(a.userId,a._log),a._version=RR,a.sdpSemantics=UC,Vj(e.sdpSemantics)?lO.isUnifiedPlanDefault()&&(a.sdpSemantics=LC):a.sdpSemantics=e.sdpSemantics,a._log.info("sdpSemantics: ".concat(a.sdpSemantics,", netType: ").concat(Fj())),e.iceTransportPolicy&&(a._iceTransportPolicy=e.iceTransportPolicy),a._enableMultiAuxStream=!Vj(e.enableMultiAuxStream)&&e.enableMultiAuxStream,a.enableSEI=e.enableSEI&&ZN,!Vj(e.enableSPC)&&ZN&&(a.enableSPC=e.enableSPC),a.preferHW=!!e.preferHW,a._initBusinessInfo(e),a.healthDetector=new vj(t(a)),a}return d(i,e),o(i,[{key:"isMainStreamPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.isMainStreamPublished)}},{key:"isMainAudioPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.localMainAudioTrack)}},{key:"isAuxStreamPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.isAuxStreamPublished)}},{key:"hasAuxStream",get:function(){return E(this.remotePublishedUserMap.values()).findIndex((function(e){return e.muteState.hasAuxiliary}))>=0}},{key:"userMap",get:function(){return this.userManager.userMap}},{key:"remotePublishedUserMap",get:function(){return this.userManager.remotePublishedUserMap}},{key:"tinyIdToUserIdMap",get:function(){return new Map(E(this.userMap.values()).map((function(e){return[e.tinyId,e.userId]})))}},{key:"join",value:function(e,t,n){return aR(this,null,f().mark((function t(){var n=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(this.userManager.mySelfId=this.userId,this.userManager.on("1",(function(e){n.emit("peer-join",e)})),this.userManager.on("2",(function(e){n.closeDownLinkConnection(e,"remote user exitRoom"),n.emit("peer-leave",e)})),this.userManager.on("3",this.createDownlinkConnection,this),this.userManager.on("5",this.closeDownLinkConnection,this),this.userManager.on("6",(function(e){var t=function(e,t){var n={};for(var r in e)zA.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&GA){var i,a=s(GA(e));try{for(a.s();!(i=a.n()).done;)r=i.value,t.indexOf(r)<0&&JA.call(e,r)&&(n[r]=e[r])}catch(o){a.e(o)}finally{a.f()}}return n}(e,[]);rO.emit(aO.REMOTE_PUBLISH_STATE_CHANGED,QA({room:n},t)),n.emit("remote-publish-state-changed",QA({},t))})),this.joinParams=e,new Promise((function(t,r){return aR(n,null,f().mark((function n(){var i,a,o;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._joinReject=r,n.prev=1,this.checkDestroy(),n.prev=3,n.next=6,Promise.all([this.initialize(),this.initSinglePC()]);case 6:n.next=15;break;case 8:if(n.prev=8,n.t0=n.catch(3),n.t0 instanceof yR&&n.t0.code===_R.SPC_INITIALIZED_FAILED){n.next=12;break}return n.abrupt("return",r(n.t0));case 12:return null==(i=this.signalChannel)||i.destroy(),n.next=15,this.initialize();case 15:return o=Uw(),n.next=18,this.doJoin(e,null==(a=this.singlePC)?void 0:a.clientAbility);case 18:IN.addSuccessEvent({key:521708,cost:Uw()-o}),t(),this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}}),n.next=26;break;case 23:n.prev=23,n.t1=n.catch(1),IN.addFailedEvent({key:521708,error:n.t1}),r(n.t1);case 26:this._joinReject=null;case 27:case"end":return n.stop()}}),n,this,[[1,23],[3,8]])})))}))));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"initSinglePC",value:function(){return aR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.enableSPC||this.singlePC){e.next=11;break}return this.singlePC=new bj({signalChannel:this.signalChannel,room:this,enableCustomMessage:!1}),this.singlePC.on("sei-message",(function(e){return t.emit("sei-message",e)})),this.singlePC.on("dump",(function(e){return t.emit("dump",e)})),this.singlePC.once("error",(function(){return t.fallbackToMPC()})),e.prev=2,e.next=5,this.singlePC.initialize();case 5:return e.abrupt("return",e.sent);case 8:throw e.prev=8,e.t0=e.catch(2),this.fallbackToMPC(),new yR({code:_R.SPC_INITIALIZED_FAILED,message:null==e.t0?void 0:e.t0.message});case 11:case"end":return e.stop()}}),e,this,[[2,8]])})))}},{key:"doJoin",value:function(e,t){var n=this;return new Promise((function(r,i){return aR(n,null,f().mark((function n(){var a,o,s,c,u,l=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:e.privateMapKey&&(this.privateMapKey=e.privateMapKey),e.latencyLevel&&(this.latencyLevel=e.latencyLevel),this.signalChannel.once(lq,(function(e){l.clearJoinTimeout(),rO.emit(aO.JOIN_SIGNAL_CONNECTION_END,{room:l,error:e}),i(e)})),Rw(null==(o=null==(a=this.scheduleResult)?void 0:a.config)?void 0:o.singlePC)&&ZN&&(this.enableSPC=this.scheduleResult.config.singlePC),this.keyPointManager.setConnectionType(this.singlePC?1:2),t&&this.playoutDelay&&(t.playoutDelay=this.playoutDelay),c={roomId:String(e.roomId||e.strRoomId),useStringRoomId:this.useStringRoomId,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel,trtcRole:e.role,trtcScene:"live"===this.scene?2:1,sdpSemantics:this.sdpSemantics,version:this._version,ua:navigator&&navigator.userAgent||"",terminalType:eO(),netType:dw(),bussinessInfo:this._businessInfo,ability:t,sdkType:this._sdkType,userSig:this.userSig,receiveMix:!0},this._log.debug("join room signal data: ".concat(JSON.stringify(c))),u=5e3,null!=(s=this.scheduleResult.config)&&s.enterRoomTimeout&&this.scheduleResult.config.enterRoomTimeout>=1&&(u=1e3*this.scheduleResult.config.enterRoomTimeout),this._joinTimeout=window.setTimeout((function(){i(new yR({code:_R.JOIN_ROOM_FAILED,message:mN({key:dN.JOIN_ROOM_TIMEOUT})}))}),u),rO.emit(aO.JOIN_SEND_CMD,{room:this}),this.signalChannel.send(this.singlePC?"join/v2":"join",c),this.signalChannel.once(fq.JOIN_ROOM_RESULT,(function(t){return aR(l,null,f().mark((function n(){var a,o,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.clearJoinTimeout(),a=t.data,o=a.code,s=a.message,c=a.data,u=a.tinyId,rO.emit(aO.JOIN_RECEIVED_CMD_RES,{room:this,code:o}),0!==o){n.next=19;break}if(this._log.info("Join room success, start heartbeat"),u&&(this.tinyId=u),this.startHeartbeat(),this.syncUserList(),this.startSyncUserListInterval(),this._firstPublishedList=c.publishers,this._iceServersFromJoin=c.iceServer?[c.iceServer]:[],n.t0=this.singlePC,!n.t0){n.next=16;break}return n.next=15,this.singlePC.setIceServers(this.getIceServers());case 15:this.singlePC.connect($A(QA({},c.ability),{useVp8:c.ability.useVp8||!!e.useVp8})).catch((function(){}));case 16:r(),n.next=20;break;case 19:this._log.error("Join room failed result: ".concat(o," error: ").concat(s)),i(new yR({code:_R.JOIN_ROOM_FAILED,extraCode:o,message:mN({key:dN.JOIN_ROOM_FAILED,data:{error:s,code:o}})}));case 20:case"end":return n.stop()}}),n,this)})))}));case 5:case"end":return n.stop()}}),n,this)})))}))}},{key:"reJoin",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return aR(this,null,f().mark((function t(){var n,r,i,a=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isJoined){t.next=22;break}return t.prev=1,this._log.warn("reJoin pending: ".concat(this.joinParams.roomId)),r=[],this.singlePC&&(this.singlePC.close(),this.singlePC=null,r.push(this.initSinglePC().then((function(e){return n=e,e})))),this.signalChannel&&(this.signalChannel.race=e,this.signalChannel.close(),r.push(this.signalChannel.connect())),t.next=8,Promise.all(r);case 8:return t.next=10,this.doJoin($A(QA({},this.joinParams),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel}),n);case 10:if(this._log.warn("reJoin success"),qP.logSuccessEvent({userId:this.userId,eventType:OC.REJOIN}),!this.singlePC){t.next=15;break}i=function(e){var t;"CONNECTED"===e.state&&(null==(t=a.singlePC)||t.off(yj.CONNECTION_STATE_CHANGED,i),a.uplinkConnection instanceof xj&&(a.uplinkConnection.installEvents(),a.uplinkConnection.onSinglePCReconnected()),a.remotePublishedUserMap.forEach((function(e){e.installEvents(),e.onSinglePCReconnected()})))},this.singlePC.on(yj.CONNECTION_STATE_CHANGED,i),this.checkConnectionsToReconnect(),this.uplinkConnection instanceof Lq&&!this.uplinkConnection.getIsReconnecting()&&this.uplinkConnection.startReconnection();case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(1),this._log.warn("reJoin fail ".concat(t.t0)),this.reset(),qP.logFailedEvent({userId:this.userId,eventType:OC.REJOIN,error:t.t0}),this.emit("error",new yR({code:_R.JOIN_ROOM_FAILED,message:mN({key:dN.REJOIN_ROOM_FAILED,data:{roomId:this.joinParams.roomId}})}));case 20:t.next=23;break;case 22:this._log.warn("reJoin abort");case 23:case"end":return t.stop()}}),t,this,[[1,17]])})))}},{key:"initialize",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.getSignalChannelUrl(),r=n.mainUrl,i=n.backupUrl,a=this.signalChannel||function(e){return E(Eq.values()).find((function(t){return t.room.userId===e&&!t.room.isJoined}))||null}(this.userId),o=!!(a&&a.isConnected&&a.keepAlive&&a.userId===this.userId),Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(t=this.scheduleResult.domains[0]),this._log.info("".concat(o?"reuse":"setup"," signal channel")),o?(a.url=r,a.backupUrl=i,a.room=this,this.signalChannel=a):(a&&a.close(),this.signalChannel=new Tq({sdkAppId:this.sdkAppId,userId:this.userId,userSig:this.userSig,url:r,backupUrl:i,race:this.enableSPC&&!this.proxy_ws,room:this,signalDomainWhenUnifiedProxy:this.proxy_unified?t:void 0}),this._customMessageManager=new Lj(this,this.signalChannel),this._customMessageManager.on("message",(function(e){s.emit("custom-message",e)}))),this.networkQuality||(this.networkQuality=new Fq({signalChannel:this.signalChannel,room:this}),this.networkQuality.on(Fq.EVENT_NETWORK_QUALITY,(function(e){var t;s.emit("network-quality",e),null==(t=s.singlePC)||t.detectTCPAndUDP(e)}))),FP(this,this.signalChannel).add("2",(function(e){rO.emit(aO.SIGNAL_CONNECTION_STATE_CHANGED,QA({room:s},e)),s.emit("signal-connection-state-changed",e)})).add("4",(function(e){s.reset(),s.emit("error",e)})).add(fq.PEER_JOIN,(function(e){var t=e.data.data,n=t.srcTinyId,r=t.userId,i=t.role;s.userManager.addUser({userId:r,tinyId:n,role:i})})).add(fq.PEER_LEAVE,(function(e){var t=e.data.data,n=t.userId,r=t.reason,i=void 0===r?0:r;s.userManager.deleteUser(n,i)})).add(fq.UPDATE_REMOTE_MUTE_STAT,(function(e){s._lastHeartBeatTime>0&&Date.now()-s._lastHeartBeatTime>=1e4&&s.doHeartbeat(),s.onPublishedUserList(e.data)})).add(fq.CLIENT_BANNED,(function(e){var t=e.data.data.reason;if(qP.uploadEvent({log:"stat-banned:".concat(t),userId:s.userId}),"user_time_out"===t)return s._log.warn("".concat(t," last heart beat time: ").concat(s._lastHeartBeatTime," interval: ").concat(Date.now()-s._lastHeartBeatTime,", visibility: ").concat(document.visibilityState)),void s.reJoin();s._log["kick"===t?"error":"info"]("user was banned because of [".concat(t,"]")),s.reset(),s.emit("banned",{reason:t})})),this.signalChannel.once("1",(function(e){s.tinyId=e.signalInfo.tinyId,rO.emit(aO.JOIN_SIGNAL_CONNECTION_END,{room:s})})),rO.emit(aO.JOIN_SIGNAL_CONNECTION_START,{room:this}),e.next=10,this.signalChannel.connect();case 10:return o&&rO.emit(aO.JOIN_SIGNAL_CONNECTION_END,{room:this}),e.abrupt("return",o);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"setSignalChannel",value:function(e){this.signalChannel=e,e||BP(this)}},{key:"leave",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.doHeartbeat();case 3:e.next=7;break;case 5:e.prev=5,e.t0=e.catch(0);case 7:this._log.info("leave() => leaving room"),rO.emit(aO.LEAVE_SEND_CMD,{room:this}),null==(t=this.signalChannel)||t.send("leave");case 8:case"end":return e.stop()}}),e,this,[[0,5]])})))}},{key:"clearNetworkQuality",value:function(){this.networkQuality&&(this.networkQuality.stop(),delete this.networkQuality)}},{key:"closeConnections",value:function(){var e=this;this.remotePublishedUserMap.forEach((function(t){e.closeDownLinkConnection(t.userId,"you exitRoom")}))}},{key:"clearJoinTimeout",value:function(){clearTimeout(this._joinTimeout),this._joinTimeout=-1}},{key:"startHeartbeat",value:function(){-1===this._heartbeat&&(this._heartbeat=MP.run("ric",this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),MP.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}},{key:"doHeartbeat",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.badCaseDetector.getMonitorFreeze(),e.next=3,this._stats.getStatsReport({uplinkConnection:this.uplinkConnection,downlinkConnections:this.remotePublishedUserMap,freezeMap:n});case 3:r=e.sent,this.badCaseDetector.resetMonitor(),i=null!=(t=this.signalChannel)&&t.isConnected?function(e){if(vF.has(e)){var t=vF.get(e).map((function(e){return{uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,uint32_param1:e.param1,uint32_param2:e.param2,uint32_video_stream_type:e.streamType}}));return vF.delete(e),t}return[]}(this.userId):[],a=$A(QA({str_sdk_version:AR,uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyId},msg_event_msg:i,str_acc_ip:this.getSignalInfo().relayIp,str_client_ip:this.getSignalInfo().clientIp},r),{msg_device_info:QA({uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:dw()},r.msg_device_info)}),this.heartbeatReport=a,rO.emit(aO.HEARTBEAT_REPORT,{room:this,report:a}),this.signalChannel&&(this.signalChannel.isConnected&&(this.signalChannel.send("quality_report",a),o=Date.now(),this._lastHeartBeatTime>0&&o-this._lastHeartBeatTime>1e4&&this._log.warn("heartbeat took ".concat(o-this._lastHeartBeatTime)),this._lastHeartBeatTime=o,this.signalChannel.isOnline||(this._log.warn("signal channel is not online"),this.signalChannel.startReconnection())),this.emit("heartbeat-report",$A(QA({},a),{bytes_sent:this._stats.totalBytesSent+this.signalChannel.bytesSent,bytes_received:this._stats.totalBytesReceived+this.signalChannel.bytesReceived}))),!this._isRelayChanged&&this.isRelayMaybeFailed()&&(this.reJoin(),this._isRelayChanged=!0);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"onPublishedUserList",value:function(e){var t=this;if(this.isJoined){var n=e.data.userList.filter((function(e){return e.flag!==fC})).map((function(e){var n=e.userId,r=e.srcTinyId,i=e.flag;n===t.userId&&t.uplinkConnection&&(t.uplinkConnection.flag=i);var a=t.remotePublishedUserMap.get(n);return a&&t.checkSubscribeBigSmallVideo(a),{userId:n,tinyId:r,flag:i}}));e.data.mixRobotList.forEach((function(e){var t=e.userId,r=e.srcTinyId,i=e.flag,a=e.mixUserList;n.unshift({userId:t,tinyId:r,flag:i,isRobot:!0,mixUserList:a})})),rO.emit(aO.RECEIVED_PUBLISHED_USER_LIST,{room:this,publishedUserList:n}),this.userManager.setRemotePublishedUserList(n)}}},{key:"closeUplink",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"you unpublished";this.uplinkConnection&&(this.localTracks.size>0&&this.uplinkConnection.doUnpublish(),this.uplinkConnection.close(e),this.uplinkConnection instanceof Lq&&(this.uplinkConnection=null)),this.localTracks.forEach((function(e){return e.unpublish()})),this.localTracks.clear()}},{key:"createDownlinkConnection",value:function(e){var t=e.userId,n=e.tinyId,r=e.flag,i=e.isRobot,a=new(this.singlePC?Pj:Nq)({userId:t,tinyId:n,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI,flag:r,isRobot:i});this.userManager.addRemotePublishedUser(a),this.installDownlinkEvents(a,t),this.emit("remote-published",a)}},{key:"closeDownLinkConnection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"remote user unpublished",n=this.remotePublishedUserMap.get(e);n&&(n.close(t),this.emit("remote-unpublished",n))}},{key:"installDownlinkEvents",value:function(e,t){var n=this;e.on("error",(function(e){var r=e.getCode();r!==_R.ICE_TRANSPORT_ERROR&&(r===_R.DOWNLINK_RECONNECTION_FAILED&&n.closeDownLinkConnection(t),n.emit("error",e))})),e.on("connection-state-changed",(function(t){n.emit("media-connection-state-changed",$A(QA({},t),{userId:e.userId}))})),e.on("firewall-restriction",(function(){n.emit("firewall-restriction")}))}},{key:"startSyncUserListInterval",value:function(){-1===this._syncUserListInterval&&(this._syncUserListInterval=MP.run("ric",this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){MP.clearTask(this._syncUserListInterval),this._syncUserListInterval=-1}},{key:"syncUserList",value:function(){var e=this;return this.getUserList().then((function(t){e.userManager.setUserList(t)})).catch((function(t){e._log.debug("sync user list failed: ".concat(t))}))}},{key:"getUserList",value:function(){var e;return null!=(e=this.signalChannel)&&e.isConnected?this.signalChannel.sendWaitForResponse({command:"get_user_list",responseCommand:fq.USER_LIST_RES,enableLog:!1,timeout:2e3}).then((function(e){var t=e.data,n=t.code,r=t.message;if(0===n)return(t.data&&t.data.userList||[]).map((function(e){return{userId:e.userId,tinyId:e.srcTinyId,role:e.role}}));throw mN({key:dN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:fq.USER_LIST_RES,code:n,message:r}})})):Promise.reject("not connected")}},{key:"getAllConnections",value:function(){var e=E(this.remotePublishedUserMap.values());return this.uplinkConnection&&e.push(this.uplinkConnection),e}},{key:"isRelayMaybeFailed",value:function(){if(this.signalChannel&&!this.signalChannel.isOnline||!Aq)return!1;if(this.singlePC)return this.singlePC.reconnectionCount>6;var e=this.getAllConnections();if(0===e.length)return!1;for(var t=0;t<e.length;t++)if(e[t].getReconnectionCount()<6)return!1;return!0}},{key:"checkConnectionsToReconnect",value:function(){var e,t=this;this.singlePC?(null==(e=this.singlePC.getPeerConnection())?void 0:e.connectionState)===AC.CLOSED&&!this.singlePC.isReconnecting&&(this._log.warn("spc pc is closed but not reconnect"),this.singlePC.startReconnection()):this.getAllConnections().forEach((function(e){if(e instanceof Rq&&!e.getIsReconnecting()){var n=e.getPeerConnection();n&&n.connectionState===AC.CLOSED&&(t._log.warn("[".concat(e.getUserId(),"] pc is closed but not reconnect")),e.startReconnection())}}))}},{key:"fallbackToMPC",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._log.warn("fallback to multi pc"),qP.uploadEvent({log:"stat-fallback",userId:this.userId}),this.enableSPC=!1,null==(t=this.singlePC)||t.close(),this.singlePC=null,e.t0=this.isJoined,!e.t0){e.next=9;break}return e.next=9,this.reJoin(!1);case 9:if(!this.uplinkConnection){e.next=21;break}if(n=this.uplinkConnection,this.uplinkConnection=new Lq({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI}),e.t1=n.isMainStreamPublished,!e.t1){e.next=16;break}return e.next=16,this.uplinkConnection.publish({localAudioTrack:n.localMainAudioTrack,localVideoTrack:n.localMainVideoTrack,isAuxiliary:!1});case 16:if(e.t2=n.isAuxStreamPublished,!e.t2){e.next=20;break}return e.next=20,this.uplinkConnection.publish({localAudioTrack:n.localAuxAudioTrack,localVideoTrack:n.localAuxVideoTrack,isAuxiliary:!0});case 20:n.close();case 21:r=0,i=E(this.remotePublishedUserMap.values());case 22:if(!(r<i.length)){e.next=38;break}if(a=i[r],o=new Nq({userId:a.userId,tinyId:a.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI,flag:a.flag,remoteAudioTrack:a.remoteAudioTrack,remoteVideoTrack:a.remoteVideoTrack,remoteAuxiliaryTrack:a.remoteAuxiliaryTrack}),this.installDownlinkEvents(o,a.userId),this.remotePublishedUserMap.set(a.userId,o),e.t3=a.isMainStreamSubscribed,!e.t3){e.next=31;break}return e.next=31,o.subscribe(a.subscribeState,"main");case 31:if(e.t4=a.isAuxStreamSubscribed,!e.t4){e.next=35;break}return e.next=35,o.subscribe(a.subscribeState,"auxiliary");case 35:r++,e.next=22;break;case 38:case"end":return e.stop()}}),e,this)})))}},{key:"destroy",value:function(){this.isDestroyed||(this.signalChannel&&(this._log.info("destroying SignalChannel"),this.signalChannel.close(),this.signalChannel=null),g(i,"destroy",this,3)([]),this._joinReject&&(this._joinReject(new yR({code:_R.INVALID_OPERATION,message:mN({key:dN.CLIENT_DESTROYED,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.removeAllListeners(),this.healthDetector.destroy(),MP.clearTask(this._audioVolumeIntervalId))}},{key:"switchRole",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.role!==e,!t.t0){t.next=5;break}return"audience"===e&&this.uplinkConnection&&this.closeUplink("you switch role to audience"),t.next=5,this.doSwitchRole(e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doSwitchRole",value:function(e){var t=this,n={command:"change_role",data:{role:"anchor"===e?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel},responseCommand:fq.SWITCH_ROLE_RES,retries:1};return this._log.info("switchRole signal data: ".concat(JSON.stringify(n.data))),this.signalChannel.sendWaitForResponseWithRetry(n).then((function(n){var r=n.data,i=r.code,a=r.message;if(0!==i)throw new yR({code:_R.SWITCH_ROLE_FAILED,message:mN({key:dN.SWITCH_ROLE_FAILED,data:{message:a,code:i}})});t.role=e})).catch((function(e){throw e instanceof yR&&e.getCode()===_R.API_CALL_TIMEOUT&&(e=new yR({code:_R.SWITCH_ROLE_FAILED,message:mN({key:dN.SWITCH_ROLE_TIMEOUT})})),t._log.error(e),e}))}},{key:"publish",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return aR(this,null,f().mark((function e(){var n,r,i,a,o,s=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},r={},t.forEach((function(e){e instanceof kL&&(e instanceof xL?r.audio=e:n.audio=e),e instanceof AL&&(e instanceof wL&&2===e.mediaType?r.video=e:n.video=e)})),i=Bj(n),a=Bj(r),(!i||!a)&&!this.uplinkConnection&&(this.singlePC?this.uplinkConnection=new xj({userId:this.userId,tinyId:this.tinyId,room:this}):this.uplinkConnection=new Lq({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI}),this.uplinkConnection.on("connection-state-changed",(function(e){s.emit("media-connection-state-changed",$A(QA({},e),{userId:s.userId}))})),this.uplinkConnection.on("firewall-restriction",(function(){s.emit("firewall-restriction")})),this.uplinkConnection.on("error",(function(e){var t=e.getCode();t!==_R.ICE_TRANSPORT_ERROR&&(t===_R.UPLINK_RECONNECTION_FAILED&&s.closeUplink(),s.emit("error",e))}))),o=t.map((function(e){return e.kind})).join(","),e.t0=i,e.t0){e.next=11;break}return this._log.info("publish() => main ".concat(o)),e.next=10,this.uplinkConnection.publish({localAudioTrack:n.audio,localVideoTrack:n.video,isAuxiliary:!1});case 10:this._log.info("main is published");case 11:if(e.t1=a,e.t1){e.next=17;break}return this._log.info("publish() => aux ".concat(o)),e.next=16,this.uplinkConnection.publish({localAudioTrack:r.audio,localVideoTrack:r.video,isAuxiliary:!0});case 16:this._log.info("aux is published");case 17:case"end":return e.stop()}}),e,this)})))}},{key:"unpublish",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return aR(this,null,f().mark((function e(){var n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(("live"!==this.scene||"anchor"===this.role)&&(this.isMainStreamPublished||this.isAuxStreamPublished)&&this.uplinkConnection){e.next=2;break}return e.abrupt("return");case 2:if(n={},r={},t.forEach((function(e){!e.mediaTrack||!e.isPublished||(e instanceof kL&&(e instanceof xL?r.audio=e:n.audio=e),e instanceof AL&&(e instanceof wL&&2===e.mediaType?r.video=e:n.video=e))})),e.prev=4,i=t.map((function(e){return e.kind})).join(","),e.t0=Bj(n),e.t0){e.next=11;break}return this._log.info("unpublish() => main ".concat(i)),e.next=11,this.uplinkConnection.unpublish({localAudioTrack:n.audio,localVideoTrack:n.video});case 11:if(e.t1=Bj(r),e.t1){e.next=16;break}return this._log.info("unpublish() => aux ".concat(i)),e.next=16,this.uplinkConnection.unpublish({localAudioTrack:r.audio,localVideoTrack:r.video});case 16:e.next=20;break;case 18:e.prev=18,e.t2=e.catch(4);case 20:0===this.localTracks.size&&this.closeUplink("you unpublished");case 21:case"end":return e.stop()}}),e,this,[[4,18]])})))}},{key:"addTrack",value:function(e){if(!this.uplinkConnection||!e.mediaTrack)return Promise.resolve();var t=this.uplinkConnection.addTrack(e);return e.publish(this,t),t}},{key:"removeTrack",value:function(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.removeTrack(e).then((function(t){return e.unpublish(),t})):Promise.resolve()}},{key:"replaceTrack",value:function(e){return this.uplinkConnection&&e.mediaTrack&&nP()?this.uplinkConnection.replaceTrack(e).then((function(t){t&&rO.emit(aO.LOCAL_TRACK_REPLACED,{track:e})})):Promise.resolve()}},{key:"setBandWidth",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.uplinkConnection,!t.t0){t.next=6;break}return t.next=4,this.uplinkConnection.setBandwidth(e);case 4:return t.next=6,this.uplinkConnection.sendMediaSettings();case 6:case"end":return t.stop()}}),t,this)})))}},{key:"enableSmall",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainVideoTrack){t.next=2;break}return t.abrupt("return",Promise.resolve());case 2:if(t.t0=e&&this.uplinkConnection.localMainVideoTrack.small,!t.t0){t.next=6;break}return t.next=6,this.setBandWidth({type:nC.VIDEO,videoType:nC.SMALL,bandwidth:this.uplinkConnection.localMainVideoTrack.small.bitrate});case 6:return t.next=8,this.uplinkConnection.enableSmall(e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"subscribe",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return aR(this,null,f().mark((function e(){var n,r,i,a,o,c,u,l,d,h;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=t.filter((function(e){return!e.isSubscribed})),0!==t.length){e.next=2;break}return e.abrupt("return");case 2:if(n=t[0].userId,r=this.remotePublishedUserMap.get(n)){e.next=5;break}return e.abrupt("return");case 5:return i=t.find((function(e){return 2===e.mediaType}))?"auxiliary":"main",e.prev=6,a=QA({},r.subscribeState),t.forEach((function(e){switch(e.mediaType){case 1:a.audio=!0;break;case 4:a.video=!0;break;case 8:a.smallVideo=!0;break;case 2:a.auxiliary=!0}})),(o=this._changeBigSmallRecords.get(n))&&o.options.smallVideo&&r.muteState.hasSmall&&a.video&&(a.video=!1,a.smallVideo=!0),rO.emit(aO.SUBSCRIBE_START,{room:this,streamType:i,remotePublishedUser:r,subscribeState:a}),this._log.info("subscribe() => ".concat(n," ").concat(i," [").concat(xq(a),"] prev: [").concat(xq(r.subscribeState),"]")),e.next=15,r.subscribe(a,i);case 15:this._log.info("subscribe ".concat(n," ").concat(i," done")),c=s(t),e.prev=17,c.s();case 19:if((u=c.n()).done){e.next=27;break}if(l=u.value,e.t0=l.mediaTrack,e.t0){e.next=25;break}return e.next=25,l.waitHasMediaTrack();case 25:e.next=19;break;case 27:e.next=32;break;case 29:e.prev=29,e.t1=e.catch(17),c.e(e.t1);case 32:return e.prev=32,c.f(),e.finish(32);case 35:rO.emit(aO.SUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:r}),e.next=42;break;case 38:throw e.prev=38,e.t2=e.catch(6),d=e.t2 instanceof yR?e.t2.getCode():_R.UNKNOWN,h=e.t2,e.t2 instanceof yR?d===_R.REMOTE_STREAM_NOT_EXIST&&(h=new yR({code:_R.API_CALL_ABORTED,message:mN({key:dN.API_CALL_ABORTED,data:{message:e.t2.message,userId:n,streamType:i}})}),this._log.warn(h)):(h=new yR({code:d,message:mN({key:dN.SUBSCRIBE_FAILED,data:{message:e.t2.message,userId:n,streamType:i}})}),this._log.error(h)),h;case 42:case"end":return e.stop()}}),e,this,[[6,38],[17,29,32,35]])})))}},{key:"unsubscribe",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return aR(this,null,f().mark((function e(){var n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t[0].userId,r=this.remotePublishedUserMap.get(n)){e.next=3;break}return e.abrupt("return");case 3:return i=t.find((function(e){return 2===e.mediaType}))?"auxiliary":"main",this._log.info("unsubscribe() => ".concat(n," ").concat(i)),e.prev=5,e.next=8,r.unsubscribe({remoteTracks:t,streamType:i});case 8:e.next=13;break;case 10:e.prev=10,e.t0=e.catch(5),this._log.warn("unsubscribe() => failed ".concat(e.t0));case 13:t.forEach((function(e){e.unsubscribe(),8===e.mediaType&&e.setMediaType(4)})),rO.emit(aO.UNSUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:r});case 14:case"end":return e.stop()}}),e,this,[[5,10]])})))}},{key:"setEncodedDataProcessingListener",value:function(e){throw new Error("Method not implemented.")}},{key:"enableAudioVolumeEvaluation",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1?arguments[1]:void 0;if(t<=0)return this._enableAudioVolumeEvaluation=!1,void MP.clearTask(this._audioVolumeIntervalId);t=Math.floor(Math.max(t,100)),rO.emit(aO.AUDIO_LEVEL_INTERVAL,{interval:t}),this._audioVolumeIntervalId&&MP.clearTask(this._audioVolumeIntervalId),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=MP.run("intervalInWorker",(function(){var r;NM.isRunning?e.stopUpdateAudioLevelFromSenderStat():e.updateAudioLevelFromSenderStat(t,n);var i=[];null==(r=e.remotePublishedUserMap)||r.forEach((function(t){if(t.muteState.hasAudio){!NM.isRunning&&t.muteState.audioAvailable&&t.remoteAudioTrack.isSubscribed?e.updateDownlinkAudioLevelFromReceiver(t):t.remoteAudioTrack.volume=0;var n=Math.floor(100*t.remoteAudioTrack.getAudioLevel());i.push({userId:t.userId,volume:n})}})),e.emit("audio-volume",i)}),{delay:t,backgroundTask:n})}},{key:"updateAudioLevelFromSenderStat",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainAudioTrack&&-1===this._updateAudioLevelTaskId){n.next=2;break}return n.abrupt("return");case 2:if(i=null==(r=this.uplinkConnection.getPeerConnection())?void 0:r.getSenders()[0]){n.next=5;break}return n.abrupt("return");case 5:a=Math.max(e,500),this._log.warn("updateAudioLevelFromSenderStat ".concat(a)),this._updateAudioLevelTaskId=MP.run("intervalInWorker",(function(){return aR(o,null,f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainAudioTrack){e.next=2;break}return e.abrupt("return",void this.stopUpdateAudioLevelFromSenderStat());case 2:return e.next=4,i.getStats();case 4:if(t=e.sent,!(this._updateAudioLevelTaskId<0)){e.next=7;break}return e.abrupt("return");case 7:n=this.uplinkConnection.localMainAudioTrack,t.forEach((function(e){"media-source"===e.type&&e.audioLevel&&(n.volume=e.audioLevel)}));case 9:case"end":return e.stop()}}),e,this)})))}),{delay:a,backgroundTask:t});case 7:case"end":return n.stop()}}),n,this)})))}},{key:"stopUpdateAudioLevelFromSenderStat",value:function(){var e;-1!==this._updateAudioLevelTaskId&&(this._log.warn("stopUpdateAudioLevelFromSenderStat"),MP.clearTask(this._updateAudioLevelTaskId),this._updateAudioLevelTaskId=-1,null!=(e=this.uplinkConnection)&&e.localMainAudioTrack&&(this.uplinkConnection.localMainAudioTrack.volume=0))}},{key:"updateDownlinkAudioLevelFromReceiver",value:function(e){var t,n=e.audioReceiver;if(iP&&n){var r=null==(t=n.getSynchronizationSources()[0])?void 0:t.audioLevel;Aw(r)?e.remoteAudioTrack.volume=Math.min(2*r,1):n.getStats().then((function(t){t.forEach((function(t){"inbound-rtp"===t.type&&Aw(t.audioLevel)&&(e.remoteAudioTrack.volume=t.audioLevel)}))}))}}},{key:"getLocalAudioStats",value:function(){return aR(this,null,f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},e.abrupt("return",(n[this.userId]={bytesSent:0,packetsSent:0,audioLevel:0},null!=(t=this.uplinkConnection)&&t.localMainAudioTrack&&(n[this.userId]=this.uplinkConnection.localMainAudioTrack.stat),n));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getLocalVideoStats",value:function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},e.abrupt("return",(r[this.userId]=(null==(n=null==(t=this.uplinkConnection)?void 0:t.localMainVideoTrack)?void 0:n.stat)||{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0},r));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getTransportStats",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={rtt:0,downlinksRTT:{}},!this.uplinkConnection){e.next=6;break}return e.next=4,this._stats.getSenderStats(this.uplinkConnection);case 4:n=e.sent,t.rtt=n.rtt;case 6:r=s(this.remotePublishedUserMap),e.prev=7,r.s();case 9:if((i=r.n()).done){e.next=17;break}return a=v(i.value,2),o=a[1],e.next=13,this._stats.getReceiverStats(o);case 13:c=e.sent,t.downlinksRTT[c.userId]=c.rtt;case 15:e.next=9;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(7),r.e(e.t0);case 22:return e.prev=22,r.f(),e.finish(22);case 25:return e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,this,[[7,19,22,25]])})))}},{key:"getRemoteVideoStats",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,c;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n={},r=s(this.remotePublishedUserMap);try{for(r.s();!(i=r.n()).done;)a=v(i.value,2),o=a[0],c=a[1],"main"===e&&c.muteState.hasVideo&&(n[o]=c.remoteVideoTrack.stat),"auxiliary"===e&&c.muteState.hasAuxiliary&&(n[o]=c.remoteAuxiliaryTrack.stat)}catch(u){r.e(u)}finally{r.f()}return t.abrupt("return",n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"getRemoteAudioStats",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t={},n=s(this.remotePublishedUserMap);try{for(n.s();!(r=n.n()).done;)i=v(r.value,2),a=i[0],(o=i[1]).muteState.hasAudio&&(t[a]=o.remoteAudioTrack.stat)}catch(c){n.e(c)}finally{n.f()}return e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"setTurnServer",value:function(e,t){this._log.info("set turn server: ".concat(JSON.stringify(e)," ").concat(t||""));var n=[];Array.isArray(e)?e.forEach((function(e){return n.push(bR.getTurnServer(e))})):bR.isPlainObject(e)&&n.push(bR.getTurnServer(e)),this._turnServers=n,t&&(this._iceTransportPolicy=t)}},{key:"sendStartMixTranscode",value:function(e){return this.signalChannel.sendWaitForResponse({command:"start_mcu_mix",data:e,timeout:5e3,responseCommand:fq.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"})}},{key:"sendStopMixTranscode",value:function(e){return this.signalChannel.sendWaitForResponse({command:"stop_mcu_mix",data:e,timeout:5e3,responseCommand:fq.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"})}},{key:"sendStartPublishCDN",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.signalChannel.sendWaitForResponse({command:t?"start_publishing":"start_push_user_cdn",data:e,timeout:5e3,responseCommand:t?fq.START_PUBLISH_TENCENT_CDN_RES:fq.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDN"})}},{key:"sendStopPublishCDN",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.signalChannel.sendWaitForResponse({command:t?"stop_publishing":"stop_push_user_cdn",data:e,timeout:5e3,responseCommand:t?fq.STOP_PUBLISH_TENCENT_CDN_RES:fq.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"})}},{key:"sendStartPushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:"start_publish_cdn_stream",data:e,timeout:5e3,responseCommand:fq.START_PUBLISH_CDN_STREAM_RES,commandDesc:"startPublishCDNStream"})}},{key:"sendUpdatePushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:"update_publish_cdn_stream",data:e,timeout:5e3,responseCommand:fq.UPDATE_PUBLISH_CDN_STREAM_RES,commandDesc:"updatePublishCDNStream"})}},{key:"sendStopPushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:"stop_publish_cdn_stream",data:e,timeout:5e3,responseCommand:fq.STOP_PUBLISH_CDN_STREAM_RES,commandDesc:"stopPublishCDNStream"})}},{key:"sendAbilityStatus",value:function(e){var t;null==(t=this.signalChannel)||t.sendWaitForResponse({command:"ability_status_report",data:e,timeout:5e3,responseCommand:fq.ABILITY_STATUS_REPORT_RESULT,commandDesc:"ability status report"}).catch((function(e){}))}},{key:"getIceServers",value:function(e){var t,n;return this._turnServers.length>0?this._turnServers:null!=(t=this.scheduleResult.iceServers)&&t.length?this.scheduleResult.iceServers:null!=e&&e.length?e:null!=(n=this._iceServersFromJoin)&&n.length?this._iceServersFromJoin:[]}},{key:"getIceTransportPolicy",value:function(){return this.forceRelay?"relay":this._iceTransportPolicy||this.scheduleResult.iceTransportPolicy||"all"}},{key:"getLogger",value:function(){return this._log}},{key:"enableAIVoice",value:function(){throw new Error("Method not implemented.")}},{key:"getSignalChannelUrl",value:function(){var e={mainUrl:"",backupUrl:""},t=bR.getEnv();return t?(e.mainUrl="wss://".concat(t,".rtc.qq.com"),e.backupUrl=e.mainUrl):this.proxy_ws?(e.mainUrl=this.proxy_ws,e.backupUrl=e.mainUrl):this.proxy_unified?(e.mainUrl="wss://".concat(this.proxy_unified),e.backupUrl=e.mainUrl):Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(e.mainUrl="wss://".concat(this.scheduleResult.domains[0]),e.backupUrl=e.mainUrl,this.scheduleResult.domains[1]&&(e.backupUrl="wss://".concat(this.scheduleResult.domains[1]))),e}},{key:"getSignalInfo",value:function(){var e;return(null==(e=this.signalChannel)?void 0:e.getSignalInfo())||{clientIp:"",relayIp:""}}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.clearNetworkQuality(),this.closeUplink("you exitRoom"),this.signalChannel&&(e&&this.signalChannel.keepAlive&&this.signalChannel.isConnected?this.signalChannel.stopKeepAliveIn(3600):(this.signalChannel.close(),this.setSignalChannel(null))),this._stats.reset(),this.userManager.clear(),this.userManager.removeAllListeners(),this.singlePC&&(this.singlePC.close(),this.singlePC=null),this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}}},{key:"checkSubscribeBigSmallVideo",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.subscribeState,r=e.userId,i=e.muteState,a=i.hasSmall,o=i.hasVideo,(a||o)&&(n.video||n.smallVideo)){t.next=3;break}return t.abrupt("return");case 3:if(!(!(s=this._changeBigSmallRecords.get(r))||s.isSubscribing||s.reSubscribeCount<=0)){t.next=6;break}return t.abrupt("return");case 6:if(c=s.options,u=s.reSubscribeCount,!(c.video&&n.video||c.smallVideo&&n.smallVideo&&a)){t.next=9;break}return t.abrupt("return");case 9:if(l={audio:e.remoteAudioTrack.isSubscribed||e.remoteAudioTrack.isSubscribing,auxiliary:e.remoteAuxiliaryTrack.isSubscribed||e.remoteAuxiliaryTrack.isSubscribing,video:c.video,smallVideo:c.smallVideo},t.prev=10,!a&&l.smallVideo&&(l.video=!0,l.smallVideo=!1),l.smallVideo!==n.smallVideo||l.video!==n.video){t.next=13;break}return t.abrupt("return");case 13:return s.isSubscribing=!0,s.reSubscribeCount=u-1,t.next=17,e.subscribe(l,"main");case 17:e.remoteVideoTrack.setMediaType(l.smallVideo?8:4),this._log.info("change [".concat(r,"] to ").concat(l.smallVideo?"small":"big"," video successfully. count ").concat(ew-s.reSubscribeCount,".")),s.isSubscribing=!1,s.reSubscribeCount=ew,t.next=26;break;case 23:t.prev=23,t.t0=t.catch(10),this._log.info("change [".concat(r,"] to ").concat(l.smallVideo?"small":"big"," video failed. count ").concat(ew-s.reSubscribeCount,".")),s.isSubscribing=!1,0===s.reSubscribeCount&&this._changeBigSmallRecords.delete(r);case 26:case"end":return t.stop()}}),t,this,[[10,23]])})))}},{key:"changeType",value:function(e,t){var n={options:{video:!e,smallVideo:e},isSubscribing:!1,reSubscribeCount:ew};this._changeBigSmallRecords.set(t.userId,n),this._log.info("set [".concat(t.userId,"] video prefer type: ").concat(e?"small":"big"));var r=this.remotePublishedUserMap.get(t.userId);r&&this.checkSubscribeBigSmallVideo(r)}},{key:"smallStreamConfig",get:function(){return this._smallStreamConfig}},{key:"_initBusinessInfo",value:function(e){this._businessInfo=e.businessInfo;var t={};if(Uj(e.businessInfo)&&(t=JSON.parse(e.businessInfo)),!Vj(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new yR({code:_R.INVALID_PARAMETER,message:mN({key:dN.INVALID_PURE_AUDIO})});this._pureAudioPushMode=e.pureAudioPushMode,t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.pure_audio_push_mod=this._pureAudioPushMode}if(!Vj(e.userDefineRecordId)){if(null===e.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi))throw new yR({code:_R.INVALID_PARAMETER,message:mN({key:dN.INVALID_USER_DEFINE_RECORDID})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!Vj(e.userDefinePushArgs)){if(!(Uj(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new yR({code:_R.INVALID_PARAMETER,message:mN({key:dN.INVALID_USER_DEFINE_PUSH_ARGS})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}Bj(t)||(this._businessInfo=JSON.stringify(t))}},{key:"sendCustomMessage",value:function(e){var t;null==(t=this._customMessageManager)||t.send(e)}},{key:"enableInsertableStreams",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.singlePC||this.singlePC.enableInsertableStreams||!sP){e.next=7;break}return this.singlePC.enableInsertableStreams=!0,e.next=4,this.singlePC.waitForPeerConnectionConnected();case 4:return e.next=6,this.singlePC.startReconnection();case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendSignalMessage",value:function(e){var t;return this.signalChannel?null==(t=this.signalChannel)?void 0:t.sendWaitForResponseWithRetry(e):Promise.reject(new yR({code:_R.INVALID_OPERATION,message:"not join"}))}},{key:"enableCodecPipeline",get:function(){return this.videoManager.encodePipeline.length>0||this.videoManager.decodePipeline.length>0||this.audioManager.encodePipeline.length>0||this.audioManager.decodePipeline.length>0}},{key:"scriptTransformWorker",get:function(){var e;return null==(e=this.singlePC)?void 0:e.scriptTransformWorker}}])}(sj);return nR([AP(["left",wP.INIT],"joined"),HP({settings:{retries:1,timeout:0},onRetrying:function(e){this._log.warn("join retry ".concat(e))},onRetryFailed:function(e){this._log.error("join failed",e)},onError:function(e,t){this._isUsingCachedSchedule&&!this.isDestroyed?(this._log.warn("is using cached schedule, retry join"),rB(!0),this.reset(),t()):this.signalChannel&&this.signalChannel.isConnected&&this.signalChannel.keepAlive?(this._log.warn("is using keepAlive ws, retry join"),this.signalChannel.close(),this.reset(),t()):(this.reset(),t())}}),uL((function(e){var t=new oq;return function(n,r,i){return aR(this,null,f().mark((function a(){var o,s,c,u=this;return f().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(o=String(n.roomId||n.strRoomId),this.userId=n.userId,this.sdkAppId=n.sdkAppId,this.userSig=n.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=r,n.privateMapKey=n.privateMapKey||"",!this.isJoined){a.next=3;break}throw new yR({code:_R.INVALID_OPERATION,message:mN({key:dN.INVALID_JOIN})});case 3:if(this.checkDestroy(),!t.isJoined({userId:this.userId,roomId:o,sdkAppId:this.sdkAppId,room:this})){a.next=5;break}throw new yR({code:_R.INVALID_OPERATION,message:mN({key:dN.REPEAT_JOIN,data:this.userId})});case 5:if(t.add({room:this,roomId:o}),this.role=21===n.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(o," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),rO.emit(aO.JOIN_START,{room:this,roomId:o,params:n}),(s=bR.getEnv())||(s=JR.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(iC.OLD_CLOUD_LADDER)?s=JR.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(iC.WEBRTC)&&(s=JR.WEBRTC))),qP.setConfig({env:s,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:o}),lO.checkSystemRequirementsInternal().then((function(e){u.checkSystemResult=e,sq.call(u)})),a.prev=8,a.t0=!(this.proxy_ws||this.proxy_wt||this.scheduleResult.domains||bR.getEnv()),!a.t0){a.next=13;break}return a.next=13,this.schedule(n,i);case 13:return a.next=15,e.call(this,n,r,i);case 15:return c=a.sent,a.abrupt("return",(this.roomId=o,this._joinedTimestamp=bR.performanceNow(),rO.emit(aO.JOIN_SUCCESS,{room:this}),30===i&&!n.component&&qP.uploadEvent({log:"stat-conv-".concat(Number(qx),"-").concat(location.hostname),userId:this.userId}),c));case 19:throw a.prev=19,a.t1=a.catch(8),t.delete({room:this,roomId:o}),rO.emit(aO.JOIN_FAILED,{room:this,error:a.t1}),a.t1;case 22:case"end":return a.stop()}}),a,this,[[8,19]])})))}}))],qj.prototype,"join",1),nR([AP("joined","left",{ignoreError:!0,success:function(){this.reset(!0)}}),uL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return rO.emit(aO.LEAVE_START,{room:this}),t.next=3,e.call.apply(e,[this].concat(n));case 3:rO.emit(aO.LEAVE_SUCCESS,{room:this,roomId:this.roomId});case 4:case"end":return t.stop()}}),t,this)})))}})),vL("leave room"),GP({fnName:"publish",validateArgs:!1}),GP({fnName:"unsubscribe",validateArgs:!1})],qj.prototype,"leave",1),nR([mL(),uL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return aR(this,null,f().mark((function t(){var r,i=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(("live"!==this.scene||"anchor"===this.role)&&(n=n.filter((function(e){return e.outMediaTrack&&"capture"===e.state})),n.length)){t.next=2;break}return t.abrupt("return");case 2:return rO.emit("61",{room:this}),r=e.apply(this,n),t.abrupt("return",(n.forEach((function(e){return e.publish(i,r)})),r));case 5:case"end":return t.stop()}}),t,this)})))}})),HP({settings:{retries:wC,timeout:function(e){return Tw(e)}},onError:function(e,t,n){var r;null!=(r=e.message)&&r.includes("timeout")?(this._log.warn("publish timeout"),t()):(this._log.error("publish failed: ".concat(e)),n(e),rO.emit(aO.PUBLISH_FAILED,{room:this}))}})],qj.prototype,"publish",1),nR([GP({fnName:"publish"}),function(e,t,n){var r=n.value;return n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=fL.get(this);if(i){var a=i.queue.filter((function(e,n){if(0===n)return!0;var r=!0;return e.args.forEach((function(e){t.find((function(t){return t===e}))||(r=!1)})),!r||(e.reject(new yR({code:_R.API_CALL_ABORTED,message:"api-call"})),!1)}));i.queue=a}return r.apply(this,t)},n},mL(),uL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=e.apply(this,n);return n.forEach((function(e){return e.unpublish()})),i}})),sL((function(){var e,t;0===this.localTracks.size&&XN()&&(null==(t=null==(e=this.singlePC)?void 0:e.getPeerConnection())||t.getSenders().forEach((function(e){return e.track&&e.replaceTrack(null)})))}))],qj.prototype,"unpublish",1),nR([cL((function(e){if(e.code!==_R.API_CALL_ABORTED)throw e})),_L((function(e){return e.userId}))],qj.prototype,"replaceTrack",1),nR([_L((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].userId})),PL(),uL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=e.apply(this,n);return n.forEach((function(e){return!e.isSubscribed&&e.subscribe(i)})),i}})),HP({settings:{retries:wC,timeout:function(e){return Tw(e)}},onError:function(e,t,n,r){e.message.includes("timeout")?(this._log.warn("subscribe timeout"),t()):(this._log.error("subscribe failed: ".concat(e)),n(e),rO.emit(aO.SUBSCRIBE_FAILED,{room:this,remoteTracks:r}))}})],qj.prototype,"subscribe",1),nR([GP({fnName:"subscribe",callback:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];this.singlePC||n.forEach((function(t){var n=e.remotePublishedUserMap.get(t.userId);n&&!n.isMainStreamSubscribed&&!n.isAuxStreamSubscribed&&n.close("you unsubscribed")}))}}),_L((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].userId}))],qj.prototype,"unsubscribe",1),aq.create=aq._create.bind(aq,qj),aq},"object"==("undefined"==typeof exports?"undefined":k(exports))&&"undefined"!=typeof module?module.exports=NN():"function"==typeof define&&define.amd?define(NN):(ON="undefined"!=typeof globalThis?globalThis:ON||self).TRTC=NN()},"function"==typeof define&&define.amd?define(factory):factory();