@vmosedge/web-sdk 1.0.3 → 1.0.4
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 +2 -2
- package/dist/index.es.js +1 -1
- package/dist/index.global.js +1 -1
- package/package.json +1 -1
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),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,
|
|
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,T(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(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 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;
|
|
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 _(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 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 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 _;if(x=!0,S=t.buffer,O=null!==(_=t.index)&&void 0!==_?_:0,S.length-O<A)throw new Error("Buffer too small")}else x=!1,S=new Uint8Array(A),O=0;var T,I={buffer:S,index:O,littleEndian:u},N=p(n.entries());try{for(N.s();!(T=N.n()).done;){var D=R(T.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 _e(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Te(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,Te(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,_e(n,0))}},e)})),Rt.apply(this,arguments)}var At,_t,Tt=function(){return k(k({},wt),{},{encoderName:void 0})}(),Mt=(At=ft,_t={action:Ne()},Se(Object.assign({},At.fields,_t),{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({},Tt),{},{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=_e(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(_(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(_(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,_n,Tn,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),_n.set(this,0),Tn.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,Tn,"f")}},{key:"bitPosition",get:function(){return kn(this,Mn,"f")}},{key:"ended",get:function(){return kn(this,Tn,"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,Tn,kn(this,Tn,"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,Tn,kn(this,Tn,"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,Tn,kn(this,Tn,"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,_n=new WeakMap,Tn=new WeakMap,Mn=new WeakMap,In=new WeakMap,Sn=new WeakSet,Nn=function e(){if(Cn(this,In,kn(this,On,"f")[kn(this,Tn,"f")],"f"),2===kn(this,_n,"f")&&3===kn(this,In,"f"))return Cn(this,_n,0,"f"),Cn(this,Tn,kn(this,Tn,"f")+1,"f"),void kn(this,Sn,"m",e).call(this);0===kn(this,In,"f")?Cn(this,_n,kn(this,_n,"f")+1,"f"):Cn(this,_n,0,"f")},Dn=function(){if(kn(this,Tn,"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,_n,"f"),bytePosition:kn(this,Tn,"f"),bitPosition:kn(this,Mn,"f"),byte:kn(this,In,"f")}},Wn=function(e){Cn(this,_n,e.zeroCount,"f"),Cn(this,Tn,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,_r=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(_(i.args)))}}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.listeners.length=0}}])}(),Tr=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,Tr),t}return g(e,_r),v(e,[{key:"addEventListener",value:function(t){var n;c(Mr,this)!==Tr&&(n=t.listener).call.apply(n,[t.thisArg,c(Mr,this)].concat(_(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",_i="blur",Ti="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(_i)}),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(Ti,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(Ti,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})}),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(Ti,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,n;if(this.isRunning){if(this.isRunning=!1,null===(e=this.stopVideoSubscription)||void 0===e||e.call(this),this.unbindInputEvents(),null===(t=this.textareaManager)||void 0===t||t.destroy(),this.emit(to.STOPPED),this.isGroupControl){var r,i=p(this.deviceTouchGroupMap.values());try{for(i.s();!(r=i.n()).done;){r.value.destroy()}}catch(e){i.e(e)}finally{i.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===(n=this.device)||void 0===n||n.destroy(),this.renderer){try{this.renderer.dispose()}catch(e){console.warn("[VmosEdgeClient] Renderer dispose error:",e)}this.renderer=null}if(this.decoder){try{var o,a;null===(o=this.decoder)||void 0===o||null===(a=o.dispose)||void 0===a||a.call(o)}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;
|