@vmosedge/web-sdk 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";function e(e,t){this.v=e,this.k=t}function t(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 n(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function r(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,c,"next",e)}function c(e){r(a,i,o,s,c,"throw",e)}s(void 0)})}}function o(t){return new e(t,0)}function a(e,t,n){return t=y(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,g()?Reflect.construct(t,n||[],y(e).constructor):t.apply(e,n))}function s(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){return e.get(n(e,t))}function l(e,t,n){s(e,t),t.set(e,n)}function d(e,t,r){return e.set(n(e,t),r),r}function f(e,t){s(e,t),t.add(e)}function h(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 p(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function v(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=R(e))||t){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 o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function _(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 m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=y(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},m.apply(null,arguments)}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function b(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&&S(e,t)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach(function(t){_(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function x(){
1
+ "use strict";function e(e,t){this.v=e,this.k=t}function t(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 n(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function r(e,t,n,r,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)})}}function o(t){return new e(t,0)}function a(e,t,n){return t=w(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,b()?Reflect.construct(t,n||[],w(e).constructor):t.apply(e,n))}function s(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){return e.get(n(e,t))}function l(e,t,n){s(e,t),t.set(e,n)}function f(e,t,r){return e.set(n(e,t),r),r}function h(e,t){s(e,t),t.add(e)}function d(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,_(r.key),r)}}function v(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function p(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=I(e))||t){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 o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function y(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=w(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},m.apply(null,arguments)}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},w(e)}function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&O(e,t)}function b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(b=function(){return!!e})()}function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach(function(t){y(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function C(){
2
2
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
- var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof s?r:s,u=Object.create(c.prototype);return k(u,"_invoke",function(n,r,i){var o,s,c,u=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,c=e,f.n=n,a}};function h(n,r){for(s=n,c=r,t=0;!d&&u&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,c=p;(t=s<2?e:c)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,c)):f.n=c:f.v=c);try{if(u=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==a)break}catch(t){o=e,s=1,c=t}finally{u=1}}return{value:t,done:d}}}(n,i,o),!0),u}var a={};function s(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(k(t={},r,function(){return this}),t),d=u.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,k(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=u,k(d,"constructor",u),k(u,"constructor",c),c.displayName="GeneratorFunction",k(u,i,"GeneratorFunction"),k(d),k(d,i,"Generator"),k(d,r,function(){return this}),k(d,"toString",function(){return"[object Generator]"}),(x=function(){return{w:o,m:f}})()}function k(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}k=function(e,t,n,r){function o(t,n){k(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},k(e,t,n,r)}function C(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},S(e,t)}function O(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,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.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&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||R(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 N(e,t,n,r){var i=m(y(e.prototype),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function A(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||R(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e){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);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function I(e){return I="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},I(e)}function R(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function M(t){var n,r;function i(n,r){try{var a=t[n](r),s=a.value,c=s instanceof e;Promise.resolve(c?s.v:s).then(function(e){if(c){var r="return"===n?"return":"next";if(!s.k||e.done)return i(r,e);e=t[r](e).value}o(a.done?"return":"normal",e)},function(e){i("throw",e)})}catch(e){o("throw",e)}}function o(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?i(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(o,a){var s={key:e,arg:t,resolve:o,reject:a,next:null};r?r=r.next=s:(n=r=s,i(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}function P(e){var t="function"==typeof Map?new Map:void 0;return P=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(g())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&S(i,n.prototype),i}(e,arguments,y(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),S(n,e)},P(e)}M.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},M.prototype.next=function(e){return this._invoke("next",e)},M.prototype.throw=function(e){return this._invoke("throw",e)},M.prototype.return=function(e){return this._invoke("return",e)};var D=function(e,t){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},D(e,t)};function L(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}D(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var W,G=function(){return G=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},G.apply(this,arguments)};function B(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})}function U(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function V(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function H(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var z=function(){return p(function e(t,n,r,i){c(this,e),_(this,"optionValue",void 0),_(this,"metadataValue",void 0),_(this,"mimeType",void 0),_(this,"webCodecId",void 0),this.optionValue=t,this.metadataValue=n,this.mimeType=r,this.webCodecId=i},[{key:"toOptionValue",value:function(){return this.optionValue}}])}();_(z,"Opus",new(W=z)("opus",1869641075,"audio/opus","opus")),_(z,"Aac",new W("aac",6381923,"audio/aac","mp4a.66")),_(z,"Flac",new W("flac",1718378851,"audio/flac","flac")),_(z,"Raw",new W("raw",7496055,"audio/raw",""));var F=0,q=1,K=2,X=3,Y=4,J=5,Z=6,$=7,Q=8,ee=9,te=10,ne=11,re=12,ie=13,oe=14,ae=15,se=16,ce=17,ue=new WeakMap,le=new WeakSet,de=function(){return p(function e(){c(this,e),f(this,le),l(this,ue,[])},[{key:"parsers",get:function(){return u(ue,this)}},{key:"add",value:function(e){if(Array.isArray(e.id)){var t,r=v(e.id);try{for(r.s();!(t=r.n()).done;){var i=t.value;n(le,this,fe).call(this,i,e)}}catch(e){r.e(e)}finally{r.f()}}else n(le,this,fe).call(this,e.id,e);return e}},{key:"parse",value:(e=i(x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:if(r=u(ue,this)[t]){e.n=1;break}throw new Error("Unknown device message id ".concat(t));case 1:return e.a(2,r.parse(t,n))}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=v(u(ue,this));try{for(t.s();!(e=t.n()).done;){e.value.close()}}catch(e){t.e(e)}finally{t.f()}}},{key:"error",value:function(e){var t,n=v(u(ue,this));try{for(n.s();!(t=n.n()).done;){t.value.error(e)}}catch(e){n.e(e)}finally{n.f()}}}]);var e}();function fe(e,t){if(u(ue,this)[e])throw new Error("Duplicate parser for id ".concat(e));u(ue,this)[e]=t}function he(e,t){if(function(e){return"object"===I(e)&&null!==e&&"toOptionValue"in e&&"function"==typeof e.toOptionValue}(e)&&(e=e.toOptionValue()),void 0===e)return t;if("string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e)throw new TypeError("Invalid option value: ".concat(JSON.stringify(e)));return e.toString()}var pe=1748121140,ve=1748121141,_e=6387249,me=new WeakMap,ye=new WeakMap,be=new WeakMap,ge=new WeakMap,we=function(){return p(function e(){var t=this;c(this,e),l(this,me,void 0),l(this,ye,void 0),l(this,be,void 0),l(this,ge,"running"),_(this,"resolve",function(e){u(ye,t).call(t,e),d(ge,t,"resolved")}),_(this,"reject",function(e){u(be,t).call(t,e),d(ge,t,"rejected")}),d(me,this,new Promise(function(e,n){d(ye,t,e),d(be,t,n)}))},[{key:"promise",get:function(){return u(me,this)}},{key:"state",get:function(){return u(ge,this)}}])}();function Ee(e){return"object"===I(e)&&null!==e&&"then"in e}function xe(e,t){for(;;){var n=e.next(t),r=n.done,i=n.value;if(r)return i;if(Ee(i))return i.then(function(t){return xe(e,{resolved:t})},function(t){return xe(e,{error:t})});t=i}}function ke(e,t){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=e.call.apply(e,[this,x().m(function e(t){var n;return x().w(function(e){for(;;)switch(e.n){case 0:if(!Ee(t)){e.n=3;break}return e.n=1,t;case 1:if(!("resolved"in(n=e.v))){e.n=2;break}return e.a(2,n.resolved);case 2:throw n.error;case 3:return e.a(2,t)}},e)})].concat(n));return xe(i,void 0)}}function Ce(e,t){return function(n,r){var i;if("buffer"in r)return null!==(i=r.index)&&void 0!==i||(r.index=0),t(n,r),e;var o=new Uint8Array(e);return t(n,{buffer:o,index:0,littleEndian:r.littleEndian}),o}}var Se=function(e,t,n,r,i){var o,a={size:e,type:t,serialize:"default"===t?(o=n,function(e,t){if("buffer"in t){var n=o(e,t);return t.buffer.set(n,t.index),n.length}return o(e,t)}):Ce(e,n),deserialize:ke(r),omitInit:null==i?void 0:i.omitInit};return null!=i&&i.init&&(a.init=i.init),a},Oe=new Uint8Array(0);function Ne(e,t){var n,r,i,o,a,s,c,u,l;return"number"==typeof e?(0===e?(n=function(){},r=t?x().m(function e(){return x().w(function(e){for(;;)if(0===e.n)return e.a(2,t.convert(Oe))},e)}):x().m(function e(){return x().w(function(e){for(;;)if(0===e.n)return e.a(2,Oe)},e)})):(n=function(t,n){return function(e,t,n,r){t.length<r?(e.set(t,n),e.fill(0,n+t.length,n+r)):t.length===r?e.set(t,n):e.set(t.subarray(0,r),n)}(n.buffer,t,n.index,e)},t?(r=x().m(function n(r,i){var o,a;return x().w(function(n){for(;;)switch(n.n){case 0:return o=i.readExactly(e),a=t,n.d(C(r(o)),1);case 1:return n.a(2,a.convert.call(a,n.v))}},n)}),i=function(e){return t.back(e)}):r=x().m(function t(n,r){var i;return x().w(function(t){for(;;)if(0===t.n)return i=r.readExactly(e),t.a(2,i)},t)})),Se(e,"byob",n,r,{init:i})):"object"!==I(e)&&"function"!=typeof e||!("serialize"in e)?"string"==typeof e?(t?(s=function(n,r,i){var o=i.dependencies;return x().m(function i(){var a,s,c;return x().w(function(i){for(;;)switch(i.n){case 0:return a=o[e],s=0!==a?r.readExactly(a):Oe,c=t,i.d(C(n(s)),1);case 1:return i.a(2,c.convert.call(c,i.v))}},i)})()},c=function(n,r){var i=t.back(n);return r[e]=i.length,i}):(s=function(t,n,r){var i=r.dependencies;return x().m(function t(){var r,o;return x().w(function(t){for(;;)if(0===t.n)return r=i[e],o=0!==r?n.readExactly(r):Oe,t.a(2,o)},t)})()},c=function(t,n){var r=t;return n[e]=r.length,r}),Se(0,"default",function(e){return e},s,{init:c})):(t?(u=function(n,r,i){var o=i.dependencies;return x().m(function i(){var a,s,c,u;return x().w(function(i){for(;;)switch(i.n){case 0:return a=o[e.field],s=e.convert(a),c=0!==s?r.readExactly(s):Oe,u=t,i.d(C(n(c)),1);case 1:return i.a(2,u.convert.call(u,i.v))}},i)})()},l=function(n,r){var i=t.back(n);return r[e.field]=e.back(i.length),i}):(u=function(t,n,r){var i=r.dependencies;return x().m(function t(){var r,o,a;return x().w(function(t){for(;;)if(0===t.n)return r=i[e.field],o=e.convert(r),a=0!==o?n.readExactly(o):Oe,t.a(2,a)},t)})()},l=function(t,n){var r=t;return n[e.field]=e.back(r.length),r}),Se(0,"default",function(e){return e},u,{init:l})):(t?(o=x().m(function n(r,i,o){var a,s,c;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(r(e.deserialize(i,o))),1);case 1:return a=n.v,s=0!==a?i.readExactly(a):Oe,c=t,n.d(C(r(s)),2);case 2:return n.a(2,c.convert.call(c,n.v))}},n)}),a=function(e){return t.back(e)}):o=x().m(function t(n,r,i){var o,a;return x().w(function(t){for(;;)switch(t.n){case 0:return t.d(C(n(e.deserialize(r,i))),1);case 1:return o=t.v,a=0!==o?r.readExactly(o):Oe,t.a(2,a)}},t)}),Se(e.size,"default",function(t,n){var r=n.littleEndian;if("default"===e.type){var i=e.serialize(t.length,{littleEndian:r});if(0===t.length)return i;var o=new Uint8Array(i.length+t.length);return o.set(i,0),o.set(t,i.length),o}var a=new Uint8Array(e.size+t.length);return e.serialize(t.length,{buffer:a,index:0,littleEndian:r}),a.set(t,e.size),a},o,{init:a}))}var Ae=function(){function e(){return c(this,e),a(this,e,["ExactReadable ended"])}return b(e,P(Error)),p(e)}(),Te=function(){function e(t){return c(this,e),a(this,e,[t])}return b(e,P(Error)),p(e)}(),Ie=function(){function e(){return c(this,e),a(this,e,["The underlying readable was ended before the struct was fully deserialized"])}return b(e,Te),p(e)}(),Re=function(){function e(){return c(this,e),a(this,e,["The underlying readable doesn't contain any more struct"])}return b(e,Te),p(e)}();function Me(e,t){for(var n=Object.entries(e),r=0,i=!0,o=0,a=n;o<a.length;o++){var s=O(a[o],2)[1];r+=s.size,i&&"byob"!==s.type&&(i=!1)}var c=t.littleEndian,u=t.extra?Object.getOwnPropertyDescriptors(t.extra):void 0;return{littleEndian:c,fields:e,extra:t.extra,type:i?"byob":"default",size:r,serialize:function(e,t){for(var r=E({},e),i=0,o=n;i<o.length;i++){var a=O(o[i],2),s=a[0],u=a[1];if(s in r&&"init"in u){var l,d=null===(l=u.init)||void 0===l?void 0:l.call(u,r[s],r);r[s]=d}}var f,h=new Array(n.length),p=new Array(n.length),_={littleEndian:c},m=v(n.entries());try{for(m.s();!(f=m.n()).done;){var y=O(f.value,2),b=y[0],g=O(y[1],2),w=g[0],x=g[1];"byob"===x.type?h[b]=x.size:(p[b]=x.serialize(r[w],_),h[b]=p[b].length)}}catch(e){m.e(e)}finally{m.f()}var k,C,S,N=h.reduce(function(e,t){return e+t},0);if(t instanceof Uint8Array){if(t.length<N)throw new Error("Buffer too small");k=!0,C=t,S=0}else if("object"===I(t)&&"buffer"in t){var A;if(k=!0,C=t.buffer,S=null!==(A=t.index)&&void 0!==A?A:0,C.length-S<N)throw new Error("Buffer too small")}else k=!1,C=new Uint8Array(N),S=0;var T,R={buffer:C,index:S,littleEndian:c},M=v(n.entries());try{for(M.s();!(T=M.n()).done;){var P=O(T.value,2),D=P[0],L=O(P[1],2),W=L[0],G=L[1];p[D]?C.set(p[D],R.index):G.serialize(r[W],R),R.index+=h[D]}}catch(e){M.e(e)}finally{M.f()}return k?N:C},deserialize:ke(x().m(function e(r,i){var o,a,s,l,d,f,h,p,v;return x().w(function(e){for(;;)switch(e.p=e.n){case 0:o=i.position,s={dependencies:a={},littleEndian:c},e.p=1,l=0,d=n;case 2:if(!(l<d.length)){e.n=5;break}return f=O(d[l],2),h=f[0],p=f[1],e.d(C(r(p.deserialize(i,s))),3);case 3:a[h]=e.v;case 4:l++,e.n=2;break;case 5:e.n=9;break;case 6:if(e.p=6,(v=e.v)instanceof Ae){e.n=7;break}throw v;case 7:if(i.position!==o){e.n=8;break}throw new Re;case 8:throw new Ie;case 9:if(u&&Object.defineProperties(a,u),!t.postDeserialize){e.n=10;break}return e.a(2,t.postDeserialize.call(a,a));case 10:return e.a(2,a);case 11:return e.a(2)}},e,null,[[1,6]])}))}}function Pe(e,t,n){return n?(e[t]|e[t+1]<<8)<<16>>16:(e[t]<<8|e[t+1])<<16>>16}function De(e,t,n){return n?e[t]|e[t+1]<<8:e[t+1]|e[t]<<8}function Le(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}function We(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function Ge(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Be(e,t,n){return n?(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0:(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Ue(e,t,n){return n?BigInt(e[t])|BigInt(e[t+1])<<8n|BigInt(e[t+2])<<16n|BigInt(e[t+3])<<24n|BigInt(e[t+4])<<32n|BigInt(e[t+5])<<40n|BigInt(e[t+6])<<48n|BigInt(e[t+7])<<56n:BigInt(e[t])<<56n|BigInt(e[t+1])<<48n|BigInt(e[t+2])<<40n|BigInt(e[t+3])<<32n|BigInt(e[t+4])<<24n|BigInt(e[t+5])<<16n|BigInt(e[t+6])<<8n|BigInt(e[t+7])}function Ve(e,t,n){var r=function(){return r};return Object.assign(r,Se(e,"byob",t,n)),r}var je=Ve(1,function(e,t){t.buffer[t.index]=e},x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:return e.d(C(t(n.readExactly(1))),1);case 1:return r=e.v,e.a(2,r[0])}},e)})),He=Ve(2,function(e,t){Le(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(2))),1);case 1:return i=n.v,n.a(2,De(i,0,r))}},n)})()}),ze=Ve(4,function(e,t){!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8,e[t+2]=n>>16,e[t+3]=n>>24):(e[t]=n>>24,e[t+1]=n>>16,e[t+2]=n>>8,e[t+3]=n)}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(4))),1);case 1:return i=n.v,n.a(2,Be(i,0,r))}},n)})()}),Fe=Ve(8,function(e,t){!function(e,t,n,r){r?(e[t]=Number(0xffn&n),e[t+1]=Number(n>>8n&0xffn),e[t+2]=Number(n>>16n&0xffn),e[t+3]=Number(n>>24n&0xffn),e[t+4]=Number(n>>32n&0xffn),e[t+5]=Number(n>>40n&0xffn),e[t+6]=Number(n>>48n&0xffn),e[t+7]=Number(n>>56n&0xffn)):(e[t]=Number(n>>56n&0xffn),e[t+1]=Number(n>>48n&0xffn),e[t+2]=Number(n>>40n&0xffn),e[t+3]=Number(n>>32n&0xffn),e[t+4]=Number(n>>24n&0xffn),e[t+5]=Number(n>>16n&0xffn),e[t+6]=Number(n>>8n&0xffn),e[t+7]=Number(0xffn&n))}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(8))),1);case 1:return i=n.v,n.a(2,Ue(i,0,r))}},n)})()}),qe=globalThis.TextEncoder,Ke=globalThis.TextDecoder,Xe=new qe,Ye=new Ke;function Je(e){return Xe.encode(e)}function Ze(e){return Ye.decode(e)}var $e=function(e){var t=Ne(e,{convert:Ze,back:Je});return t.as=function(){return t},t},Qe=Me({type:je},{littleEndian:!1}),et=globalThis.AbortController,tt=function(){var e=globalThis.ReadableStream;return e.from||(e.from=function(t){var n=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return new e({pull:function(e){return i(x().m(function t(){var r;return x().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.next();case 1:if(!(r=t.v).done){t.n=2;break}return e.close(),t.a(2);case 2:e.enqueue(r.value);case 3:return t.a(2)}},t)}))()},cancel:function(e){return i(x().m(function t(){var r;return x().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,null===(r=n.return)||void 0===r?void 0:r.call(n,e);case 1:return t.a(2)}},t)}))()}})}),e.prototype[Symbol.asyncIterator]&&e.prototype.values||(e.prototype.values=function(){var e,t=(e=x().m(function e(t){var n,r,i,a;return x().w(function(e){for(;;)switch(e.p=e.n){case 0:n=this.getReader(),e.p=1;case 2:return e.n=3,o(n.read());case 3:if(r=e.v,i=r.done,a=r.value,!i){e.n=4;break}return e.a(2);case 4:return e.n=5,a;case 5:e.n=2;break;case 6:if(e.p=6,null!=t&&t.preventCancel){e.n=7;break}return e.n=7,o(n.cancel());case 7:return n.releaseLock(),e.f(6);case 8:return e.a(2)}},e,this,[[1,,6,8]])}),function(){return new M(e.apply(this,arguments))});return function(e){return t.apply(this,arguments)}}(),e.prototype[Symbol.asyncIterator]=e.prototype.values),e}(),nt=globalThis.WritableStream,rt=globalThis.TransformStream,it=function(){function e(t,n,r){var o;c(this,e);var s=!1,u=new et;return a(this,e,[{start:function(e){var n,a=t({abortSignal:u.signal,enqueue:(n=i(x().m(function t(n){return x().w(function(t){for(;;)switch(t.n){case 0:if(null==r||r({source:"producer",operation:"enqueue",value:n,phase:"start"}),!u.signal.aborted){t.n=1;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),t.a(2);case 1:if(null!==e.desiredSize){t.n=2;break}return e.enqueue(n),t.a(2);case 2:if(!s){t.n=3;break}return s=!1,e.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"}),t.a(2);case 3:if(!(e.desiredSize<=0)){t.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"waiting"}),o=new we,t.n=4,o.promise;case 4:if(!u.signal.aborted){t.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),t.a(2);case 5:e.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"});case 6:return t.a(2)}},t)})),function(e){return n.apply(this,arguments)}),close:function(){null==r||r({source:"producer",operation:"close",explicit:!0,phase:"start"}),u.signal.aborted?null==r||r({source:"producer",operation:"close",explicit:!0,phase:"ignored"}):(e.close(),null==r||r({source:"producer",operation:"close",explicit:!0,phase:"complete"}))},error:function(t){null==r||r({source:"producer",operation:"error",explicit:!0,phase:"start"}),e.error(t),null==r||r({source:"producer",operation:"error",explicit:!0,phase:"complete"})}});a&&"then"in a&&a.then(function(){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"start"});try{e.close(),null==r||r({source:"producer",operation:"close",explicit:!1,phase:"complete"})}catch(e){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"ignored"})}},function(t){null==r||r({source:"producer",operation:"error",explicit:!1,phase:"start"}),e.error(t),null==r||r({source:"producer",operation:"error",explicit:!1,phase:"complete"})})},pull:function(){null==r||r({source:"consumer",operation:"pull",phase:"start"}),o?o.resolve():0===(null==n?void 0:n.highWaterMark)&&(s=!0),null==r||r({source:"consumer",operation:"pull",phase:"complete"})},cancel:function(e){var t;null==r||r({source:"consumer",operation:"cancel",phase:"start"}),u.abort(e),null===(t=o)||void 0===t||t.resolve(),null==r||r({source:"consumer",operation:"cancel",phase:"complete"})}},n])}return b(e,tt),p(e)}();function ot(e){return at.apply(this,arguments)}function at(){return at=i(x().m(function e(t){return x().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.cancel();case 1:return e.a(2,!0);case 2:return e.p=2,e.v,e.a(2,!1)}},e,null,[[0,2]])})),at.apply(this,arguments)}var st=new WeakMap,ct=new WeakMap,ut=new WeakMap,lt=new WeakMap,dt=new WeakSet,ft=function(){return p(function e(t){c(this,e),f(this,dt),l(this,st,void 0),l(this,ct,0),l(this,ut,0),l(this,lt,0),_(this,"stream",void 0),_(this,"reader",void 0),_(this,"readExactly",ke(x().m(function e(t,r){var i,o,a,s;return x().w(function(e){for(;;)switch(e.n){case 0:if(o=0,!(a=n(dt,this,ht).call(this,r))){e.n=2;break}if(a.length!==r){e.n=1;break}return e.a(2,a);case 1:(i=new Uint8Array(r)).set(a,o),o+=a.length,r-=a.length,e.n=3;break;case 2:i=new Uint8Array(r);case 3:if(!(r>0)){e.n=5;break}return e.d(C(t(n(dt,this,pt).call(this,r))),4);case 4:s=e.v,i.set(s,o),o+=s.length,r-=s.length,e.n=3;break;case 5:return e.a(2,i)}},e,this)}))),this.stream=t,this.reader=t.getReader()},[{key:"position",get:function(){return u(lt,this)}},{key:"iterateExactly",value:function(e){var t=this,r=u(st,this)?0:1;return{next:function(){switch(r){case 0:var i=n(dt,t,ht).call(t,e);return i.length===e?r=2:(e-=i.length,r=1),{done:!1,value:i};case 1:return r=3,{done:!1,value:n(dt,t,pt).call(t,e).then(function(t){return t.length===e?r=2:(e-=t.length,r=1),t})};case 2:return{done:!0,value:void 0};case 3:throw new Error("Can't call `next` before previous Promise resolves");default:throw new Error("unreachable")}}}}},{key:"release",value:function(){var e=this;return u(ut,this)>0?new it(function(){var t=i(x().m(function t(n){var r,i,o,a;return x().w(function(t){for(;;)switch(t.n){case 0:return r=u(st,e).subarray(u(ct,e)),t.n=1,n.enqueue(r);case 1:n.abortSignal.addEventListener("abort",function(){ot(e.reader)});case 2:return t.n=3,e.reader.read();case 3:if(i=t.v,o=i.done,a=i.value,!o){t.n=4;break}return t.a(2);case 4:return t.n=5,n.enqueue(a);case 5:t.n=2;break;case 6:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()):(this.reader.releaseLock(),this.stream)}},{key:"cancel",value:(e=i(x().m(function e(t){return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.cancel(t);case 1:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}();function ht(e){if(u(st,this)){var t=u(st,this).subarray(u(ct,this),u(ct,this)+e);return u(ut,this)>e?(d(lt,this,u(lt,this)+e),d(ct,this,u(ct,this)+e),d(ut,this,u(ut,this)-e),t):(d(lt,this,u(lt,this)+u(ut,this)),d(st,this,void 0),d(ct,this,0),d(ut,this,0),t)}}function pt(e){return vt.apply(this,arguments)}function vt(){return(vt=i(x().m(function e(t){var n,r,i;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.read();case 1:if(n=e.v,r=n.done,i=n.value,!r){e.n=2;break}throw new Ae;case 2:if(!(i.length>t)){e.n=3;break}return d(st,this,i),d(ct,this,t),d(ut,this,i.length-t),d(lt,this,u(lt,this)+t),e.a(2,i.subarray(0,t));case 3:return d(lt,this,u(lt,this)+i.length),e.a(2,i)}},e,this)}))).apply(this,arguments)}var _t=new WeakMap,mt=new WeakMap,yt=function(){return p(function e(t){var n,r;c(this,e),l(this,_t,void 0),l(this,mt,void 0);var o=new ft(new it(function(e){n=e}));d(_t,this,new tt({pull:function(e){return i(x().m(function n(){var r,i;return x().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,t(o);case 1:r=n.v,e.enqueue(r),n.n=4;break;case 2:if(n.p=2,!((i=n.v)instanceof Re)){n.n=3;break}return e.close(),n.a(2);case 3:throw i;case 4:return n.a(2)}},n,null,[[0,2]])}))()},cancel:function(e){return r.error(e)}})),d(mt,this,new nt({start:function(e){r=e},write:function(e){return i(x().m(function t(){return x().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.enqueue(e);case 1:return t.a(2)}},t)}))()},abort:function(){n.close()},close:function(){n.close()}}))},[{key:"readable",get:function(){return u(_t,this)}},{key:"writable",get:function(){return u(mt,this)}}])}(),bt=function(){function e(t){return c(this,e),a(this,e,[function(e){return t.deserialize(e)}])}return b(e,yt),p(e)}(),gt=Qe,wt=Me({content:$e(ze)},{littleEndian:!1}),Et=new WeakMap,xt=function(){function e(){var t,n;return c(this,e),l(t=a(this,e,[function(e){n=e}]),Et,void 0),_(t,"id",0),d(Et,t,n),t}return b(e,it),p(e,[{key:"parse",value:(t=i(x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,wt.deserialize(n);case 1:return r=e.v,e.n=2,u(Et,this).enqueue(r.content);case 2:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"close",value:function(){u(Et,this).close()}},{key:"error",value:function(e){u(Et,this).error(e)}}]);var t}(),kt=function(){return[F,q,K,X,Y,J,$,Q,ee,te,ne]}();var Ct={repeatPreviousFrameAfter:"long",maxPtsGapToEncoder:"long"},St=function(){return p(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),_(this,"options",void 0);for(var n=0,r=Object.entries(t);n<r.length;n++){var i=O(r[n],2),o=i[0],a=i[1];if(void 0!==a&&"number"!=typeof a)throw new Error("Invalid option value for ".concat(o,": ").concat(String(a)))}this.options=t},[{key:"toOptionValue",value:function(){var e=Object.entries(this.options).filter(function(e){return void 0!==O(e,2)[1]});if(0!==e.length)return e.map(function(e){var t=O(e,2),n=t[0],r=t[1],i=n.replace(/([A-Z])/g,"-$1").toLowerCase(),o=Ct[n];return o&&(i+=":".concat(o)),i+="=".concat(r)}).join(",")}}])}();_(St,"Empty",new St);var Ot={logLevel:"debug",maxSize:0,bitRate:8e6,maxFps:0,lockVideoOrientation:-1,tunnelForward:!1,crop:void 0,sendFrameMeta:!0,control:!0,displayId:0,showTouches:!1,stayAwake:!1,codecOptions:void 0};function Nt(e,t,n){return e<t?t:e>n?n:e}function At(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 Object.fromEntries(Object.entries(e).filter(function(e){var t=O(e,1)[0];return!n.includes(t)}))}var Tt=Se(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;Le(n,r,e=1===(e=Nt(e,-1,1))?65535:65536*e,i)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i,o;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(2))),1);case 1:return i=n.v,o=De(i,0,r),n.a(2,65535===o?1:o/65536)}},n)})()}),It=Me({pts:Fe,data:Ne(ze)},{littleEndian:!1}),Rt=1n<<63n;function Mt(e,t){return Pt.apply(this,arguments)}function Pt(){return Pt=i(x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(n);case 1:return r=e.v,e.a(2,Ze(r.subarray(0,r.indexOf(0))))}},e)})),Pt.apply(this,arguments)}function Dt(e){return Lt.apply(this,arguments)}function Lt(){return Lt=i(x().m(function e(t){var n;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(4);case 1:return n=e.v,e.a(2,Ge(n,0))}},e)})),Lt.apply(this,arguments)}var Wt,Gt,Bt=function(){return E(E({},Ot),{},{encoderName:void 0})}(),Ut=(Wt=gt,Gt={action:je()},Me(Object.assign({},Wt.fields,Gt),{littleEndian:Wt.littleEndian,extra:Wt.extra,postDeserialize:void 0}));var Vt=function(){var e=kt.slice();return e.splice(6,0,Z),e}(),jt=-1,Ht=function(){return E(E({},Bt),{},{logLevel:"debug",lockVideoOrientation:jt,powerOffOnClose:!1})}(),zt=function(){return E(E({},Ht),{},{clipboardAutosync:!0})}();function Ft(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase()}var qt=Me({sequence:Fe},{littleEndian:!1}),Kt=Me({type:je,sequence:Fe,paste:je(),content:$e(ze)},{littleEndian:!1}),Xt=new WeakMap,Yt=new WeakMap,Jt=function(){return p(function e(){c(this,e),l(this,Xt,new Map),l(this,Yt,!1),_(this,"id",1)},[{key:"parse",value:(e=i(x().m(function e(t,n){var r,i;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,qt.deserialize(n);case 1:r=e.v,(i=u(Xt,this).get(r.sequence))&&(i.resolve(),u(Xt,this).delete(r.sequence));case 2:return e.a(2)}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=v(u(Xt,this).values());try{for(t.s();!(e=t.n()).done;){e.value.reject()}}catch(e){t.e(e)}finally{t.f()}u(Xt,this).clear(),d(Yt,this,!0)}},{key:"error",value:function(e){var t,n=v(u(Xt,this).values());try{for(n.s();!(t=n.n()).done;){t.value.reject(e)}}catch(e){n.e(e)}finally{n.f()}u(Xt,this).clear(),d(Yt,this,!0)}},{key:"serializeSetClipboardControlMessage",value:function(e){if(0n===e.sequence)return Kt.serialize(e);if(u(Yt,this))throw new Error;var t=new we;return u(Xt,this).set(e.sequence,t),[Kt.serialize(e),t.promise]}}]);var e}(),Zt=function(){return E(E({},zt),{},{downsizeOnError:!0,sendDeviceMeta:!0,sendDummyByte:!0})}(),$t=function(){return E(E({},Zt),{},{cleanup:!0})}(),Qt=1n<<62n;var en=function(){return E(E({},$t),{},{powerOn:!0})}(),tn=Se(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}(n,r,e=1===(e=Nt(e,-1,1))?32767:32768*e,i)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i,o;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(2))),1);case 1:return i=n.v,o=Pe(i,0,r),n.a(2,32767===o?1:o/32768)}},n)})()}),nn=function(){return Me({type:je(X),pointerX:ze,pointerY:ze,videoWidth:He,videoHeight:He,scrollX:tn,scrollY:tn,buttons:ze},{littleEndian:!1})}(),rn=function(){return E(E({},At(en,"bitRate","codecOptions","encoderName")),{},{scid:void 0,videoCodec:"h264",videoBitRate:8e6,videoCodecOptions:void 0,videoEncoder:void 0,audio:!0,audioCodec:"opus",audioBitRate:128e3,audioCodecOptions:void 0,audioEncoder:void 0,listEncoders:!1,listDisplays:!1,sendCodecMeta:!0})}(),on=function(){return Me({type:je(K),action:je(),pointerId:Fe,pointerX:ze,pointerY:ze,videoWidth:He,videoHeight:He,pressure:Tt,actionButton:ze,buttons:ze},{littleEndian:!1})}();function an(){return an=i(x().m(function e(t,n){var r,o,a,s,c,u,l,d;return x().w(function(e){for(;;)switch(e.n){case 0:return r=new ft(t),e.n=1,r.readExactly(4);case 1:o=e.v,a=Ge(o,0),u=a,e.n=0===u?2:1===u?3:4;break;case 2:return e.a(2,{type:"disabled"});case 3:return e.a(2,{type:"errored"});case 4:if(!n.sendCodecMeta){e.n=11;break}l=a,e.n=l===z.Raw.metadataValue?5:l===z.Opus.metadataValue?6:l===z.Aac.metadataValue?7:l===z.Flac.metadataValue?8:9;break;case 5:return s=z.Raw,e.a(3,10);case 6:return s=z.Opus,e.a(3,10);case 7:return s=z.Aac,e.a(3,10);case 8:return s=z.Flac,e.a(3,10);case 9:case 16:throw new Error("Unknown audio codec metadata value: ".concat(a));case 10:return e.a(2,{type:"success",codec:s,stream:r.release()});case 11:d=n.audioCodec,e.n="raw"===d?12:"opus"===d?13:"aac"===d?14:"flac"===d?15:16;break;case 12:return c=z.Raw,e.a(3,17);case 13:return c=z.Opus,e.a(3,17);case 14:return c=z.Aac,e.a(3,17);case 15:return c=z.Flac,e.a(3,17);case 17:return e.a(2,{type:"success",codec:c,stream:new it(function(){var e=i(x().m(function e(t){var n,i,a,s,c;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.enqueue(o);case 1:n=r.release(),i=n.getReader();case 2:return e.n=3,i.read();case 3:if(a=e.v,s=a.done,c=a.value,!s){e.n=4;break}return e.a(3,6);case 4:return e.n=5,t.enqueue(c);case 5:e.n=2;break;case 6:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}())})}},e)})),an.apply(this,arguments)}function sn(e){switch(e){case"h264":return pe;case"h265":return ve;case"av1":return _e;default:throw new Error("Unknown video codec: ".concat(e))}}function cn(){return cn=i(x().m(function e(t,n){var r,i,o,a,s;return x().w(function(e){for(;;)switch(e.n){case 0:if(r=new ft(n),!t.sendDeviceMeta){e.n=2;break}return e.n=1,Mt(r,64);case 1:i=e.v;case 2:if(!t.sendCodecMeta){e.n=6;break}return e.n=3,Dt(r);case 3:return o=e.v,e.n=4,Dt(r);case 4:return a=e.v,e.n=5,Dt(r);case 5:s=e.v,e.n=7;break;case 6:o=sn(t.videoCodec);case 7:return e.a(2,{stream:r.release(),metadata:{deviceName:i,codec:o,width:a,height:s}})}},e)})),cn.apply(this,arguments)}function un(e,t){return e.sendDeviceMeta||e.sendCodecMeta?function(e,t){return cn.apply(this,arguments)}(e,t):{stream:t,metadata:{codec:sn(e.videoCodec)}}}var ln=function(){return E(E({},rn),{},{video:!0,audioSource:"output"})}(),dn=function(){return E(E({},ln),{},{videoSource:"display",displayId:0,cameraId:void 0,cameraSize:void 0,cameraFacing:void 0,cameraAr:void 0,cameraFps:void 0,cameraHighSpeed:!1,listCameras:!1,listCameraSizes:!1})}();var fn=function(){return[].concat(A(Vt),[re,ie,ae])}(),hn=Me({id:He,data:Ne(He)},{littleEndian:!1}),pn=new WeakMap,vn=function(){function e(){var t,n;return c(this,e),l(t=a(this,e,[function(e){n=e}]),pn,void 0),_(t,"id",2),d(pn,t,n),t}return b(e,it),p(e,[{key:"parse",value:(t=i(x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,hn.deserialize(n);case 1:return r=e.v,e.n=2,u(pn,this).enqueue(r);case 2:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"close",value:function(){u(pn,this).close()}},{key:"error",value:function(e){u(pn,this).error(e)}}]);var t}(),_n=function(){return E(E({},dn),{},{audioDup:!1})}(),mn=function(){var e=fn.slice();return e.splice(14,0,oe),e}(),yn=function(){return[].concat(A(mn),[se,ce])}(),bn=function(){return E(E({},At(_n,"lockVideoOrientation")),{},{captureOrientation:void 0,angle:0,screenOffTimeout:void 0,listApps:!1,newDisplay:void 0,vdSystemDecorations:!0})}(),gn=/^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder=(\S+)(?:\s*\((sw|hw|hybrid)\))?(?:\s*\[vendor\])?(?:\s*\(alias for (\S+)\))?$/;function wn(e){switch(e){case"sw":return"software";case"hw":return"hardware";case"hybrid":return"hybrid";default:throw new Error("Unknown hardware type: ".concat(e))}}var En=function(){return E(E({},bn),{},{vdDestroyContent:!1})}(),xn=Me({type:je,id:He,vendorId:He,productId:He,name:$e(je),data:Ne(He)},{littleEndian:!1});var kn=function(){return E(E({},En),{},{displayImePolicy:void 0})}(),Cn=function(){return p(function e(){c(this,e)},[{key:"serializeScrollMessage",value:function(e){return e=E(E({},e),{},{scrollX:e.scrollX/16,scrollY:e.scrollY/16}),nn.serialize(e)}}])}();var Sn=new WeakMap,On=new WeakMap,Nn=new WeakMap,An=new WeakMap,Tn=function(){return p(function e(t){c(this,e),_(this,"value",void 0),l(this,Sn,void 0),l(this,On,void 0),l(this,Nn,void 0),l(this,An,new de),this.value=E(E({},kn),t),"camera"===this.value.videoSource&&(this.value.control=!1),this.value.audioDup&&(this.value.audioSource="playback"),this.value.control&&(this.value.clipboardAutosync&&(d(Sn,this,u(An,this).add(new xt)),d(On,this,u(An,this).add(new Jt))),d(Nn,this,u(An,this).add(new vn)))},[{key:"controlMessageTypes",get:function(){return yn}},{key:"clipboard",get:function(){return u(Sn,this)}},{key:"uHidOutput",get:function(){return u(Nn,this)}},{key:"deviceMessageParsers",get:function(){return u(An,this)}},{key:"serialize",value:function(){return function(e,t){for(var n=[],r=0,i=Object.entries(e);r<i.length;r++){var o=O(i[r],2),a=o[0],s=he(o[1],void 0);void 0!==s&&s!==he(t[a],void 0)&&n.push("".concat(Ft(a),"=").concat(s))}return n}(this.value,kn)}},{key:"setListDisplays",value:function(){this.value.listDisplays=!0}},{key:"parseDisplay",value:function(e){return function(e){var t=e.match(/^\s+--display-id=(\d+)\s+\(([^)]+)\)$/);if(t){var n={id:Number.parseInt(t[1],10)};return"size unknown"!==t[2]&&(n.resolution=t[2]),n}}(e)}},{key:"setListEncoders",value:function(){this.value.listEncoders=!0}},{key:"parseEncoder",value:function(e){return function(e){var t=e.match(gn);return t?{type:t[1],name:t[3],codec:t[2],hardwareType:t[4]?wn(t[4]):void 0,vendor:!!t[5],aliasFor:t[6]}:void 0}(e)}},{key:"parseVideoStreamMetadata",value:function(e){return un(this.value,e)}},{key:"parseAudioStreamMetadata",value:function(e){return function(e,t){return an.apply(this,arguments)}(e,this.value)}},{key:"createMediaStreamTransformer",value:function(){return function(e){if(!e.sendFrameMeta)return new rt({transform:function(e,t){t.enqueue({type:"data",data:e})}});var t=new bt(It);return{writable:t.writable,readable:t.readable.pipeThrough(new rt({transform:function(e,t){e.pts!==Rt?e.pts&Qt?t.enqueue({type:"data",keyframe:!0,pts:e.pts&~Qt,data:e.data}):t.enqueue({type:"data",keyframe:!1,pts:e.pts,data:e.data}):t.enqueue({type:"configuration",data:e.data})}}))}}(this.value)}},{key:"serializeInjectTouchControlMessage",value:function(e){return function(e){return on.serialize(e)}(e)}},{key:"serializeBackOrScreenOnControlMessage",value:function(e){return function(e){return Ut.serialize(e)}(e)}},{key:"serializeSetClipboardControlMessage",value:function(e){return u(On,this).serializeSetClipboardControlMessage(e)}},{key:"createScrollController",value:function(){return new Cn}},{key:"serializeUHidCreateControlMessage",value:function(e){return function(e){return xn.serialize(e)}(e)}}])}();_(Tn,"Defaults",kn);var In=new WeakMap,Rn=new WeakMap,Mn=new WeakMap,Pn=new WeakMap,Dn=function(){return p(function e(t){c(this,e),l(this,In,void 0),l(this,Rn,void 0),l(this,Mn,0),l(this,Pn,7),d(In,this,t),d(Rn,this,t[0])},[{key:"byteAligned",get:function(){return 7===u(Pn,this)}},{key:"ended",get:function(){return u(Mn,this)>=u(In,this).length}},{key:"f1",value:function(){var e=u(Rn,this)>>u(Pn,this);return d(Pn,this,u(Pn,this)-1),u(Pn,this)<0&&(d(Mn,this,u(Mn,this)+1),d(Pn,this,7),d(Rn,this,u(In,this)[u(Mn,this)])),1&e}},{key:"f",value:function(e){for(var t=0;e>0;e-=1)t<<=1,t|=this.f1();return t}},{key:"skip",value:function(e){if(e<=u(Pn,this)+1)return d(Mn,this,u(Mn,this)+1),d(Pn,this,7),void d(Rn,this,u(In,this)[u(Mn,this)]);e-=u(Pn,this)+1,d(Mn,this,u(Mn,this)+1);var t=e/8|0;t>0&&(d(Mn,this,u(Mn,this)+t),e-=8*t),d(Pn,this,7-e),d(Rn,this,u(In,this)[u(Mn,this)])}},{key:"readBytes",value:function(e){if(!this.byteAligned)throw new Error("Bytes must be byte-aligned");var t=u(In,this).subarray(u(Mn,this),u(Mn,this)+e);return d(Mn,this,u(Mn,this)+e),d(Rn,this,u(In,this)[u(Mn,this)]),t}},{key:"getPosition",value:function(){return[u(Mn,this),u(Pn,this)]}},{key:"setPosition",value:function(e){var t=O(e,2),n=t[0],r=t[1];d(Mn,this,n),d(Pn,this,r),d(Rn,this,u(In,this)[n])}}])}(),Ln=new WeakMap,Wn=new WeakMap,Gn=function(){function e(){var t;c(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return l(t=a(this,e,[].concat(r)),Ln,0),l(t,Wn,0),t}return b(e,Dn),p(e,[{key:"uvlc",value:function(){for(var e=0;!this.f1();)e+=1;return e>=32?Math.pow(2,32)-1:this.f(e)+(1<<e>>>0)-1}},{key:"leb128",value:function(){if(!this.byteAligned)throw new Error("LEB128 must be byte-aligned");var e=0n;d(Ln,this,0);for(var t=0n;t<8n;t+=1n){var n=this.f(8);if(e|=BigInt(127&n)<<7n*t,d(Ln,this,u(Ln,this)+1),!(128&n))break}return e}},{key:"annexBBitstream",value:x().m(function e(){var t;return x().w(function(e){for(;;)switch(e.n){case 0:if(this.ended){e.n=2;break}return t=this.leb128(),e.d(C(this.temporalUnit(t)),1);case 1:e.n=0;break;case 2:return e.a(2)}},e,this)})},{key:"temporalUnit",value:x().m(function e(t){var n;return x().w(function(e){for(;;)switch(e.n){case 0:if(!(t>0)){e.n=2;break}return n=this.leb128(),t-=BigInt(u(Ln,this)),e.d(C(this.frameUnit(n)),1);case 1:t-=n,e.n=0;break;case 2:return e.a(2)}},e,this)})},{key:"frameUnit",value:x().m(function e(t){var n,r;return x().w(function(e){for(;;)switch(e.n){case 0:if(!(t>0)){e.n=2;break}if(n=this.leb128(),t-=BigInt(u(Ln,this)),!(r=this.openBitstreamUnit(n))){e.n=1;break}return e.n=1,r;case 1:t-=n,e.n=0;break;case 2:return e.a(2)}},e,this)})},{key:"openBitstreamUnit",value:function(t){var n,r=this.obuHeader();if(r.obu_has_size_field)n=this.leb128();else{if(void 0===t)throw new Error("obu_has_size_field must be true");n=t-1n-(r.obu_extension_flag?1n:0n)}var i,o=this.getPosition();if(r.obu_type!==e.ObuType.SequenceHeader&&r.obu_type!==e.ObuType.TemporalDelimiter&&0!==u(Wn,this)&&r.obu_extension_header){var a=!!(u(Wn,this)&1<<r.obu_extension_header.temporal_id),s=!!(u(Wn,this)&1<<r.obu_extension_header.spatial_id+8);if(!a||!s)return void this.skip(Number(n))}if(r.obu_type===e.ObuType.SequenceHeader)i=this.sequenceHeaderObu();var c=this.getPosition(),l=8*(c[0]-o[0])+(o[1]-c[1]);return n>0&&this.skip(8*Number(n)-l),{obu_header:r,obu_size:n,sequence_header_obu:i}}},{key:"obuHeader",value:function(){if(!!this.f1())throw new Error("Invalid data");var e,t=this.f(4),n=!!this.f1(),r=!!this.f1();return this.f1(),n&&(e=this.obuExtensionHeader()),{obu_type:t,obu_extension_flag:n,obu_has_size_field:r,obu_extension_header:e}}},{key:"obuExtensionHeader",value:function(){var e=this.f(3),t=this.f(2);return this.skip(3),{temporal_id:e,spatial_id:t}}},{key:"sequenceHeaderObu",value:function(){var t,n,r,i,o=this.f(3),a=!!this.f1(),s=!!this.f1(),c=!1,u=!1,l=!1,f=0,h=[],p=[],v=[],_=[],m=[];if(s)h[0]=0,p[0]=this.f(5),v[0]=0,_[0]=!1,m[0]=!1;else{(c=!!this.f1())&&(t=this.timingInfo(),(u=!!this.f1())&&(n=this.decoderModelInfo(),r=[])),(l=!!this.f1())&&(i=[]),f=this.f(5);for(var y=0;y<=f;y+=1)h[y]=this.f(12),p[y]=this.f(5),p[y]>7?v[y]=this.f1():v[y]=0,u?(_[y]=!!this.f1(),_[y]&&(r[y]=this.operatingParametersInfo(n))):_[y]=!1,l&&(m[y]=!!this.f1(),m[y]&&(i[y]=this.f(4)))}var b=this.chooseOperatingPoint();d(Wn,this,h[b]);var g,w,E=this.f(4),x=this.f(4),k=this.f(E+1),C=this.f(x+1),S=!1;s||(S=!!this.f1())&&(g=this.f(4),w=this.f(3));var O,N=!!this.f1(),A=!!this.f1(),T=!!this.f1(),I=!1,R=!1,M=!1,P=!1,D=!1,L=!1,W=!1,G=!1,B=e.SelectScreenContentTools,U=!1,V=e.SelectIntegerMv;return s||(I=!!this.f1(),R=!!this.f1(),M=!!this.f1(),P=!!this.f1(),(D=!!this.f1())&&(L=!!this.f1(),W=!!this.f1()),(G=!!this.f1())||(B=this.f1()),B>0&&((U=!!this.f1())||(V=this.f1())),D&&(O=this.f(3))),{seq_profile:o,still_picture:a,reduced_still_picture_header:s,timing_info_present_flag:c,timing_info:t,decoder_model_info_present_flag:u,decoder_model_info:n,initial_display_delay_present_flag:l,initial_display_delay_minus_1:i,operating_points_cnt_minus_1:f,operating_point_idc:h,seq_level_idx:p,seq_tier:v,decoder_model_present_for_this_op:_,operating_parameters_info:r,initial_display_delay_present_for_this_op:m,frame_width_bits_minus_1:E,frame_height_bits_minus_1:x,max_frame_width_minus_1:k,max_frame_height_minus_1:C,frame_id_numbers_present_flag:S,delta_frame_id_length_minus_2:g,additional_frame_id_length_minus_1:w,use_128x128_superblock:N,enable_filter_intra:A,enable_intra_edge_filter:T,enable_interintra_compound:I,enable_masked_compound:R,enable_warped_motion:M,enable_dual_filter:P,enable_order_hint:D,enable_jnt_comp:L,enable_ref_frame_mvs:W,seq_choose_screen_content_tools:G,seq_force_screen_content_tools:B,seq_choose_integer_mv:U,seq_force_integer_mv:V,order_hint_bits_minus_1:O,enable_superres:!!this.f1(),enable_cdef:!!this.f1(),enable_restoration:!!this.f1(),color_config:this.colorConfig(o),film_grain_params_present:!!this.f1()}}},{key:"searchSequenceHeaderObu",value:function(){for(;!this.ended;){var e=this.openBitstreamUnit();if(e&&e.sequence_header_obu)return e.sequence_header_obu}}},{key:"timingInfo",value:function(){var e,t=this.f(32),n=this.f(32),r=!!this.f1();return r&&(e=this.uvlc()),{num_units_in_display_tick:t,time_scale:n,equal_picture_interval:r,num_ticks_per_picture_minus_1:e}}},{key:"decoderModelInfo",value:function(){return{buffer_delay_length_minus_1:this.f(5),num_units_in_decoding_tick:this.f(32),buffer_removal_time_length_minus_1:this.f(5),frame_presentation_time_length_minus_1:this.f(5)}}},{key:"operatingParametersInfo",value:function(e){var t=e.buffer_delay_length_minus_1+1;return{decoder_buffer_delay:this.f(t),encoder_buffer_delay:this.f(t),low_delay_mode_flag:!!this.f1()}}},{key:"chooseOperatingPoint",value:function(){return 0}},{key:"colorConfig",value:function(t){var n=!!this.f1(),r=!1,i=8;2===t&&n?i=(r=!!this.f1())?12:10:t<=2&&(i=n?10:8);var o=!1;1===t&&(o=!!this.f1());var a=!!this.f1(),s=e.ColorPrimaries.Unspecified,c=e.TransferCharacteristics.Unspecified,u=e.MatrixCoefficients.Unspecified;a&&(s=this.f(8),c=this.f(8),u=this.f(8));var l,d,f=!1,h=0,p=!1;if(o)f=!!this.f1(),l=!0,d=!0;else{if(s===e.ColorPrimaries.Bt709&&c===e.TransferCharacteristics.Srgb&&u===e.MatrixCoefficients.Identity)f=!0,l=!1,d=!1;else{switch(f=!!this.f1(),t){case 0:l=!0,d=!0;break;case 1:l=!1,d=!1;break;default:12==i?d=!!(l=!!this.f1())&&!!this.f1():(l=!0,d=!1)}l&&d&&(h=this.f(2))}p=!!this.f1()}return{high_bitdepth:n,twelve_bit:r,BitDepth:i,mono_chrome:o,color_description_present_flag:a,color_primaries:s,transfer_characteristics:c,matrix_coefficients:u,color_range:f,subsampling_x:l,subsampling_y:d,chroma_sample_position:h,separate_uv_delta_q:p}}}])}();_(Gn,"ObuType",{SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15}),_(Gn,"ColorPrimaries",{Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22}),_(Gn,"TransferCharacteristics",{Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,Linear:8,Log100:9,Log100Sqrt10:10,Iec61966:11,Bt1361:12,Srgb:13,Bt2020Ten:14,Bt2020Twelve:15,Smpte2084:16,Smpte428:17,Hlg:18}),_(Gn,"MatrixCoefficients",{Identity:0,Bt709:1,Unspecified:2,Fcc:4,Bt470BG:5,Bt601:6,Smpte240:7,YCgCo:8,Bt2020Ncl:9,Bt2020Cl:10,Smpte2085:11,ChromatNcl:12,ChromatCl:13,ICtCp:14}),_(Gn,"SelectScreenContentTools",2),_(Gn,"SelectIntegerMv",2);var Bn=x().m(Un);function Un(e){var t,n,r,i,o,a,s;return x().w(function(c){for(;;)switch(c.n){case 0:t=-1,n=0,r=!1,i=0;case 1:if(!(i<e.length)){c.n=15;break}if(o=e[i],!r){c.n=3;break}if(!(o>3)){c.n=2;break}throw new Error("Invalid data");case 2:return r=!1,c.a(3,14);case 3:if(0!==o){c.n=4;break}return n+=1,c.a(3,14);case 4:if(a=n,n=0,-1!==t){c.n=6;break}if(!(a>=2&&1===o)){c.n=5;break}return t=i+1,c.a(3,14);case 5:throw new Error("Invalid data");case 6:if(!(a<2)){c.n=7;break}return c.a(3,14);case 7:if(1!==o){c.n=9;break}return c.n=8,e.subarray(t,i-a);case 8:return t=i+1,c.a(3,14);case 9:if(!(a>2)){c.n=10;break}throw new Error("Invalid data");case 10:s=o,c.n=2===s?11:3===s?12:13;break;case 11:throw new Error("Invalid data");case 12:return r=!0,c.a(3,14);case 13:return c.a(3,14);case 14:i+=1,c.n=1;break;case 15:if(!r){c.n=16;break}throw new Error("Invalid data");case 16:return c.n=17,e.subarray(t,e.length);case 17:return c.a(2)}},Bn)}var Vn=new WeakMap,jn=new WeakMap,Hn=new WeakMap,zn=new WeakMap,Fn=new WeakMap,qn=new WeakMap,Kn=new WeakMap,Xn=new WeakSet,Yn=function(){return p(function e(t){c(this,e),f(this,Xn),l(this,Vn,void 0),l(this,jn,void 0),l(this,Hn,void 0),l(this,zn,0),l(this,Fn,0),l(this,qn,7),l(this,Kn,0),d(Vn,this,t);for(var r=t.length-1;r>=0;r-=1)if(0!==u(Vn,this)[r])for(var i=t[r],o=0;o<8;o+=1)if(1==(i>>o&1))return d(jn,this,r),d(Hn,this,o),void n(Xn,this,Jn).call(this);throw new Error("Stop bit not found")},[{key:"byteLength",get:function(){return u(jn,this)}},{key:"stopBitIndex",get:function(){return u(Hn,this)}},{key:"bytePosition",get:function(){return u(Fn,this)}},{key:"bitPosition",get:function(){return u(qn,this)}},{key:"ended",get:function(){return u(Fn,this)>=u(jn,this)&&u(qn,this)<=u(Hn,this)}},{key:"next",value:function(){if(this.ended)throw new Error("Bit index out of bounds");var e=u(Kn,this)>>u(qn,this)&1;return d(qn,this,u(qn,this)-1),u(qn,this)<0&&(d(Fn,this,u(Fn,this)+1),d(qn,this,7),n(Xn,this,Jn).call(this)),e}},{key:"read",value:function(e){if(e>32)throw new Error("Read length too large");for(var t=0,n=0;n<e;n+=1)t=t<<1|this.next();return t}},{key:"skip",value:function(e){if(e<=u(qn,this)+1)return d(qn,this,u(qn,this)-e),void n(Xn,this,Zn).call(this);for(e-=u(qn,this)+1,d(Fn,this,u(Fn,this)+1),d(qn,this,7),n(Xn,this,Jn).call(this),n(Xn,this,Zn).call(this);e>=8;e-=8)d(Fn,this,u(Fn,this)+1),n(Xn,this,Jn).call(this),n(Xn,this,Zn).call(this);d(qn,this,7-e),n(Xn,this,Zn).call(this)}},{key:"decodeExponentialGolombNumber",value:function(){for(var e=0;0===this.next();)e+=1;return 0===e?0:(1<<e|this.read(e))-1}},{key:"peek",value:function(e){var t=n(Xn,this,$n).call(this),r=this.read(e);return n(Xn,this,Qn).call(this,t),r}},{key:"readBytes",value:function(e){for(var t=new Uint8Array(e),n=0;n<e;n+=1)t[n]=this.read(8);return t}},{key:"peekBytes",value:function(e){var t=n(Xn,this,$n).call(this),r=this.readBytes(e);return n(Xn,this,Qn).call(this,t),r}}])}();function Jn(){if(d(Kn,this,u(Vn,this)[u(Fn,this)]),2===u(zn,this)&&3===u(Kn,this))return d(zn,this,0),d(Fn,this,u(Fn,this)+1),void n(Xn,this,Jn).call(this);0===u(Kn,this)?d(zn,this,u(zn,this)+1):d(zn,this,0)}function Zn(){if(u(Fn,this)>=u(jn,this)&&u(qn,this)<u(Hn,this))throw new Error("Bit index out of bounds")}function $n(){return{zeroCount:u(zn,this),bytePosition:u(Fn,this),bitPosition:u(qn,this),byte:u(Kn,this)}}function Qn(e){d(zn,this,e.zeroCount),d(Fn,this,e.bytePosition),d(qn,this,e.bitPosition),d(Kn,this,e.byte)}function er(e){var t=function(e){var t,n,r,i=v(Un(e));try{for(i.s();!(r=i.n()).done;){var o=r.value;switch(31&o[0]){case 7:if(t=o,n)return{sequenceParameterSet:t,pictureParameterSet:n};break;case 8:if(n=o,t)return{sequenceParameterSet:t,pictureParameterSet:n}}}}catch(e){i.e(e)}finally{i.f()}throw new Error("Invalid data")}(e),n=t.sequenceParameterSet,r=t.pictureParameterSet,i=function(e){var t=new Yn(e);if(0!==t.next())throw new Error("Invalid data");var n=t.read(2);if(7!==t.read(5))throw new Error("Invalid data");if(0===n)throw new Error("Invalid data");var r=t.read(8),i=t.peek(8),o=!!t.next(),a=!!t.next(),s=!!t.next(),c=!!t.next(),u=!!t.next(),l=!!t.next();if(0!==t.read(2))throw new Error("Invalid data");var d=t.read(8),f=t.decodeExponentialGolombNumber();if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||139===r||134===r){var h=t.decodeExponentialGolombNumber();if(3===h&&t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber(),t.next(),t.next())for(var p=[],v=0;v<(3!==h?8:12);v+=1)p[v]=!!t.next(),p[v]}t.decodeExponentialGolombNumber();var _=t.decodeExponentialGolombNumber();if(0===_)t.decodeExponentialGolombNumber();else if(1===_){t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber();for(var m=t.decodeExponentialGolombNumber(),y=[],b=0;b<m;b+=1)y[b]=t.decodeExponentialGolombNumber()}t.decodeExponentialGolombNumber(),t.next();var g=t.decodeExponentialGolombNumber(),w=t.decodeExponentialGolombNumber(),E=t.next();E||t.next(),t.next();var x,k,C,S,O=!!t.next();return O?(x=t.decodeExponentialGolombNumber(),k=t.decodeExponentialGolombNumber(),C=t.decodeExponentialGolombNumber(),S=t.decodeExponentialGolombNumber()):(x=0,k=0,C=0,S=0),t.next(),{profile_idc:r,constraint_set:i,constraint_set0_flag:o,constraint_set1_flag:a,constraint_set2_flag:s,constraint_set3_flag:c,constraint_set4_flag:u,constraint_set5_flag:l,level_idc:d,seq_parameter_set_id:f,pic_width_in_mbs_minus1:g,pic_height_in_map_units_minus1:w,frame_mbs_only_flag:E,frame_cropping_flag:O,frame_crop_left_offset:x,frame_crop_right_offset:k,frame_crop_top_offset:C,frame_crop_bottom_offset:S}}(n),o=i.profile_idc,a=i.constraint_set,s=i.level_idc,c=16*(i.pic_width_in_mbs_minus1+1),u=(i.pic_height_in_map_units_minus1+1)*(2-i.frame_mbs_only_flag)*16,l=2*i.frame_crop_left_offset,d=2*i.frame_crop_right_offset,f=2*i.frame_crop_top_offset,h=2*i.frame_crop_bottom_offset;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:a,levelIndex:s,encodedWidth:c,encodedHeight:u,cropLeft:l,cropRight:d,cropTop:f,cropBottom:h,croppedWidth:c-l-d,croppedHeight:u-f-h}}function tr(e){var t=new Yn(e);if(0!==t.next())throw new Error("Invalid NALU header");return{nal_unit_type:t.read(6),nuh_layer_id:t.read(6),nuh_temporal_id_plus1:t.read(3)}}function nr(e){var t,n=new Yn(e),r=n.read(4),i=n.read(3),o=!!n.next(),a=ir(n,!0,i),s=n.decodeExponentialGolombNumber(),c=n.decodeExponentialGolombNumber();3===c&&(t=!!n.next());var u,l,d,f,h=n.decodeExponentialGolombNumber(),p=n.decodeExponentialGolombNumber(),v=!!n.next();v&&(u=n.decodeExponentialGolombNumber(),l=n.decodeExponentialGolombNumber(),d=n.decodeExponentialGolombNumber(),f=n.decodeExponentialGolombNumber());for(var _=n.decodeExponentialGolombNumber(),m=n.decodeExponentialGolombNumber(),y=n.decodeExponentialGolombNumber(),b=[],g=[],w=[],E=!!n.next(),x=E?0:i;x<=i;x+=1)b[x]=n.decodeExponentialGolombNumber(),g[x]=n.decodeExponentialGolombNumber(),w[x]=n.decodeExponentialGolombNumber();var k,C,S=n.decodeExponentialGolombNumber(),O=n.decodeExponentialGolombNumber(),N=n.decodeExponentialGolombNumber(),A=n.decodeExponentialGolombNumber(),T=n.decodeExponentialGolombNumber(),I=n.decodeExponentialGolombNumber(),R=!!n.next();R&&(k=!!n.next())&&(C=function(e){for(var t=[],n=0;n<4;n+=1){t[n]=[];for(var r=0;r<6;r+=3===n?3:1){if(!!e.next()){var i=8,o=Math.min(64,1<<4+(n<<1));if(n>1)i=e.decodeExponentialGolombNumber()+8;t[n][r]=[];for(var a=0;a<o;a+=1){i=(i+e.decodeExponentialGolombNumber()+256)%256,t[n][r][a]=i}}else e.decodeExponentialGolombNumber()}}return t}(n));var M,P,D,L,W,G=!!n.next(),B=!!n.next(),U=!!n.next();U&&(M=n.read(4),P=n.read(4),D=n.decodeExponentialGolombNumber(),L=n.decodeExponentialGolombNumber(),W=!!n.next());for(var V=n.decodeExponentialGolombNumber(),j=[],H=0;H<V;H+=1)j[H]=or(n,H,V,j);var z,F,q,K=!!n.next();if(K){z=n.decodeExponentialGolombNumber(),F=[],q=[];for(var X=0;X<z;X+=1)F[X]=n.read(y+4),q[X]=!!n.next()}var Y,J=!!n.next(),Z=!!n.next(),$=!!n.next();$&&(Y=function(e,t){var n,r,i,o=!!e.next();o&&(n=e.read(8))===ar.Extended&&(r=e.read(16),i=e.read(16));var a,s=!!e.next();s&&(a=!!e.next());var c,u,l,d,f,h,p=!!e.next();p&&(c=e.read(3),u=!!e.next(),(l=!!e.next())&&(d=e.read(8),f=e.read(8),h=e.read(8)));var v,_,m=!!e.next();m&&(v=e.decodeExponentialGolombNumber(),_=e.decodeExponentialGolombNumber());var y,b,g,w,E=!!e.next(),x=!!e.next(),k=!!e.next(),C=!!e.next();C&&(y=e.decodeExponentialGolombNumber(),b=e.decodeExponentialGolombNumber(),g=e.decodeExponentialGolombNumber(),w=e.decodeExponentialGolombNumber());var S,O,N,A,T,I,R=!!e.next();R&&(S=e.read(32),O=e.read(32),(N=!!e.next())&&(A=e.decodeExponentialGolombNumber()),(T=!!e.next())&&(I=sr(e,!0,t)));var M,P,D,L,W,G,B,U,V=!!e.next();V&&(M=!!e.next(),P=!!e.next(),D=!!e.next(),L=e.decodeExponentialGolombNumber(),W=e.decodeExponentialGolombNumber(),G=e.decodeExponentialGolombNumber(),B=e.decodeExponentialGolombNumber(),U=e.decodeExponentialGolombNumber());return{aspect_ratio_info_present_flag:o,aspect_ratio_idc:n,sar_width:r,sar_height:i,overscan_info_present_flag:s,overscan_appropriate_flag:a,video_signal_type_present_flag:p,video_format:c,video_full_range_flag:u,colour_description_present_flag:l,colour_primaries:d,transfer_characteristics:f,matrix_coeffs:h,chroma_loc_info_present_flag:m,chroma_sample_loc_type_top_field:v,chroma_sample_loc_type_bottom_field:_,neutral_chroma_indication_flag:E,field_seq_flag:x,frame_field_info_present_flag:k,default_display_window_flag:C,def_disp_win_left_offset:y,def_disp_win_right_offset:b,def_disp_win_top_offset:g,def_disp_win_bottom_offset:w,vui_timing_info_present_flag:R,vui_num_units_in_tick:S,vui_time_scale:O,vui_poc_proportional_to_timing_flag:N,vui_num_ticks_poc_diff_one_minus1:A,vui_hrd_parameters_present_flag:T,vui_hrd_parameters:I,bitstream_restriction_flag:V,tiles_fixed_structure_flag:M,motion_vectors_over_pic_boundaries_flag:P,restricted_ref_pic_lists_flag:D,min_spatial_segmentation_idc:L,max_bytes_per_pic_denom:W,max_bits_per_min_cu_denom:G,log2_max_mv_length_horizontal:B,log2_max_mv_length_vertical:U}}(n,i));var Q,ee,te,ne,re,ie,oe,ae,se=!!n.next();if(se&&(Q=!!n.next(),ee=!!n.next(),te=!!n.next(),ne=!!n.next(),re=n.read(4)),Q)throw new Error("Not implemented");if(ee&&(ie=function(e){var t=!!e.next();return{inter_view_mv_vert_constraint_flag:t}}(n)),te&&(oe=function(e){var t=[],n=[];t[0]=!!e.next(),n[0]=!!e.next();var r=e.decodeExponentialGolombNumber(),i=!!e.next(),o=!!e.next(),a=!!e.next(),s=!!e.next();t[1]=!!e.next(),n[1]=!!e.next();var c=!!e.next(),u=e.decodeExponentialGolombNumber(),l=!!e.next(),d=!!e.next(),f=!!e.next(),h=!!e.next(),p=!!e.next();return{iv_di_mc_enabled_flag:t,iv_mv_scal_enabled_flag:n,log2_ivmc_sub_pb_size_minus3:r,iv_res_pred_enabled_flag:i,depth_ref_enabled_flag:o,vsp_mc_enabled_flag:a,dbbp_enabled_flag:s,tex_mc_enabled_flag:c,log2_texmc_sub_pb_size_minus3:u,intra_contour_enabled_flag:l,intra_dc_only_wedge_enabled_flag:d,cqt_cu_part_pred_enabled_flag:f,inter_dc_only_enabled_flag:h,skip_intra_enabled_flag:p}}(n)),ne)throw new Error("Not implemented");if(re){ae=[];for(var ce=0;!n.ended;)ae[ce]=!!n.next(),ce+=1}return{sps_video_parameter_set_id:r,sps_max_sub_layers_minus1:i,sps_temporal_id_nesting_flag:o,profileTierLevel:a,sps_seq_parameter_set_id:s,chroma_format_idc:c,separate_colour_plane_flag:t,pic_width_in_luma_samples:h,pic_height_in_luma_samples:p,conformance_window_flag:v,conf_win_left_offset:u,conf_win_right_offset:l,conf_win_top_offset:d,conf_win_bottom_offset:f,bit_depth_luma_minus8:_,bit_depth_chroma_minus8:m,log2_max_pic_order_cnt_lsb_minus4:y,sps_sub_layer_ordering_info_present_flag:E,sps_max_dec_pic_buffering_minus1:b,sps_max_num_reorder_pics:g,sps_max_latency_increase_plus1:w,log2_min_luma_coding_block_size_minus3:S,log2_diff_max_min_luma_coding_block_size:O,log2_min_luma_transform_block_size_minus2:N,log2_diff_max_min_luma_transform_block_size:A,max_transform_hierarchy_depth_inter:T,max_transform_hierarchy_depth_intra:I,scaling_list_enabled_flag:R,sps_scaling_list_data_present_flag:k,scalingListData:C,amp_enabled_flag:G,sample_adaptive_offset_enabled_flag:B,pcm_enabled_flag:U,pcm_sample_bit_depth_luma_minus1:M,pcm_sample_bit_depth_chroma_minus1:P,log2_min_pcm_luma_coding_block_size_minus3:D,log2_diff_max_min_pcm_luma_coding_block_size:L,pcm_loop_filter_disabled_flag:W,num_short_term_ref_pic_sets:V,shortTermRefPicSets:j,long_term_ref_pics_present_flag:K,num_long_term_ref_pics_sps:z,lt_ref_pic_poc_lsb_sps:F,used_by_curr_pic_lt_sps_flag:q,sps_temporal_mvp_enabled_flag:J,strong_intra_smoothing_enabled_flag:Z,vui_parameters_present_flag:$,vuiParameters:Y,sps_extension_present_flag:se,sps_range_extension_flag:Q,sps_multilayer_extension_flag:ee,sps_3d_extension_flag:te,sps_scc_extension_flag:ne,sps_extension_4bits:re,spsMultilayerExtension:ie,sps3dExtension:oe,sps_extension_data_flag:ae}}function rr(e){for(var t=e.read(2),n=!!e.next(),r=e.read(5),i=e.peekBytes(4),o=[],a=0;a<32;a+=1)o[a]=!!e.next();var s,c,u,l,d,f,h,p,v,_,m,y=e.peekBytes(6),b=!!e.next(),g=!!e.next(),w=!!e.next(),E=!!e.next();return 4===r||o[4]||5===r||o[5]||6===r||o[6]||7===r||o[7]||8===r||o[8]||9===r||o[9]||10===r||o[10]||11===r||o[11]?(s=!!e.next(),c=!!e.next(),u=!!e.next(),l=!!e.next(),d=!!e.next(),f=!!e.next(),h=!!e.next(),p=!!e.next(),v=!!e.next(),5===r||o[5]||9===r||o[9]||10===r||o[10]||11===r||o[11]?(_=!!e.next(),e.skip(33)):e.skip(34)):2===r||o[2]?(e.skip(7),p=!!e.next(),e.skip(35)):e.skip(43),1===r||o[1]||2===r||o[2]||3===r||o[3]||4===r||o[4]||5===r||o[5]||9===r||o[9]||11===r||o[11]?m=!!e.next():e.skip(1),{profile_space:t,tier_flag:n,profile_idc:r,profileCompatibilitySet:i,profile_compatibility_flag:o,constraintSet:y,progressive_source_flag:b,interlaced_source_flag:g,non_packed_constraint_flag:w,frame_only_constraint_flag:E,max_12bit_constraint_flag:s,max_10bit_constraint_flag:c,max_8bit_constraint_flag:u,max_422chroma_constraint_flag:l,max_420chroma_constraint_flag:d,max_monochrome_constraint_flag:f,intra_constraint_flag:h,one_picture_only_constraint_flag:p,lower_bit_rate_constraint_flag:v,max_14bit_constraint_flag:_,inbld_flag:m}}function ir(e,t,n){var r;r=rr(e);for(var i=e.read(8),o=[],a=[],s=0;s<n;s+=1)o[s]=!!e.next(),a[s]=!!e.next();if(n>0)for(var c=n;c<8;c+=1)e.read(2);for(var u=[],l=[],d=0;d<n;d+=1)o[d]&&(u[d]=rr(e)),a[d]&&(l[d]=e.read(8));return{generalProfileTier:r,general_level_idc:i,sub_layer_profile_present_flag:o,sub_layer_level_present_flag:a,subLayerProfileTier:u,sub_layer_level_idc:l}}function or(e,t,n,r){var i=!1;0!==t&&(i=!!e.next());var o=0,a=!1,s=0,c=[],u=[],l=0,d=0,f=[],h=[],p=[],v=[];if(i){t===n&&(o=e.decodeExponentialGolombNumber()),a=!!e.next(),s=e.decodeExponentialGolombNumber();for(var _=r[t-(o+1)],m=_.num_negative_pics+_.num_positive_pics,y=0;y<=m;y+=1)c[y]=!!e.next(),c[y]?u[y]=!0:u[y]=!!e.next();for(var b=(1-2*Number(a))*(s+1),g=[],w=[],E=[],x=[],k=0,C=0;C<_.num_negative_pics;C+=1)k-=_.delta_poc_s0_minus1[C]+1,g[C]=k;k=0;for(var S=0;S<_.num_positive_pics;S+=1)k+=_.delta_poc_s1_minus1[S]+1,w[S]=k;var O=0;if(_.num_positive_pics>0)for(var N=_.num_positive_pics-1;N>=0;N-=1)(k=w[N]+b)<0&&u[_.num_negative_pics+N]&&(E[O]=k,h[O]=c[_.num_negative_pics+N],O+=1);b<0&&u[m]&&(E[O]=b,h[O]=c[m],O+=1);for(var A=0;A<_.num_negative_pics;A+=1)(k=g[A]+b)<0&&u[A]&&(E[O]=k,h[O]=c[A],O+=1);l=O;var T=0;for(O=0;O<l;O+=1){var I=E[O];f[O]=-(I-T-1),T=I}if(O=0,_.num_negative_pics>0)for(var R=_.num_negative_pics-1;R>=0;R-=1)(k=g[R]+b)>0&&u[R]&&(x[O]=k,v[O]=c[R],O+=1);b>0&&u[m]&&(x[O]=b,v[O]=c[m],O+=1);for(var M=0;M<_.num_positive_pics;M+=1)(k=w[M]+b)>0&&u[_.num_negative_pics+M]&&(x[O]=k,v[O]=c[_.num_negative_pics+M],O+=1);for(d=O,T=0,O=0;O<d;O+=1){var P=x[O];p[O]=P-T-1,T=P}}else{l=e.decodeExponentialGolombNumber(),d=e.decodeExponentialGolombNumber();for(var D=0;D<l;D+=1)f[D]=e.decodeExponentialGolombNumber(),h[D]=!!e.next();for(var L=0;L<d;L+=1)p[L]=e.decodeExponentialGolombNumber(),v[L]=!!e.next()}return{stRpsIdx:t,num_short_term_ref_pic_sets:n,inter_ref_pic_set_prediction_flag:i,delta_idx_minus1:o,delta_rps_sign:a,abs_delta_rps_minus1:s,used_by_curr_pic_flag:c,use_delta_flag:u,num_negative_pics:l,num_positive_pics:d,delta_poc_s0_minus1:f,used_by_curr_pic_s0_flag:h,delta_poc_s1_minus1:p,used_by_curr_pic_s1_flag:v}}var ar={Extended:255};function sr(e,t,n){var r,i,o,a,s,c,u,l,d,f,h,p,v;t&&(r=!!e.next(),i=!!e.next(),(r||i)&&((o=!!e.next())&&(a=e.read(8),s=e.read(5),c=!!e.next(),u=e.read(5)),l=e.read(4),d=e.read(4),o&&(f=e.read(4)),h=e.read(5),p=e.read(5),v=e.read(5)));for(var _=[],m=[],y=[],b=[],g=[],w=[],E=[],x=0;x<=n;x+=1)_[x]=!!e.next(),_[x]||(m[x]=!!e.next()),m[x]?y[x]=e.decodeExponentialGolombNumber():b[x]=!!e.next(),b[x]||(g[x]=e.decodeExponentialGolombNumber()),r&&(w[x]=cr(e,x,ur(g[x]))),i&&(E[x]=cr(e,x,ur(g[x])));return{nal_hrd_parameters_present_flag:r,vcl_hrd_parameters_present_flag:i,sub_pic_hrd_params_present_flag:o,tick_divisor_minus2:a,du_cpb_removal_delay_increment_length_minus1:s,sub_pic_cpb_params_in_pic_timing_sei_flag:c,dpb_output_delay_du_length_minus1:u,bit_rate_scale:l,cpb_size_scale:d,cpb_size_du_scale:f,initial_cpb_removal_delay_length_minus1:h,au_cpb_removal_delay_length_minus1:p,dpb_output_delay_length_minus1:v,fixed_pic_rate_general_flag:_,fixed_pic_rate_within_cvs_flag:m,elemental_duration_in_tc_minus1:y,low_delay_hrd_flag:b,cpb_cnt_minus1:g,nalHrdParameters:w,vclHrdParameters:E}}function cr(e,t,n){for(var r=[],i=[],o=[],a=0;a<n;a+=1)r[a]=e.decodeExponentialGolombNumber(),i[a]=e.decodeExponentialGolombNumber(),t>0&&(o[a]=!!e.next());return{bit_rate_value_minus1:r,cpb_size_value_minus1:i,cpb_size_du_value_minus1:[],bit_rate_du_value_minus1:[],cbr_flag:o}}function ur(e){return e+1}function lr(e){var t=function(e){var t,n,r,i,o=0,a=v(Un(e));try{for(a.s();!(i=a.n()).done;){var s=i.value,c=tr(s),u=E(E({},c),{},{data:s,rbsp:s.subarray(2)});switch(c.nal_unit_type){case 32:t=u;break;case 33:n=u;break;case 34:r=u;break;default:continue}if(3===(o+=1))return{videoParameterSet:t,sequenceParameterSet:n,pictureParameterSet:r}}}catch(e){a.e(e)}finally{a.f()}throw new Error("Invalid data")}(e),n=t.videoParameterSet,r=t.sequenceParameterSet,i=t.pictureParameterSet,o=function(e){var t=new Yn(e),n=t.read(4),r=!!t.next(),i=!!t.next(),o=t.read(6),a=t.read(3),s=!!t.next();t.skip(16);for(var c=ir(t,0,a),u=!!t.next(),l=[],d=[],f=[],h=u?0:a;h<=a;h+=1)l[h]=t.decodeExponentialGolombNumber(),d[h]=t.decodeExponentialGolombNumber(),f[h]=t.decodeExponentialGolombNumber();for(var p=t.read(6),v=t.decodeExponentialGolombNumber(),_=[],m=1;m<=v;m+=1){_[m]=[];for(var y=0;y<=p;y+=1)_[m][y]=!!t.next()}var b,g,w,E,x,k,C,S,O=!!t.next();if(O){b=t.read(32),g=t.read(32),(w=!!t.next())&&(E=t.decodeExponentialGolombNumber()),x=t.decodeExponentialGolombNumber(),k=[],C=[!0],S=[];for(var N=0;N<x;N+=1)k[N]=t.decodeExponentialGolombNumber(),N>0&&(C[N]=!!t.next()),S[N]=sr(t,C[N],a)}return{vps_video_parameter_set_id:n,vps_base_layer_internal_flag:r,vps_base_layer_available_flag:i,vps_max_layers_minus1:o,vps_max_sub_layers_minus1:a,vps_temporal_id_nesting_flag:s,profileTierLevel:c,vps_sub_layer_ordering_info_present_flag:u,vps_max_dec_pic_buffering_minus1:l,vps_max_num_reorder_pics:d,vps_max_latency_increase_plus1:f,vps_max_layer_id:p,vps_num_layer_sets_minus1:v,layer_id_included_flag:_,vps_timing_info_present_flag:O,vps_num_units_in_tick:b,vps_time_scale:g,vps_poc_proportional_to_timing_flag:w,vps_num_ticks_poc_diff_one_minus1:E,vps_num_hrd_parameters:x,hrd_layer_set_idx:k,cprms_present_flag:C,hrdParameters:S,vps_extension_flag:!!t.next()}}(n.rbsp).profileTierLevel,a=o.generalProfileTier,s=a.profile_space,c=a.tier_flag,u=a.profile_idc,l=a.profileCompatibilitySet,d=a.constraintSet,f=o.general_level_idc,h=nr(r.rbsp),p=h.chroma_format_idc,_=h.pic_width_in_luma_samples,m=h.pic_height_in_luma_samples,y=h.conf_win_left_offset,b=void 0===y?0:y,g=h.conf_win_right_offset,w=void 0===g?0:g,x=h.conf_win_top_offset,k=void 0===x?0:x,C=h.conf_win_bottom_offset,S=void 0===C?0:C,O=function(e){switch(e){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}(p),N=function(e){switch(e){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}(p);return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:i,generalProfileSpace:s,generalProfileIndex:u,generalProfileCompatibilitySet:l,generalTierFlag:c,generalLevelIndex:f,generalConstraintSet:d,encodedWidth:_,encodedHeight:m,cropLeft:b,cropRight:w,cropTop:k,cropBottom:S,croppedWidth:_-O*(b+w),croppedHeight:m-N*(k+S)}}function dr(e){return e.toString(16).toUpperCase()}function fr(e){return e.toString(16).toUpperCase().padStart(2,"0")}function hr(e){return e.toString(10).padStart(2,"0")}var pr=new WeakMap,vr=new WeakMap,_r=new WeakMap,mr=new WeakSet,yr=function(){return p(function e(t,n,r){c(this,e),f(this,mr),l(this,pr,void 0),l(this,vr,void 0),l(this,_r,void 0),d(pr,this,t),d(vr,this,n),d(_r,this,r)},[{key:"decode",value:function(e){"configuration"!==e.type&&(n(mr,this,br).call(this,e.data),u(pr,this).decode(new EncodedVideoChunk({type:!1===e.keyframe?"delta":"key",timestamp:0,data:e.data})))}}])}();function br(e){var t,n,r=new Gn(e).searchSequenceHeaderObu();if(r){var i,o,a,s,c=r.seq_profile,l=O(r.seq_level_idx,1)[0],d=void 0===l?0:l,f=r.max_frame_width_minus_1,h=r.max_frame_height_minus_1,p=r.color_config,v=p.BitDepth,_=p.mono_chrome,m=p.subsampling_x,y=p.subsampling_y,b=p.chroma_sample_position;if(p.color_description_present_flag){var g=r.color_config;i=g.color_primaries,o=g.transfer_characteristics,a=g.matrix_coefficients,s=g.color_range}else i=Gn.ColorPrimaries.Bt709,o=Gn.TransferCharacteristics.Bt709,a=Gn.MatrixCoefficients.Bt709,s=!1;var w=f+1,E=h+1;u(vr,this).call(this,w,E);var x=["av01",c.toString(16),hr(d)+(r.seq_tier[0]?"H":"M"),hr(v),_?"1":"0",(m?"1":"0")+(y?"1":"0")+b.toString(),hr(i),hr(o),hr(a),s?"1":"0"].join(".");u(pr,this).configure({codec:x,hardwareAcceleration:null!==(t=null===(n=u(_r,this))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0})}}var gr=new WeakMap,wr=new WeakMap,Er=function(){return p(function e(t){c(this,e),l(this,gr,void 0),l(this,wr,void 0),d(wr,this,t)},[{key:"decode",value:function(e){if("configuration"===e.type)return d(gr,this,e.data),void this.configure(e.data);var t;void 0!==u(gr,this)?((t=new Uint8Array(u(gr,this).length+e.data.length)).set(u(gr,this),0),t.set(e.data,u(gr,this).length),d(gr,this,void 0)):t=e.data,u(wr,this).decode(new EncodedVideoChunk({type:!1===e.keyframe?"delta":"key",timestamp:0,data:t}))}}])}(),xr=new WeakMap,kr=new WeakMap,Cr=new WeakMap,Sr=function(){function e(t,n,r){var i;return c(this,e),l(i=a(this,e,[t]),xr,void 0),l(i,kr,void 0),l(i,Cr,void 0),d(xr,i,t),d(kr,i,n),d(Cr,i,r),i}return b(e,Er),p(e,[{key:"configure",value:function(e){var t,n,r=er(e),i=r.profileIndex,o=r.constraintSet,a=r.levelIndex,s=r.croppedWidth,c=r.croppedHeight;u(kr,this).call(this,s,c);var l="avc1."+fr(i)+fr(o)+fr(a);u(xr,this).configure({codec:l,hardwareAcceleration:null!==(t=null===(n=u(Cr,this))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0})}}])}(),Or=new WeakMap,Nr=new WeakMap,Ar=new WeakMap,Tr=function(){function e(t,n,r){var i;return c(this,e),l(i=a(this,e,[t]),Or,void 0),l(i,Nr,void 0),l(i,Ar,void 0),d(Or,i,t),d(Nr,i,n),d(Ar,i,r),i}return b(e,Er),p(e,[{key:"configure",value:function(e){var t,n,r=lr(e),i=r.generalProfileSpace,o=r.generalProfileIndex,a=r.generalProfileCompatibilitySet,s=r.generalTierFlag,c=r.generalLevelIndex,l=r.generalConstraintSet,d=r.croppedWidth,f=r.croppedHeight;u(Nr,this).call(this,d,f);var h=["hev1",["","A","B","C"][i]+o.toString(),dr(We(a,0)),(s?"H":"L")+c.toString()].concat(A(Array.from(l,dr))).join(".");u(Or,this).configure({codec:h,codedWidth:d,codedHeight:f,hardwareAcceleration:null!==(t=null===(n=u(Ar,this))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0})}}])}(),Ir=function(){return p(function e(){var t=this;c(this,e),_(this,"listeners",[]),_(this,"event",function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];var a={listener:e,thisArg:n,args:i};return t.addEventListener(a)}),this.event=this.event.bind(this)},[{key:"addEventListener",value:function(e){var t=this;this.listeners.push(e);var n=function(){var n=t.listeners.indexOf(e);-1!==n&&t.listeners.splice(n,1)};return n.dispose=n,n}},{key:"fire",value:function(e){var t,n=v(this.listeners.slice());try{for(n.s();!(t=n.n()).done;){var r,i=t.value;(r=i.listener).call.apply(r,[i.thisArg,e].concat(A(i.args)))}}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.listeners.length=0}}])}(),Rr=Symbol("undefined"),Mr=new WeakMap,Pr=function(){function e(){var t;c(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return l(t=a(this,e,[].concat(r)),Mr,Rr),t}return b(e,Ir),p(e,[{key:"addEventListener",value:function(t){var n;u(Mr,this)!==Rr&&(n=t.listener).call.apply(n,[t.thisArg,u(Mr,this)].concat(A(t.args)));return N(e,"addEventListener",this,3)([t])}},{key:"fire",value:function(t){d(Mr,this,t),N(e,"fire",this,3)([t])}}])}(),Dr=new WeakMap,Lr=new WeakMap,Wr=new WeakMap,Gr=new WeakMap,Br=new WeakMap,Ur=new WeakMap,Vr=function(){return p(function e(t,n){var r=this;c(this,e),l(this,Dr,void 0),l(this,Lr,new ReadableStream({start:function(e){d(Dr,r,e)},pull:function(e){e.enqueue(u(Gr,r).call(r))}},{highWaterMark:0})),l(this,Wr,u(Lr,this).getReader()),l(this,Gr,void 0),l(this,Br,0),l(this,Ur,void 0),d(Gr,this,t),d(Ur,this,n)},[{key:"borrow",value:(e=i(x().m(function e(){var t;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,u(Wr,this).read();case 1:return t=e.v,e.a(2,t.value)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"return",value:function(e){u(Br,this)<u(Ur,this)&&(u(Dr,this).enqueue(e),d(Br,this,u(Br,this)+1))}}]);var e}(),jr=new WeakMap,Hr=new WeakMap,zr=function(){return p(function e(){c(this,e),l(this,jr,void 0),l(this,Hr,void 0),"undefined"!=typeof OffscreenCanvas?d(jr,this,new OffscreenCanvas(1,1)):(d(jr,this,document.createElement("canvas")),u(jr,this).width=1,u(jr,this).height=1),d(Hr,this,u(jr,this).getContext("bitmaprenderer",{alpha:!1}))},[{key:"capture",value:(e=i(x().m(function e(t){var n,r=this;return x().w(function(e){for(;;)switch(e.n){case 0:return u(jr,this).width=t.displayWidth,u(jr,this).height=t.displayHeight,e.n=1,createImageBitmap(t);case 1:if(n=e.v,u(Hr,this).transferFromImageBitmap(n),!(u(jr,this)instanceof OffscreenCanvas)){e.n=3;break}return e.n=2,u(jr,this).convertToBlob({type:"image/png"});case 2:return e.a(2,e.v);case 3:return e.a(2,new Promise(function(e,t){u(jr,r).toBlob(function(n){n?e(n):t(new Error("Failed to convert canvas to blob"))},"image/png")}));case 4:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}(),Fr=["codec","renderer"],qr=new Vr(function(){return new zr},4),Kr=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,$r=new WeakMap,Qr=new WeakMap,ei=new WeakMap,ti=new WeakMap,ni=new WeakMap,ri=new WeakMap,ii=new WeakMap,oi=new WeakMap,ai=new WeakMap,si=new WeakMap,ci=new WeakMap,ui=new WeakMap,li=new WeakMap,di=new WeakSet,fi=new WeakMap,hi=new WeakMap,pi=function(){return p(function e(t){var r=this,i=t.codec,o=t.renderer,a=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,Fr);switch(c(this,e),f(this,di),l(this,Kr,void 0),l(this,Xr,void 0),l(this,Yr,void 0),l(this,Jr,void 0),l(this,Zr,void 0),l(this,$r,void 0),l(this,Qr,void 0),l(this,ei,0),l(this,ti,0),l(this,ni,0),l(this,ri,new Pr),l(this,ii,0),l(this,oi,0),l(this,ai,void 0),l(this,si,!1),l(this,ci,void 0),l(this,ui,void 0),l(this,li,0),l(this,fi,function(e,t){u(Xr,r).setSize(e,t),d(ii,r,e),d(oi,r,t),u(ri,r).fire({width:e,height:t})}),l(this,hi,function(){u(ei,r)>0&&(d(ti,r,u(ti,r)+1),d(ni,r,u(ni,r)+(u(ei,r)-1)),d(ei,r,0)),d(li,r,requestAnimationFrame(u(hi,r)))}),d(Kr,this,i),d(Xr,this,o),d(Yr,this,a),d(ai,this,new VideoDecoder({output:function(e){var t;if(null===(t=u(ui,r))||void 0===t||t.close(),d(ui,r,e.clone()),u(si,r))return u(ci,r)&&(u(ci,r).close(),d(ni,r,u(ni,r)+1)),void d(ci,r,e);n(di,r,_i).call(r,e)},error:function(e){n(di,r,vi).call(r,e)}})),u(Kr,this)){case pe:d(Jr,this,new Sr(u(ai,this),u(fi,this),u(Yr,this)));break;case ve:d(Jr,this,new Tr(u(ai,this),u(fi,this),u(Yr,this)));break;case _e:d(Jr,this,new yr(u(ai,this),u(fi,this),u(Yr,this)));break;default:throw new Error("Unsupported codec: ".concat(u(Kr,this)))}d(Zr,this,new nt({start:function(e){u($r,r)?e.error(u($r,r)):d(Qr,r,e)},write:function(e){u(Jr,r).decode(e)}})),u(hi,this).call(this)},[{key:"codec",get:function(){return u(Kr,this)}},{key:"renderer",get:function(){return u(Xr,this)}},{key:"writable",get:function(){return u(Zr,this)}},{key:"framesRendered",get:function(){return u(ti,this)}},{key:"framesSkipped",get:function(){return u(ni,this)}},{key:"sizeChanged",get:function(){return u(ri,this).event}},{key:"width",get:function(){return u(ii,this)}},{key:"height",get:function(){return u(oi,this)}},{key:"snapshot",value:(e=i(x().m(function e(){var t,n,r;return x().w(function(e){for(;;)switch(e.n){case 0:if(t=u(ui,this)){e.n=1;break}return e.a(2,void 0);case 1:return e.n=2,qr.borrow();case 2:return n=e.v,e.n=3,n.capture(t);case 3:return r=e.v,qr.return(n),e.a(2,r)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"dispose",value:function(){var e,t;cancelAnimationFrame(u(li,this)),"closed"!==u(ai,this).state&&u(ai,this).close(),null===(e=u(ci,this))||void 0===e||e.close(),null===(t=u(ui,this))||void 0===t||t.close()}}],[{key:"isSupported",get:function(){return void 0!==globalThis.VideoDecoder}}]);var e}();function vi(e){if(u(Qr,this))try{u(Qr,this).error(e)}catch(e){}else d($r,this,e)}function _i(e){return mi.apply(this,arguments)}function mi(){return(mi=i(x().m(function e(t){var r,i;return x().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,d(si,this,!0),u(fi,this).call(this,t.displayWidth,t.displayHeight),e.n=1,u(Xr,this).draw(t);case 1:if(d(ei,this,u(ei,this)+1),t.close(),!u(ci,this)){e.n=2;break}return r=u(ci,this),d(ci,this,void 0),e.n=2,n(di,this,_i).call(this,r);case 2:d(si,this,!1),e.n=4;break;case 3:e.p=3,i=e.v,n(di,this,vi).call(this,i);case 4:return e.a(2)}},e,this,[[0,3]])}))).apply(this,arguments)}_(pi,"capabilities",{h264:{},h265:{},av1:{}});var yi=function(){function e(e,t){this.program=null,this.texture=null,this.vertexBuffer=null,this.canvas=e;var n={alpha:!1,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,powerPreference:null!=t?t:"low-power",failIfMajorPerformanceCaveat:!0},r=e.getContext("webgl2",n)||e.getContext("webgl",n);if(!r)throw new Error("WebGL not supported");this.gl=r,this.initGL()}return Object.defineProperty(e,"isSupported",{get:function(){try{var e=new OffscreenCanvas(1,1);return!(!e.getContext("webgl2")&&!e.getContext("webgl"))}catch(e){return!1}},enumerable:!1,configurable:!0}),e.prototype.initGL=function(){var e=this.gl,t=this.createShader(e.VERTEX_SHADER,"\n attribute vec2 a_pos;\n varying highp vec2 v_texCoord;\n void main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n // Map [-1, 1] to [0, 1] and flip Y for texture\n v_texCoord = vec2((a_pos.x + 1.0) * 0.5, (1.0 - a_pos.y) * 0.5);\n }\n "),n=this.createShader(e.FRAGMENT_SHADER,"\n varying highp vec2 v_texCoord;\n uniform sampler2D u_sampler;\n void main() {\n gl_FragColor = texture2D(u_sampler, v_texCoord);\n }\n ");this.program=this.createProgram(t,n),e.useProgram(this.program);var r=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.vertexBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW);var i=e.getAttribLocation(this.program,"a_pos");e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.clearColor(1,1,1,1),e.clear(e.COLOR_BUFFER_BIT)},e.prototype.setSize=function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)},e.prototype.draw=function(e){var t=this.gl;t&&this.program&&(t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.drawArrays(t.TRIANGLE_STRIP,0,4))},e.prototype.createShader=function(e,t){var n=this.gl,r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS)){var i=n.getShaderInfoLog(r);throw n.deleteShader(r),new Error("Shader compile error: "+i)}return r},e.prototype.createProgram=function(e,t){var n=this.gl,r=n.createProgram();if(n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),!n.getProgramParameter(r,n.LINK_STATUS)){var i=n.getProgramInfoLog(r);throw n.deleteProgram(r),new Error("Program link error: "+i)}return n.detachShader(r,e),n.detachShader(r,t),n.deleteShader(e),n.deleteShader(t),r},e.prototype.dispose=function(){var e,t=this.gl;this.texture&&t.deleteTexture(this.texture),this.vertexBuffer&&t.deleteBuffer(this.vertexBuffer),this.program&&t.deleteProgram(this.program),null===(e=t.getExtension("WEBGL_lose_context"))||void 0===e||e.loseContext()},e}(),bi=function(){function e(e){if(this.canvas=e,this.ctx=null,this.ctx=e.getContext("2d",{alpha:!1,desynchronized:!0}),!this.ctx)throw new Error("Canvas 2D not supported")}return e.prototype.setSize=function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)},e.prototype.draw=function(e){this.ctx&&this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height)},e.prototype.dispose=function(){this.ctx=null,this.canvas.width=0,this.canvas.height=0},e}(),gi=function(){function e(){this.listeners=new Map}return e.prototype.on=function(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)},e.prototype.once=function(e,t){var n=this,r=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];t.apply(void 0,H([],j(i),!1)),n.off(e,r)};this.on(e,r)},e.prototype.off=function(e,t){var n;null===(n=this.listeners.get(e))||void 0===n||n.delete(t)},e.prototype.emit=function(e){for(var t,n,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=this.listeners.get(e);if(o)try{for(var a=V(o),s=a.next();!s.done;s=a.next()){var c=s.value;try{c.apply(void 0,H([],j(r),!1))}catch(t){console.error("EventEmitter '".concat(e,"' listener error"),t)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},e.prototype.clear=function(e){e?this.listeners.delete(e):this.listeners.clear()},e}(),wi=function(e){function t(t){var n,r=e.call(this)||this;return r.sockets={video:null,audio:null,touch:null},r.subscribers={video:new Set,audio:new Set,touch:new Set},r.deviceId=t.deviceId,r.ip=t.ip,r.ports=null!==(n=t.ports)&&void 0!==n?n:{},r}return L(t,e),t.prototype.getUrl=function(e){var t=this.ports[e];return"ws://".concat(this.ip,":").concat(t)},t.prototype.getChannelStatus=function(e){var t=this.sockets[e];if(!t)return"disconnected";switch(t.readyState){case WebSocket.CONNECTING:return"connecting";case WebSocket.OPEN:return"connected";case WebSocket.CLOSING:case WebSocket.CLOSED:default:return"disconnected"}},t.prototype.getAllChannelsStatus=function(){return{video:this.getChannelStatus("video"),audio:this.getChannelStatus("audio"),touch:this.getChannelStatus("touch")}},t.prototype.emitChannelStatus=function(e,t){var n=this.getAllChannelsStatus();this.emit(t,e,n)},t.prototype.ensureChannel=function(e){var t=this;if(this.sockets[e]){var n=this.sockets[e].readyState;if(n===WebSocket.OPEN||n===WebSocket.CONNECTING)return;this.sockets[e]=null}var r=new WebSocket(this.getUrl(e));r.binaryType="arraybuffer",r.onopen=function(){console.log("[".concat(t.deviceId,":").concat(e,"] connected")),t.emitChannelStatus(e,"open")},r.onmessage=function(n){var r,i;try{try{for(var o=V(t.subscribers[e]),a=o.next();!a.done;a=o.next()){(0,a.value)(n.data)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}catch(n){console.error("[".concat(t.deviceId,":").concat(e,"] message error"),n)}},r.onerror=function(n){console.error("[".concat(t.deviceId,":").concat(e,"] error"),n),t.emit("error",e,n)},r.onclose=function(n){console.warn("[".concat(t.deviceId,":").concat(e,"] closed"),n),t.sockets[e]=null,t.emit("close",e,n)},this.sockets[e]=r},t.prototype.subscribe=function(e,t){this.subscribers[e].add(t),this.sockets[e]||this.ensureChannel(e)},t.prototype.unsubscribe=function(e,t){var n;t?this.subscribers[e].delete(t):this.subscribers[e].clear(),0===this.subscribers[e].size&&(console.log("[".concat(this.deviceId,":").concat(e,"] no subscribers, closing")),null===(n=this.sockets[e])||void 0===n||n.close(),this.sockets[e]=null)},t.prototype.send=function(e,t){var n=this.sockets[e];if(n&&n.readyState===WebSocket.OPEN)try{t instanceof ArrayBuffer||t instanceof Uint8Array?n.send(t):n.send(JSON.stringify(t))}catch(t){console.error("[".concat(e,"] send error"),t)}},t.prototype.sendTouch=function(e){this.send("touch",e)},t.prototype.destroy=function(){var e=this;["video","audio","touch"].forEach(function(t){console.log("[".concat(e.deviceId,":").concat(t,"] destroying"));var n=e.sockets[t];n&&(n.onopen=null,n.onmessage=null,n.onerror=null,n.onclose=null,n.close(),e.sockets[t]=null),e.subscribers[t].clear()}),this.clear()},t}(gi),Ei="focus",xi="blur",ki="input",Ci="delete",Si="enter",Oi="arrow-up",Ni="arrow-down",Ai="arrow-left",Ti="arrow-right",Ii=function(){function e(e){this.emitter=new gi,this.isComposing=!1,this.el=document.createElement("textarea"),this.el.style.cssText="\n position:absolute;\n top:0;\n left:0;\n pointer-events:none;\n opacity:0.01;\n width:100%;\n max-width:95%;\n height: 40px;\n resize: none;\n overflow: hidden;\n ",this.el.autocomplete="off",e.appendChild(this.el),this.bindEvents()}return e.prototype.on=function(e,t){var n;null===(n=this.emitter)||void 0===n||n.on(e,t)},e.prototype.off=function(e,t){var n;null===(n=this.emitter)||void 0===n||n.off(e,t)},e.prototype.bindEvents=function(){var e=this;this.el.addEventListener("focus",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(Ei)}),this.el.addEventListener("blur",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(xi)}),this.el.addEventListener("compositionstart",function(){e.isComposing=!0}),this.el.addEventListener("compositionend",function(t){var n;e.isComposing=!1;var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(ki,r.value),e.el.value=""}),this.el.addEventListener("input",function(t){var n;if(!e.isComposing){var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(ki,r.value),e.el.value=""}}),this.el.addEventListener("keydown",function(t){var n,r,i,o,a,s;switch(t.key){case"Backspace":case"Delete":null===(n=e.emitter)||void 0===n||n.emit(Ci);break;case"Enter":null===(r=e.emitter)||void 0===r||r.emit(Si),e.el.blur();break;case"ArrowUp":null===(i=e.emitter)||void 0===i||i.emit(Oi);break;case"ArrowDown":null===(o=e.emitter)||void 0===o||o.emit(Ni);break;case"ArrowLeft":null===(a=e.emitter)||void 0===a||a.emit(Ai);break;case"ArrowRight":null===(s=e.emitter)||void 0===s||s.emit(Ti)}})},e.prototype.focus=function(){this.el.focus()},e.prototype.blur=function(){this.el.blur()},e.prototype.moveTo=function(e,t,n){this.el.style.left="".concat(e,"px"),this.el.style.top="".concat(t,"px"),n&&(this.el.style.width="".concat(n,"px"))},e.prototype.destroy=function(){var e;null===(e=this.emitter)||void 0===e||e.clear(),this.emitter=null,this.el.remove()},e}(),Ri={AndroidHome:3,AndroidBack:4,AndroidCall:5,AndroidEndCall:6,Digit0:7,Digit1:8,Digit2:9,Digit3:10,Digit4:11,Digit5:12,Digit6:13,Digit7:14,Digit8:15,Digit9:16,Star:17,Pound:18,ArrowUp:19,ArrowDown:20,ArrowLeft:21,ArrowRight:22,AndroidDPadCenter:23,VolumeUp:24,VolumeDown:25,Power:26,AndroidCamera:27,Clear:28,KeyA:29,KeyB:30,KeyC:31,KeyD:32,KeyE:33,KeyF:34,KeyG:35,KeyH:36,KeyI:37,KeyJ:38,KeyK:39,KeyL:40,KeyM:41,KeyN:42,KeyO:43,KeyP:44,KeyQ:45,KeyR:46,KeyS:47,KeyT:48,KeyU:49,KeyV:50,KeyW:51,KeyX:52,KeyY:53,KeyZ:54,Comma:55,Period:56,AltLeft:57,AltRight:58,ShiftLeft:59,ShiftRight:60,Tab:61,Space:62,AndroidSymbol:63,AndroidExplorer:64,AndroidEnvelope:65,Enter:66,Backspace:67,Backquote:68,Minus:69,Equal:70,BracketLeft:71,BracketRight:72,Backslash:73,Semicolon:74,Quote:75,Slash:76,At:77,AndroidNum:78,AndroidHeadsetHook:79,AndroidFocus:80,Plus:81,ContextMenu:82,AndroidNotification:83,AndroidSearch:84,PageUp:92,PageDown:93,Escape:111,Delete:112,ControlLeft:113,ControlRight:114,CapsLock:115,ScrollLock:116,MetaLeft:117,MetaRight:118,AndroidFunction:119,PrintScreen:120,Pause:121,Home:122,End:123,Insert:124,AndroidForward:125,F1:131,F2:132,F3:133,F4:134,F5:135,F6:136,F7:137,F8:138,F9:139,F10:140,F11:141,F12:142,NumLock:143,Numpad0:144,Numpad1:145,Numpad2:146,Numpad3:147,Numpad4:148,Numpad5:149,Numpad6:150,Numpad7:151,Numpad8:152,Numpad9:153,NumpadDivide:154,NumpadMultiply:155,NumpadSubtract:156,NumpadAdd:157,NumpadDecimal:158,NumpadComma:159,NumpadEnter:160,NumpadEquals:161,NumpadLeftParen:162,NumpadRightParen:163,VolumeMute:164,AndroidAppSwitch:187,AndroidCut:277,AndroidCopy:278,AndroidPaste:279};Object.fromEntries(Object.entries(Ri).map(function(e){var t=j(e,2),n=t[0];return[t[1],n]}));var Mi,Pi,Di={Down:0,Up:1},Li={Down:0,Up:1,Move:2,Cancel:3,Outside:4,PointerDown:5,PointerUp:6,HoverMove:7,Scroll:8,HoverEnter:9,HoverExit:10,ButtonPress:11,ButtonRelease:12},Wi={None:0,Primary:1,Secondary:2,Tertiary:4,Back:8,Forward:16,StylusPrimary:32,StylusSecondary:64};function Gi(e,t,n){return e.setUint16(t,n),t+2}function Bi(e,t,n){return e.setUint32(t,n),t+4}function Ui(e,t,n){return e.setInt32(t,n),t+4}function Vi(e,t,n){var r=Math.round(n/16*32767);return e.setInt16(t,r),t+2}function ji(e,t,n){return e.setUint8(t,n),t+1}function Hi(e,t,n){return e.setBigInt64(t,n),t+8}!function(e){e[e.injectKeyCode=0]="injectKeyCode",e[e.injectText=1]="injectText",e[e.injectTouchEvent=2]="injectTouchEvent",e[e.injectScrollEvent=3]="injectScrollEvent",e[e.backOrScreenOn=4]="backOrScreenOn",e[e.expandNotificationPanel=5]="expandNotificationPanel",e[e.expandSettingsPanel=6]="expandSettingsPanel",e[e.collapsePanels=7]="collapsePanels",e[e.getClipboard=8]="getClipboard",e[e.setClipboard=9]="setClipboard",e[e.setDisplayPower=10]="setDisplayPower",e[e.rotateDevice=11]="rotateDevice",e[e.uhidCreate=12]="uhidCreate",e[e.uhidInput=13]="uhidInput",e[e.uhidDestroy=14]="uhidDestroy",e[e.openHardKeyboardSettings=15]="openHardKeyboardSettings",e[e.startApp=16]="startApp",e[e.resetVideo=17]="resetVideo"}(Mi||(Mi={})),function(e){e[e.Clipboard=0]="Clipboard",e[e.AckClipboard=1]="AckClipboard",e[e.UhidOutput=2]="UhidOutput"}(Pi||(Pi={}));var zi=function(){function e(){}return e.injectKeyCode=function(e){var t=e.action,n=e.keyCode,r=e.repeat,i=void 0===r?0:r,o=e.metaState,a=void 0===o?0:o,s=new ArrayBuffer(14),c=new DataView(s),u=0;return u=ji(c,u,Mi.injectKeyCode),u=Ui(c,u=ji(c,u,t),n),u=Ui(c,u,i),u=Ui(c,u,a),new Uint8Array(s)},e.injectText=function(e){var t=e.text,n=this.encoder.encode(t),r=new ArrayBuffer(5+n.length),i=new DataView(r),o=0;return o=Bi(i,o=ji(i,o,Mi.injectText),n.length),new Uint8Array(r,o).set(n),new Uint8Array(r)},e.injectTouch=function(e){var t=e.action,n=e.pointerId,r=e.pointerX,i=e.pointerY,o=e.screenWidth,a=e.screenHeight,s=e.pressure,c=e.actionButton,u=e.buttons,l=new ArrayBuffer(32),d=new DataView(l),f=0;return f=ji(d,f,Mi.injectTouchEvent),f=Ui(d,f=Hi(d,f=ji(d,f,t),BigInt(n)),r),f=Gi(d,f=Ui(d,f,i),o),f=function(e,t,n){var r=65535*Math.max(0,Math.min(1,n));return e.setUint16(t,r),t+2}(d,f=Gi(d,f,a),s),f=Ui(d,f,c),f=Ui(d,f,u),new Uint8Array(l)},e.injectScroll=function(e){var t=e.pointerX,n=e.pointerY,r=e.screenWidth,i=e.screenHeight,o=e.scrollX,a=e.scrollY,s=e.buttons,c=new ArrayBuffer(21),u=new DataView(c),l=0;return l=Ui(u,l=ji(u,l,Mi.injectScrollEvent),t),l=Gi(u,l=Ui(u,l,n),r),l=Vi(u,l=Gi(u,l,i),o),l=Ui(u,l=Vi(u,l,a),s),new Uint8Array(c)},e.setClipboard=function(e){var t=e.sequence,n=e.text,r=e.paste,i=void 0!==r&&r,o=this.encoder.encode(n),a=new ArrayBuffer(14+o.length),s=new DataView(a),c=0;return c=ji(s,c,Mi.setClipboard),c=Bi(s,c=ji(s,c=Hi(s,c,BigInt(t)),i?1:0),o.length),new Uint8Array(a,c).set(o),new Uint8Array(a)},e.encoder=new TextEncoder,e}(),Fi=function(){function e(){}return e.parse=function(e){var t=new DataView(e instanceof Uint8Array?e.buffer:e,e instanceof Uint8Array?e.byteOffset:0,e.byteLength);if(t.byteLength<1)return null;var n=function(e,t){return e.getUint8(t)}(t,0);switch(n){case Pi.Clipboard:return this.parseClipboard(t);case Pi.AckClipboard:return this.parseAckClipboard(t);default:return null}},e.parseClipboard=function(e){if(e.byteLength<5)return null;var t=function(e,t){return e.getUint32(t)}(e,1);if(e.byteLength<5+t)return null;var n=new Uint8Array(e.buffer,e.byteOffset+5,t),r=this.decoder.decode(n);return{type:Pi.Clipboard,content:r}},e.parseAckClipboard=function(e){if(e.byteLength<9)return null;var t=function(e,t){return e.getBigInt64(t)}(e,1);return{type:Pi.AckClipboard,sequence:t}},e.decoder=new TextDecoder,e}();function qi(e,t,n){return Math.max(t,Math.min(n,e))}var Ki,Xi,Yi={SIZE_CHANGED:"size-changed",ERROR:"error",STARTED:"started",STOPPED:"stopped",CLIPBOARD_CHANGED:"clipboard-changed",CHANNEL_CONNECTED:"channel-connected",GROUP_CONTROL_JOINED:"group-control-joined",GROUP_CONTROL_LEAVE:"group-control-leave"};exports.VmosEdgeErrorType=void 0,(Ki=exports.VmosEdgeErrorType||(exports.VmosEdgeErrorType={})).CONNECTION="connection",Ki.VIDEO="video",Ki.AUDIO="audio",Ki.TOUCH="touch",Ki.DECODER="decoder",Ki.RENDERER="renderer",exports.VmosEdgeErrorCode=void 0,(Xi=exports.VmosEdgeErrorCode||(exports.VmosEdgeErrorCode={})).CONNECTION_FAILED="CONNECTION_FAILED",Xi.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",Xi.CONNECTION_LOST="CONNECTION_LOST",Xi.VIDEO_CHANNEL_CONNECTION_FAILED="VIDEO_CHANNEL_CONNECTION_FAILED",Xi.VIDEO_CHANNEL_CLOSED="VIDEO_CHANNEL_CLOSED",Xi.VIDEO_STREAM_ERROR="VIDEO_STREAM_ERROR",Xi.VIDEO_PIPELINE_ERROR="VIDEO_PIPELINE_ERROR",Xi.AUDIO_CHANNEL_CONNECTION_FAILED="AUDIO_CHANNEL_CONNECTION_FAILED",Xi.AUDIO_STREAM_ERROR="AUDIO_STREAM_ERROR",Xi.TOUCH_CHANNEL_CONNECTION_FAILED="TOUCH_CHANNEL_CONNECTION_FAILED",Xi.TOUCH_MESSAGE_PARSE_ERROR="TOUCH_MESSAGE_PARSE_ERROR",Xi.DECODER_INIT_FAILED="DECODER_INIT_FAILED",Xi.DECODER_ERROR="DECODER_ERROR",Xi.RENDERER_INIT_FAILED="RENDERER_INIT_FAILED",Xi.RENDERER_ERROR="RENDERER_ERROR",Xi.UNKNOWN_ERROR="UNKNOWN_ERROR";var Ji=function(e){function t(t){var n,r,i,o,a,s=e.call(this)||this;return s.canvas=null,s.canvasContainer=null,s.device=null,s.isGroupControl=!1,s.deviceTouchGroupMap=new Map,s.config=null,s.renderer=null,s.videoCodecPreference="no-preference",s.renderPreference="default",s.decoder=null,s.textareaManager=null,s.videoWidth=0,s.videoHeight=0,s.isRunning=!1,s.rotation=0,s.manualRotation=!1,s.currentRotationAngle=0,s.resizeObserver=null,s.pointerMoveThrottleMap=new Map,s.touchMoveInterval=1e3/60,s.retryCount=0,s.maxRetries=0,s.retryInterval=1e3,s.stopVideoSubscription=null,s.container=t.container,s.config=t.config,s.device=new wi(s.config),s.maxRetries=null!==(n=t.retryCount)&&void 0!==n?n:0,s.retryInterval=null!==(r=t.retryInterval)&&void 0!==r?r:1e3,s.isGroupControl=null!==(i=t.isGroupControl)&&void 0!==i&&i,s.videoCodecPreference=null!==(o=t.videoCodecPreference)&&void 0!==o?o:"no-preference",s.renderPreference=null!==(a=t.renderPreference)&&void 0!==a?a:"default",t.touchMoveFrequency&&(s.touchMoveInterval=1e3/t.touchMoveFrequency),s.initCanvas(),s.handlePointerEvent=s.handlePointerEvent.bind(s),s.handleWheelEvent=s.handleWheelEvent.bind(s),s.handleContextMenu=s.handleContextMenu.bind(s),s.initTextareaManager(),s.observeContainerResize(),s}return L(t,e),t.prototype.setupChannelStatusListener=function(){var e,t,n=this;null===(e=this.device)||void 0===e||e.on("open",function(e,t){var r,i=null===(r=n.config)||void 0===r?void 0:r.ports[e];n.emit(Yi.CHANNEL_CONNECTED,{channel:e,port:i,allChannelsStatus:t})}),null===(t=this.device)||void 0===t||t.on("error",function(e,t){var r,i=n.extractErrorMessage(t);i||(i="WebSocket ".concat(e," channel connection failed"));var o=n.getErrorCodeForChannel(e,"connection_failed");n.emit(Yi.ERROR,{type:n.channelToErrorType(e),code:o,message:i,port:null===(r=n.config)||void 0===r?void 0:r.ports[e]})})},t.prototype.extractErrorMessage=function(e){if(e instanceof Error)return e.message||e.toString();if(e instanceof Event)return"".concat(e.type||"unknown");if("string"==typeof e)return e;if(e&&"object"===I(e))return e.message||e.reason||String(e);var t=String(e);return"[object Object]"===t||"[object Event]"===t?"":t},t.prototype.channelToErrorType=function(e){switch(e){case"video":return exports.VmosEdgeErrorType.VIDEO;case"audio":return exports.VmosEdgeErrorType.AUDIO;case"touch":return exports.VmosEdgeErrorType.TOUCH;default:return exports.VmosEdgeErrorType.CONNECTION}},t.prototype.getErrorCodeForChannel=function(e,t){if("video"===e)switch(t){case"connection_failed":return exports.VmosEdgeErrorCode.VIDEO_CHANNEL_CONNECTION_FAILED;case"connection_closed":return exports.VmosEdgeErrorCode.VIDEO_CHANNEL_CLOSED;default:return exports.VmosEdgeErrorCode.VIDEO_STREAM_ERROR}else{if("audio"===e)return"connection_failed"===t?exports.VmosEdgeErrorCode.AUDIO_CHANNEL_CONNECTION_FAILED:exports.VmosEdgeErrorCode.AUDIO_STREAM_ERROR;switch(t){case"connection_failed":default:return exports.VmosEdgeErrorCode.TOUCH_CHANNEL_CONNECTION_FAILED;case"parse_error":return exports.VmosEdgeErrorCode.TOUCH_MESSAGE_PARSE_ERROR}}},t.prototype.initCanvas=function(){this.canvasContainer=document.createElement("div"),this.canvasContainer.className="vmos-canvas-container",this.container.appendChild(this.canvasContainer),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),this.canvasContainer.appendChild(this.canvas),this.container.appendChild(this.canvasContainer)},t.prototype.replaceCanvas=function(){var e;this.canvas&&this.canvasContainer&&this.canvasContainer.removeChild(this.canvas),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),null===(e=this.canvasContainer)||void 0===e||e.appendChild(this.canvas)},t.prototype.applyCanvasStyle=function(e){e.style.width="100%",e.style.height="100%",e.style.outline="none",e.style.userSelect="none",e.style.backgroundColor="transparent",e.style.touchAction="none"},t.prototype.initTextareaManager=function(){var e=this;this.textareaManager=new Ii(this.container),this.textareaManager.on(ki,function(t){e.sendText(t)}),this.textareaManager.on(Ci,function(){e.sendKeyCode(Ri.Backspace,Di.Down),e.sendKeyCode(Ri.Backspace,Di.Up)}),this.textareaManager.on(Si,function(){e.sendKeyCode(Ri.Enter,Di.Down),e.sendKeyCode(Ri.Enter,Di.Up)}),this.textareaManager.on(Oi,function(){e.sendKeyCode(Ri.ArrowUp,Di.Down),e.sendKeyCode(Ri.ArrowUp,Di.Up)}),this.textareaManager.on(Ni,function(){e.sendKeyCode(Ri.ArrowDown,Di.Down),e.sendKeyCode(Ri.ArrowDown,Di.Up)}),this.textareaManager.on(Ai,function(){e.sendKeyCode(Ri.ArrowLeft,Di.Down),e.sendKeyCode(Ri.ArrowLeft,Di.Up)}),this.textareaManager.on(Ti,function(){e.sendKeyCode(Ri.ArrowRight,Di.Down),e.sendKeyCode(Ri.ArrowRight,Di.Up)})},t.prototype.observeContainerResize=function(){var e=this;"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(function(){e.updateCanvasSize()}),this.resizeObserver.observe(this.container))},t.prototype.on=function(t,n){return e.prototype.on.call(this,t,n),this},t.prototype.once=function(t,n){return e.prototype.once.call(this,t,n),this},t.prototype.off=function(t,n){return n?e.prototype.off.call(this,t,n):e.prototype.clear.call(this,t),this},t.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];e.prototype.emit.apply(this,H([t],j(n),!1))},t.prototype.start=function(){return B(this,void 0,void 0,function(){return U(this,function(e){switch(e.label){case 0:if(this.isRunning)return[2];this.isRunning=!0,this.retryCount=0,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.connectWithRetry()];case 2:return e.sent(),this.setupChannelStatusListener(),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}})})},t.prototype.connectWithRetry=function(){return B(this,void 0,void 0,function(){var e=this;return U(this,function(t){return[2,new Promise(function(t,n){var r=function(){return B(e,void 0,void 0,function(){var e,i,o,a=this;return U(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.internalStart()];case 1:return s.sent(),t(),[3,3];case 2:return e=s.sent(),console.error("[VmosEdgeClient] Connection failed (Attempt ".concat(this.retryCount+1,"/").concat(this.maxRetries+1,"):"),e),this.retryCount<this.maxRetries&&this.isRunning?(this.retryCount++,i=Math.min(this.retryInterval*Math.pow(2,this.retryCount-1),1e4),console.log("[VmosEdgeClient] Retrying in ".concat(i,"ms...")),setTimeout(function(){a.isRunning?r():n(new Error("Stopped"))},i)):(o=this.extractErrorMessage(e)||"连接失败",this.emit(Yi.ERROR,{type:exports.VmosEdgeErrorType.CONNECTION,code:exports.VmosEdgeErrorCode.CONNECTION_FAILED,message:o}),this.stop(),n(e)),[3,3];case 3:return[2]}})})};r()})]})})},t.prototype.internalStart=function(){return B(this,void 0,void 0,function(){var e,t,n,r,i,o,a,s,c,u,l=this;return U(this,function(d){switch(d.label){case 0:this.canvas&&this.canvasContainer||this.initCanvas(),this.stopVideoSubscription&&(this.stopVideoSubscription(),this.stopVideoSubscription=null),e=new Tn({sendFrameMeta:!0,sendCodecMeta:!0,sendDeviceMeta:!0}),t=null,n=null,d.label=1;case 1:return d.trys.push([1,3,,4]),r=this.createVideoStream(),i=r.videoStream,o=r.stopVideoSubscription,t=o,[4,this.performHandshake(e,i)];case 2:return a=d.sent(),s=a.metadata,c=a.stream,n=this.setupTouch(),this.createRenderer(),this.decoder=new pi({codec:s.codec,renderer:this.renderer,hardwareAcceleration:this.videoCodecPreference}),this.decoder.sizeChanged(function(e){var t=e.width,n=e.height,r=l.videoWidth,i=l.videoHeight;if(t!==r||n!==i){l.videoWidth=t,l.videoHeight=n;var o=t>n;0!==r&&0!==i&&r>i!==o&&(l.manualRotation=!1),l.manualRotation||(l.rotation=o?1:0),l.emitSizeChanged()}}),c.pipeThrough(e.createMediaStreamTransformer()).pipeTo(this.decoder.writable).catch(function(e){var t,n;console.error("[VmosEdgeClient] Video pipeline error:",e),null===(t=l.stopVideoSubscription)||void 0===t||t.call(l);var r=null===(n=l.config)||void 0===n?void 0:n.ports.video,i=l.extractErrorMessage(e)||"视频管道处理错误";l.emit(Yi.ERROR,{type:exports.VmosEdgeErrorType.VIDEO,code:exports.VmosEdgeErrorCode.VIDEO_PIPELINE_ERROR,message:i,port:r})}),this.bindInputEvents(),this.emit(Yi.STARTED),[3,4];case 3:throw u=d.sent(),null==t||t(),null==n||n(),u;case 4:return[2]}})})},t.prototype.createVideoStream=function(){var e,t,n=this,r=new ReadableStream({start:function(e){t=e},cancel:function(){var e;null===(e=n.stopVideoSubscription)||void 0===e||e.call(n)}}),i=function(e){var r,i;if(null!==t.desiredSize)try{var o=e instanceof Uint8Array?e:new Uint8Array(e);t.enqueue(o)}catch(e){null===(i=n.stopVideoSubscription)||void 0===i||i.call(n);var a=n.extractErrorMessage(e)||"视频流数据处理错误";n.emit(Yi.ERROR,{type:exports.VmosEdgeErrorType.VIDEO,code:exports.VmosEdgeErrorCode.VIDEO_STREAM_ERROR,message:a})}else null===(r=n.stopVideoSubscription)||void 0===r||r.call(n)};return null===(e=this.device)||void 0===e||e.subscribe("video",i),this.stopVideoSubscription=function(){var e;null===(e=n.device)||void 0===e||e.unsubscribe("video",i),n.stopVideoSubscription=null;try{t&&null!==t.desiredSize&&t.close()}catch(e){console.error("[VmosEdgeClient] stopVideoSubscription error:",e)}},{videoStream:r,stopVideoSubscription:this.stopVideoSubscription}},t.prototype.setupTouch=function(){var e,t=this,n=function(e){var n;try{var r=Fi.parse(e);(null==r?void 0:r.type)===Pi.Clipboard&&t.emit(Yi.CLIPBOARD_CHANGED,null!==(n=null==r?void 0:r.content)&&void 0!==n?n:"")}catch(e){console.error("[VmosEdgeClient] Touch channel error:",e)}};return null===(e=this.device)||void 0===e||e.subscribe("touch",n),function(){var e;return null===(e=t.device)||void 0===e?void 0:e.unsubscribe("touch",n)}},t.prototype.performHandshake=function(e,t){return B(this,void 0,void 0,function(){var n,r,i=this;return U(this,function(o){switch(o.label){case 0:n=null,r=new Promise(function(e,t){var r,o,a=!1,s=function(e){a||(a=!0,t(e))},c=function(e,t){console.error("[VmosEdgeClient] Handshake error on ".concat(e,":"),t),"video"===e&&s(new Error("Video channel connection failed"))},u=function(e){"video"===e&&s(new Error("Video channel closed unexpectedly during handshake"))};null===(r=i.device)||void 0===r||r.on("error",c),null===(o=i.device)||void 0===o||o.on("close",u),n=function(){var e,t;null===(e=i.device)||void 0===e||e.off("error",c),null===(t=i.device)||void 0===t||t.off("close",u)}}),o.label=1;case 1:return o.trys.push([1,,3,4]),[4,Promise.race([e.parseVideoStreamMetadata(t),r])];case 2:return[2,o.sent()];case 3:return n&&n(),[7];case 4:return[2]}})})},t.prototype.setGroupControlMode=function(e){var t,n;if(this.isGroupControl=e,!e){try{for(var r=V(this.deviceTouchGroupMap.values()),i=r.next();!i.done;i=r.next()){i.value.destroy()}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.deviceTouchGroupMap.clear()}},t.prototype.joinGroupControl=function(e){var t,n,r=this;if(this.isGroupControl){console.log("[VmosEdgeClient] joinGroupControl start",e);var i=function(e){if(!e.deviceId)return"continue";if(o.deviceTouchGroupMap.has(e.deviceId))return"continue";var t=new wi(e);t.subscribe("touch",function(){}),t.on("open",function(){r.emit(Yi.GROUP_CONTROL_JOINED,e)}),t.on("close",function(){t.destroy(),r.deviceTouchGroupMap.delete(e.deviceId),r.emit(Yi.GROUP_CONTROL_LEAVE,e)}),o.deviceTouchGroupMap.set(e.deviceId,t)},o=this;try{for(var a=V(e),s=a.next();!s.done;s=a.next()){i(s.value)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}},t.prototype.leaveGroupControl=function(e){var t,n,r;if(this.isGroupControl)try{for(var i=V(e),o=i.next();!o.done;o=i.next()){var a=o.value;a.deviceId&&(this.deviceTouchGroupMap.has(a.deviceId)&&(null===(r=this.deviceTouchGroupMap.get(a.deviceId))||void 0===r||r.destroy(),this.deviceTouchGroupMap.delete(a.deviceId)))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},t.prototype.stop=function(){var e,t,n,r;if(this.isRunning){if(this.isRunning=!1,null===(n=this.stopVideoSubscription)||void 0===n||n.call(this),this.unbindInputEvents(),this.emit(Yi.STOPPED),this.isGroupControl){try{for(var i=V(this.deviceTouchGroupMap.values()),o=i.next();!o.done;o=i.next()){o.value.destroy()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}this.deviceTouchGroupMap.clear()}if(this.clear(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.canvasContainer&&this.canvasContainer.parentNode&&(this.canvasContainer.parentNode.removeChild(this.canvasContainer),this.canvasContainer=null,this.canvas=null),null===(r=this.device)||void 0===r||r.destroy(),this.renderer){try{this.renderer.dispose()}catch(e){console.warn("[VmosEdgeClient] Renderer dispose error:",e)}this.renderer=null}if(this.decoder){if("function"==typeof this.decoder.dispose)try{this.decoder.dispose()}catch(e){console.warn("[VmosEdgeClient] Decoder dispose error:",e)}this.decoder=null}}},t.prototype.emitSizeChanged=function(){var e=this.updateCanvasSize(),t={idealWidth:e.idealWidth,idealHeight:e.idealHeight,videoWidth:e.videoWidth,videoHeight:e.videoHeight,rotation:this.rotation};this.emit(Yi.SIZE_CHANGED,t)},t.prototype.mapCoordinates=function(e,t){var n,r;switch(this.currentRotationAngle){case 90:n=t*this.videoWidth,r=(1-e)*this.videoHeight;break;case 270:n=(1-t)*this.videoWidth,r=e*this.videoHeight;break;default:n=e*this.videoWidth,r=t*this.videoHeight}return{x:n,y:r}},t.prototype.updateCanvasSize=function(){if(!this.canvasContainer||!this.videoWidth||!this.videoHeight)return{idealWidth:0,idealHeight:0,videoWidth:0,videoHeight:0};var e,t,n=this.container,r=n.clientWidth,i=n.clientHeight,o=this,a=o.videoWidth,s=o.videoHeight,c=o.rotation,u=r,l=i,d=Math.max(u,l),f=Math.min(u,l);1===c?(e=d,t=f):(e=f,t=d);var h=Math.min(r/e,i/t,1),p=e*h,v=t*h,_=a>s,m=0,y=90===(m=1===c?_?0:270:_?90:0)||270===m,b=y?s:a,g=y?a:s,w=Math.min(p/b,v/g),E=b*w,x=g*w,k=this.canvasContainer.style;k.width="".concat(Math.ceil(E),"px"),k.height="".concat(Math.ceil(x),"px"),k.display="block",k.position="relative",k.transform="none";var C=this.canvas,S=C.style;C.width!==a&&(C.width=a),C.height!==s&&(C.height=s);var O=y?x:E,N=y?E:x;S.width="".concat(Math.ceil(O),"px"),S.height="".concat(Math.ceil(N),"px"),S.position="absolute",S.top="50%",S.left="50%",S.transformOrigin="center center",S.transform="translate(-50%, -50%) rotate(".concat(m,"deg)"),this.currentRotationAngle=m;var A=Math.min(e/b,t/g);return{idealWidth:b*A,idealHeight:g*A,videoWidth:a,videoHeight:s}},t.prototype.createRenderer=function(){try{if(!yi.isSupported)throw new Error("WebGL not supported check");console.log("[VmosEdgeClient] Using WebGLVideoFrameRenderer"),this.renderer=new yi(this.canvas,this.renderPreference)}catch(e){console.warn("[VmosEdgeClient] WebGL initialization failed, falling back to Canvas2DRenderer:",e),this.replaceCanvas(),this.renderer=new bi(this.canvas)}},t.prototype.bindInputEvents=function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.addEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.addEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.addEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.addEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.addEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.addEventListener("wheel",this.handleWheelEvent,{passive:!1}),null===(a=this.canvas)||void 0===a||a.addEventListener("contextmenu",this.handleContextMenu)},t.prototype.unbindInputEvents=function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.removeEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.removeEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.removeEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.removeEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.removeEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.removeEventListener("wheel",this.handleWheelEvent),null===(a=this.canvas)||void 0===a||a.removeEventListener("contextmenu",this.handleContextMenu)},t.prototype.handleContextMenu=function(e){e.preventDefault(),e.stopPropagation()},t.prototype.handlePointerEvent=function(e){var n;if(this.videoWidth&&this.videoHeight){e.preventDefault(),e.stopPropagation();var r,i=this.canvas,o=e.type,a=e.clientX,s=e.clientY,c=e.button,u=e.buttons,l=e.pointerId;if("pointermove"===o){var d=Date.now();if(d-(this.pointerMoveThrottleMap.get(l)||0)<this.touchMoveInterval)return;this.pointerMoveThrottleMap.set(l,d)}if("pointerdown"===o){if(2===c)return void this.back();if(1===c)return void this.home()}else if("pointerup"===o){if(2===c||1===c)return}else if("pointermove"===o&&(2&u||4&u))return;switch(o){case"pointerdown":r=Li.Down,i.setPointerCapture(l),null===(n=this.textareaManager)||void 0===n||n.focus();break;case"pointermove":r=0===u?Li.HoverMove:Li.Move;break;case"pointerup":case"pointercancel":case"pointerleave":r=Li.Up,i.releasePointerCapture(l),this.pointerMoveThrottleMap.delete(l);break;default:return}var f=i.getBoundingClientRect(),h=qi((a-f.x)/f.width,0,1),p=qi((s-f.y)/f.height,0,1),v=this.mapCoordinates(h,p),_=v.x,m=v.y,y=zi.injectTouch({action:r,pointerId:BigInt(l),pointerX:_,pointerY:m,screenWidth:this.videoWidth,screenHeight:this.videoHeight,pressure:0===u?0:1,actionButton:t.PointerEventButtonToAndroidButton[c]||Wi.Primary,buttons:u});this.sendTouch(y)}},t.prototype.sendTouch=function(e){var t,n,r;if(null===(r=this.device)||void 0===r||r.sendTouch(e),this.isGroupControl)try{for(var i=V(this.deviceTouchGroupMap.values()),o=i.next();!o.done;o=i.next()){o.value.sendTouch(e)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},t.prototype.handleWheelEvent=function(e){if(this.videoWidth&&this.videoHeight&&this.device){e.preventDefault(),e.stopPropagation();var t=this.canvas.getBoundingClientRect(),n=qi((e.clientX-t.x)/t.width,0,1),r=qi((e.clientY-t.y)/t.height,0,1),i=this.mapCoordinates(n,r),o=i.x,a=i.y,s=zi.injectScroll({pointerX:o,pointerY:a,screenWidth:this.videoWidth,screenHeight:this.videoHeight,scrollX:-e.deltaX,scrollY:-e.deltaY,buttons:0});this.sendTouch(s)}},t.prototype.sendText=function(e){this.device&&this.sendTouch(zi.injectText({text:e}))},t.prototype.sendKeyCode=function(e,t,n){void 0===n&&(n=0),this.device&&this.sendTouch(zi.injectKeyCode({keyCode:e,action:t,repeat:0,metaState:n}))},t.prototype.clickKey=function(e,t){void 0===t&&(t=0),this.sendKeyCode(e,Di.Down,t),this.sendKeyCode(e,Di.Up,t)},t.prototype.volumeUp=function(){this.clickKey(Ri.VolumeUp)},t.prototype.volumeDown=function(){this.clickKey(Ri.VolumeDown)},t.prototype.home=function(){this.clickKey(Ri.AndroidHome)},t.prototype.back=function(){this.clickKey(Ri.AndroidBack)},t.prototype.menu=function(){this.clickKey(Ri.AndroidAppSwitch)},t.prototype.setRotation=function(e){this.rotation!==e&&(this.manualRotation=!0,this.rotation=e,this.emitSizeChanged())},t.prototype.getRotation=function(){return this.rotation},t.prototype.getRunningState=function(){return this.isRunning},t.prototype.getVideoSize=function(){return{width:this.videoWidth,height:this.videoHeight}},t.prototype.getConfig=function(){return this.config?G({},this.config):null},t.prototype.getScale=function(){return this.canvas&&this.videoWidth?this.canvas.getBoundingClientRect().width/this.videoWidth:1},t.PointerEventButtonToAndroidButton=[Wi.Primary,Wi.Tertiary,Wi.Secondary,Wi.Back,Wi.Forward],t}(gi);exports.AndroidKeyCode=Ri,exports.AndroidKeyEventAction=Di,exports.AndroidMetaState={None:0,AltOn:2,AltLeftOn:16,AltRightOn:32,ShiftOn:1,ShiftLeftOn:64,ShiftRightOn:128,SymOn:4,FunctionOn:8,CtrlOn:4096,CtrlLeftOn:8192,CtrlRightOn:16384,MetaOn:65536,MetaLeftOn:131072,MetaRightOn:262144,CapsLockOn:1048576,NumLockOn:2097152,ScrollLockOn:4194304},exports.AndroidMotionEventAction=Li,exports.AndroidMotionEventButton=Wi,exports.VmosEdgeClient=Ji,exports.VmosEdgeClientEvents=Yi;
3
+ var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return x(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function d(n,r){for(s=n,u=r,t=0;!f&&c&&!i&&t<l.length;t++){var i,o=l[t],d=h.p,v=o[2];n>3?(i=v===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=d&&((i=n<2&&d<o[1])?(s=0,h.v=r,h.n=o[1]):d<v&&(i=n<3||o[0]>r||r>v)&&(o[4]=n,o[5]=r,h.n=v,s=0))}if(i||n>1)return a;throw f=!0,r}return function(i,l,v){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,v),s=l,u=v;(t=s<2?e:u)||!f;){o||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(f=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(x(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,x(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,x(f,"constructor",c),x(c,"constructor",u),u.displayName="GeneratorFunction",x(c,i,"GeneratorFunction"),x(f),x(f,i,"Generator"),x(f,r,function(){return this}),x(f,"toString",function(){return"[object Generator]"}),(C=function(){return{w:o,m:h}})()}function x(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}x=function(e,t,n,r){function o(t,n){x(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},x(e,t,n,r)}function S(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function O(e,t){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},O(e,t)}function R(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,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||I(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 A(e,t,n,r){var i=m(w(e.prototype),t,n);return"function"==typeof i?function(e){return i.apply(n,e)}:i}function T(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||I(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(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);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function M(e){return M="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},M(e)}function I(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function N(t){var n,r;function i(n,r){try{var a=t[n](r),s=a.value,u=s instanceof e;Promise.resolve(u?s.v:s).then(function(e){if(u){var r="return"===n?"return":"next";if(!s.k||e.done)return i(r,e);e=t[r](e).value}o(a.done?"return":"normal",e)},function(e){i("throw",e)})}catch(e){o("throw",e)}}function o(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?i(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(o,a){var s={key:e,arg:t,resolve:o,reject:a,next:null};r?r=r.next=s:(n=r=s,i(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}function D(e){var t="function"==typeof Map?new Map:void 0;return D=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(b())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&O(i,n.prototype),i}(e,arguments,w(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),O(n,e)},D(e)}var P;N.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},N.prototype.next=function(e){return this._invoke("next",e)},N.prototype.throw=function(e){return this._invoke("throw",e)},N.prototype.return=function(e){return this._invoke("return",e)};var W=function(){return v(function e(t,n,r,i){u(this,e),y(this,"optionValue",void 0),y(this,"metadataValue",void 0),y(this,"mimeType",void 0),y(this,"webCodecId",void 0),this.optionValue=t,this.metadataValue=n,this.mimeType=r,this.webCodecId=i},[{key:"toOptionValue",value:function(){return this.optionValue}}])}();y(W,"Opus",new(P=W)("opus",1869641075,"audio/opus","opus")),y(W,"Aac",new P("aac",6381923,"audio/aac","mp4a.66")),y(W,"Flac",new P("flac",1718378851,"audio/flac","flac")),y(W,"Raw",new P("raw",7496055,"audio/raw",""));var L=0,V=1,U=2,B=3,j=4,F=5,G=6,z=7,H=8,K=9,q=10,X=11,Y=12,J=13,Q=14,Z=15,$=16,ee=17,te=new WeakMap,ne=new WeakSet,re=function(){return v(function e(){u(this,e),h(this,ne),l(this,te,[])},[{key:"parsers",get:function(){return c(te,this)}},{key:"add",value:function(e){if(Array.isArray(e.id)){var t,r=p(e.id);try{for(r.s();!(t=r.n()).done;){var i=t.value;n(ne,this,ie).call(this,i,e)}}catch(e){r.e(e)}finally{r.f()}}else n(ne,this,ie).call(this,e.id,e);return e}},{key:"parse",value:(e=i(C().m(function e(t,n){var r;return C().w(function(e){for(;;)switch(e.n){case 0:if(r=c(te,this)[t]){e.n=1;break}throw new Error("Unknown device message id ".concat(t));case 1:return e.a(2,r.parse(t,n))}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=p(c(te,this));try{for(t.s();!(e=t.n()).done;){e.value.close()}}catch(e){t.e(e)}finally{t.f()}}},{key:"error",value:function(e){var t,n=p(c(te,this));try{for(n.s();!(t=n.n()).done;){t.value.error(e)}}catch(e){n.e(e)}finally{n.f()}}}]);var e}();function ie(e,t){if(c(te,this)[e])throw new Error("Duplicate parser for id ".concat(e));c(te,this)[e]=t}function oe(e,t){if(function(e){return"object"===M(e)&&null!==e&&"toOptionValue"in e&&"function"==typeof e.toOptionValue}(e)&&(e=e.toOptionValue()),void 0===e)return t;if("string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e)throw new TypeError("Invalid option value: ".concat(JSON.stringify(e)));return e.toString()}var ae=1748121140,se=1748121141,ue=6387249,ce=new WeakMap,le=new WeakMap,fe=new WeakMap,he=new WeakMap,de=function(){return v(function e(){var t=this;u(this,e),l(this,ce,void 0),l(this,le,void 0),l(this,fe,void 0),l(this,he,"running"),y(this,"resolve",function(e){c(le,t).call(t,e),f(he,t,"resolved")}),y(this,"reject",function(e){c(fe,t).call(t,e),f(he,t,"rejected")}),f(ce,this,new Promise(function(e,n){f(le,t,e),f(fe,t,n)}))},[{key:"promise",get:function(){return c(ce,this)}},{key:"state",get:function(){return c(he,this)}}])}();function ve(e){return"object"===M(e)&&null!==e&&"then"in e}function pe(e,t){for(;;){var n=e.next(t),r=n.done,i=n.value;if(r)return i;if(ve(i))return i.then(function(t){return pe(e,{resolved:t})},function(t){return pe(e,{error:t})});t=i}}function ye(e,t){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return pe(e.call.apply(e,[this,C().m(function e(t){var n;return C().w(function(e){for(;;)switch(e.n){case 0:if(!ve(t)){e.n=3;break}return e.n=1,t;case 1:if(!("resolved"in(n=e.v))){e.n=2;break}return e.a(2,n.resolved);case 2:throw n.error;case 3:return e.a(2,t)}},e)})].concat(n)),void 0)}}function me(e,t){return function(n,r){var i;if("buffer"in r)return null!==(i=r.index)&&void 0!==i||(r.index=0),t(n,r),e;var o=new Uint8Array(e);return t(n,{buffer:o,index:0,littleEndian:r.littleEndian}),o}}var we=function(e,t,n,r,i){var o,a={size:e,type:t,serialize:"default"===t?(o=n,function(e,t){if("buffer"in t){var n=o(e,t);return t.buffer.set(n,t.index),n.length}return o(e,t)}):me(e,n),deserialize:ye(r),omitInit:null==i?void 0:i.omitInit};return null!=i&&i.init&&(a.init=i.init),a},ge=new Uint8Array(0);function be(e,t){var n,r,i,o,a,s,u,c,l;return"number"==typeof e?(0===e?(n=function(){},r=t?C().m(function e(){return C().w(function(e){for(;;)if(0===e.n)return e.a(2,t.convert(ge))},e)}):C().m(function e(){return C().w(function(e){for(;;)if(0===e.n)return e.a(2,ge)},e)})):(n=function(t,n){return function(e,t,n,r){t.length<r?(e.set(t,n),e.fill(0,n+t.length,n+r)):t.length===r?e.set(t,n):e.set(t.subarray(0,r),n)}(n.buffer,t,n.index,e)},t?(r=C().m(function n(r,i){var o,a;return C().w(function(n){for(;;)switch(n.n){case 0:return o=i.readExactly(e),a=t,n.d(S(r(o)),1);case 1:return n.a(2,a.convert.call(a,n.v))}},n)}),i=function(e){return t.back(e)}):r=C().m(function t(n,r){var i;return C().w(function(t){for(;;)if(0===t.n)return i=r.readExactly(e),t.a(2,i)},t)})),we(e,"byob",n,r,{init:i})):"object"!==M(e)&&"function"!=typeof e||!("serialize"in e)?"string"==typeof e?(t?(s=function(n,r,i){var o=i.dependencies;return C().m(function i(){var a,s,u;return C().w(function(i){for(;;)switch(i.n){case 0:return a=o[e],s=0!==a?r.readExactly(a):ge,u=t,i.d(S(n(s)),1);case 1:return i.a(2,u.convert.call(u,i.v))}},i)})()},u=function(n,r){var i=t.back(n);return r[e]=i.length,i}):(s=function(t,n,r){var i=r.dependencies;return C().m(function t(){var r,o;return C().w(function(t){for(;;)if(0===t.n)return r=i[e],o=0!==r?n.readExactly(r):ge,t.a(2,o)},t)})()},u=function(t,n){var r=t;return n[e]=r.length,r}),we(0,"default",function(e){return e},s,{init:u})):(t?(c=function(n,r,i){var o=i.dependencies;return C().m(function i(){var a,s,u,c;return C().w(function(i){for(;;)switch(i.n){case 0:return a=o[e.field],s=e.convert(a),u=0!==s?r.readExactly(s):ge,c=t,i.d(S(n(u)),1);case 1:return i.a(2,c.convert.call(c,i.v))}},i)})()},l=function(n,r){var i=t.back(n);return r[e.field]=e.back(i.length),i}):(c=function(t,n,r){var i=r.dependencies;return C().m(function t(){var r,o,a;return C().w(function(t){for(;;)if(0===t.n)return r=i[e.field],o=e.convert(r),a=0!==o?n.readExactly(o):ge,t.a(2,a)},t)})()},l=function(t,n){var r=t;return n[e.field]=e.back(r.length),r}),we(0,"default",function(e){return e},c,{init:l})):(t?(o=C().m(function n(r,i,o){var a,s,u;return C().w(function(n){for(;;)switch(n.n){case 0:return n.d(S(r(e.deserialize(i,o))),1);case 1:return a=n.v,s=0!==a?i.readExactly(a):ge,u=t,n.d(S(r(s)),2);case 2:return n.a(2,u.convert.call(u,n.v))}},n)}),a=function(e){return t.back(e)}):o=C().m(function t(n,r,i){var o,a;return C().w(function(t){for(;;)switch(t.n){case 0:return t.d(S(n(e.deserialize(r,i))),1);case 1:return o=t.v,a=0!==o?r.readExactly(o):ge,t.a(2,a)}},t)}),we(e.size,"default",function(t,n){var r=n.littleEndian;if("default"===e.type){var i=e.serialize(t.length,{littleEndian:r});if(0===t.length)return i;var o=new Uint8Array(i.length+t.length);return o.set(i,0),o.set(t,i.length),o}var a=new Uint8Array(e.size+t.length);return e.serialize(t.length,{buffer:a,index:0,littleEndian:r}),a.set(t,e.size),a},o,{init:a}))}var Ee=function(){function e(){return u(this,e),a(this,e,["ExactReadable ended"])}return g(e,D(Error)),v(e)}(),ke=function(){function e(t){return u(this,e),a(this,e,[t])}return g(e,D(Error)),v(e)}(),Ce=function(){function e(){return u(this,e),a(this,e,["The underlying readable was ended before the struct was fully deserialized"])}return g(e,ke),v(e)}(),xe=function(){function e(){return u(this,e),a(this,e,["The underlying readable doesn't contain any more struct"])}return g(e,ke),v(e)}();function Se(e,t){for(var n=Object.entries(e),r=0,i=!0,o=0,a=n;o<a.length;o++){var s=R(a[o],2)[1];r+=s.size,i&&"byob"!==s.type&&(i=!1)}var u=t.littleEndian,c=t.extra?Object.getOwnPropertyDescriptors(t.extra):void 0;return{littleEndian:u,fields:e,extra:t.extra,type:i?"byob":"default",size:r,serialize:function(e,t){for(var r=k({},e),i=0,o=n;i<o.length;i++){var a=R(o[i],2),s=a[0],c=a[1];if(s in r&&"init"in c){var l,f=null===(l=c.init)||void 0===l?void 0:l.call(c,r[s],r);r[s]=f}}var h,d=new Array(n.length),v=new Array(n.length),y={littleEndian:u},m=p(n.entries());try{for(m.s();!(h=m.n()).done;){var w=R(h.value,2),g=w[0],b=R(w[1],2),E=b[0],C=b[1];"byob"===C.type?d[g]=C.size:(v[g]=C.serialize(r[E],y),d[g]=v[g].length)}}catch(e){m.e(e)}finally{m.f()}var x,S,O,A=d.reduce(function(e,t){return e+t},0);if(t instanceof Uint8Array){if(t.length<A)throw new Error("Buffer too small");x=!0,S=t,O=0}else if("object"===M(t)&&"buffer"in t){var T;if(x=!0,S=t.buffer,O=null!==(T=t.index)&&void 0!==T?T:0,S.length-O<A)throw new Error("Buffer too small")}else x=!1,S=new Uint8Array(A),O=0;var _,I={buffer:S,index:O,littleEndian:u},N=p(n.entries());try{for(N.s();!(_=N.n()).done;){var D=R(_.value,2),P=D[0],W=R(D[1],2),L=W[0],V=W[1];v[P]?S.set(v[P],I.index):V.serialize(r[L],I),I.index+=d[P]}}catch(e){N.e(e)}finally{N.f()}return x?A:S},deserialize:ye(C().m(function e(r,i){var o,a,s,l,f,h,d,v,p;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:o=i.position,s={dependencies:a={},littleEndian:u},e.p=1,l=0,f=n;case 2:if(!(l<f.length)){e.n=5;break}return h=R(f[l],2),d=h[0],v=h[1],e.d(S(r(v.deserialize(i,s))),3);case 3:a[d]=e.v;case 4:l++,e.n=2;break;case 5:e.n=9;break;case 6:if(e.p=6,(p=e.v)instanceof Ee){e.n=7;break}throw p;case 7:if(i.position!==o){e.n=8;break}throw new xe;case 8:throw new Ce;case 9:if(c&&Object.defineProperties(a,c),!t.postDeserialize){e.n=10;break}return e.a(2,t.postDeserialize.call(a,a));case 10:return e.a(2,a);case 11:return e.a(2)}},e,null,[[1,6]])}))}}function Oe(e,t,n){return n?(e[t]|e[t+1]<<8)<<16>>16:(e[t]<<8|e[t+1])<<16>>16}function Re(e,t,n){return n?e[t]|e[t+1]<<8:e[t+1]|e[t]<<8}function Ae(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}function Te(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function _e(e,t,n){return n?(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0:(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Me(e,t,n){return n?BigInt(e[t])|BigInt(e[t+1])<<8n|BigInt(e[t+2])<<16n|BigInt(e[t+3])<<24n|BigInt(e[t+4])<<32n|BigInt(e[t+5])<<40n|BigInt(e[t+6])<<48n|BigInt(e[t+7])<<56n:BigInt(e[t])<<56n|BigInt(e[t+1])<<48n|BigInt(e[t+2])<<40n|BigInt(e[t+3])<<32n|BigInt(e[t+4])<<24n|BigInt(e[t+5])<<16n|BigInt(e[t+6])<<8n|BigInt(e[t+7])}function Ie(e,t,n){var r=function(){return r};return Object.assign(r,we(e,"byob",t,n)),r}var Ne=Ie(1,function(e,t){t.buffer[t.index]=e},C().m(function e(t,n){var r;return C().w(function(e){for(;;)switch(e.n){case 0:return e.d(S(t(n.readExactly(1))),1);case 1:return r=e.v,e.a(2,r[0])}},e)})),De=Ie(2,function(e,t){Ae(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return C().m(function n(){var i;return C().w(function(n){for(;;)switch(n.n){case 0:return n.d(S(e(t.readExactly(2))),1);case 1:return i=n.v,n.a(2,Re(i,0,r))}},n)})()}),Pe=Ie(4,function(e,t){!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8,e[t+2]=n>>16,e[t+3]=n>>24):(e[t]=n>>24,e[t+1]=n>>16,e[t+2]=n>>8,e[t+3]=n)}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return C().m(function n(){var i;return C().w(function(n){for(;;)switch(n.n){case 0:return n.d(S(e(t.readExactly(4))),1);case 1:return i=n.v,n.a(2,_e(i,0,r))}},n)})()}),We=Ie(8,function(e,t){!function(e,t,n,r){r?(e[t]=Number(0xffn&n),e[t+1]=Number(n>>8n&0xffn),e[t+2]=Number(n>>16n&0xffn),e[t+3]=Number(n>>24n&0xffn),e[t+4]=Number(n>>32n&0xffn),e[t+5]=Number(n>>40n&0xffn),e[t+6]=Number(n>>48n&0xffn),e[t+7]=Number(n>>56n&0xffn)):(e[t]=Number(n>>56n&0xffn),e[t+1]=Number(n>>48n&0xffn),e[t+2]=Number(n>>40n&0xffn),e[t+3]=Number(n>>32n&0xffn),e[t+4]=Number(n>>24n&0xffn),e[t+5]=Number(n>>16n&0xffn),e[t+6]=Number(n>>8n&0xffn),e[t+7]=Number(0xffn&n))}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return C().m(function n(){var i;return C().w(function(n){for(;;)switch(n.n){case 0:return n.d(S(e(t.readExactly(8))),1);case 1:return i=n.v,n.a(2,Me(i,0,r))}},n)})()}),Le=globalThis.TextEncoder,Ve=globalThis.TextDecoder,Ue=new Le,Be=new Ve;function je(e){return Ue.encode(e)}function Fe(e){return Be.decode(e)}var Ge=function(e){var t=be(e,{convert:Fe,back:je});return t.as=function(){return t},t},ze=Se({type:Ne},{littleEndian:!1}),He=globalThis.AbortController,Ke=function(){var e=globalThis.ReadableStream;return e.from||(e.from=function(t){var n=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return new e({pull:function(e){return i(C().m(function t(){var r;return C().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.next();case 1:if(!(r=t.v).done){t.n=2;break}return e.close(),t.a(2);case 2:e.enqueue(r.value);case 3:return t.a(2)}},t)}))()},cancel:function(e){return i(C().m(function t(){var r;return C().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,null===(r=n.return)||void 0===r?void 0:r.call(n,e);case 1:return t.a(2)}},t)}))()}})}),e.prototype[Symbol.asyncIterator]&&e.prototype.values||(e.prototype.values=function(){var e,t=(e=C().m(function e(t){var n,r,i,a;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:n=this.getReader(),e.p=1;case 2:return e.n=3,o(n.read());case 3:if(r=e.v,i=r.done,a=r.value,!i){e.n=4;break}return e.a(2);case 4:return e.n=5,a;case 5:e.n=2;break;case 6:if(e.p=6,null!=t&&t.preventCancel){e.n=7;break}return e.n=7,o(n.cancel());case 7:return n.releaseLock(),e.f(6);case 8:return e.a(2)}},e,this,[[1,,6,8]])}),function(){return new N(e.apply(this,arguments))});return function(e){return t.apply(this,arguments)}}(),e.prototype[Symbol.asyncIterator]=e.prototype.values),e}(),qe=globalThis.WritableStream,Xe=globalThis.TransformStream,Ye=function(){function e(t,n,r){var o;u(this,e);var s=!1,c=new He;return a(this,e,[{start:function(e){var n,a=t({abortSignal:c.signal,enqueue:(n=i(C().m(function t(n){return C().w(function(t){for(;;)switch(t.n){case 0:if(null==r||r({source:"producer",operation:"enqueue",value:n,phase:"start"}),!c.signal.aborted){t.n=1;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),t.a(2);case 1:if(null!==e.desiredSize){t.n=2;break}return e.enqueue(n),t.a(2);case 2:if(!s){t.n=3;break}return s=!1,e.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"}),t.a(2);case 3:if(!(e.desiredSize<=0)){t.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"waiting"}),o=new de,t.n=4,o.promise;case 4:if(!c.signal.aborted){t.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),t.a(2);case 5:e.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"});case 6:return t.a(2)}},t)})),function(e){return n.apply(this,arguments)}),close:function(){null==r||r({source:"producer",operation:"close",explicit:!0,phase:"start"}),c.signal.aborted?null==r||r({source:"producer",operation:"close",explicit:!0,phase:"ignored"}):(e.close(),null==r||r({source:"producer",operation:"close",explicit:!0,phase:"complete"}))},error:function(t){null==r||r({source:"producer",operation:"error",explicit:!0,phase:"start"}),e.error(t),null==r||r({source:"producer",operation:"error",explicit:!0,phase:"complete"})}});a&&"then"in a&&a.then(function(){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"start"});try{e.close(),null==r||r({source:"producer",operation:"close",explicit:!1,phase:"complete"})}catch(e){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"ignored"})}},function(t){null==r||r({source:"producer",operation:"error",explicit:!1,phase:"start"}),e.error(t),null==r||r({source:"producer",operation:"error",explicit:!1,phase:"complete"})})},pull:function(){null==r||r({source:"consumer",operation:"pull",phase:"start"}),o?o.resolve():0===(null==n?void 0:n.highWaterMark)&&(s=!0),null==r||r({source:"consumer",operation:"pull",phase:"complete"})},cancel:function(e){var t;null==r||r({source:"consumer",operation:"cancel",phase:"start"}),c.abort(e),null===(t=o)||void 0===t||t.resolve(),null==r||r({source:"consumer",operation:"cancel",phase:"complete"})}},n])}return g(e,Ke),v(e)}();function Je(e){return Qe.apply(this,arguments)}function Qe(){return(Qe=i(C().m(function e(t){return C().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.cancel();case 1:return e.a(2,!0);case 2:return e.p=2,e.v,e.a(2,!1)}},e,null,[[0,2]])}))).apply(this,arguments)}var Ze=new WeakMap,$e=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakSet,rt=function(){return v(function e(t){u(this,e),h(this,nt),l(this,Ze,void 0),l(this,$e,0),l(this,et,0),l(this,tt,0),y(this,"stream",void 0),y(this,"reader",void 0),y(this,"readExactly",ye(C().m(function e(t,r){var i,o,a,s;return C().w(function(e){for(;;)switch(e.n){case 0:if(o=0,!(a=n(nt,this,it).call(this,r))){e.n=2;break}if(a.length!==r){e.n=1;break}return e.a(2,a);case 1:(i=new Uint8Array(r)).set(a,o),o+=a.length,r-=a.length,e.n=3;break;case 2:i=new Uint8Array(r);case 3:if(!(r>0)){e.n=5;break}return e.d(S(t(n(nt,this,ot).call(this,r))),4);case 4:s=e.v,i.set(s,o),o+=s.length,r-=s.length,e.n=3;break;case 5:return e.a(2,i)}},e,this)}))),this.stream=t,this.reader=t.getReader()},[{key:"position",get:function(){return c(tt,this)}},{key:"iterateExactly",value:function(e){var t=this,r=c(Ze,this)?0:1;return{next:function(){switch(r){case 0:var i=n(nt,t,it).call(t,e);return i.length===e?r=2:(e-=i.length,r=1),{done:!1,value:i};case 1:return r=3,{done:!1,value:n(nt,t,ot).call(t,e).then(function(t){return t.length===e?r=2:(e-=t.length,r=1),t})};case 2:return{done:!0,value:void 0};case 3:throw new Error("Can't call `next` before previous Promise resolves");default:throw new Error("unreachable")}}}}},{key:"release",value:function(){var e=this;return c(et,this)>0?new Ye(function(){var t=i(C().m(function t(n){var r,i,o,a;return C().w(function(t){for(;;)switch(t.n){case 0:return r=c(Ze,e).subarray(c($e,e)),t.n=1,n.enqueue(r);case 1:n.abortSignal.addEventListener("abort",function(){Je(e.reader)});case 2:return t.n=3,e.reader.read();case 3:if(i=t.v,o=i.done,a=i.value,!o){t.n=4;break}return t.a(2);case 4:return t.n=5,n.enqueue(a);case 5:t.n=2;break;case 6:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()):(this.reader.releaseLock(),this.stream)}},{key:"cancel",value:(e=i(C().m(function e(t){return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.cancel(t);case 1:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}();function it(e){if(c(Ze,this)){var t=c(Ze,this).subarray(c($e,this),c($e,this)+e);return c(et,this)>e?(f(tt,this,c(tt,this)+e),f($e,this,c($e,this)+e),f(et,this,c(et,this)-e),t):(f(tt,this,c(tt,this)+c(et,this)),f(Ze,this,void 0),f($e,this,0),f(et,this,0),t)}}function ot(e){return at.apply(this,arguments)}function at(){return(at=i(C().m(function e(t){var n,r,i;return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.read();case 1:if(n=e.v,r=n.done,i=n.value,!r){e.n=2;break}throw new Ee;case 2:if(!(i.length>t)){e.n=3;break}return f(Ze,this,i),f($e,this,t),f(et,this,i.length-t),f(tt,this,c(tt,this)+t),e.a(2,i.subarray(0,t));case 3:return f(tt,this,c(tt,this)+i.length),e.a(2,i)}},e,this)}))).apply(this,arguments)}var st=new WeakMap,ut=new WeakMap,ct=function(){return v(function e(t){var n,r;u(this,e),l(this,st,void 0),l(this,ut,void 0);var o=new rt(new Ye(function(e){n=e}));f(st,this,new Ke({pull:function(e){return i(C().m(function n(){var r,i;return C().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,t(o);case 1:r=n.v,e.enqueue(r),n.n=4;break;case 2:if(n.p=2,!((i=n.v)instanceof xe)){n.n=3;break}return e.close(),n.a(2);case 3:throw i;case 4:return n.a(2)}},n,null,[[0,2]])}))()},cancel:function(e){return r.error(e)}})),f(ut,this,new qe({start:function(e){r=e},write:function(e){return i(C().m(function t(){return C().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.enqueue(e);case 1:return t.a(2)}},t)}))()},abort:function(){n.close()},close:function(){n.close()}}))},[{key:"readable",get:function(){return c(st,this)}},{key:"writable",get:function(){return c(ut,this)}}])}(),lt=function(){function e(t){return u(this,e),a(this,e,[function(e){return t.deserialize(e)}])}return g(e,ct),v(e)}(),ft=ze,ht=Se({content:Ge(Pe)},{littleEndian:!1}),dt=new WeakMap,vt=function(){function e(){var t,n;return u(this,e),l(t=a(this,e,[function(e){n=e}]),dt,void 0),y(t,"id",0),f(dt,t,n),t}return g(e,Ye),v(e,[{key:"parse",value:(t=i(C().m(function e(t,n){var r;return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ht.deserialize(n);case 1:return r=e.v,e.n=2,c(dt,this).enqueue(r.content);case 2:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"close",value:function(){c(dt,this).close()}},{key:"error",value:function(e){c(dt,this).error(e)}}]);var t}(),pt=function(){return[L,V,U,B,j,F,z,H,K,q,X]}();var yt={repeatPreviousFrameAfter:"long",maxPtsGapToEncoder:"long"},mt=function(){return v(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,e),y(this,"options",void 0);for(var n=0,r=Object.entries(t);n<r.length;n++){var i=R(r[n],2),o=i[0],a=i[1];if(void 0!==a&&"number"!=typeof a)throw new Error("Invalid option value for ".concat(o,": ").concat(String(a)))}this.options=t},[{key:"toOptionValue",value:function(){var e=Object.entries(this.options).filter(function(e){return void 0!==R(e,2)[1]});if(0!==e.length)return e.map(function(e){var t=R(e,2),n=t[0],r=t[1],i=n.replace(/([A-Z])/g,"-$1").toLowerCase(),o=yt[n];return o&&(i+=":".concat(o)),i+="=".concat(r)}).join(",")}}])}();y(mt,"Empty",new mt);var wt={logLevel:"debug",maxSize:0,bitRate:8e6,maxFps:0,lockVideoOrientation:-1,tunnelForward:!1,crop:void 0,sendFrameMeta:!0,control:!0,displayId:0,showTouches:!1,stayAwake:!1,codecOptions:void 0};function gt(e,t,n){return e<t?t:e>n?n:e}function bt(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 Object.fromEntries(Object.entries(e).filter(function(e){var t=R(e,1)[0];return!n.includes(t)}))}var Et=we(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;Ae(n,r,e=1===(e=gt(e,-1,1))?65535:65536*e,i)},function(e,t,n){var r=n.littleEndian;return C().m(function n(){var i,o;return C().w(function(n){for(;;)switch(n.n){case 0:return n.d(S(e(t.readExactly(2))),1);case 1:return i=n.v,o=Re(i,0,r),n.a(2,65535===o?1:o/65536)}},n)})()}),kt=Se({pts:We,data:be(Pe)},{littleEndian:!1}),Ct=1n<<63n;function xt(e,t){return St.apply(this,arguments)}function St(){return St=i(C().m(function e(t,n){var r;return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(n);case 1:return r=e.v,e.a(2,Fe(r.subarray(0,r.indexOf(0))))}},e)})),St.apply(this,arguments)}function Ot(e){return Rt.apply(this,arguments)}function Rt(){return Rt=i(C().m(function e(t){var n;return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(4);case 1:return n=e.v,e.a(2,Te(n,0))}},e)})),Rt.apply(this,arguments)}var At,Tt,_t=function(){return k(k({},wt),{},{encoderName:void 0})}(),Mt=(At=ft,Tt={action:Ne()},Se(Object.assign({},At.fields,Tt),{littleEndian:At.littleEndian,extra:At.extra,postDeserialize:void 0}));var It=function(){var e=pt.slice();return e.splice(6,0,G),e}(),Nt=-1,Dt=function(){return k(k({},_t),{},{logLevel:"debug",lockVideoOrientation:Nt,powerOffOnClose:!1})}(),Pt=function(){return k(k({},Dt),{},{clipboardAutosync:!0})}();function Wt(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase()}var Lt=Se({sequence:We},{littleEndian:!1}),Vt=Se({type:Ne,sequence:We,paste:Ne(),content:Ge(Pe)},{littleEndian:!1}),Ut=new WeakMap,Bt=new WeakMap,jt=function(){return v(function e(){u(this,e),l(this,Ut,new Map),l(this,Bt,!1),y(this,"id",1)},[{key:"parse",value:(e=i(C().m(function e(t,n){var r,i;return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,Lt.deserialize(n);case 1:r=e.v,(i=c(Ut,this).get(r.sequence))&&(i.resolve(),c(Ut,this).delete(r.sequence));case 2:return e.a(2)}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=p(c(Ut,this).values());try{for(t.s();!(e=t.n()).done;){e.value.reject()}}catch(e){t.e(e)}finally{t.f()}c(Ut,this).clear(),f(Bt,this,!0)}},{key:"error",value:function(e){var t,n=p(c(Ut,this).values());try{for(n.s();!(t=n.n()).done;){t.value.reject(e)}}catch(e){n.e(e)}finally{n.f()}c(Ut,this).clear(),f(Bt,this,!0)}},{key:"serializeSetClipboardControlMessage",value:function(e){if(0n===e.sequence)return Vt.serialize(e);if(c(Bt,this))throw new Error;var t=new de;return c(Ut,this).set(e.sequence,t),[Vt.serialize(e),t.promise]}}]);var e}(),Ft=function(){return k(k({},Pt),{},{downsizeOnError:!0,sendDeviceMeta:!0,sendDummyByte:!0})}(),Gt=function(){return k(k({},Ft),{},{cleanup:!0})}(),zt=1n<<62n;var Ht=function(){return k(k({},Gt),{},{powerOn:!0})}(),Kt=we(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}(n,r,e=1===(e=gt(e,-1,1))?32767:32768*e,i)},function(e,t,n){var r=n.littleEndian;return C().m(function n(){var i,o;return C().w(function(n){for(;;)switch(n.n){case 0:return n.d(S(e(t.readExactly(2))),1);case 1:return i=n.v,o=Oe(i,0,r),n.a(2,32767===o?1:o/32768)}},n)})()}),qt=function(){return Se({type:Ne(B),pointerX:Pe,pointerY:Pe,videoWidth:De,videoHeight:De,scrollX:Kt,scrollY:Kt,buttons:Pe},{littleEndian:!1})}(),Xt=function(){return k(k({},bt(Ht,"bitRate","codecOptions","encoderName")),{},{scid:void 0,videoCodec:"h264",videoBitRate:8e6,videoCodecOptions:void 0,videoEncoder:void 0,audio:!0,audioCodec:"opus",audioBitRate:128e3,audioCodecOptions:void 0,audioEncoder:void 0,listEncoders:!1,listDisplays:!1,sendCodecMeta:!0})}(),Yt=function(){return Se({type:Ne(U),action:Ne(),pointerId:We,pointerX:Pe,pointerY:Pe,videoWidth:De,videoHeight:De,pressure:Et,actionButton:Pe,buttons:Pe},{littleEndian:!1})}();function Jt(){return Jt=i(C().m(function e(t,n){var r,o,a,s,u,c,l,f;return C().w(function(e){for(;;)switch(e.n){case 0:return r=new rt(t),e.n=1,r.readExactly(4);case 1:o=e.v,a=Te(o,0),c=a,e.n=0===c?2:1===c?3:4;break;case 2:return e.a(2,{type:"disabled"});case 3:return e.a(2,{type:"errored"});case 4:if(!n.sendCodecMeta){e.n=11;break}l=a,e.n=l===W.Raw.metadataValue?5:l===W.Opus.metadataValue?6:l===W.Aac.metadataValue?7:l===W.Flac.metadataValue?8:9;break;case 5:return s=W.Raw,e.a(3,10);case 6:return s=W.Opus,e.a(3,10);case 7:return s=W.Aac,e.a(3,10);case 8:return s=W.Flac,e.a(3,10);case 9:case 16:throw new Error("Unknown audio codec metadata value: ".concat(a));case 10:return e.a(2,{type:"success",codec:s,stream:r.release()});case 11:f=n.audioCodec,e.n="raw"===f?12:"opus"===f?13:"aac"===f?14:"flac"===f?15:16;break;case 12:return u=W.Raw,e.a(3,17);case 13:return u=W.Opus,e.a(3,17);case 14:return u=W.Aac,e.a(3,17);case 15:return u=W.Flac,e.a(3,17);case 17:return e.a(2,{type:"success",codec:u,stream:new Ye(function(){var e=i(C().m(function e(t){var n,i,a,s,u;return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.enqueue(o);case 1:n=r.release(),i=n.getReader();case 2:return e.n=3,i.read();case 3:if(a=e.v,s=a.done,u=a.value,!s){e.n=4;break}return e.a(3,6);case 4:return e.n=5,t.enqueue(u);case 5:e.n=2;break;case 6:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}())})}},e)})),Jt.apply(this,arguments)}function Qt(e){switch(e){case"h264":return ae;case"h265":return se;case"av1":return ue;default:throw new Error("Unknown video codec: ".concat(e))}}function Zt(){return(Zt=i(C().m(function e(t,n){var r,i,o,a,s;return C().w(function(e){for(;;)switch(e.n){case 0:if(r=new rt(n),!t.sendDeviceMeta){e.n=2;break}return e.n=1,xt(r,64);case 1:i=e.v;case 2:if(!t.sendCodecMeta){e.n=6;break}return e.n=3,Ot(r);case 3:return o=e.v,e.n=4,Ot(r);case 4:return a=e.v,e.n=5,Ot(r);case 5:s=e.v,e.n=7;break;case 6:o=Qt(t.videoCodec);case 7:return e.a(2,{stream:r.release(),metadata:{deviceName:i,codec:o,width:a,height:s}})}},e)}))).apply(this,arguments)}function $t(e,t){return e.sendDeviceMeta||e.sendCodecMeta?function(e,t){return Zt.apply(this,arguments)}(e,t):{stream:t,metadata:{codec:Qt(e.videoCodec)}}}var en=function(){return k(k({},Xt),{},{video:!0,audioSource:"output"})}(),tn=function(){return k(k({},en),{},{videoSource:"display",displayId:0,cameraId:void 0,cameraSize:void 0,cameraFacing:void 0,cameraAr:void 0,cameraFps:void 0,cameraHighSpeed:!1,listCameras:!1,listCameraSizes:!1})}();var nn=function(){return[].concat(T(It),[Y,J,Z])}(),rn=Se({id:De,data:be(De)},{littleEndian:!1}),on=new WeakMap,an=function(){function e(){var t,n;return u(this,e),l(t=a(this,e,[function(e){n=e}]),on,void 0),y(t,"id",2),f(on,t,n),t}return g(e,Ye),v(e,[{key:"parse",value:(t=i(C().m(function e(t,n){var r;return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,rn.deserialize(n);case 1:return r=e.v,e.n=2,c(on,this).enqueue(r);case 2:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"close",value:function(){c(on,this).close()}},{key:"error",value:function(e){c(on,this).error(e)}}]);var t}(),sn=function(){return k(k({},tn),{},{audioDup:!1})}(),un=function(){var e=nn.slice();return e.splice(14,0,Q),e}(),cn=function(){return[].concat(T(un),[$,ee])}(),ln=function(){return k(k({},bt(sn,"lockVideoOrientation")),{},{captureOrientation:void 0,angle:0,screenOffTimeout:void 0,listApps:!1,newDisplay:void 0,vdSystemDecorations:!0})}(),fn=/^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder=(\S+)(?:\s*\((sw|hw|hybrid)\))?(?:\s*\[vendor\])?(?:\s*\(alias for (\S+)\))?$/;function hn(e){switch(e){case"sw":return"software";case"hw":return"hardware";case"hybrid":return"hybrid";default:throw new Error("Unknown hardware type: ".concat(e))}}var dn=function(){return k(k({},ln),{},{vdDestroyContent:!1})}(),vn=Se({type:Ne,id:De,vendorId:De,productId:De,name:Ge(Ne),data:be(De)},{littleEndian:!1});var pn=function(){return k(k({},dn),{},{displayImePolicy:void 0})}(),yn=function(){return v(function e(){u(this,e)},[{key:"serializeScrollMessage",value:function(e){return e=k(k({},e),{},{scrollX:e.scrollX/16,scrollY:e.scrollY/16}),qt.serialize(e)}}])}();var mn=new WeakMap,wn=new WeakMap,gn=new WeakMap,bn=new WeakMap,En=function(){return v(function e(t){u(this,e),y(this,"value",void 0),l(this,mn,void 0),l(this,wn,void 0),l(this,gn,void 0),l(this,bn,new re),this.value=k(k({},pn),t),"camera"===this.value.videoSource&&(this.value.control=!1),this.value.audioDup&&(this.value.audioSource="playback"),this.value.control&&(this.value.clipboardAutosync&&(f(mn,this,c(bn,this).add(new vt)),f(wn,this,c(bn,this).add(new jt))),f(gn,this,c(bn,this).add(new an)))},[{key:"controlMessageTypes",get:function(){return cn}},{key:"clipboard",get:function(){return c(mn,this)}},{key:"uHidOutput",get:function(){return c(gn,this)}},{key:"deviceMessageParsers",get:function(){return c(bn,this)}},{key:"serialize",value:function(){return function(e,t){for(var n=[],r=0,i=Object.entries(e);r<i.length;r++){var o=R(i[r],2),a=o[0],s=oe(o[1],void 0);void 0!==s&&s!==oe(t[a],void 0)&&n.push("".concat(Wt(a),"=").concat(s))}return n}(this.value,pn)}},{key:"setListDisplays",value:function(){this.value.listDisplays=!0}},{key:"parseDisplay",value:function(e){return function(e){var t=e.match(/^\s+--display-id=(\d+)\s+\(([^)]+)\)$/);if(t){var n={id:Number.parseInt(t[1],10)};return"size unknown"!==t[2]&&(n.resolution=t[2]),n}}(e)}},{key:"setListEncoders",value:function(){this.value.listEncoders=!0}},{key:"parseEncoder",value:function(e){return function(e){var t=e.match(fn);return t?{type:t[1],name:t[3],codec:t[2],hardwareType:t[4]?hn(t[4]):void 0,vendor:!!t[5],aliasFor:t[6]}:void 0}(e)}},{key:"parseVideoStreamMetadata",value:function(e){return $t(this.value,e)}},{key:"parseAudioStreamMetadata",value:function(e){return function(e,t){return Jt.apply(this,arguments)}(e,this.value)}},{key:"createMediaStreamTransformer",value:function(){return function(e){if(!e.sendFrameMeta)return new Xe({transform:function(e,t){t.enqueue({type:"data",data:e})}});var t=new lt(kt);return{writable:t.writable,readable:t.readable.pipeThrough(new Xe({transform:function(e,t){e.pts!==Ct?e.pts&zt?t.enqueue({type:"data",keyframe:!0,pts:e.pts&~zt,data:e.data}):t.enqueue({type:"data",keyframe:!1,pts:e.pts,data:e.data}):t.enqueue({type:"configuration",data:e.data})}}))}}(this.value)}},{key:"serializeInjectTouchControlMessage",value:function(e){return function(e){return Yt.serialize(e)}(e)}},{key:"serializeBackOrScreenOnControlMessage",value:function(e){return function(e){return Mt.serialize(e)}(e)}},{key:"serializeSetClipboardControlMessage",value:function(e){return c(wn,this).serializeSetClipboardControlMessage(e)}},{key:"createScrollController",value:function(){return new yn}},{key:"serializeUHidCreateControlMessage",value:function(e){return function(e){return vn.serialize(e)}(e)}}])}();function kn(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function Cn(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function xn(e){if(e%1!=0)throw new Error("Value must be an integer");if(e<0)throw new Error("Value must be positive");if(e>=256)throw new Error("Value must be less than 256");return e<16?"0"+e.toString(16).toUpperCase():e.toString(16).toUpperCase()}y(En,"Defaults",pn),"function"==typeof SuppressedError&&SuppressedError;var Sn,On,Rn,An,Tn,_n,Mn,In,Nn,Dn,Pn,Wn,Ln=C().m(Vn);function Vn(e){var t,n,r,i,o,a,s;return C().w(function(u){for(;;)switch(u.n){case 0:t=-1,n=0,r=!1,i=0;case 1:if(!(i<e.length)){u.n=15;break}if(o=e[i],!r){u.n=3;break}if(!(o>3)){u.n=2;break}throw new Error("Invalid data");case 2:return r=!1,u.a(3,14);case 3:if(0!==o){u.n=4;break}return n+=1,u.a(3,14);case 4:if(a=n,n=0,-1!==t){u.n=6;break}if(!(a>=2&&1===o)){u.n=5;break}return t=i+1,u.a(3,14);case 5:throw new Error("Invalid data");case 6:if(!(a<2)){u.n=7;break}return u.a(3,14);case 7:if(1!==o){u.n=9;break}return u.n=8,e.subarray(t,i-a);case 8:return t=i+1,u.a(3,14);case 9:if(!(a>2)){u.n=10;break}throw new Error("Invalid data");case 10:s=o,u.n=2===s?11:3===s?12:13;break;case 11:throw new Error("Invalid data");case 12:return r=!0,u.a(3,14);case 13:return u.a(3,14);case 14:i+=1,u.n=1;break;case 15:if(!r){u.n=16;break}throw new Error("Invalid data");case 16:return u.n=17,e.subarray(t,e.length);case 17:return u.a(2)}},Ln)}var Un,Bn,jn,Fn,Gn=function(){return v(function e(t){u(this,e),Sn.add(this),On.set(this,void 0),Rn.set(this,void 0),An.set(this,void 0),Tn.set(this,0),_n.set(this,0),Mn.set(this,7),In.set(this,0),Cn(this,On,t,"f");for(var n=t.length-1;n>=0;n-=1)if(0!==kn(this,On,"f")[n])for(var r=t[n],i=0;i<8;i+=1)if(1==(r>>i&1))return Cn(this,Rn,n,"f"),Cn(this,An,i,"f"),void kn(this,Sn,"m",Nn).call(this);throw new Error("Stop bit not found")},[{key:"byteLength",get:function(){return kn(this,Rn,"f")}},{key:"stopBitIndex",get:function(){return kn(this,An,"f")}},{key:"bytePosition",get:function(){return kn(this,_n,"f")}},{key:"bitPosition",get:function(){return kn(this,Mn,"f")}},{key:"ended",get:function(){return kn(this,_n,"f")>=kn(this,Rn,"f")&&kn(this,Mn,"f")<=kn(this,An,"f")}},{key:"next",value:function(){if(this.ended)throw new Error("Bit index out of bounds");var e=kn(this,In,"f")>>kn(this,Mn,"f")&1;return Cn(this,Mn,kn(this,Mn,"f")-1,"f"),kn(this,Mn,"f")<0&&(Cn(this,_n,kn(this,_n,"f")+1,"f"),Cn(this,Mn,7,"f"),kn(this,Sn,"m",Nn).call(this)),e}},{key:"read",value:function(e){if(e>32)throw new Error("Read length too large");for(var t=0,n=0;n<e;n+=1)t=t<<1|this.next();return t}},{key:"skip",value:function(e){if(e<=kn(this,Mn,"f")+1)return Cn(this,Mn,kn(this,Mn,"f")-e,"f"),void kn(this,Sn,"m",Dn).call(this);for(e-=kn(this,Mn,"f")+1,Cn(this,_n,kn(this,_n,"f")+1,"f"),Cn(this,Mn,7,"f"),kn(this,Sn,"m",Nn).call(this),kn(this,Sn,"m",Dn).call(this);e>=8;e-=8)Cn(this,_n,kn(this,_n,"f")+1,"f"),kn(this,Sn,"m",Nn).call(this),kn(this,Sn,"m",Dn).call(this);Cn(this,Mn,7-e,"f"),kn(this,Sn,"m",Dn).call(this)}},{key:"decodeExponentialGolombNumber",value:function(){for(var e=0;0===this.next();)e+=1;return 0===e?0:(1<<e|this.read(e))-1}},{key:"peek",value:function(e){var t=kn(this,Sn,"m",Pn).call(this),n=this.read(e);return kn(this,Sn,"m",Wn).call(this,t),n}},{key:"readBytes",value:function(e){for(var t=new Uint8Array(e),n=0;n<e;n+=1)t[n]=this.read(8);return t}},{key:"peekBytes",value:function(e){var t=kn(this,Sn,"m",Pn).call(this),n=this.readBytes(e);return kn(this,Sn,"m",Wn).call(this,t),n}}])}();function zn(e){var t=function(e){var t,n,r,i=p(Vn(e));try{for(i.s();!(r=i.n()).done;){var o=r.value;switch(31&o[0]){case 7:if(t=o,n)return{sequenceParameterSet:t,pictureParameterSet:n};break;case 8:if(n=o,t)return{sequenceParameterSet:t,pictureParameterSet:n}}}}catch(e){i.e(e)}finally{i.f()}throw new Error("Invalid data")}(e),n=t.sequenceParameterSet,r=t.pictureParameterSet,i=function(e){var t=new Gn(e);if(0!==t.next())throw new Error("Invalid data");var n=t.read(2);if(7!==t.read(5))throw new Error("Invalid data");if(0===n)throw new Error("Invalid data");var r=t.read(8),i=t.peek(8),o=!!t.next(),a=!!t.next(),s=!!t.next(),u=!!t.next(),c=!!t.next(),l=!!t.next();if(0!==t.read(2))throw new Error("Invalid data");var f=t.read(8),h=t.decodeExponentialGolombNumber();if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||139===r||134===r){var d=t.decodeExponentialGolombNumber();if(3===d&&t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber(),t.next(),t.next())for(var v=[],p=0;p<(3!==d?8:12);p+=1)v[p]=!!t.next(),v[p]}t.decodeExponentialGolombNumber();var y=t.decodeExponentialGolombNumber();if(0===y)t.decodeExponentialGolombNumber();else if(1===y){t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber();for(var m=t.decodeExponentialGolombNumber(),w=[],g=0;g<m;g+=1)w[g]=t.decodeExponentialGolombNumber()}t.decodeExponentialGolombNumber(),t.next();var b=t.decodeExponentialGolombNumber(),E=t.decodeExponentialGolombNumber(),k=t.next();k||t.next(),t.next();var C,x,S,O,R=!!t.next();return R?(C=t.decodeExponentialGolombNumber(),x=t.decodeExponentialGolombNumber(),S=t.decodeExponentialGolombNumber(),O=t.decodeExponentialGolombNumber()):(C=0,x=0,S=0,O=0),t.next(),{profile_idc:r,constraint_set:i,constraint_set0_flag:o,constraint_set1_flag:a,constraint_set2_flag:s,constraint_set3_flag:u,constraint_set4_flag:c,constraint_set5_flag:l,level_idc:f,seq_parameter_set_id:h,pic_width_in_mbs_minus1:b,pic_height_in_map_units_minus1:E,frame_mbs_only_flag:k,frame_cropping_flag:R,frame_crop_left_offset:C,frame_crop_right_offset:x,frame_crop_top_offset:S,frame_crop_bottom_offset:O}}(n),o=i.profile_idc,a=i.constraint_set,s=i.level_idc,u=16*(i.pic_width_in_mbs_minus1+1),c=(i.pic_height_in_map_units_minus1+1)*(2-i.frame_mbs_only_flag)*16,l=2*i.frame_crop_left_offset,f=2*i.frame_crop_right_offset,h=2*i.frame_crop_top_offset,d=2*i.frame_crop_bottom_offset;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:a,levelIndex:s,encodedWidth:u,encodedHeight:c,cropLeft:l,cropRight:f,cropTop:h,cropBottom:d,croppedWidth:u-l-f,croppedHeight:c-h-d}}function Hn(e){var t=e.profileIndex,n=e.constraintSet,r=e.levelIndex;return"avc1."+xn(t)+xn(n)+xn(r)}On=new WeakMap,Rn=new WeakMap,An=new WeakMap,Tn=new WeakMap,_n=new WeakMap,Mn=new WeakMap,In=new WeakMap,Sn=new WeakSet,Nn=function e(){if(Cn(this,In,kn(this,On,"f")[kn(this,_n,"f")],"f"),2===kn(this,Tn,"f")&&3===kn(this,In,"f"))return Cn(this,Tn,0,"f"),Cn(this,_n,kn(this,_n,"f")+1,"f"),void kn(this,Sn,"m",e).call(this);0===kn(this,In,"f")?Cn(this,Tn,kn(this,Tn,"f")+1,"f"):Cn(this,Tn,0,"f")},Dn=function(){if(kn(this,_n,"f")>=kn(this,Rn,"f")&&kn(this,Mn,"f")<kn(this,An,"f"))throw new Error("Bit index out of bounds")},Pn=function(){return{zeroCount:kn(this,Tn,"f"),bytePosition:kn(this,_n,"f"),bitPosition:kn(this,Mn,"f"),byte:kn(this,In,"f")}},Wn=function(e){Cn(this,Tn,e.zeroCount,"f"),Cn(this,_n,e.bytePosition,"f"),Cn(this,Mn,e.bitPosition,"f"),Cn(this,In,e.byte,"f")};var Kn,qn,Xn,Yn=function(){return v(function e(t){u(this,e),Un.set(this,void 0),Bn.set(this,void 0),jn.set(this,!1),Fn.set(this,void 0),Cn(this,Fn,t,"f")},[{key:"decode",value:function(e){if("configuration"===e.type)return Cn(this,Un,e.data,"f"),Cn(this,Bn,this.configure(e.data),"f"),void Cn(this,jn,!0,"f");var t;e.keyframe&&kn(this,Bn,"f")&&(kn(this,Fn,"f").reset(),kn(this,Fn,"f").configure(kn(this,Bn,"f")),kn(this,Un,"f")&&Cn(this,jn,!0,"f")),kn(this,jn,"f")&&void 0!==kn(this,Un,"f")?((t=new Uint8Array(kn(this,Un,"f").length+e.data.length)).set(kn(this,Un,"f"),0),t.set(e.data,kn(this,Un,"f").length),Cn(this,jn,!1,"f")):t=e.data,kn(this,Fn,"f").decode(new EncodedVideoChunk({type:!1===e.keyframe?"delta":"key",timestamp:void 0!==e.pts?Number(e.pts):1,data:t}))}}])}();Un=new WeakMap,Bn=new WeakMap,jn=new WeakMap,Fn=new WeakMap;var Jn,Qn,Zn,$n,er,tr,nr=function(){function e(t,n,r){var i;return u(this,e),i=a(this,e,[t]),Kn.set(i,void 0),qn.set(i,void 0),Xn.set(i,void 0),Cn(i,Kn,t,"f"),Cn(i,qn,n,"f"),Cn(i,Xn,r,"f"),i}return g(e,Yn),v(e,[{key:"configure",value:function(e){var t,n,r=zn(e);kn(this,qn,"f").call(this,r.croppedWidth,r.croppedHeight);var i={codec:Hn(r),hardwareAcceleration:null!==(t=null===(n=kn(this,Xn,"f"))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0};return kn(this,Kn,"f").configure(i),i}}])}();Kn=new WeakMap,qn=new WeakMap,Xn=new WeakMap;var rr,ir,or=function(){return v(function e(t,n){var r=this;u(this,e),Jn.set(this,void 0),Qn.set(this,new ReadableStream({start:function(e){Cn(r,Jn,e,"f")},pull:function(e){e.enqueue(kn(r,$n,"f").call(r))}},{highWaterMark:0})),Zn.set(this,kn(this,Qn,"f").getReader()),$n.set(this,void 0),er.set(this,0),tr.set(this,void 0),Cn(this,$n,t,"f"),Cn(this,tr,n,"f")},[{key:"borrow",value:(e=i(C().m(function e(){var t;return C().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,kn(this,Zn,"f").read();case 1:return t=e.v,e.a(2,t.value)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"return",value:function(e){kn(this,er,"f")<kn(this,tr,"f")&&(kn(this,Jn,"f").enqueue(e),Cn(this,er,kn(this,er,"f")+1,"f"))}}]);var e}();Jn=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap;var ar,sr,ur,cr,lr,fr,hr,dr,vr,pr,yr,mr,wr=function(){return v(function e(){u(this,e),rr.set(this,void 0),ir.set(this,void 0),"undefined"!=typeof OffscreenCanvas?Cn(this,rr,new OffscreenCanvas(1,1),"f"):(Cn(this,rr,document.createElement("canvas"),"f"),kn(this,rr,"f").width=1,kn(this,rr,"f").height=1);var t=kn(this,rr,"f").getContext("bitmaprenderer",{alpha:!1});if(!t)throw new Error("ImageBitmapRenderingContext is not supported");Cn(this,ir,t,"f")},[{key:"capture",value:(e=i(C().m(function e(t){var n,r=this;return C().w(function(e){for(;;)switch(e.n){case 0:return kn(this,rr,"f").width=t.displayWidth,kn(this,rr,"f").height=t.displayHeight,e.n=1,createImageBitmap(t);case 1:if(n=e.v,kn(this,ir,"f").transferFromImageBitmap(n),!(kn(this,rr,"f")instanceof OffscreenCanvas)){e.n=3;break}return e.n=2,kn(this,rr,"f").convertToBlob({type:"image/png"});case 2:return e.a(2,e.v);case 3:return e.a(2,new Promise(function(e,t){kn(r,rr,"f").toBlob(function(n){n?e(n):t(new Error("Failed to convert canvas to blob"))},"image/png")}));case 4:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}();rr=new WeakMap,ir=new WeakMap;var gr,br,Er,kr,Cr,xr=function(){return v(function e(t,n){var r=this;u(this,e),ar.add(this),sr.set(this,!1),ur.set(this,!1),cr.set(this,void 0),lr.set(this,void 0),fr.set(this,void 0),hr.set(this,[]),dr.set(this,void 0),vr.set(this,!1),this.write=function(){var e=i(C().m(function e(t){var n,i;return C().w(function(e){for(;;)switch(e.n){case 0:if(!kn(r,vr,"f")){e.n=1;break}throw new Error("Attempt to write to a closed decoder");case 1:if(!kn(r,sr,"f")){e.n=5;break}n=t.type,e.n="configuration"===n?2:"data"===n?3:4;break;case 2:return Cn(r,fr,t,"f"),kn(r,hr,"f").length=0,e.a(3,4);case 3:return t.keyframe&&(kn(r,hr,"f").length=0),kn(r,hr,"f").push(t),e.a(3,4);case 4:case 12:return e.a(2);case 5:return e.n=6,kn(r,dr,"f");case 6:if(!kn(r,vr,"f")){e.n=7;break}return e.a(2);case 7:i=t.type,e.n="configuration"===i?8:"data"===i?10:12;break;case 8:return e.n=9,kn(r,cr,"f").call(r,t);case 9:case 11:return e.a(3,12);case 10:return e.n=11,kn(r,lr,"f").call(r,t,!1)}},e)}));return function(t){return e.apply(this,arguments)}}(),mr.set(this,void 0),Cn(this,cr,t,"f"),Cn(this,lr,n,"f")},[{key:"paused",get:function(){return kn(this,sr,"f")}},{key:"pause",value:function(){kn(this,ar,"m",pr).call(this,!0)}},{key:"resume",value:function(){return kn(this,ar,"m",yr).call(this,!0)}},{key:"trackDocumentVisibility",value:function(e){var t,n=this;null===(t=kn(this,mr,"f"))||void 0===t||t.call(this);var r=function(){"hidden"===e.visibilityState?kn(n,ar,"m",pr).call(n,!1):kn(n,ar,"m",yr).call(n,!1)};r(),e.addEventListener("visibilitychange",r);var i=!1;return Cn(this,mr,function(){i||(i=!0,e.removeEventListener("visibilitychange",r),kn(n,vr,"f")||kn(n,ar,"m",yr).call(n,!1))},"f"),kn(this,mr,"f")}},{key:"dispose",value:function(){var e;kn(this,vr,"f")||(Cn(this,vr,!0,"f"),Cn(this,fr,void 0,"f"),kn(this,hr,"f").length=0,null===(e=kn(this,mr,"f"))||void 0===e||e.call(this))}}])}();sr=new WeakMap,ur=new WeakMap,cr=new WeakMap,lr=new WeakMap,fr=new WeakMap,hr=new WeakMap,dr=new WeakMap,vr=new WeakMap,mr=new WeakMap,ar=new WeakSet,pr=function(e){if(kn(this,vr,"f"))throw new Error("Attempt to pause a closed decoder");Cn(this,sr,!0,"f"),e&&Cn(this,ur,!0,"f")},yr=function(){var e=i(C().m(function e(t){var n,r,i,o;return C().w(function(e){for(;;)switch(e.n){case 0:if(!kn(this,vr,"f")){e.n=1;break}throw new Error("Attempt to resume a closed decoder");case 1:if(kn(this,sr,"f")){e.n=2;break}return e.a(2);case 2:if(!kn(this,ur,"f")||t){e.n=3;break}return e.a(2);case 3:if(n=new de,Cn(this,dr,n.promise,"f"),Cn(this,sr,!1,"f"),Cn(this,ur,!1,"f"),!kn(this,fr,"f")){e.n=5;break}return e.n=4,kn(this,cr,"f").call(this,kn(this,fr,"f"));case 4:if(Cn(this,fr,void 0,"f"),!kn(this,vr,"f")){e.n=5;break}return e.a(2);case 5:r=0,i=kn(this,hr,"f").length;case 6:if(!(r<i)){e.n=9;break}return o=kn(this,hr,"f")[r],e.n=7,kn(this,lr,"f").call(this,o,r!==i-1);case 7:if(!kn(this,vr,"f")){e.n=8;break}return e.a(2);case 8:r+=1,e.n=6;break;case 9:kn(this,hr,"f").length=0,n.resolve(void 0),Cn(this,dr,void 0,"f");case 10:return e.a(2)}},e,this)}));return function(t){return e.apply(this,arguments)}}();var Sr=function(){return v(function e(){var t=this;u(this,e),gr.set(this,0),br.set(this,0),Er.set(this,0),kr.set(this,void 0),Cr.set(this,function(){kn(t,gr,"f")>0&&(Cn(t,br,kn(t,br,"f")+1,"f"),Cn(t,gr,0,"f")),Cn(t,kr,requestAnimationFrame(kn(t,Cr,"f")),"f")});try{Cn(this,kr,requestAnimationFrame(kn(this,Cr,"f")),"f")}catch(e){}},[{key:"framesDrawn",get:function(){return kn(this,gr,"f")}},{key:"framesRendered",get:function(){return kn(this,gr,"f")}},{key:"framesPresented",get:function(){return kn(this,br,"f")}},{key:"framesSkipped",get:function(){return kn(this,Er,"f")}},{key:"increaseFramesSkipped",value:function(){Cn(this,Er,kn(this,Er,"f")+1,"f")}},{key:"increaseFramesDrawn",value:function(){Cn(this,gr,kn(this,gr,"f")+1,"f")}},{key:"dispose",value:function(){void 0!==kn(this,kr,"f")&&cancelAnimationFrame(kn(this,kr,"f"))}}])}();gr=new WeakMap,br=new WeakMap,Er=new WeakMap,kr=new WeakMap,Cr=new WeakMap;var Or,Rr,Ar,Tr=function(){return v(function e(){var t=this;u(this,e),y(this,"listeners",[]),y(this,"event",function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];var a={listener:e,thisArg:n,args:i};return t.addEventListener(a)}),this.event=this.event.bind(this)},[{key:"addEventListener",value:function(e){var t=this;this.listeners.push(e);var n=function(){var n=t.listeners.indexOf(e);-1!==n&&t.listeners.splice(n,1)};return n.dispose=n,n}},{key:"fire",value:function(e){var t,n=p(this.listeners.slice());try{for(n.s();!(t=n.n()).done;){var r,i=t.value;(r=i.listener).call.apply(r,[i.thisArg,e].concat(T(i.args)))}}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.listeners.length=0}}])}(),_r=Symbol("undefined"),Mr=new WeakMap,Ir=function(){function e(){var t;u(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return l(t=a(this,e,[].concat(r)),Mr,_r),t}return g(e,Tr),v(e,[{key:"addEventListener",value:function(t){var n;c(Mr,this)!==_r&&(n=t.listener).call.apply(n,[t.thisArg,c(Mr,this)].concat(T(t.args)));return A(e,"addEventListener",this)([t])}},{key:"fire",value:function(t){f(Mr,this,t),A(e,"fire",this)([t])}}])}(),Nr=function(){return v(function e(){u(this,e),Or.set(this,0),Rr.set(this,0),Ar.set(this,new Ir)},[{key:"width",get:function(){return kn(this,Or,"f")}},{key:"height",get:function(){return kn(this,Rr,"f")}},{key:"sizeChanged",get:function(){return kn(this,Ar,"f").event}},{key:"setSize",value:function(e,t){kn(this,Or,"f")===e&&kn(this,Rr,"f")===t||(Cn(this,Or,e,"f"),Cn(this,Rr,t,"f"),kn(this,Ar,"f").fire({width:e,height:t}))}},{key:"dispose",value:function(){kn(this,Ar,"f").dispose()}}])}();Or=new WeakMap,Rr=new WeakMap,Ar=new WeakMap;var Dr,Pr,Wr,Lr,Vr,Ur,Br,jr,Fr,Gr,zr,Hr,Kr,qr,Xr,Yr,Jr,Qr,Zr,$r,ei,ti,ni,ri,ii,oi,ai,si,ui,ci,li,fi,hi,di=["codec","renderer","frameDropMode"],vi=new or(function(){return new wr},4);!function(e){e.RenderLatest="render-latest",e.DropWhenBusy="drop-when-busy",e.RenderAll="render-all"}(hi||(hi={}));var pi,yi=function(){return v(function e(t){var n=this,r=t.codec,i=t.renderer,o=t.frameDropMode,a=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,di);if(u(this,e),Dr.add(this),Pr.set(this,void 0),Wr.set(this,void 0),Lr.set(this,void 0),Vr.set(this,void 0),Ur.set(this,hi.RenderLatest),Br.set(this,1),jr.set(this,[]),Fr.set(this,1),Gr.set(this,[]),zr.set(this,void 0),Hr.set(this,void 0),Kr.set(this,new Nr),qr.set(this,new Sr),Xr.set(this,void 0),Yr.set(this,void 0),Jr.set(this,void 0),Qr.set(this,0),Zr.set(this,0),$r.set(this,!1),ei.set(this,void 0),ti.set(this,[]),ni.set(this,void 0),oi.set(this,function(e,t){kn(n,Wr,"f").setSize(e,t),kn(n,Kr,"f").setSize(e,t)}),Cn(this,Pr,r,"f"),Cn(this,Wr,i,"f"),Cn(this,Lr,a,"f"),Cn(this,Ur,null!=o?o:hi.RenderLatest,"f"),Cn(this,Yr,new VideoDecoder({output:function(e){var t;return kn(n,Ur,"f")!==hi.RenderLatest&&kn(n,Dr,"m",ui).call(n),kn(n,Vr,"f")||0===e.timestamp?(e.close(),void(kn(n,Ur,"f")===hi.RenderAll&&kn(n,Dr,"m",li).call(n))):(Cn(n,Qr,kn(n,Qr,"f")+1,"f"),Cn(n,Zr,kn(n,Zr,"f")+(performance.now()-e.timestamp/1e3),"f"),null===(t=kn(n,ni,"f"))||void 0===t||t.close(),Cn(n,ni,e.clone(),"f"),void kn(n,Dr,"m",ii).call(n,e))},error:function(e){kn(n,Ur,"f")!==hi.RenderLatest&&kn(n,Dr,"m",ui).call(n),kn(n,Ur,"f")===hi.RenderAll&&kn(n,Dr,"m",li).call(n),kn(n,Dr,"m",ri).call(n,e)}}),"f"),kn(this,Pr,"f")!==ae)throw new Error("Unsupported codec: ".concat(kn(this,Pr,"f")));Cn(this,Jr,new nr(kn(this,Yr,"f"),kn(this,oi,"f"),kn(this,Lr,"f")),"f"),Cn(this,Xr,new xr(function(e){return kn(n,Jr,"f").decode(e)},function(e,t){kn(n,Dr,"m",ai).call(n,e,t)}),"f"),Cn(this,zr,new qe({start:function(e){kn(n,Vr,"f")?e.error(kn(n,Vr,"f")):Cn(n,Hr,e,"f")},write:kn(this,Xr,"f").write}),"f")},[{key:"codec",get:function(){return kn(this,Pr,"f")}},{key:"renderer",get:function(){return kn(this,Wr,"f")}},{key:"writable",get:function(){return kn(this,zr,"f")}},{key:"width",get:function(){return kn(this,Kr,"f").width}},{key:"height",get:function(){return kn(this,Kr,"f").height}},{key:"sizeChanged",get:function(){return kn(this,Kr,"f").sizeChanged}},{key:"framesDrawn",get:function(){return kn(this,qr,"f").framesDrawn}},{key:"framesRendered",get:function(){return kn(this,qr,"f").framesRendered}},{key:"framesPresented",get:function(){return kn(this,qr,"f").framesPresented}},{key:"framesSkipped",get:function(){return kn(this,qr,"f").framesSkipped}},{key:"paused",get:function(){return kn(this,Xr,"f").paused}},{key:"framesDecoded",get:function(){return kn(this,Qr,"f")}},{key:"decodeQueueSize",get:function(){return kn(this,Yr,"f").decodeQueueSize}},{key:"decodingTime",get:function(){return kn(this,Zr,"f")}},{key:"snapshot",value:(e=i(C().m(function e(){var t,n;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=kn(this,ni,"f")){e.n=1;break}return e.a(2,void 0);case 1:return e.n=2,vi.borrow();case 2:return n=e.v,e.p=3,e.n=4,n.capture(t);case 4:return e.a(2,e.v);case 5:return e.p=5,vi.return(n),e.f(5);case 6:return e.a(2)}},e,this,[[3,,5,6]])})),function(){return e.apply(this,arguments)})},{key:"pause",value:function(){kn(this,Xr,"f").pause()}},{key:"resume",value:function(){return kn(this,Xr,"f").resume()}},{key:"trackDocumentVisibility",value:function(e){return kn(this,Xr,"f").trackDocumentVisibility(e)}},{key:"dispose",value:function(){var e,t;null===(e=kn(this,ni,"f"))||void 0===e||e.close(),kn(this,qr,"f").dispose(),kn(this,Wr,"f").dispose(),kn(this,Kr,"f").dispose(),null===(t=kn(this,ei,"f"))||void 0===t||t.close();var n,r=p(kn(this,ti,"f"));try{for(r.s();!(n=r.n()).done;){n.value.close()}}catch(e){r.e(e)}finally{r.f()}kn(this,ti,"f").length=0,"closed"!==kn(this,Yr,"f").state&&kn(this,Yr,"f").close(),kn(this,Xr,"f").dispose()}}],[{key:"isSupported",get:function(){return void 0!==globalThis.VideoDecoder}}]);var e}();function mi(){if("undefined"!=typeof document)return document.createElement("canvas");if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(1,1);throw new Error("no canvas input found nor any canvas can be created")}function wi(e,t){try{var n=e.getContext("webgl2",t);if(n)return n}catch(e){}try{var r=e.getContext("webgl",t);if(r)return r}catch(e){}if(e instanceof HTMLCanvasElement){var i=e.getContext("experimental-webgl",t);if(i)return i}return null}function gi(e){try{var t;null===(t=e.getExtension("WEBGL_lose_context"))||void 0===t||t.loseContext()}catch(e){}}Pr=new WeakMap,Wr=new WeakMap,Lr=new WeakMap,Vr=new WeakMap,Ur=new WeakMap,Br=new WeakMap,jr=new WeakMap,Fr=new WeakMap,Gr=new WeakMap,zr=new WeakMap,Hr=new WeakMap,Kr=new WeakMap,qr=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,$r=new WeakMap,ei=new WeakMap,ti=new WeakMap,ni=new WeakMap,oi=new WeakMap,Dr=new WeakSet,ri=function(e){if(!kn(this,Vr,"f")){Cn(this,Vr,e,"f");try{var t;null===(t=kn(this,Hr,"f"))||void 0===t||t.error(e)}catch(e){}kn(this,Dr,"m",fi).call(this),this.dispose()}},ii=function(){var e=i(C().m(function e(t){var n,r;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,!kn(this,$r,"f")){e.n=1;break}return kn(this,Ur,"f")===hi.RenderAll?kn(this,ti,"f").push(t):(kn(this,ei,"f")&&(kn(this,ei,"f").close(),kn(this,qr,"f").increaseFramesSkipped()),Cn(this,ei,t,"f")),e.a(2);case 1:Cn(this,$r,!0,"f");case 2:return kn(this,oi,"f").call(this,t.displayWidth,t.displayHeight),e.n=3,kn(this,Wr,"f").draw(t);case 3:if(t.close(),kn(this,qr,"f").increaseFramesDrawn(),kn(this,Ur,"f")!==hi.RenderAll){e.n=6;break}if(!(n=kn(this,ti,"f").shift())){e.n=4;break}t=n,e.n=5;break;case 4:return e.a(3,9);case 5:e.n=8;break;case 6:if(!kn(this,ei,"f")){e.n=7;break}t=kn(this,ei,"f"),Cn(this,ei,void 0,"f"),e.n=8;break;case 7:return e.a(3,9);case 8:e.n=2;break;case 9:Cn(this,$r,!1,"f"),kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),e.n=11;break;case 10:e.p=10,r=e.v,kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),kn(this,Dr,"m",ri).call(this,r);case 11:return e.a(2)}},e,this,[[0,10]])}));return function(t){return e.apply(this,arguments)}}(),ai=function(){var e=i(C().m(function e(t,n){var r,i,o,a,s,u;return C().w(function(e){for(;;)switch(e.n){case 0:if(kn(this,Ur,"f")!==hi.RenderAll){e.n=3;break}return e.n=1,kn(this,Dr,"m",ci).call(this);case 1:return e.n=2,kn(this,Dr,"m",si).call(this);case 2:e.n=4;break;case 3:if(kn(this,Ur,"f")!==hi.DropWhenBusy){e.n=4;break}return e.n=4,kn(this,Dr,"m",si).call(this);case 4:n?r=0n:(i=performance.now(),o=i.toString().split("."),a=R(o,2),s=a[0],u=a[1],r=BigInt(s+((void 0===u?"":u)+"000").slice(0,3)));try{kn(this,Jr,"f").decode(k(k({},t),{},{pts:r}))}catch(e){kn(this,Ur,"f")!==hi.RenderLatest&&kn(this,Dr,"m",ui).call(this),kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),kn(this,Dr,"m",ri).call(this,e)}case 5:return e.a(2)}},e,this)}));return function(t,n){return e.apply(this,arguments)}}(),si=function(){var e=i(C().m(function e(){var t=this;return C().w(function(e){for(;;)switch(e.n){case 0:if(!(kn(this,Br,"f")>0)){e.n=1;break}return Cn(this,Br,kn(this,Br,"f")-1,"f"),e.a(2);case 1:return e.n=2,new Promise(function(e){kn(t,jr,"f").push(e)});case 2:return e.a(2)}},e,this)}));return function(){return e.apply(this,arguments)}}(),ui=function(){kn(this,jr,"f").length>0?kn(this,jr,"f").shift()():kn(this,Br,"f")<1&&Cn(this,Br,kn(this,Br,"f")+1,"f")},ci=function(){var e=i(C().m(function e(){var t=this;return C().w(function(e){for(;;)switch(e.n){case 0:if(!(kn(this,Fr,"f")>0)){e.n=1;break}return Cn(this,Fr,kn(this,Fr,"f")-1,"f"),e.a(2);case 1:return e.n=2,new Promise(function(e){kn(t,Gr,"f").push(e)});case 2:return e.a(2)}},e,this)}));return function(){return e.apply(this,arguments)}}(),li=function(){kn(this,Gr,"f").length>0?kn(this,Gr,"f").shift()():kn(this,Fr,"f")<1&&Cn(this,Fr,kn(this,Fr,"f")+1,"f")},fi=function(){var e,t=p(kn(this,jr,"f"));try{for(t.s();!(e=t.n()).done;){(0,e.value)()}}catch(e){t.e(e)}finally{t.f()}kn(this,jr,"f").length=0,Cn(this,Br,1,"f");var n,r=p(kn(this,Gr,"f"));try{for(r.s();!(n=r.n()).done;){(0,n.value)()}}catch(e){r.e(e)}finally{r.f()}kn(this,Gr,"f").length=0,Cn(this,Fr,1,"f")},yi.capabilities={h264:{}};var bi,Ei=function(){return v(function e(t){u(this,e),pi.set(this,void 0),Cn(this,pi,t||mi(),"f")},[{key:"canvas",get:function(){return kn(this,pi,"f")}},{key:"setSize",value:function(e,t){kn(this,pi,"f").width===e&&kn(this,pi,"f").height===t||(kn(this,pi,"f").width=e,kn(this,pi,"f").height=t)}},{key:"dispose",value:function(){kn(this,pi,"f").width=0,kn(this,pi,"f").height=0}}])}();pi=new WeakMap;var ki=Promise.resolve(),Ci=function(){function e(t,n){var r;u(this,e),r=a(this,e,[t]),bi.set(r,void 0);var i=wi(r.canvas,{powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n,desynchronized:!n,antialias:!1,depth:!1,premultipliedAlpha:!0,stencil:!1});if(!i)throw new Error("WebGL not supported, check `isSupported` first");Cn(r,bi,i,"f");var o=i.createShader(i.VERTEX_SHADER);if(i.shaderSource(o,e.VertexShaderSource),i.compileShader(o),!i.getShaderParameter(o,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(o));var s=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,e.FragmentShaderSource),i.compileShader(s),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(s));var c=i.createProgram();if(i.attachShader(c,o),i.attachShader(c,s),i.linkProgram(c),!i.getProgramParameter(c,i.LINK_STATUS))throw new Error(i.getProgramInfoLog(c));i.useProgram(c);var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),i.STATIC_DRAW);var f=i.getAttribLocation(c,"xy");i.vertexAttribPointer(f,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(f);var h=i.createTexture();return i.bindTexture(i.TEXTURE_2D,h),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i instanceof WebGL2RenderingContext?i.NEAREST_MIPMAP_LINEAR:i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),r}return g(e,Ei),v(e,[{key:"draw",value:function(e){var t=kn(this,bi,"f");return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t instanceof WebGL2RenderingContext&&t.generateMipmap(t.TEXTURE_2D),t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.drawArrays(t.TRIANGLE_FAN,0,4),ki}},{key:"dispose",value:function(){gi(kn(this,bi,"f"))}}],[{key:"isSupported",get:function(){return e={failIfMajorPerformanceCaveat:!0},(t=wi(mi(),e))&&gi(t),!!t;var e,t}}])}();bi=new WeakMap,Ci.VertexShaderSource="\n attribute vec2 xy;\n\n varying highp vec2 uv;\n\n void main(void) {\n gl_Position = vec4(xy, 0.0, 1.0);\n // Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).\n // UV coordinates are Y-flipped relative to vertex coordinates.\n uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);\n }\n",Ci.FragmentShaderSource="\n precision mediump float;\n\n varying highp vec2 uv;\n uniform sampler2D texture;\n\n void main(void) {\n gl_FragColor = texture2D(texture, uv);\n }\n";var xi=function(){return v(function e(t,n){u(this,e),this.program=null,this.texture=null,this.vertexBuffer=null,this.canvas=t;var r={alpha:!1,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,powerPreference:null!=n?n:"low-power",failIfMajorPerformanceCaveat:!0},i=t.getContext("webgl2",r)||t.getContext("webgl",r);if(!i)throw new Error("WebGL not supported");this.gl=i,this.initGL()},[{key:"initGL",value:function(){var e=this.gl,t=this.createShader(e.VERTEX_SHADER,"\n attribute vec2 a_pos;\n varying highp vec2 v_texCoord;\n void main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n // Map [-1, 1] to [0, 1] and flip Y for texture\n v_texCoord = vec2((a_pos.x + 1.0) * 0.5, (1.0 - a_pos.y) * 0.5);\n }\n "),n=this.createShader(e.FRAGMENT_SHADER,"\n varying highp vec2 v_texCoord;\n uniform sampler2D u_sampler;\n void main() {\n gl_FragColor = texture2D(u_sampler, v_texCoord);\n }\n ");this.program=this.createProgram(t,n),e.useProgram(this.program);var r=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.vertexBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW);var i=e.getAttribLocation(this.program,"a_pos");e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.clearColor(1,1,1,1),e.clear(e.COLOR_BUFFER_BIT)}},{key:"setSize",value:function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)}},{key:"draw",value:function(e){var t=this.gl;t&&this.program&&(t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.drawArrays(t.TRIANGLE_STRIP,0,4))}},{key:"createShader",value:function(e,t){var n=this.gl,r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS)){var i=n.getShaderInfoLog(r);throw n.deleteShader(r),new Error("Shader compile error: "+i)}return r}},{key:"createProgram",value:function(e,t){var n=this.gl,r=n.createProgram();if(n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),!n.getProgramParameter(r,n.LINK_STATUS)){var i=n.getProgramInfoLog(r);throw n.deleteProgram(r),new Error("Program link error: "+i)}return n.detachShader(r,e),n.detachShader(r,t),n.deleteShader(e),n.deleteShader(t),r}},{key:"dispose",value:function(){var e,t=this.gl;this.texture&&t.deleteTexture(this.texture),this.vertexBuffer&&t.deleteBuffer(this.vertexBuffer),this.program&&t.deleteProgram(this.program),null===(e=t.getExtension("WEBGL_lose_context"))||void 0===e||e.loseContext()}}],[{key:"isSupported",get:function(){try{var e=new OffscreenCanvas(1,1);return!(!e.getContext("webgl2")&&!e.getContext("webgl"))}catch(e){return!1}}}])}(),Si=function(){return v(function e(t){if(u(this,e),this.canvas=t,this.ctx=null,this.ctx=t.getContext("2d",{alpha:!1,desynchronized:!0}),!this.ctx)throw new Error("Canvas 2D not supported")},[{key:"setSize",value:function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)}},{key:"draw",value:function(e){this.ctx&&this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height)}},{key:"dispose",value:function(){this.ctx=null,this.canvas.width=0,this.canvas.height=0}}])}(),Oi=function(){return v(function e(){u(this,e),this.listeners=new Map},[{key:"on",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}},{key:"once",value:function(e,t){var n=this,r=function(){t.apply(void 0,arguments),n.off(e,r)};this.on(e,r)}},{key:"off",value:function(e,t){var n;null===(n=this.listeners.get(e))||void 0===n||n.delete(t)}},{key:"emit",value:function(e){var t=this.listeners.get(e);if(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var o,a=p(t);try{for(a.s();!(o=a.n()).done;){var s=o.value;try{s.apply(void 0,r)}catch(t){console.error("EventEmitter '".concat(e,"' listener error"),t)}}}catch(e){a.e(e)}finally{a.f()}}}},{key:"clear",value:function(e){e?this.listeners.delete(e):this.listeners.clear()}}])}(),Ri=function(){function e(t){var n,r;return u(this,e),(r=a(this,e)).sockets={video:null,audio:null,touch:null},r.subscribers={video:new Set,audio:new Set,touch:new Set},r.deviceId=t.deviceId,r.ip=t.ip,r.ports=null!==(n=t.ports)&&void 0!==n?n:{},r}return g(e,Oi),v(e,[{key:"getUrl",value:function(e){var t=this.ports[e];return"ws://".concat(this.ip,":").concat(t)}},{key:"getChannelStatus",value:function(e){var t=this.sockets[e];if(!t)return"disconnected";switch(t.readyState){case WebSocket.CONNECTING:return"connecting";case WebSocket.OPEN:return"connected";case WebSocket.CLOSING:case WebSocket.CLOSED:default:return"disconnected"}}},{key:"getAllChannelsStatus",value:function(){return{video:this.getChannelStatus("video"),audio:this.getChannelStatus("audio"),touch:this.getChannelStatus("touch")}}},{key:"emitChannelStatus",value:function(e,t){var n=this.getAllChannelsStatus();this.emit(t,e,n)}},{key:"ensureChannel",value:function(e){var t=this;if(this.sockets[e]){var n=this.sockets[e].readyState;if(n===WebSocket.OPEN||n===WebSocket.CONNECTING)return;this.sockets[e]=null}var r=new WebSocket(this.getUrl(e));r.binaryType="arraybuffer",r.onopen=function(){console.log("[".concat(t.deviceId,":").concat(e,"] connected")),t.emitChannelStatus(e,"open")},r.onmessage=function(n){try{var r,i=p(t.subscribers[e]);try{for(i.s();!(r=i.n()).done;){(0,r.value)(n.data)}}catch(e){i.e(e)}finally{i.f()}}catch(n){console.error("[".concat(t.deviceId,":").concat(e,"] message error"),n)}},r.onerror=function(n){console.error("[".concat(t.deviceId,":").concat(e,"] error"),n),t.emit("error",e,n)},r.onclose=function(n){console.warn("[".concat(t.deviceId,":").concat(e,"] closed"),n),t.sockets[e]=null,t.emit("close",e,n)},this.sockets[e]=r}},{key:"subscribe",value:function(e,t){this.subscribers[e].add(t),this.sockets[e]||this.ensureChannel(e)}},{key:"unsubscribe",value:function(e,t){var n;(t?this.subscribers[e].delete(t):this.subscribers[e].clear(),0===this.subscribers[e].size)&&(console.log("[".concat(this.deviceId,":").concat(e,"] no subscribers, closing")),null===(n=this.sockets[e])||void 0===n||n.close(),this.sockets[e]=null)}},{key:"send",value:function(e,t){var n=this.sockets[e];if(n&&n.readyState===WebSocket.OPEN)try{t instanceof ArrayBuffer||t instanceof Uint8Array?n.send(t):n.send(JSON.stringify(t))}catch(t){console.error("[".concat(e,"] send error"),t)}}},{key:"sendTouch",value:function(e){this.send("touch",e)}},{key:"destroy",value:function(){var e=this;["video","audio","touch"].forEach(function(t){console.log("[".concat(e.deviceId,":").concat(t,"] destroying"));var n=e.sockets[t];n&&(n.onopen=null,n.onmessage=null,n.onerror=null,n.onclose=null,n.close(),e.sockets[t]=null),e.subscribers[t].clear()}),this.clear()}}])}(),Ai="focus",Ti="blur",_i="input",Mi="delete",Ii="enter",Ni="arrow-up",Di="arrow-down",Pi="arrow-left",Wi="arrow-right",Li=function(){return v(function e(t){u(this,e),this.emitter=new Oi,this.isComposing=!1,this.el=document.createElement("textarea"),this.el.style.cssText="\n position:absolute;\n top:0;\n left:0;\n pointer-events:none;\n opacity:0.01;\n width:100%;\n max-width:95%;\n height: 40px;\n resize: none;\n overflow: hidden;\n ",this.el.autocomplete="off",t.appendChild(this.el),this.bindEvents()},[{key:"on",value:function(e,t){var n;null===(n=this.emitter)||void 0===n||n.on(e,t)}},{key:"off",value:function(e,t){var n;null===(n=this.emitter)||void 0===n||n.off(e,t)}},{key:"bindEvents",value:function(){var e=this;this.el.addEventListener("focus",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(Ai)}),this.el.addEventListener("blur",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(Ti)}),this.el.addEventListener("compositionstart",function(){e.isComposing=!0}),this.el.addEventListener("compositionend",function(t){var n;e.isComposing=!1;var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(_i,r.value),e.el.value=""}),this.el.addEventListener("input",function(t){var n;if(!e.isComposing){var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(_i,r.value),e.el.value=""}}),this.el.addEventListener("keydown",function(t){var n,r,i,o,a,s;switch(t.key){case"Backspace":case"Delete":null===(n=e.emitter)||void 0===n||n.emit(Mi);break;case"Enter":null===(r=e.emitter)||void 0===r||r.emit(Ii),e.el.blur();break;case"ArrowUp":null===(i=e.emitter)||void 0===i||i.emit(Ni);break;case"ArrowDown":null===(o=e.emitter)||void 0===o||o.emit(Di);break;case"ArrowLeft":null===(a=e.emitter)||void 0===a||a.emit(Pi);break;case"ArrowRight":null===(s=e.emitter)||void 0===s||s.emit(Wi)}})}},{key:"focus",value:function(){this.el.focus()}},{key:"blur",value:function(){this.el.blur()}},{key:"moveTo",value:function(e,t,n){this.el.style.left="".concat(e,"px"),this.el.style.top="".concat(t,"px"),n&&(this.el.style.width="".concat(n,"px"))}},{key:"destroy",value:function(){var e;null===(e=this.emitter)||void 0===e||e.clear(),this.emitter=null,this.el.remove()}}])}(),Vi={AndroidHome:3,AndroidBack:4,AndroidCall:5,AndroidEndCall:6,Digit0:7,Digit1:8,Digit2:9,Digit3:10,Digit4:11,Digit5:12,Digit6:13,Digit7:14,Digit8:15,Digit9:16,Star:17,Pound:18,ArrowUp:19,ArrowDown:20,ArrowLeft:21,ArrowRight:22,AndroidDPadCenter:23,VolumeUp:24,VolumeDown:25,Power:26,AndroidCamera:27,Clear:28,KeyA:29,KeyB:30,KeyC:31,KeyD:32,KeyE:33,KeyF:34,KeyG:35,KeyH:36,KeyI:37,KeyJ:38,KeyK:39,KeyL:40,KeyM:41,KeyN:42,KeyO:43,KeyP:44,KeyQ:45,KeyR:46,KeyS:47,KeyT:48,KeyU:49,KeyV:50,KeyW:51,KeyX:52,KeyY:53,KeyZ:54,Comma:55,Period:56,AltLeft:57,AltRight:58,ShiftLeft:59,ShiftRight:60,Tab:61,Space:62,AndroidSymbol:63,AndroidExplorer:64,AndroidEnvelope:65,Enter:66,Backspace:67,Backquote:68,Minus:69,Equal:70,BracketLeft:71,BracketRight:72,Backslash:73,Semicolon:74,Quote:75,Slash:76,At:77,AndroidNum:78,AndroidHeadsetHook:79,AndroidFocus:80,Plus:81,ContextMenu:82,AndroidNotification:83,AndroidSearch:84,PageUp:92,PageDown:93,Escape:111,Delete:112,ControlLeft:113,ControlRight:114,CapsLock:115,ScrollLock:116,MetaLeft:117,MetaRight:118,AndroidFunction:119,PrintScreen:120,Pause:121,Home:122,End:123,Insert:124,AndroidForward:125,F1:131,F2:132,F3:133,F4:134,F5:135,F6:136,F7:137,F8:138,F9:139,F10:140,F11:141,F12:142,NumLock:143,Numpad0:144,Numpad1:145,Numpad2:146,Numpad3:147,Numpad4:148,Numpad5:149,Numpad6:150,Numpad7:151,Numpad8:152,Numpad9:153,NumpadDivide:154,NumpadMultiply:155,NumpadSubtract:156,NumpadAdd:157,NumpadDecimal:158,NumpadComma:159,NumpadEnter:160,NumpadEquals:161,NumpadLeftParen:162,NumpadRightParen:163,VolumeMute:164,AndroidAppSwitch:187,AndroidCut:277,AndroidCopy:278,AndroidPaste:279};Object.fromEntries(Object.entries(Vi).map(function(e){var t=R(e,2),n=t[0];return[t[1],n]}));var Ui,Bi,ji={Down:0,Up:1},Fi={Down:0,Up:1,Move:2,Cancel:3,Outside:4,PointerDown:5,PointerUp:6,HoverMove:7,Scroll:8,HoverEnter:9,HoverExit:10,ButtonPress:11,ButtonRelease:12},Gi={None:0,Primary:1,Secondary:2,Tertiary:4,Back:8,Forward:16,StylusPrimary:32,StylusSecondary:64};function zi(e,t,n){return e.setUint16(t,n),t+2}function Hi(e,t,n){return e.setUint32(t,n),t+4}function Ki(e,t,n){return e.setInt32(t,n),t+4}function qi(e,t,n){var r=Math.round(n/16*32767);return e.setInt16(t,r),t+2}function Xi(e,t,n){return e.setUint8(t,n),t+1}function Yi(e,t,n){return e.setBigInt64(t,n),t+8}!function(e){e[e.injectKeyCode=0]="injectKeyCode",e[e.injectText=1]="injectText",e[e.injectTouchEvent=2]="injectTouchEvent",e[e.injectScrollEvent=3]="injectScrollEvent",e[e.backOrScreenOn=4]="backOrScreenOn",e[e.expandNotificationPanel=5]="expandNotificationPanel",e[e.expandSettingsPanel=6]="expandSettingsPanel",e[e.collapsePanels=7]="collapsePanels",e[e.getClipboard=8]="getClipboard",e[e.setClipboard=9]="setClipboard",e[e.setDisplayPower=10]="setDisplayPower",e[e.rotateDevice=11]="rotateDevice",e[e.uhidCreate=12]="uhidCreate",e[e.uhidInput=13]="uhidInput",e[e.uhidDestroy=14]="uhidDestroy",e[e.openHardKeyboardSettings=15]="openHardKeyboardSettings",e[e.startApp=16]="startApp",e[e.resetVideo=17]="resetVideo"}(Ui||(Ui={})),function(e){e[e.Clipboard=0]="Clipboard",e[e.AckClipboard=1]="AckClipboard",e[e.UhidOutput=2]="UhidOutput"}(Bi||(Bi={}));var Ji=function(){return v(function e(){u(this,e)},null,[{key:"injectKeyCode",value:function(e){var t=e.action,n=e.keyCode,r=e.repeat,i=void 0===r?0:r,o=e.metaState,a=void 0===o?0:o,s=new ArrayBuffer(14),u=new DataView(s),c=0;return c=Xi(u,c,Ui.injectKeyCode),c=Ki(u,c=Xi(u,c,t),n),c=Ki(u,c,i),c=Ki(u,c,a),new Uint8Array(s)}},{key:"injectText",value:function(e){var t=e.text,n=this.encoder.encode(t),r=new ArrayBuffer(5+n.length),i=new DataView(r),o=0;return o=Hi(i,o=Xi(i,o,Ui.injectText),n.length),new Uint8Array(r,o).set(n),new Uint8Array(r)}},{key:"injectTouch",value:function(e){var t=e.action,n=e.pointerId,r=e.pointerX,i=e.pointerY,o=e.screenWidth,a=e.screenHeight,s=e.pressure,u=e.actionButton,c=e.buttons,l=new ArrayBuffer(32),f=new DataView(l),h=0;return h=Xi(f,h,Ui.injectTouchEvent),h=Ki(f,h=Yi(f,h=Xi(f,h,t),BigInt(n)),r),h=zi(f,h=Ki(f,h,i),o),h=function(e,t,n){var r=65535*Math.max(0,Math.min(1,n));return e.setUint16(t,r),t+2}(f,h=zi(f,h,a),s),h=Ki(f,h,u),h=Ki(f,h,c),new Uint8Array(l)}},{key:"injectScroll",value:function(e){var t=e.pointerX,n=e.pointerY,r=e.screenWidth,i=e.screenHeight,o=e.scrollX,a=e.scrollY,s=e.buttons,u=new ArrayBuffer(21),c=new DataView(u),l=0;return l=Ki(c,l=Xi(c,l,Ui.injectScrollEvent),t),l=zi(c,l=Ki(c,l,n),r),l=qi(c,l=zi(c,l,i),o),l=Ki(c,l=qi(c,l,a),s),new Uint8Array(u)}},{key:"setClipboard",value:function(e){var t=e.sequence,n=e.text,r=e.paste,i=void 0!==r&&r,o=this.encoder.encode(n),a=new ArrayBuffer(14+o.length),s=new DataView(a),u=0;return u=Xi(s,u,Ui.setClipboard),u=Hi(s,u=Xi(s,u=Yi(s,u,BigInt(t)),i?1:0),o.length),new Uint8Array(a,u).set(o),new Uint8Array(a)}},{key:"resetVideo",value:function(){var e=new ArrayBuffer(1);return Xi(new DataView(e),0,Ui.resetVideo),new Uint8Array(e)}}])}();Ji.encoder=new TextEncoder;var Qi=function(){return v(function e(){u(this,e)},null,[{key:"parse",value:function(e){var t=new DataView(e instanceof Uint8Array?e.buffer:e,e instanceof Uint8Array?e.byteOffset:0,e.byteLength);if(t.byteLength<1)return null;var n=function(e,t){return e.getUint8(t)}(t,0);switch(n){case Bi.Clipboard:return this.parseClipboard(t);case Bi.AckClipboard:return this.parseAckClipboard(t);default:return null}}},{key:"parseClipboard",value:function(e){if(e.byteLength<5)return null;var t=function(e,t){return e.getUint32(t)}(e,1);if(e.byteLength<5+t)return null;var n=new Uint8Array(e.buffer,e.byteOffset+5,t),r=this.decoder.decode(n);return{type:Bi.Clipboard,content:r}}},{key:"parseAckClipboard",value:function(e){if(e.byteLength<9)return null;var t=function(e,t){return e.getBigInt64(t)}(e,1);return{type:Bi.AckClipboard,sequence:t}}}])}();function Zi(e,t,n){return Math.max(t,Math.min(n,e))}Qi.decoder=new TextDecoder;var $i,eo,to={SIZE_CHANGED:"size-changed",ERROR:"error",STARTED:"started",STOPPED:"stopped",CLIPBOARD_CHANGED:"clipboard-changed",CHANNEL_CONNECTED:"channel-connected",GROUP_CONTROL_JOINED:"group-control-joined",GROUP_CONTROL_LEAVE:"group-control-leave"};exports.VmosEdgeErrorType=void 0,($i=exports.VmosEdgeErrorType||(exports.VmosEdgeErrorType={})).CONNECTION="connection",$i.VIDEO="video",$i.AUDIO="audio",$i.TOUCH="touch",$i.DECODER="decoder",$i.RENDERER="renderer",exports.VmosEdgeErrorCode=void 0,(eo=exports.VmosEdgeErrorCode||(exports.VmosEdgeErrorCode={})).CONNECTION_FAILED="CONNECTION_FAILED",eo.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",eo.CONNECTION_LOST="CONNECTION_LOST",eo.VIDEO_CHANNEL_CONNECTION_FAILED="VIDEO_CHANNEL_CONNECTION_FAILED",eo.VIDEO_CHANNEL_CLOSED="VIDEO_CHANNEL_CLOSED",eo.VIDEO_STREAM_ERROR="VIDEO_STREAM_ERROR",eo.VIDEO_PIPELINE_ERROR="VIDEO_PIPELINE_ERROR",eo.AUDIO_CHANNEL_CONNECTION_FAILED="AUDIO_CHANNEL_CONNECTION_FAILED",eo.AUDIO_STREAM_ERROR="AUDIO_STREAM_ERROR",eo.TOUCH_CHANNEL_CONNECTION_FAILED="TOUCH_CHANNEL_CONNECTION_FAILED",eo.TOUCH_MESSAGE_PARSE_ERROR="TOUCH_MESSAGE_PARSE_ERROR",eo.DECODER_INIT_FAILED="DECODER_INIT_FAILED",eo.DECODER_ERROR="DECODER_ERROR",eo.RENDERER_INIT_FAILED="RENDERER_INIT_FAILED",eo.RENDERER_ERROR="RENDERER_ERROR",eo.UNKNOWN_ERROR="UNKNOWN_ERROR";function no(e,t){var n,r,i=!1,o=0,a=0;return new Xe({transform:function(s,u){var c=Date.now();if("configuration"===s.type)return r=s,void(i||u.enqueue(s));if(void 0!==s.pts)if(void 0===n)n=s.pts,o=c;else{var l=s.pts-n,f=c-(o+Number(l)/1e3),h=t();f<-1e3&&(n=s.pts,o=c),!i&&(f>5e3||h>14)&&(i=!0,console.warn("[PacketDropper] Entering drop mode: lag=".concat(f.toFixed(0),"ms, queue=").concat(h)))}if(i){if(c-a>1600&&(e(),a=c,console.log("[PacketDropper] Requested keyframe")),!s.keyframe)return;i=!1,n=s.pts,o=c,console.log("[PacketDropper] Recovered from drop mode: received keyframe"),r&&(u.enqueue(r),r=void 0)}u.enqueue(s)}})}var ro=function(){function e(t){var n,r,i,o,s,c;return u(this,e),(c=a(this,e)).canvas=null,c.canvasContainer=null,c.device=null,c.isGroupControl=!1,c.deviceTouchGroupMap=new Map,c.config=null,c.renderer=null,c.videoCodecPreference="no-preference",c.renderPreference="default",c.decoder=null,c.textareaManager=null,c.videoWidth=0,c.videoHeight=0,c.isRunning=!1,c.rotation=0,c.manualRotation=!1,c.currentRotationAngle=0,c.resizeObserver=null,c.pointerMoveThrottleMap=new Map,c.touchMoveInterval=1e3/60,c.retryCount=0,c.maxRetries=0,c.retryInterval=1e3,c.stopVideoSubscription=null,c.container=t.container,c.config=t.config,c.device=new Ri(c.config),c.maxRetries=null!==(n=t.retryCount)&&void 0!==n?n:0,c.retryInterval=null!==(r=t.retryInterval)&&void 0!==r?r:1e3,c.isGroupControl=null!==(i=t.isGroupControl)&&void 0!==i&&i,c.videoCodecPreference=null!==(o=t.videoCodecPreference)&&void 0!==o?o:"no-preference",c.renderPreference=null!==(s=t.renderPreference)&&void 0!==s?s:"default",t.touchMoveFrequency&&(c.touchMoveInterval=1e3/t.touchMoveFrequency),c.initCanvas(),c.handlePointerEvent=c.handlePointerEvent.bind(c),c.handleWheelEvent=c.handleWheelEvent.bind(c),c.handleContextMenu=c.handleContextMenu.bind(c),c.initTextareaManager(),c.observeContainerResize(),c}return g(e,Oi),v(e,[{key:"setupChannelStatusListener",value:function(){var e,t,n=this;null===(e=this.device)||void 0===e||e.on("open",function(e,t){var r,i=null===(r=n.config)||void 0===r?void 0:r.ports[e];n.emit(to.CHANNEL_CONNECTED,{channel:e,port:i,allChannelsStatus:t}),"connected"===t.video&&"connected"===t.touch&&n.sendTouch(Ji.resetVideo(),!0)}),null===(t=this.device)||void 0===t||t.on("error",function(e,t){var r,i=n.extractErrorMessage(t);i||(i="WebSocket ".concat(e," channel connection failed"));var o=n.getErrorCodeForChannel(e,"connection_failed");n.emit(to.ERROR,{type:n.channelToErrorType(e),code:o,message:i,port:null===(r=n.config)||void 0===r?void 0:r.ports[e]})})}},{key:"extractErrorMessage",value:function(e){if(e instanceof Error)return e.message||e.toString();if(e instanceof Event)return"".concat(e.type||"unknown");if("string"==typeof e)return e;if(e&&"object"===M(e))return e.message||e.reason||String(e);var t=String(e);return"[object Object]"===t||"[object Event]"===t?"":t}},{key:"channelToErrorType",value:function(e){switch(e){case"video":return exports.VmosEdgeErrorType.VIDEO;case"audio":return exports.VmosEdgeErrorType.AUDIO;case"touch":return exports.VmosEdgeErrorType.TOUCH;default:return exports.VmosEdgeErrorType.CONNECTION}}},{key:"getErrorCodeForChannel",value:function(e,t){if("video"===e)switch(t){case"connection_failed":return exports.VmosEdgeErrorCode.VIDEO_CHANNEL_CONNECTION_FAILED;case"connection_closed":return exports.VmosEdgeErrorCode.VIDEO_CHANNEL_CLOSED;default:return exports.VmosEdgeErrorCode.VIDEO_STREAM_ERROR}else{if("audio"===e)return"connection_failed"===t?exports.VmosEdgeErrorCode.AUDIO_CHANNEL_CONNECTION_FAILED:exports.VmosEdgeErrorCode.AUDIO_STREAM_ERROR;switch(t){case"connection_failed":default:return exports.VmosEdgeErrorCode.TOUCH_CHANNEL_CONNECTION_FAILED;case"parse_error":return exports.VmosEdgeErrorCode.TOUCH_MESSAGE_PARSE_ERROR}}}},{key:"initCanvas",value:function(){this.canvasContainer=document.createElement("div"),this.canvasContainer.className="vmos-canvas-container",this.container.appendChild(this.canvasContainer),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),this.canvasContainer.appendChild(this.canvas),this.container.appendChild(this.canvasContainer)}},{key:"replaceCanvas",value:function(){var e;this.canvas&&this.canvasContainer&&this.canvasContainer.removeChild(this.canvas),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),null===(e=this.canvasContainer)||void 0===e||e.appendChild(this.canvas)}},{key:"applyCanvasStyle",value:function(e){e.style.width="100%",e.style.height="100%",e.style.outline="none",e.style.userSelect="none",e.style.backgroundColor="transparent",e.style.touchAction="none"}},{key:"initTextareaManager",value:function(){var e=this;this.textareaManager=new Li(this.container),this.textareaManager.on(_i,function(t){e.sendText(t)}),this.textareaManager.on(Mi,function(){e.sendKeyCode(Vi.Backspace,ji.Down),e.sendKeyCode(Vi.Backspace,ji.Up)}),this.textareaManager.on(Ii,function(){e.sendKeyCode(Vi.Enter,ji.Down),e.sendKeyCode(Vi.Enter,ji.Up)}),this.textareaManager.on(Ni,function(){e.sendKeyCode(Vi.ArrowUp,ji.Down),e.sendKeyCode(Vi.ArrowUp,ji.Up)}),this.textareaManager.on(Di,function(){e.sendKeyCode(Vi.ArrowDown,ji.Down),e.sendKeyCode(Vi.ArrowDown,ji.Up)}),this.textareaManager.on(Pi,function(){e.sendKeyCode(Vi.ArrowLeft,ji.Down),e.sendKeyCode(Vi.ArrowLeft,ji.Up)}),this.textareaManager.on(Wi,function(){e.sendKeyCode(Vi.ArrowRight,ji.Down),e.sendKeyCode(Vi.ArrowRight,ji.Up)})}},{key:"observeContainerResize",value:function(){var e=this;"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(function(){e.updateCanvasSize()}),this.resizeObserver.observe(this.container))}},{key:"on",value:function(t,n){return A(e,"on",this)([t,n]),this}},{key:"once",value:function(t,n){return A(e,"once",this)([t,n]),this}},{key:"off",value:function(t,n){return n?A(e,"off",this)([t,n]):A(e,"clear",this)([t]),this}},{key:"emit",value:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];A(e,"emit",this)([t].concat(r))}},{key:"start",value:(o=i(C().m(function e(){return C().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isRunning){e.n=1;break}return e.a(2);case 1:return this.isRunning=!0,this.retryCount=0,e.p=2,e.n=3,this.connectWithRetry();case 3:this.setupChannelStatusListener(),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,this,[[2,4]])})),function(){return o.apply(this,arguments)})},{key:"connectWithRetry",value:(r=i(C().m(function e(){var t=this;return C().w(function(e){for(;;)if(0===e.n)return e.a(2,new Promise(function(e,n){var r=function(){var o=i(C().m(function i(){var o,a,s;return C().w(function(i){for(;;)switch(i.p=i.n){case 0:return i.p=0,i.n=1,t.internalStart();case 1:e(),i.n=4;break;case 2:if(i.p=2,s=i.v,t.isRunning){i.n=3;break}return console.log("[VmosEdgeClient] Connection stopped by user during handshake/start."),i.a(2);case 3:console.error("[VmosEdgeClient] Connection failed (Attempt ".concat(t.retryCount+1,"/").concat(t.maxRetries+1,"):"),s),t.retryCount<t.maxRetries&&t.isRunning?(t.retryCount++,o=Math.min(t.retryInterval*Math.pow(2,t.retryCount-1),1e4),console.log("[VmosEdgeClient] Retrying in ".concat(o,"ms...")),setTimeout(function(){t.isRunning?r():n(new Error("Stopped"))},o)):(a=t.extractErrorMessage(s)||"连接失败",t.emit(to.ERROR,{type:exports.VmosEdgeErrorType.CONNECTION,code:exports.VmosEdgeErrorCode.CONNECTION_FAILED,message:a}),t.stop(),n(s));case 4:return i.a(2)}},i,null,[[0,2]])}));return function(){return o.apply(this,arguments)}}();r()}))},e)})),function(){return r.apply(this,arguments)})},{key:"internalStart",value:(n=i(C().m(function e(){var t,n,r,i,o,a,s,u,c,l,f,h,d=this;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:return this.canvas&&this.canvasContainer||this.initCanvas(),this.stopVideoSubscription&&(this.stopVideoSubscription(),this.stopVideoSubscription=null),t=new En({sendFrameMeta:!0,sendCodecMeta:!0,sendDeviceMeta:!0}),n=null,r=null,e.p=1,i=this.createVideoStream(),o=i.videoStream,a=i.stopVideoSubscription,n=a,e.n=2,this.performHandshake(t,o);case 2:s=e.v,u=s.metadata,c=s.stream,r=this.setupTouch(),this.createRenderer(),this.decoder=new yi({codec:u.codec,renderer:this.renderer,hardwareAcceleration:this.videoCodecPreference}),this.decoder.sizeChanged(function(e){var t=e.width,n=e.height,r=d.videoWidth,i=d.videoHeight;if(t!==r||n!==i){d.videoWidth=t,d.videoHeight=n;var o=t>n;0!==r&&0!==i&&r>i!==o&&(d.manualRotation=!1),d.manualRotation||(d.rotation=o?1:0),d.emitSizeChanged()}}),c.pipeThrough(t.createMediaStreamTransformer()).pipeThrough(no(function(){d.sendTouch(Ji.resetVideo())},function(){var e,t;return null!==(e=null===(t=d.decoder)||void 0===t?void 0:t.decodeQueueSize)&&void 0!==e?e:0})).pipeTo(this.decoder.writable).catch(function(e){var t,n;if(d.isRunning){console.error("[VmosEdgeClient] Video pipeline error:",e),null===(t=d.stopVideoSubscription)||void 0===t||t.call(d);var r=null===(n=d.config)||void 0===n?void 0:n.ports.video,i=d.extractErrorMessage(e)||"视频管道处理错误";d.emit(to.ERROR,{type:exports.VmosEdgeErrorType.VIDEO,code:exports.VmosEdgeErrorCode.VIDEO_PIPELINE_ERROR,message:i,port:r})}else console.log("[VmosEdgeClient] Video pipeline error: stopped by user during handshake/start.")}),this.bindInputEvents(),this.emit(to.STARTED),e.n=4;break;case 3:throw e.p=3,h=e.v,null===(l=n)||void 0===l||l(),null===(f=r)||void 0===f||f(),h;case 4:return e.a(2)}},e,this,[[1,3]])})),function(){return n.apply(this,arguments)})},{key:"createVideoStream",value:function(){var e,t,n=this,r=new ReadableStream({start:function(e){t=e},cancel:function(){var e;null===(e=n.stopVideoSubscription)||void 0===e||e.call(n)}}),i=function(e){var r;if(null!==t.desiredSize)try{var i=e instanceof Uint8Array?e:new Uint8Array(e);t.enqueue(i)}catch(e){var o;null===(o=n.stopVideoSubscription)||void 0===o||o.call(n);var a=n.extractErrorMessage(e)||"视频流数据处理错误";n.emit(to.ERROR,{type:exports.VmosEdgeErrorType.VIDEO,code:exports.VmosEdgeErrorCode.VIDEO_STREAM_ERROR,message:a})}else null===(r=n.stopVideoSubscription)||void 0===r||r.call(n)};return null===(e=this.device)||void 0===e||e.subscribe("video",i),this.stopVideoSubscription=function(){var e;null===(e=n.device)||void 0===e||e.unsubscribe("video",i),n.stopVideoSubscription=null;try{t&&null!==t.desiredSize&&t.close()}catch(e){if(e instanceof TypeError)return;console.error("[VmosEdgeClient] stopVideoSubscription error:",e)}},{videoStream:r,stopVideoSubscription:this.stopVideoSubscription}}},{key:"setupTouch",value:function(){var e,t=this,n=function(e){try{var n,r=Qi.parse(e);if((null==r?void 0:r.type)===Bi.Clipboard)t.emit(to.CLIPBOARD_CHANGED,null!==(n=null==r?void 0:r.content)&&void 0!==n?n:"")}catch(e){console.error("[VmosEdgeClient] Touch channel error:",e)}};return null===(e=this.device)||void 0===e||e.subscribe("touch",n),function(){var e;return null===(e=t.device)||void 0===e?void 0:e.unsubscribe("touch",n)}}},{key:"performHandshake",value:(t=i(C().m(function e(t,n){var r,i,o=this;return C().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=null,i=new Promise(function(e,t){var n,i,a=!1,s=function(e){a||(a=!0,t(e))},u=function(e,t){console.error("[VmosEdgeClient] Handshake error on ".concat(e,":"),t),"video"===e&&s(new Error("Video channel connection failed"))},c=function(e){"video"===e&&s(new Error("Video channel closed unexpectedly during handshake"))};null===(n=o.device)||void 0===n||n.on("error",u),null===(i=o.device)||void 0===i||i.on("close",c),r=function(){var e,t;null===(e=o.device)||void 0===e||e.off("error",u),null===(t=o.device)||void 0===t||t.off("close",c)}}),e.p=1,e.n=2,Promise.race([t.parseVideoStreamMetadata(n),i]);case 2:return e.a(2,e.v);case 3:return e.p=3,r&&r(),e.f(3);case 4:return e.a(2)}},e,null,[[1,,3,4]])})),function(e,n){return t.apply(this,arguments)})},{key:"setGroupControlMode",value:function(e){if(this.isGroupControl=e,!e){var t,n=p(this.deviceTouchGroupMap.values());try{for(n.s();!(t=n.n()).done;){t.value.destroy()}}catch(e){n.e(e)}finally{n.f()}this.deviceTouchGroupMap.clear()}}},{key:"joinGroupControl",value:function(e){var t=this;if(this.isGroupControl){console.log("[VmosEdgeClient] joinGroupControl start",e);var n,r=p(e);try{var i=function(){var e=n.value;if(!e.deviceId)return 0;if(t.deviceTouchGroupMap.has(e.deviceId))return 0;var r=new Ri(e);r.subscribe("touch",function(){}),r.on("open",function(){t.emit(to.GROUP_CONTROL_JOINED,e)}),r.on("close",function(){r.destroy(),t.deviceTouchGroupMap.delete(e.deviceId),t.emit(to.GROUP_CONTROL_LEAVE,e)}),t.deviceTouchGroupMap.set(e.deviceId,r)};for(r.s();!(n=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}}}},{key:"leaveGroupControl",value:function(e){if(this.isGroupControl){var t,n=p(e);try{for(n.s();!(t=n.n()).done;){var r,i=t.value;i.deviceId&&(this.deviceTouchGroupMap.has(i.deviceId)&&(null===(r=this.deviceTouchGroupMap.get(i.deviceId))||void 0===r||r.destroy(),this.deviceTouchGroupMap.delete(i.deviceId)))}}catch(e){n.e(e)}finally{n.f()}}}},{key:"stop",value:function(){var e,t;if(this.isRunning){if(this.isRunning=!1,null===(e=this.stopVideoSubscription)||void 0===e||e.call(this),this.unbindInputEvents(),this.emit(to.STOPPED),this.isGroupControl){var n,r=p(this.deviceTouchGroupMap.values());try{for(r.s();!(n=r.n()).done;){n.value.destroy()}}catch(e){r.e(e)}finally{r.f()}this.deviceTouchGroupMap.clear()}if(this.clear(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.canvasContainer&&this.canvasContainer.parentNode&&(this.canvasContainer.parentNode.removeChild(this.canvasContainer),this.canvasContainer=null,this.canvas=null),null===(t=this.device)||void 0===t||t.destroy(),this.renderer){try{this.renderer.dispose()}catch(e){console.warn("[VmosEdgeClient] Renderer dispose error:",e)}this.renderer=null}if(this.decoder){try{var i,o;null===(i=this.decoder)||void 0===i||null===(o=i.dispose)||void 0===o||o.call(i)}catch(e){console.warn("[VmosEdgeClient] Decoder dispose error:",e)}this.decoder=null}}}},{key:"emitSizeChanged",value:function(){var e=this.updateCanvasSize(),t={idealWidth:e.idealWidth,idealHeight:e.idealHeight,videoWidth:e.videoWidth,videoHeight:e.videoHeight,rotation:this.rotation};this.emit(to.SIZE_CHANGED,t)}},{key:"mapCoordinates",value:function(e,t){var n,r;switch(this.currentRotationAngle){case 90:n=t*this.videoWidth,r=(1-e)*this.videoHeight;break;case 270:n=(1-t)*this.videoWidth,r=e*this.videoHeight;break;default:n=e*this.videoWidth,r=t*this.videoHeight}return{x:n,y:r}}},{key:"updateCanvasSize",value:function(){if(!this.canvasContainer||!this.videoWidth||!this.videoHeight)return{idealWidth:0,idealHeight:0,videoWidth:0,videoHeight:0};var e,t,n=this.container,r=n.clientWidth,i=n.clientHeight,o=this.videoWidth,a=this.videoHeight,s=this.rotation,u=r,c=i,l=Math.max(u,c),f=Math.min(u,c);1===s?(e=l,t=f):(e=f,t=l);var h=Math.min(r/e,i/t,1),d=e*h,v=t*h,p=o>a,y=0,m=90===(y=1===s?p?0:270:p?90:0)||270===y,w=m?a:o,g=m?o:a,b=Math.min(d/w,v/g),E=w*b,k=g*b,C=this.canvasContainer.style;C.width="".concat(Math.ceil(E),"px"),C.height="".concat(Math.ceil(k),"px"),C.display="block",C.position="relative",C.transform="none";var x=this.canvas,S=x.style;x.width!==o&&(x.width=o),x.height!==a&&(x.height=a);var O=m?k:E,R=m?E:k;S.width="".concat(Math.ceil(O),"px"),S.height="".concat(Math.ceil(R),"px"),S.position="absolute",S.top="50%",S.left="50%",S.transformOrigin="center center",S.transform="translate(-50%, -50%) rotate(".concat(y,"deg)"),this.currentRotationAngle=y;var A=Math.min(e/w,t/g);return{idealWidth:w*A,idealHeight:g*A,videoWidth:o,videoHeight:a}}},{key:"createRenderer",value:function(){try{if(!xi.isSupported)throw new Error("WebGL not supported check");console.log("[VmosEdgeClient] Using WebGLVideoFrameRenderer"),this.renderer=new xi(this.canvas,this.renderPreference)}catch(e){console.warn("[VmosEdgeClient] WebGL initialization failed, falling back to Canvas2DRenderer:",e),this.replaceCanvas(),this.renderer=new Si(this.canvas)}}},{key:"bindInputEvents",value:function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.addEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.addEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.addEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.addEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.addEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.addEventListener("wheel",this.handleWheelEvent,{passive:!1}),null===(a=this.canvas)||void 0===a||a.addEventListener("contextmenu",this.handleContextMenu)}},{key:"unbindInputEvents",value:function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.removeEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.removeEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.removeEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.removeEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.removeEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.removeEventListener("wheel",this.handleWheelEvent),null===(a=this.canvas)||void 0===a||a.removeEventListener("contextmenu",this.handleContextMenu)}},{key:"handleContextMenu",value:function(e){e.preventDefault(),e.stopPropagation()}},{key:"handlePointerEvent",value:function(t){var n;if(this.videoWidth&&this.videoHeight){t.preventDefault(),t.stopPropagation();var r,i=this.canvas,o=t.type,a=t.clientX,s=t.clientY,u=t.button,c=t.buttons,l=t.pointerId;if("pointermove"===o){var f=Date.now();if(f-(this.pointerMoveThrottleMap.get(l)||0)<this.touchMoveInterval)return;this.pointerMoveThrottleMap.set(l,f)}if("pointerdown"===o){if(2===u)return void this.back();if(1===u)return void this.home()}else if("pointerup"===o){if(2===u||1===u)return}else if("pointermove"===o&&(2&c||4&c))return;switch(o){case"pointerdown":r=Fi.Down,i.setPointerCapture(l),null===(n=this.textareaManager)||void 0===n||n.focus();break;case"pointermove":if(0===c)return;r=Fi.Move;break;case"pointerup":case"pointercancel":case"pointerleave":r=Fi.Up,i.releasePointerCapture(l),this.pointerMoveThrottleMap.delete(l);break;default:return}var h=i.getBoundingClientRect(),d=Zi((a-h.x)/h.width,0,1),v=Zi((s-h.y)/h.height,0,1),p=this.mapCoordinates(d,v),y=p.x,m=p.y,w=Ji.injectTouch({action:r,pointerId:BigInt(l),pointerX:y,pointerY:m,screenWidth:this.videoWidth,screenHeight:this.videoHeight,pressure:0===c?0:1,actionButton:e.PointerEventButtonToAndroidButton[u]||Gi.Primary,buttons:c});this.sendTouch(w)}}},{key:"sendTouch",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null===(t=this.device)||void 0===t||t.sendTouch(e),this.isGroupControl&&!n){var r,i=p(this.deviceTouchGroupMap.values());try{for(i.s();!(r=i.n()).done;){r.value.sendTouch(e)}}catch(e){i.e(e)}finally{i.f()}}}},{key:"handleWheelEvent",value:function(e){if(this.videoWidth&&this.videoHeight&&this.device){e.preventDefault(),e.stopPropagation();var t=this.canvas.getBoundingClientRect(),n=Zi((e.clientX-t.x)/t.width,0,1),r=Zi((e.clientY-t.y)/t.height,0,1),i=this.mapCoordinates(n,r),o=i.x,a=i.y,s=Ji.injectScroll({pointerX:o,pointerY:a,screenWidth:this.videoWidth,screenHeight:this.videoHeight,scrollX:-e.deltaX,scrollY:-e.deltaY,buttons:0});this.sendTouch(s)}}},{key:"sendText",value:function(e){this.device&&this.sendTouch(Ji.injectText({text:e}))}},{key:"sendKeyCode",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.device&&this.sendTouch(Ji.injectKeyCode({keyCode:e,action:t,repeat:0,metaState:n}))}},{key:"clickKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.sendKeyCode(e,ji.Down,t),this.sendKeyCode(e,ji.Up,t)}},{key:"volumeUp",value:function(){this.clickKey(Vi.VolumeUp)}},{key:"volumeDown",value:function(){this.clickKey(Vi.VolumeDown)}},{key:"home",value:function(){this.clickKey(Vi.AndroidHome)}},{key:"back",value:function(){this.clickKey(Vi.AndroidBack)}},{key:"menu",value:function(){this.clickKey(Vi.AndroidAppSwitch)}},{key:"setRotation",value:function(e){this.rotation!==e&&(this.manualRotation=!0,this.rotation=e,this.emitSizeChanged())}},{key:"getRotation",value:function(){return this.rotation}},{key:"getRunningState",value:function(){return this.isRunning}},{key:"getVideoSize",value:function(){return{width:this.videoWidth,height:this.videoHeight}}},{key:"getConfig",value:function(){return this.config?k({},this.config):null}},{key:"getScale",value:function(){return this.canvas&&this.videoWidth?this.canvas.getBoundingClientRect().width/this.videoWidth:1}}]);var t,n,r,o}();ro.PointerEventButtonToAndroidButton=[Gi.Primary,Gi.Tertiary,Gi.Secondary,Gi.Back,Gi.Forward],exports.AndroidKeyCode=Vi,exports.AndroidKeyEventAction=ji,exports.AndroidMetaState={None:0,AltOn:2,AltLeftOn:16,AltRightOn:32,ShiftOn:1,ShiftLeftOn:64,ShiftRightOn:128,SymOn:4,FunctionOn:8,CtrlOn:4096,CtrlLeftOn:8192,CtrlRightOn:16384,MetaOn:65536,MetaLeftOn:131072,MetaRightOn:262144,CapsLockOn:1048576,NumLockOn:2097152,ScrollLockOn:4194304},exports.AndroidMotionEventAction=Fi,exports.AndroidMotionEventButton=Gi,exports.VmosEdgeClient=ro,exports.VmosEdgeClientEvents=to;