@vmosedge/web-sdk 1.0.1
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/README.md +50 -0
- package/dist/index.cjs.js +3 -0
- package/dist/index.es.js +3 -0
- package/dist/index.global.js +3 -0
- package/dist/types/index.d.ts +381 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Vmos Edge Web SDK
|
|
2
|
+
|
|
3
|
+
用于在 Web 端实现高性能 Android 设备远程控制的 SDK。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
* WebCodecs + WebGL 高性能低延迟视频渲染
|
|
8
|
+
* 完整的触摸事件支持(多指触控)
|
|
9
|
+
* 设备控制(按键、文本输入、剪贴板)
|
|
10
|
+
* 群控功能支持
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @vmosedge/web-sdk
|
|
16
|
+
# 或
|
|
17
|
+
pnpm add @vmosedge/web-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 使用
|
|
21
|
+
|
|
22
|
+
详细使用说明请参考 [SDK 文档](https://help.vmosedge.com/zh/sdk/web/)。
|
|
23
|
+
|
|
24
|
+
## 快速开始
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { VmosEdgeClient, VmosEdgeClientEvents } from "@vmosedge/web-sdk";
|
|
28
|
+
|
|
29
|
+
// 创建客户端实例
|
|
30
|
+
const client = new VmosEdgeClient({
|
|
31
|
+
container: document.getElementById("container")!,
|
|
32
|
+
config: {
|
|
33
|
+
ip: "192.168.1.100",
|
|
34
|
+
deviceId: "device_001",
|
|
35
|
+
ports: {
|
|
36
|
+
video: 8000,
|
|
37
|
+
touch: 8002,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// 监听连接成功事件
|
|
43
|
+
client.on(VmosEdgeClientEvents.STARTED, () => {
|
|
44
|
+
console.log("设备连接成功!");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// 启动连接
|
|
48
|
+
client.start();
|
|
49
|
+
```
|
|
50
|
+
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";function e(e,t){this.v=e,this.k=t}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function r(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,c,"next",e)}function c(e){r(a,i,o,s,c,"throw",e)}s(void 0)})}}function o(t){return new e(t,0)}function a(e,t,n){return t=y(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,g()?Reflect.construct(t,n||[],y(e).constructor):t.apply(e,n))}function s(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){return e.get(n(e,t))}function l(e,t,n){s(e,t),t.set(e,n)}function d(e,t,r){return e.set(n(e,t),r),r}function f(e,t){s(e,t),t.add(e)}function h(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,T(r.key),r)}}function p(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function v(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=R(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function _(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=y(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},m.apply(null,arguments)}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function b(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&S(e,t)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach(function(t){_(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function x(){
|
|
2
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
+
var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof s?r:s,u=Object.create(c.prototype);return k(u,"_invoke",function(n,r,i){var o,s,c,u=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,c=e,f.n=n,a}};function h(n,r){for(s=n,c=r,t=0;!d&&u&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,c=p;(t=s<2?e:c)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,c)):f.n=c:f.v=c);try{if(u=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==a)break}catch(t){o=e,s=1,c=t}finally{u=1}}return{value:t,done:d}}}(n,i,o),!0),u}var a={};function s(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(k(t={},r,function(){return this}),t),d=u.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,k(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=u,k(d,"constructor",u),k(u,"constructor",c),c.displayName="GeneratorFunction",k(u,i,"GeneratorFunction"),k(d),k(d,i,"Generator"),k(d,r,function(){return this}),k(d,"toString",function(){return"[object Generator]"}),(x=function(){return{w:o,m:f}})()}function k(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}k=function(e,t,n,r){function o(t,n){k(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},k(e,t,n,r)}function C(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},S(e,t)}function O(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||R(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t,n,r){var i=m(y(e.prototype),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function A(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||R(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function R(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function M(t){var n,r;function i(n,r){try{var a=t[n](r),s=a.value,c=s instanceof e;Promise.resolve(c?s.v:s).then(function(e){if(c){var r="return"===n?"return":"next";if(!s.k||e.done)return i(r,e);e=t[r](e).value}o(a.done?"return":"normal",e)},function(e){i("throw",e)})}catch(e){o("throw",e)}}function o(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?i(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(o,a){var s={key:e,arg:t,resolve:o,reject:a,next:null};r?r=r.next=s:(n=r=s,i(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}function P(e){var t="function"==typeof Map?new Map:void 0;return P=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(g())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&S(i,n.prototype),i}(e,arguments,y(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),S(n,e)},P(e)}M.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},M.prototype.next=function(e){return this._invoke("next",e)},M.prototype.throw=function(e){return this._invoke("throw",e)},M.prototype.return=function(e){return this._invoke("return",e)};var D=function(e,t){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},D(e,t)};function L(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}D(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var W,G=function(){return G=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},G.apply(this,arguments)};function B(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})}function U(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function V(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function H(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var z=function(){return p(function e(t,n,r,i){c(this,e),_(this,"optionValue",void 0),_(this,"metadataValue",void 0),_(this,"mimeType",void 0),_(this,"webCodecId",void 0),this.optionValue=t,this.metadataValue=n,this.mimeType=r,this.webCodecId=i},[{key:"toOptionValue",value:function(){return this.optionValue}}])}();_(z,"Opus",new(W=z)("opus",1869641075,"audio/opus","opus")),_(z,"Aac",new W("aac",6381923,"audio/aac","mp4a.66")),_(z,"Flac",new W("flac",1718378851,"audio/flac","flac")),_(z,"Raw",new W("raw",7496055,"audio/raw",""));var F=0,q=1,K=2,X=3,Y=4,J=5,Z=6,$=7,Q=8,ee=9,te=10,ne=11,re=12,ie=13,oe=14,ae=15,se=16,ce=17,ue=new WeakMap,le=new WeakSet,de=function(){return p(function e(){c(this,e),f(this,le),l(this,ue,[])},[{key:"parsers",get:function(){return u(ue,this)}},{key:"add",value:function(e){if(Array.isArray(e.id)){var t,r=v(e.id);try{for(r.s();!(t=r.n()).done;){var i=t.value;n(le,this,fe).call(this,i,e)}}catch(e){r.e(e)}finally{r.f()}}else n(le,this,fe).call(this,e.id,e);return e}},{key:"parse",value:(e=i(x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:if(r=u(ue,this)[t]){e.n=1;break}throw new Error("Unknown device message id ".concat(t));case 1:return e.a(2,r.parse(t,n))}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=v(u(ue,this));try{for(t.s();!(e=t.n()).done;){e.value.close()}}catch(e){t.e(e)}finally{t.f()}}},{key:"error",value:function(e){var t,n=v(u(ue,this));try{for(n.s();!(t=n.n()).done;){t.value.error(e)}}catch(e){n.e(e)}finally{n.f()}}}]);var e}();function fe(e,t){if(u(ue,this)[e])throw new Error("Duplicate parser for id ".concat(e));u(ue,this)[e]=t}function he(e,t){if(function(e){return"object"===I(e)&&null!==e&&"toOptionValue"in e&&"function"==typeof e.toOptionValue}(e)&&(e=e.toOptionValue()),void 0===e)return t;if("string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e)throw new TypeError("Invalid option value: ".concat(JSON.stringify(e)));return e.toString()}var pe=1748121140,ve=1748121141,_e=6387249,me=new WeakMap,ye=new WeakMap,be=new WeakMap,ge=new WeakMap,we=function(){return p(function e(){var t=this;c(this,e),l(this,me,void 0),l(this,ye,void 0),l(this,be,void 0),l(this,ge,"running"),_(this,"resolve",function(e){u(ye,t).call(t,e),d(ge,t,"resolved")}),_(this,"reject",function(e){u(be,t).call(t,e),d(ge,t,"rejected")}),d(me,this,new Promise(function(e,n){d(ye,t,e),d(be,t,n)}))},[{key:"promise",get:function(){return u(me,this)}},{key:"state",get:function(){return u(ge,this)}}])}();function Ee(e){return"object"===I(e)&&null!==e&&"then"in e}function xe(e,t){for(;;){var n=e.next(t),r=n.done,i=n.value;if(r)return i;if(Ee(i))return i.then(function(t){return xe(e,{resolved:t})},function(t){return xe(e,{error:t})});t=i}}function ke(e,t){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=e.call.apply(e,[this,x().m(function e(t){var n;return x().w(function(e){for(;;)switch(e.n){case 0:if(!Ee(t)){e.n=3;break}return e.n=1,t;case 1:if(!("resolved"in(n=e.v))){e.n=2;break}return e.a(2,n.resolved);case 2:throw n.error;case 3:return e.a(2,t)}},e)})].concat(n));return xe(i,void 0)}}function Ce(e,t){return function(n,r){var i;if("buffer"in r)return null!==(i=r.index)&&void 0!==i||(r.index=0),t(n,r),e;var o=new Uint8Array(e);return t(n,{buffer:o,index:0,littleEndian:r.littleEndian}),o}}var Se=function(e,t,n,r,i){var o,a={size:e,type:t,serialize:"default"===t?(o=n,function(e,t){if("buffer"in t){var n=o(e,t);return t.buffer.set(n,t.index),n.length}return o(e,t)}):Ce(e,n),deserialize:ke(r),omitInit:null==i?void 0:i.omitInit};return null!=i&&i.init&&(a.init=i.init),a},Oe=new Uint8Array(0);function Ne(e,t){var n,r,i,o,a,s,c,u,l;return"number"==typeof e?(0===e?(n=function(){},r=t?x().m(function e(){return x().w(function(e){for(;;)if(0===e.n)return e.a(2,t.convert(Oe))},e)}):x().m(function e(){return x().w(function(e){for(;;)if(0===e.n)return e.a(2,Oe)},e)})):(n=function(t,n){return function(e,t,n,r){t.length<r?(e.set(t,n),e.fill(0,n+t.length,n+r)):t.length===r?e.set(t,n):e.set(t.subarray(0,r),n)}(n.buffer,t,n.index,e)},t?(r=x().m(function n(r,i){var o,a;return x().w(function(n){for(;;)switch(n.n){case 0:return o=i.readExactly(e),a=t,n.d(C(r(o)),1);case 1:return n.a(2,a.convert.call(a,n.v))}},n)}),i=function(e){return t.back(e)}):r=x().m(function t(n,r){var i;return x().w(function(t){for(;;)if(0===t.n)return i=r.readExactly(e),t.a(2,i)},t)})),Se(e,"byob",n,r,{init:i})):"object"!==I(e)&&"function"!=typeof e||!("serialize"in e)?"string"==typeof e?(t?(s=function(n,r,i){var o=i.dependencies;return x().m(function i(){var a,s,c;return x().w(function(i){for(;;)switch(i.n){case 0:return a=o[e],s=0!==a?r.readExactly(a):Oe,c=t,i.d(C(n(s)),1);case 1:return i.a(2,c.convert.call(c,i.v))}},i)})()},c=function(n,r){var i=t.back(n);return r[e]=i.length,i}):(s=function(t,n,r){var i=r.dependencies;return x().m(function t(){var r,o;return x().w(function(t){for(;;)if(0===t.n)return r=i[e],o=0!==r?n.readExactly(r):Oe,t.a(2,o)},t)})()},c=function(t,n){var r=t;return n[e]=r.length,r}),Se(0,"default",function(e){return e},s,{init:c})):(t?(u=function(n,r,i){var o=i.dependencies;return x().m(function i(){var a,s,c,u;return x().w(function(i){for(;;)switch(i.n){case 0:return a=o[e.field],s=e.convert(a),c=0!==s?r.readExactly(s):Oe,u=t,i.d(C(n(c)),1);case 1:return i.a(2,u.convert.call(u,i.v))}},i)})()},l=function(n,r){var i=t.back(n);return r[e.field]=e.back(i.length),i}):(u=function(t,n,r){var i=r.dependencies;return x().m(function t(){var r,o,a;return x().w(function(t){for(;;)if(0===t.n)return r=i[e.field],o=e.convert(r),a=0!==o?n.readExactly(o):Oe,t.a(2,a)},t)})()},l=function(t,n){var r=t;return n[e.field]=e.back(r.length),r}),Se(0,"default",function(e){return e},u,{init:l})):(t?(o=x().m(function n(r,i,o){var a,s,c;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(r(e.deserialize(i,o))),1);case 1:return a=n.v,s=0!==a?i.readExactly(a):Oe,c=t,n.d(C(r(s)),2);case 2:return n.a(2,c.convert.call(c,n.v))}},n)}),a=function(e){return t.back(e)}):o=x().m(function t(n,r,i){var o,a;return x().w(function(t){for(;;)switch(t.n){case 0:return t.d(C(n(e.deserialize(r,i))),1);case 1:return o=t.v,a=0!==o?r.readExactly(o):Oe,t.a(2,a)}},t)}),Se(e.size,"default",function(t,n){var r=n.littleEndian;if("default"===e.type){var i=e.serialize(t.length,{littleEndian:r});if(0===t.length)return i;var o=new Uint8Array(i.length+t.length);return o.set(i,0),o.set(t,i.length),o}var a=new Uint8Array(e.size+t.length);return e.serialize(t.length,{buffer:a,index:0,littleEndian:r}),a.set(t,e.size),a},o,{init:a}))}var Ae=function(){function e(){return c(this,e),a(this,e,["ExactReadable ended"])}return b(e,P(Error)),p(e)}(),Te=function(){function e(t){return c(this,e),a(this,e,[t])}return b(e,P(Error)),p(e)}(),Ie=function(){function e(){return c(this,e),a(this,e,["The underlying readable was ended before the struct was fully deserialized"])}return b(e,Te),p(e)}(),Re=function(){function e(){return c(this,e),a(this,e,["The underlying readable doesn't contain any more struct"])}return b(e,Te),p(e)}();function Me(e,t){for(var n=Object.entries(e),r=0,i=!0,o=0,a=n;o<a.length;o++){var s=O(a[o],2)[1];r+=s.size,i&&"byob"!==s.type&&(i=!1)}var c=t.littleEndian,u=t.extra?Object.getOwnPropertyDescriptors(t.extra):void 0;return{littleEndian:c,fields:e,extra:t.extra,type:i?"byob":"default",size:r,serialize:function(e,t){for(var r=E({},e),i=0,o=n;i<o.length;i++){var a=O(o[i],2),s=a[0],u=a[1];if(s in r&&"init"in u){var l,d=null===(l=u.init)||void 0===l?void 0:l.call(u,r[s],r);r[s]=d}}var f,h=new Array(n.length),p=new Array(n.length),_={littleEndian:c},m=v(n.entries());try{for(m.s();!(f=m.n()).done;){var y=O(f.value,2),b=y[0],g=O(y[1],2),w=g[0],x=g[1];"byob"===x.type?h[b]=x.size:(p[b]=x.serialize(r[w],_),h[b]=p[b].length)}}catch(e){m.e(e)}finally{m.f()}var k,C,S,N=h.reduce(function(e,t){return e+t},0);if(t instanceof Uint8Array){if(t.length<N)throw new Error("Buffer too small");k=!0,C=t,S=0}else if("object"===I(t)&&"buffer"in t){var A;if(k=!0,C=t.buffer,S=null!==(A=t.index)&&void 0!==A?A:0,C.length-S<N)throw new Error("Buffer too small")}else k=!1,C=new Uint8Array(N),S=0;var T,R={buffer:C,index:S,littleEndian:c},M=v(n.entries());try{for(M.s();!(T=M.n()).done;){var P=O(T.value,2),D=P[0],L=O(P[1],2),W=L[0],G=L[1];p[D]?C.set(p[D],R.index):G.serialize(r[W],R),R.index+=h[D]}}catch(e){M.e(e)}finally{M.f()}return k?N:C},deserialize:ke(x().m(function e(r,i){var o,a,s,l,d,f,h,p,v;return x().w(function(e){for(;;)switch(e.p=e.n){case 0:o=i.position,s={dependencies:a={},littleEndian:c},e.p=1,l=0,d=n;case 2:if(!(l<d.length)){e.n=5;break}return f=O(d[l],2),h=f[0],p=f[1],e.d(C(r(p.deserialize(i,s))),3);case 3:a[h]=e.v;case 4:l++,e.n=2;break;case 5:e.n=9;break;case 6:if(e.p=6,(v=e.v)instanceof Ae){e.n=7;break}throw v;case 7:if(i.position!==o){e.n=8;break}throw new Re;case 8:throw new Ie;case 9:if(u&&Object.defineProperties(a,u),!t.postDeserialize){e.n=10;break}return e.a(2,t.postDeserialize.call(a,a));case 10:return e.a(2,a);case 11:return e.a(2)}},e,null,[[1,6]])}))}}function Pe(e,t,n){return n?(e[t]|e[t+1]<<8)<<16>>16:(e[t]<<8|e[t+1])<<16>>16}function De(e,t,n){return n?e[t]|e[t+1]<<8:e[t+1]|e[t]<<8}function Le(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}function We(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function Ge(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Be(e,t,n){return n?(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0:(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Ue(e,t,n){return n?BigInt(e[t])|BigInt(e[t+1])<<8n|BigInt(e[t+2])<<16n|BigInt(e[t+3])<<24n|BigInt(e[t+4])<<32n|BigInt(e[t+5])<<40n|BigInt(e[t+6])<<48n|BigInt(e[t+7])<<56n:BigInt(e[t])<<56n|BigInt(e[t+1])<<48n|BigInt(e[t+2])<<40n|BigInt(e[t+3])<<32n|BigInt(e[t+4])<<24n|BigInt(e[t+5])<<16n|BigInt(e[t+6])<<8n|BigInt(e[t+7])}function Ve(e,t,n){var r=function(){return r};return Object.assign(r,Se(e,"byob",t,n)),r}var je=Ve(1,function(e,t){t.buffer[t.index]=e},x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:return e.d(C(t(n.readExactly(1))),1);case 1:return r=e.v,e.a(2,r[0])}},e)})),He=Ve(2,function(e,t){Le(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(2))),1);case 1:return i=n.v,n.a(2,De(i,0,r))}},n)})()}),ze=Ve(4,function(e,t){!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8,e[t+2]=n>>16,e[t+3]=n>>24):(e[t]=n>>24,e[t+1]=n>>16,e[t+2]=n>>8,e[t+3]=n)}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(4))),1);case 1:return i=n.v,n.a(2,Be(i,0,r))}},n)})()}),Fe=Ve(8,function(e,t){!function(e,t,n,r){r?(e[t]=Number(0xffn&n),e[t+1]=Number(n>>8n&0xffn),e[t+2]=Number(n>>16n&0xffn),e[t+3]=Number(n>>24n&0xffn),e[t+4]=Number(n>>32n&0xffn),e[t+5]=Number(n>>40n&0xffn),e[t+6]=Number(n>>48n&0xffn),e[t+7]=Number(n>>56n&0xffn)):(e[t]=Number(n>>56n&0xffn),e[t+1]=Number(n>>48n&0xffn),e[t+2]=Number(n>>40n&0xffn),e[t+3]=Number(n>>32n&0xffn),e[t+4]=Number(n>>24n&0xffn),e[t+5]=Number(n>>16n&0xffn),e[t+6]=Number(n>>8n&0xffn),e[t+7]=Number(0xffn&n))}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(8))),1);case 1:return i=n.v,n.a(2,Ue(i,0,r))}},n)})()}),qe=globalThis.TextEncoder,Ke=globalThis.TextDecoder,Xe=new qe,Ye=new Ke;function Je(e){return Xe.encode(e)}function Ze(e){return Ye.decode(e)}var $e=function(e){var t=Ne(e,{convert:Ze,back:Je});return t.as=function(){return t},t},Qe=Me({type:je},{littleEndian:!1}),et=globalThis.AbortController,tt=function(){var e=globalThis.ReadableStream;return e.from||(e.from=function(t){var n=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return new e({pull:function(e){return i(x().m(function t(){var r;return x().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.next();case 1:if(!(r=t.v).done){t.n=2;break}return e.close(),t.a(2);case 2:e.enqueue(r.value);case 3:return t.a(2)}},t)}))()},cancel:function(e){return i(x().m(function t(){var r;return x().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,null===(r=n.return)||void 0===r?void 0:r.call(n,e);case 1:return t.a(2)}},t)}))()}})}),e.prototype[Symbol.asyncIterator]&&e.prototype.values||(e.prototype.values=function(){var e,t=(e=x().m(function e(t){var n,r,i,a;return x().w(function(e){for(;;)switch(e.p=e.n){case 0:n=this.getReader(),e.p=1;case 2:return e.n=3,o(n.read());case 3:if(r=e.v,i=r.done,a=r.value,!i){e.n=4;break}return e.a(2);case 4:return e.n=5,a;case 5:e.n=2;break;case 6:if(e.p=6,null!=t&&t.preventCancel){e.n=7;break}return e.n=7,o(n.cancel());case 7:return n.releaseLock(),e.f(6);case 8:return e.a(2)}},e,this,[[1,,6,8]])}),function(){return new M(e.apply(this,arguments))});return function(e){return t.apply(this,arguments)}}(),e.prototype[Symbol.asyncIterator]=e.prototype.values),e}(),nt=globalThis.WritableStream,rt=globalThis.TransformStream,it=function(){function e(t,n,r){var o;c(this,e);var s=!1,u=new et;return a(this,e,[{start:function(e){var n,a=t({abortSignal:u.signal,enqueue:(n=i(x().m(function t(n){return x().w(function(t){for(;;)switch(t.n){case 0:if(null==r||r({source:"producer",operation:"enqueue",value:n,phase:"start"}),!u.signal.aborted){t.n=1;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),t.a(2);case 1:if(null!==e.desiredSize){t.n=2;break}return e.enqueue(n),t.a(2);case 2:if(!s){t.n=3;break}return s=!1,e.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"}),t.a(2);case 3:if(!(e.desiredSize<=0)){t.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"waiting"}),o=new we,t.n=4,o.promise;case 4:if(!u.signal.aborted){t.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),t.a(2);case 5:e.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"});case 6:return t.a(2)}},t)})),function(e){return n.apply(this,arguments)}),close:function(){null==r||r({source:"producer",operation:"close",explicit:!0,phase:"start"}),u.signal.aborted?null==r||r({source:"producer",operation:"close",explicit:!0,phase:"ignored"}):(e.close(),null==r||r({source:"producer",operation:"close",explicit:!0,phase:"complete"}))},error:function(t){null==r||r({source:"producer",operation:"error",explicit:!0,phase:"start"}),e.error(t),null==r||r({source:"producer",operation:"error",explicit:!0,phase:"complete"})}});a&&"then"in a&&a.then(function(){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"start"});try{e.close(),null==r||r({source:"producer",operation:"close",explicit:!1,phase:"complete"})}catch(e){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"ignored"})}},function(t){null==r||r({source:"producer",operation:"error",explicit:!1,phase:"start"}),e.error(t),null==r||r({source:"producer",operation:"error",explicit:!1,phase:"complete"})})},pull:function(){null==r||r({source:"consumer",operation:"pull",phase:"start"}),o?o.resolve():0===(null==n?void 0:n.highWaterMark)&&(s=!0),null==r||r({source:"consumer",operation:"pull",phase:"complete"})},cancel:function(e){var t;null==r||r({source:"consumer",operation:"cancel",phase:"start"}),u.abort(e),null===(t=o)||void 0===t||t.resolve(),null==r||r({source:"consumer",operation:"cancel",phase:"complete"})}},n])}return b(e,tt),p(e)}();function ot(e){return at.apply(this,arguments)}function at(){return at=i(x().m(function e(t){return x().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.cancel();case 1:return e.a(2,!0);case 2:return e.p=2,e.v,e.a(2,!1)}},e,null,[[0,2]])})),at.apply(this,arguments)}var st=new WeakMap,ct=new WeakMap,ut=new WeakMap,lt=new WeakMap,dt=new WeakSet,ft=function(){return p(function e(t){c(this,e),f(this,dt),l(this,st,void 0),l(this,ct,0),l(this,ut,0),l(this,lt,0),_(this,"stream",void 0),_(this,"reader",void 0),_(this,"readExactly",ke(x().m(function e(t,r){var i,o,a,s;return x().w(function(e){for(;;)switch(e.n){case 0:if(o=0,!(a=n(dt,this,ht).call(this,r))){e.n=2;break}if(a.length!==r){e.n=1;break}return e.a(2,a);case 1:(i=new Uint8Array(r)).set(a,o),o+=a.length,r-=a.length,e.n=3;break;case 2:i=new Uint8Array(r);case 3:if(!(r>0)){e.n=5;break}return e.d(C(t(n(dt,this,pt).call(this,r))),4);case 4:s=e.v,i.set(s,o),o+=s.length,r-=s.length,e.n=3;break;case 5:return e.a(2,i)}},e,this)}))),this.stream=t,this.reader=t.getReader()},[{key:"position",get:function(){return u(lt,this)}},{key:"iterateExactly",value:function(e){var t=this,r=u(st,this)?0:1;return{next:function(){switch(r){case 0:var i=n(dt,t,ht).call(t,e);return i.length===e?r=2:(e-=i.length,r=1),{done:!1,value:i};case 1:return r=3,{done:!1,value:n(dt,t,pt).call(t,e).then(function(t){return t.length===e?r=2:(e-=t.length,r=1),t})};case 2:return{done:!0,value:void 0};case 3:throw new Error("Can't call `next` before previous Promise resolves");default:throw new Error("unreachable")}}}}},{key:"release",value:function(){var e=this;return u(ut,this)>0?new it(function(){var t=i(x().m(function t(n){var r,i,o,a;return x().w(function(t){for(;;)switch(t.n){case 0:return r=u(st,e).subarray(u(ct,e)),t.n=1,n.enqueue(r);case 1:n.abortSignal.addEventListener("abort",function(){ot(e.reader)});case 2:return t.n=3,e.reader.read();case 3:if(i=t.v,o=i.done,a=i.value,!o){t.n=4;break}return t.a(2);case 4:return t.n=5,n.enqueue(a);case 5:t.n=2;break;case 6:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()):(this.reader.releaseLock(),this.stream)}},{key:"cancel",value:(e=i(x().m(function e(t){return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.cancel(t);case 1:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}();function ht(e){if(u(st,this)){var t=u(st,this).subarray(u(ct,this),u(ct,this)+e);return u(ut,this)>e?(d(lt,this,u(lt,this)+e),d(ct,this,u(ct,this)+e),d(ut,this,u(ut,this)-e),t):(d(lt,this,u(lt,this)+u(ut,this)),d(st,this,void 0),d(ct,this,0),d(ut,this,0),t)}}function pt(e){return vt.apply(this,arguments)}function vt(){return(vt=i(x().m(function e(t){var n,r,i;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.read();case 1:if(n=e.v,r=n.done,i=n.value,!r){e.n=2;break}throw new Ae;case 2:if(!(i.length>t)){e.n=3;break}return d(st,this,i),d(ct,this,t),d(ut,this,i.length-t),d(lt,this,u(lt,this)+t),e.a(2,i.subarray(0,t));case 3:return d(lt,this,u(lt,this)+i.length),e.a(2,i)}},e,this)}))).apply(this,arguments)}var _t=new WeakMap,mt=new WeakMap,yt=function(){return p(function e(t){var n,r;c(this,e),l(this,_t,void 0),l(this,mt,void 0);var o=new ft(new it(function(e){n=e}));d(_t,this,new tt({pull:function(e){return i(x().m(function n(){var r,i;return x().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,t(o);case 1:r=n.v,e.enqueue(r),n.n=4;break;case 2:if(n.p=2,!((i=n.v)instanceof Re)){n.n=3;break}return e.close(),n.a(2);case 3:throw i;case 4:return n.a(2)}},n,null,[[0,2]])}))()},cancel:function(e){return r.error(e)}})),d(mt,this,new nt({start:function(e){r=e},write:function(e){return i(x().m(function t(){return x().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.enqueue(e);case 1:return t.a(2)}},t)}))()},abort:function(){n.close()},close:function(){n.close()}}))},[{key:"readable",get:function(){return u(_t,this)}},{key:"writable",get:function(){return u(mt,this)}}])}(),bt=function(){function e(t){return c(this,e),a(this,e,[function(e){return t.deserialize(e)}])}return b(e,yt),p(e)}(),gt=Qe,wt=Me({content:$e(ze)},{littleEndian:!1}),Et=new WeakMap,xt=function(){function e(){var t,n;return c(this,e),l(t=a(this,e,[function(e){n=e}]),Et,void 0),_(t,"id",0),d(Et,t,n),t}return b(e,it),p(e,[{key:"parse",value:(t=i(x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,wt.deserialize(n);case 1:return r=e.v,e.n=2,u(Et,this).enqueue(r.content);case 2:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"close",value:function(){u(Et,this).close()}},{key:"error",value:function(e){u(Et,this).error(e)}}]);var t}(),kt=function(){return[F,q,K,X,Y,J,$,Q,ee,te,ne]}();var Ct={repeatPreviousFrameAfter:"long",maxPtsGapToEncoder:"long"},St=function(){return p(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),_(this,"options",void 0);for(var n=0,r=Object.entries(t);n<r.length;n++){var i=O(r[n],2),o=i[0],a=i[1];if(void 0!==a&&"number"!=typeof a)throw new Error("Invalid option value for ".concat(o,": ").concat(String(a)))}this.options=t},[{key:"toOptionValue",value:function(){var e=Object.entries(this.options).filter(function(e){return void 0!==O(e,2)[1]});if(0!==e.length)return e.map(function(e){var t=O(e,2),n=t[0],r=t[1],i=n.replace(/([A-Z])/g,"-$1").toLowerCase(),o=Ct[n];return o&&(i+=":".concat(o)),i+="=".concat(r)}).join(",")}}])}();_(St,"Empty",new St);var Ot={logLevel:"debug",maxSize:0,bitRate:8e6,maxFps:0,lockVideoOrientation:-1,tunnelForward:!1,crop:void 0,sendFrameMeta:!0,control:!0,displayId:0,showTouches:!1,stayAwake:!1,codecOptions:void 0};function Nt(e,t,n){return e<t?t:e>n?n:e}function At(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Object.fromEntries(Object.entries(e).filter(function(e){var t=O(e,1)[0];return!n.includes(t)}))}var Tt=Se(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;Le(n,r,e=1===(e=Nt(e,-1,1))?65535:65536*e,i)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i,o;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(2))),1);case 1:return i=n.v,o=De(i,0,r),n.a(2,65535===o?1:o/65536)}},n)})()}),It=Me({pts:Fe,data:Ne(ze)},{littleEndian:!1}),Rt=1n<<63n;function Mt(e,t){return Pt.apply(this,arguments)}function Pt(){return Pt=i(x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(n);case 1:return r=e.v,e.a(2,Ze(r.subarray(0,r.indexOf(0))))}},e)})),Pt.apply(this,arguments)}function Dt(e){return Lt.apply(this,arguments)}function Lt(){return Lt=i(x().m(function e(t){var n;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(4);case 1:return n=e.v,e.a(2,Ge(n,0))}},e)})),Lt.apply(this,arguments)}var Wt,Gt,Bt=function(){return E(E({},Ot),{},{encoderName:void 0})}(),Ut=(Wt=gt,Gt={action:je()},Me(Object.assign({},Wt.fields,Gt),{littleEndian:Wt.littleEndian,extra:Wt.extra,postDeserialize:void 0}));var Vt=function(){var e=kt.slice();return e.splice(6,0,Z),e}(),jt=-1,Ht=function(){return E(E({},Bt),{},{logLevel:"debug",lockVideoOrientation:jt,powerOffOnClose:!1})}(),zt=function(){return E(E({},Ht),{},{clipboardAutosync:!0})}();function Ft(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase()}var qt=Me({sequence:Fe},{littleEndian:!1}),Kt=Me({type:je,sequence:Fe,paste:je(),content:$e(ze)},{littleEndian:!1}),Xt=new WeakMap,Yt=new WeakMap,Jt=function(){return p(function e(){c(this,e),l(this,Xt,new Map),l(this,Yt,!1),_(this,"id",1)},[{key:"parse",value:(e=i(x().m(function e(t,n){var r,i;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,qt.deserialize(n);case 1:r=e.v,(i=u(Xt,this).get(r.sequence))&&(i.resolve(),u(Xt,this).delete(r.sequence));case 2:return e.a(2)}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=v(u(Xt,this).values());try{for(t.s();!(e=t.n()).done;){e.value.reject()}}catch(e){t.e(e)}finally{t.f()}u(Xt,this).clear(),d(Yt,this,!0)}},{key:"error",value:function(e){var t,n=v(u(Xt,this).values());try{for(n.s();!(t=n.n()).done;){t.value.reject(e)}}catch(e){n.e(e)}finally{n.f()}u(Xt,this).clear(),d(Yt,this,!0)}},{key:"serializeSetClipboardControlMessage",value:function(e){if(0n===e.sequence)return Kt.serialize(e);if(u(Yt,this))throw new Error;var t=new we;return u(Xt,this).set(e.sequence,t),[Kt.serialize(e),t.promise]}}]);var e}(),Zt=function(){return E(E({},zt),{},{downsizeOnError:!0,sendDeviceMeta:!0,sendDummyByte:!0})}(),$t=function(){return E(E({},Zt),{},{cleanup:!0})}(),Qt=1n<<62n;var en=function(){return E(E({},$t),{},{powerOn:!0})}(),tn=Se(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}(n,r,e=1===(e=Nt(e,-1,1))?32767:32768*e,i)},function(e,t,n){var r=n.littleEndian;return x().m(function n(){var i,o;return x().w(function(n){for(;;)switch(n.n){case 0:return n.d(C(e(t.readExactly(2))),1);case 1:return i=n.v,o=Pe(i,0,r),n.a(2,32767===o?1:o/32768)}},n)})()}),nn=function(){return Me({type:je(X),pointerX:ze,pointerY:ze,videoWidth:He,videoHeight:He,scrollX:tn,scrollY:tn,buttons:ze},{littleEndian:!1})}(),rn=function(){return E(E({},At(en,"bitRate","codecOptions","encoderName")),{},{scid:void 0,videoCodec:"h264",videoBitRate:8e6,videoCodecOptions:void 0,videoEncoder:void 0,audio:!0,audioCodec:"opus",audioBitRate:128e3,audioCodecOptions:void 0,audioEncoder:void 0,listEncoders:!1,listDisplays:!1,sendCodecMeta:!0})}(),on=function(){return Me({type:je(K),action:je(),pointerId:Fe,pointerX:ze,pointerY:ze,videoWidth:He,videoHeight:He,pressure:Tt,actionButton:ze,buttons:ze},{littleEndian:!1})}();function an(){return an=i(x().m(function e(t,n){var r,o,a,s,c,u,l,d;return x().w(function(e){for(;;)switch(e.n){case 0:return r=new ft(t),e.n=1,r.readExactly(4);case 1:o=e.v,a=Ge(o,0),u=a,e.n=0===u?2:1===u?3:4;break;case 2:return e.a(2,{type:"disabled"});case 3:return e.a(2,{type:"errored"});case 4:if(!n.sendCodecMeta){e.n=11;break}l=a,e.n=l===z.Raw.metadataValue?5:l===z.Opus.metadataValue?6:l===z.Aac.metadataValue?7:l===z.Flac.metadataValue?8:9;break;case 5:return s=z.Raw,e.a(3,10);case 6:return s=z.Opus,e.a(3,10);case 7:return s=z.Aac,e.a(3,10);case 8:return s=z.Flac,e.a(3,10);case 9:case 16:throw new Error("Unknown audio codec metadata value: ".concat(a));case 10:return e.a(2,{type:"success",codec:s,stream:r.release()});case 11:d=n.audioCodec,e.n="raw"===d?12:"opus"===d?13:"aac"===d?14:"flac"===d?15:16;break;case 12:return c=z.Raw,e.a(3,17);case 13:return c=z.Opus,e.a(3,17);case 14:return c=z.Aac,e.a(3,17);case 15:return c=z.Flac,e.a(3,17);case 17:return e.a(2,{type:"success",codec:c,stream:new it(function(){var e=i(x().m(function e(t){var n,i,a,s,c;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.enqueue(o);case 1:n=r.release(),i=n.getReader();case 2:return e.n=3,i.read();case 3:if(a=e.v,s=a.done,c=a.value,!s){e.n=4;break}return e.a(3,6);case 4:return e.n=5,t.enqueue(c);case 5:e.n=2;break;case 6:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}())})}},e)})),an.apply(this,arguments)}function sn(e){switch(e){case"h264":return pe;case"h265":return ve;case"av1":return _e;default:throw new Error("Unknown video codec: ".concat(e))}}function cn(){return cn=i(x().m(function e(t,n){var r,i,o,a,s;return x().w(function(e){for(;;)switch(e.n){case 0:if(r=new ft(n),!t.sendDeviceMeta){e.n=2;break}return e.n=1,Mt(r,64);case 1:i=e.v;case 2:if(!t.sendCodecMeta){e.n=6;break}return e.n=3,Dt(r);case 3:return o=e.v,e.n=4,Dt(r);case 4:return a=e.v,e.n=5,Dt(r);case 5:s=e.v,e.n=7;break;case 6:o=sn(t.videoCodec);case 7:return e.a(2,{stream:r.release(),metadata:{deviceName:i,codec:o,width:a,height:s}})}},e)})),cn.apply(this,arguments)}function un(e,t){return e.sendDeviceMeta||e.sendCodecMeta?function(e,t){return cn.apply(this,arguments)}(e,t):{stream:t,metadata:{codec:sn(e.videoCodec)}}}var ln=function(){return E(E({},rn),{},{video:!0,audioSource:"output"})}(),dn=function(){return E(E({},ln),{},{videoSource:"display",displayId:0,cameraId:void 0,cameraSize:void 0,cameraFacing:void 0,cameraAr:void 0,cameraFps:void 0,cameraHighSpeed:!1,listCameras:!1,listCameraSizes:!1})}();var fn=function(){return[].concat(A(Vt),[re,ie,ae])}(),hn=Me({id:He,data:Ne(He)},{littleEndian:!1}),pn=new WeakMap,vn=function(){function e(){var t,n;return c(this,e),l(t=a(this,e,[function(e){n=e}]),pn,void 0),_(t,"id",2),d(pn,t,n),t}return b(e,it),p(e,[{key:"parse",value:(t=i(x().m(function e(t,n){var r;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,hn.deserialize(n);case 1:return r=e.v,e.n=2,u(pn,this).enqueue(r);case 2:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"close",value:function(){u(pn,this).close()}},{key:"error",value:function(e){u(pn,this).error(e)}}]);var t}(),_n=function(){return E(E({},dn),{},{audioDup:!1})}(),mn=function(){var e=fn.slice();return e.splice(14,0,oe),e}(),yn=function(){return[].concat(A(mn),[se,ce])}(),bn=function(){return E(E({},At(_n,"lockVideoOrientation")),{},{captureOrientation:void 0,angle:0,screenOffTimeout:void 0,listApps:!1,newDisplay:void 0,vdSystemDecorations:!0})}(),gn=/^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder=(\S+)(?:\s*\((sw|hw|hybrid)\))?(?:\s*\[vendor\])?(?:\s*\(alias for (\S+)\))?$/;function wn(e){switch(e){case"sw":return"software";case"hw":return"hardware";case"hybrid":return"hybrid";default:throw new Error("Unknown hardware type: ".concat(e))}}var En=function(){return E(E({},bn),{},{vdDestroyContent:!1})}(),xn=Me({type:je,id:He,vendorId:He,productId:He,name:$e(je),data:Ne(He)},{littleEndian:!1});var kn=function(){return E(E({},En),{},{displayImePolicy:void 0})}(),Cn=function(){return p(function e(){c(this,e)},[{key:"serializeScrollMessage",value:function(e){return e=E(E({},e),{},{scrollX:e.scrollX/16,scrollY:e.scrollY/16}),nn.serialize(e)}}])}();var Sn=new WeakMap,On=new WeakMap,Nn=new WeakMap,An=new WeakMap,Tn=function(){return p(function e(t){c(this,e),_(this,"value",void 0),l(this,Sn,void 0),l(this,On,void 0),l(this,Nn,void 0),l(this,An,new de),this.value=E(E({},kn),t),"camera"===this.value.videoSource&&(this.value.control=!1),this.value.audioDup&&(this.value.audioSource="playback"),this.value.control&&(this.value.clipboardAutosync&&(d(Sn,this,u(An,this).add(new xt)),d(On,this,u(An,this).add(new Jt))),d(Nn,this,u(An,this).add(new vn)))},[{key:"controlMessageTypes",get:function(){return yn}},{key:"clipboard",get:function(){return u(Sn,this)}},{key:"uHidOutput",get:function(){return u(Nn,this)}},{key:"deviceMessageParsers",get:function(){return u(An,this)}},{key:"serialize",value:function(){return function(e,t){for(var n=[],r=0,i=Object.entries(e);r<i.length;r++){var o=O(i[r],2),a=o[0],s=he(o[1],void 0);void 0!==s&&s!==he(t[a],void 0)&&n.push("".concat(Ft(a),"=").concat(s))}return n}(this.value,kn)}},{key:"setListDisplays",value:function(){this.value.listDisplays=!0}},{key:"parseDisplay",value:function(e){return function(e){var t=e.match(/^\s+--display-id=(\d+)\s+\(([^)]+)\)$/);if(t){var n={id:Number.parseInt(t[1],10)};return"size unknown"!==t[2]&&(n.resolution=t[2]),n}}(e)}},{key:"setListEncoders",value:function(){this.value.listEncoders=!0}},{key:"parseEncoder",value:function(e){return function(e){var t=e.match(gn);return t?{type:t[1],name:t[3],codec:t[2],hardwareType:t[4]?wn(t[4]):void 0,vendor:!!t[5],aliasFor:t[6]}:void 0}(e)}},{key:"parseVideoStreamMetadata",value:function(e){return un(this.value,e)}},{key:"parseAudioStreamMetadata",value:function(e){return function(e,t){return an.apply(this,arguments)}(e,this.value)}},{key:"createMediaStreamTransformer",value:function(){return function(e){if(!e.sendFrameMeta)return new rt({transform:function(e,t){t.enqueue({type:"data",data:e})}});var t=new bt(It);return{writable:t.writable,readable:t.readable.pipeThrough(new rt({transform:function(e,t){e.pts!==Rt?e.pts&Qt?t.enqueue({type:"data",keyframe:!0,pts:e.pts&~Qt,data:e.data}):t.enqueue({type:"data",keyframe:!1,pts:e.pts,data:e.data}):t.enqueue({type:"configuration",data:e.data})}}))}}(this.value)}},{key:"serializeInjectTouchControlMessage",value:function(e){return function(e){return on.serialize(e)}(e)}},{key:"serializeBackOrScreenOnControlMessage",value:function(e){return function(e){return Ut.serialize(e)}(e)}},{key:"serializeSetClipboardControlMessage",value:function(e){return u(On,this).serializeSetClipboardControlMessage(e)}},{key:"createScrollController",value:function(){return new Cn}},{key:"serializeUHidCreateControlMessage",value:function(e){return function(e){return xn.serialize(e)}(e)}}])}();_(Tn,"Defaults",kn);var In=new WeakMap,Rn=new WeakMap,Mn=new WeakMap,Pn=new WeakMap,Dn=function(){return p(function e(t){c(this,e),l(this,In,void 0),l(this,Rn,void 0),l(this,Mn,0),l(this,Pn,7),d(In,this,t),d(Rn,this,t[0])},[{key:"byteAligned",get:function(){return 7===u(Pn,this)}},{key:"ended",get:function(){return u(Mn,this)>=u(In,this).length}},{key:"f1",value:function(){var e=u(Rn,this)>>u(Pn,this);return d(Pn,this,u(Pn,this)-1),u(Pn,this)<0&&(d(Mn,this,u(Mn,this)+1),d(Pn,this,7),d(Rn,this,u(In,this)[u(Mn,this)])),1&e}},{key:"f",value:function(e){for(var t=0;e>0;e-=1)t<<=1,t|=this.f1();return t}},{key:"skip",value:function(e){if(e<=u(Pn,this)+1)return d(Mn,this,u(Mn,this)+1),d(Pn,this,7),void d(Rn,this,u(In,this)[u(Mn,this)]);e-=u(Pn,this)+1,d(Mn,this,u(Mn,this)+1);var t=e/8|0;t>0&&(d(Mn,this,u(Mn,this)+t),e-=8*t),d(Pn,this,7-e),d(Rn,this,u(In,this)[u(Mn,this)])}},{key:"readBytes",value:function(e){if(!this.byteAligned)throw new Error("Bytes must be byte-aligned");var t=u(In,this).subarray(u(Mn,this),u(Mn,this)+e);return d(Mn,this,u(Mn,this)+e),d(Rn,this,u(In,this)[u(Mn,this)]),t}},{key:"getPosition",value:function(){return[u(Mn,this),u(Pn,this)]}},{key:"setPosition",value:function(e){var t=O(e,2),n=t[0],r=t[1];d(Mn,this,n),d(Pn,this,r),d(Rn,this,u(In,this)[n])}}])}(),Ln=new WeakMap,Wn=new WeakMap,Gn=function(){function e(){var t;c(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return l(t=a(this,e,[].concat(r)),Ln,0),l(t,Wn,0),t}return b(e,Dn),p(e,[{key:"uvlc",value:function(){for(var e=0;!this.f1();)e+=1;return e>=32?Math.pow(2,32)-1:this.f(e)+(1<<e>>>0)-1}},{key:"leb128",value:function(){if(!this.byteAligned)throw new Error("LEB128 must be byte-aligned");var e=0n;d(Ln,this,0);for(var t=0n;t<8n;t+=1n){var n=this.f(8);if(e|=BigInt(127&n)<<7n*t,d(Ln,this,u(Ln,this)+1),!(128&n))break}return e}},{key:"annexBBitstream",value:x().m(function e(){var t;return x().w(function(e){for(;;)switch(e.n){case 0:if(this.ended){e.n=2;break}return t=this.leb128(),e.d(C(this.temporalUnit(t)),1);case 1:e.n=0;break;case 2:return e.a(2)}},e,this)})},{key:"temporalUnit",value:x().m(function e(t){var n;return x().w(function(e){for(;;)switch(e.n){case 0:if(!(t>0)){e.n=2;break}return n=this.leb128(),t-=BigInt(u(Ln,this)),e.d(C(this.frameUnit(n)),1);case 1:t-=n,e.n=0;break;case 2:return e.a(2)}},e,this)})},{key:"frameUnit",value:x().m(function e(t){var n,r;return x().w(function(e){for(;;)switch(e.n){case 0:if(!(t>0)){e.n=2;break}if(n=this.leb128(),t-=BigInt(u(Ln,this)),!(r=this.openBitstreamUnit(n))){e.n=1;break}return e.n=1,r;case 1:t-=n,e.n=0;break;case 2:return e.a(2)}},e,this)})},{key:"openBitstreamUnit",value:function(t){var n,r=this.obuHeader();if(r.obu_has_size_field)n=this.leb128();else{if(void 0===t)throw new Error("obu_has_size_field must be true");n=t-1n-(r.obu_extension_flag?1n:0n)}var i,o=this.getPosition();if(r.obu_type!==e.ObuType.SequenceHeader&&r.obu_type!==e.ObuType.TemporalDelimiter&&0!==u(Wn,this)&&r.obu_extension_header){var a=!!(u(Wn,this)&1<<r.obu_extension_header.temporal_id),s=!!(u(Wn,this)&1<<r.obu_extension_header.spatial_id+8);if(!a||!s)return void this.skip(Number(n))}if(r.obu_type===e.ObuType.SequenceHeader)i=this.sequenceHeaderObu();var c=this.getPosition(),l=8*(c[0]-o[0])+(o[1]-c[1]);return n>0&&this.skip(8*Number(n)-l),{obu_header:r,obu_size:n,sequence_header_obu:i}}},{key:"obuHeader",value:function(){if(!!this.f1())throw new Error("Invalid data");var e,t=this.f(4),n=!!this.f1(),r=!!this.f1();return this.f1(),n&&(e=this.obuExtensionHeader()),{obu_type:t,obu_extension_flag:n,obu_has_size_field:r,obu_extension_header:e}}},{key:"obuExtensionHeader",value:function(){var e=this.f(3),t=this.f(2);return this.skip(3),{temporal_id:e,spatial_id:t}}},{key:"sequenceHeaderObu",value:function(){var t,n,r,i,o=this.f(3),a=!!this.f1(),s=!!this.f1(),c=!1,u=!1,l=!1,f=0,h=[],p=[],v=[],_=[],m=[];if(s)h[0]=0,p[0]=this.f(5),v[0]=0,_[0]=!1,m[0]=!1;else{(c=!!this.f1())&&(t=this.timingInfo(),(u=!!this.f1())&&(n=this.decoderModelInfo(),r=[])),(l=!!this.f1())&&(i=[]),f=this.f(5);for(var y=0;y<=f;y+=1)h[y]=this.f(12),p[y]=this.f(5),p[y]>7?v[y]=this.f1():v[y]=0,u?(_[y]=!!this.f1(),_[y]&&(r[y]=this.operatingParametersInfo(n))):_[y]=!1,l&&(m[y]=!!this.f1(),m[y]&&(i[y]=this.f(4)))}var b=this.chooseOperatingPoint();d(Wn,this,h[b]);var g,w,E=this.f(4),x=this.f(4),k=this.f(E+1),C=this.f(x+1),S=!1;s||(S=!!this.f1())&&(g=this.f(4),w=this.f(3));var O,N=!!this.f1(),A=!!this.f1(),T=!!this.f1(),I=!1,R=!1,M=!1,P=!1,D=!1,L=!1,W=!1,G=!1,B=e.SelectScreenContentTools,U=!1,V=e.SelectIntegerMv;return s||(I=!!this.f1(),R=!!this.f1(),M=!!this.f1(),P=!!this.f1(),(D=!!this.f1())&&(L=!!this.f1(),W=!!this.f1()),(G=!!this.f1())||(B=this.f1()),B>0&&((U=!!this.f1())||(V=this.f1())),D&&(O=this.f(3))),{seq_profile:o,still_picture:a,reduced_still_picture_header:s,timing_info_present_flag:c,timing_info:t,decoder_model_info_present_flag:u,decoder_model_info:n,initial_display_delay_present_flag:l,initial_display_delay_minus_1:i,operating_points_cnt_minus_1:f,operating_point_idc:h,seq_level_idx:p,seq_tier:v,decoder_model_present_for_this_op:_,operating_parameters_info:r,initial_display_delay_present_for_this_op:m,frame_width_bits_minus_1:E,frame_height_bits_minus_1:x,max_frame_width_minus_1:k,max_frame_height_minus_1:C,frame_id_numbers_present_flag:S,delta_frame_id_length_minus_2:g,additional_frame_id_length_minus_1:w,use_128x128_superblock:N,enable_filter_intra:A,enable_intra_edge_filter:T,enable_interintra_compound:I,enable_masked_compound:R,enable_warped_motion:M,enable_dual_filter:P,enable_order_hint:D,enable_jnt_comp:L,enable_ref_frame_mvs:W,seq_choose_screen_content_tools:G,seq_force_screen_content_tools:B,seq_choose_integer_mv:U,seq_force_integer_mv:V,order_hint_bits_minus_1:O,enable_superres:!!this.f1(),enable_cdef:!!this.f1(),enable_restoration:!!this.f1(),color_config:this.colorConfig(o),film_grain_params_present:!!this.f1()}}},{key:"searchSequenceHeaderObu",value:function(){for(;!this.ended;){var e=this.openBitstreamUnit();if(e&&e.sequence_header_obu)return e.sequence_header_obu}}},{key:"timingInfo",value:function(){var e,t=this.f(32),n=this.f(32),r=!!this.f1();return r&&(e=this.uvlc()),{num_units_in_display_tick:t,time_scale:n,equal_picture_interval:r,num_ticks_per_picture_minus_1:e}}},{key:"decoderModelInfo",value:function(){return{buffer_delay_length_minus_1:this.f(5),num_units_in_decoding_tick:this.f(32),buffer_removal_time_length_minus_1:this.f(5),frame_presentation_time_length_minus_1:this.f(5)}}},{key:"operatingParametersInfo",value:function(e){var t=e.buffer_delay_length_minus_1+1;return{decoder_buffer_delay:this.f(t),encoder_buffer_delay:this.f(t),low_delay_mode_flag:!!this.f1()}}},{key:"chooseOperatingPoint",value:function(){return 0}},{key:"colorConfig",value:function(t){var n=!!this.f1(),r=!1,i=8;2===t&&n?i=(r=!!this.f1())?12:10:t<=2&&(i=n?10:8);var o=!1;1===t&&(o=!!this.f1());var a=!!this.f1(),s=e.ColorPrimaries.Unspecified,c=e.TransferCharacteristics.Unspecified,u=e.MatrixCoefficients.Unspecified;a&&(s=this.f(8),c=this.f(8),u=this.f(8));var l,d,f=!1,h=0,p=!1;if(o)f=!!this.f1(),l=!0,d=!0;else{if(s===e.ColorPrimaries.Bt709&&c===e.TransferCharacteristics.Srgb&&u===e.MatrixCoefficients.Identity)f=!0,l=!1,d=!1;else{switch(f=!!this.f1(),t){case 0:l=!0,d=!0;break;case 1:l=!1,d=!1;break;default:12==i?d=!!(l=!!this.f1())&&!!this.f1():(l=!0,d=!1)}l&&d&&(h=this.f(2))}p=!!this.f1()}return{high_bitdepth:n,twelve_bit:r,BitDepth:i,mono_chrome:o,color_description_present_flag:a,color_primaries:s,transfer_characteristics:c,matrix_coefficients:u,color_range:f,subsampling_x:l,subsampling_y:d,chroma_sample_position:h,separate_uv_delta_q:p}}}])}();_(Gn,"ObuType",{SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15}),_(Gn,"ColorPrimaries",{Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22}),_(Gn,"TransferCharacteristics",{Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,Linear:8,Log100:9,Log100Sqrt10:10,Iec61966:11,Bt1361:12,Srgb:13,Bt2020Ten:14,Bt2020Twelve:15,Smpte2084:16,Smpte428:17,Hlg:18}),_(Gn,"MatrixCoefficients",{Identity:0,Bt709:1,Unspecified:2,Fcc:4,Bt470BG:5,Bt601:6,Smpte240:7,YCgCo:8,Bt2020Ncl:9,Bt2020Cl:10,Smpte2085:11,ChromatNcl:12,ChromatCl:13,ICtCp:14}),_(Gn,"SelectScreenContentTools",2),_(Gn,"SelectIntegerMv",2);var Bn=x().m(Un);function Un(e){var t,n,r,i,o,a,s;return x().w(function(c){for(;;)switch(c.n){case 0:t=-1,n=0,r=!1,i=0;case 1:if(!(i<e.length)){c.n=15;break}if(o=e[i],!r){c.n=3;break}if(!(o>3)){c.n=2;break}throw new Error("Invalid data");case 2:return r=!1,c.a(3,14);case 3:if(0!==o){c.n=4;break}return n+=1,c.a(3,14);case 4:if(a=n,n=0,-1!==t){c.n=6;break}if(!(a>=2&&1===o)){c.n=5;break}return t=i+1,c.a(3,14);case 5:throw new Error("Invalid data");case 6:if(!(a<2)){c.n=7;break}return c.a(3,14);case 7:if(1!==o){c.n=9;break}return c.n=8,e.subarray(t,i-a);case 8:return t=i+1,c.a(3,14);case 9:if(!(a>2)){c.n=10;break}throw new Error("Invalid data");case 10:s=o,c.n=2===s?11:3===s?12:13;break;case 11:throw new Error("Invalid data");case 12:return r=!0,c.a(3,14);case 13:return c.a(3,14);case 14:i+=1,c.n=1;break;case 15:if(!r){c.n=16;break}throw new Error("Invalid data");case 16:return c.n=17,e.subarray(t,e.length);case 17:return c.a(2)}},Bn)}var Vn=new WeakMap,jn=new WeakMap,Hn=new WeakMap,zn=new WeakMap,Fn=new WeakMap,qn=new WeakMap,Kn=new WeakMap,Xn=new WeakSet,Yn=function(){return p(function e(t){c(this,e),f(this,Xn),l(this,Vn,void 0),l(this,jn,void 0),l(this,Hn,void 0),l(this,zn,0),l(this,Fn,0),l(this,qn,7),l(this,Kn,0),d(Vn,this,t);for(var r=t.length-1;r>=0;r-=1)if(0!==u(Vn,this)[r])for(var i=t[r],o=0;o<8;o+=1)if(1==(i>>o&1))return d(jn,this,r),d(Hn,this,o),void n(Xn,this,Jn).call(this);throw new Error("Stop bit not found")},[{key:"byteLength",get:function(){return u(jn,this)}},{key:"stopBitIndex",get:function(){return u(Hn,this)}},{key:"bytePosition",get:function(){return u(Fn,this)}},{key:"bitPosition",get:function(){return u(qn,this)}},{key:"ended",get:function(){return u(Fn,this)>=u(jn,this)&&u(qn,this)<=u(Hn,this)}},{key:"next",value:function(){if(this.ended)throw new Error("Bit index out of bounds");var e=u(Kn,this)>>u(qn,this)&1;return d(qn,this,u(qn,this)-1),u(qn,this)<0&&(d(Fn,this,u(Fn,this)+1),d(qn,this,7),n(Xn,this,Jn).call(this)),e}},{key:"read",value:function(e){if(e>32)throw new Error("Read length too large");for(var t=0,n=0;n<e;n+=1)t=t<<1|this.next();return t}},{key:"skip",value:function(e){if(e<=u(qn,this)+1)return d(qn,this,u(qn,this)-e),void n(Xn,this,Zn).call(this);for(e-=u(qn,this)+1,d(Fn,this,u(Fn,this)+1),d(qn,this,7),n(Xn,this,Jn).call(this),n(Xn,this,Zn).call(this);e>=8;e-=8)d(Fn,this,u(Fn,this)+1),n(Xn,this,Jn).call(this),n(Xn,this,Zn).call(this);d(qn,this,7-e),n(Xn,this,Zn).call(this)}},{key:"decodeExponentialGolombNumber",value:function(){for(var e=0;0===this.next();)e+=1;return 0===e?0:(1<<e|this.read(e))-1}},{key:"peek",value:function(e){var t=n(Xn,this,$n).call(this),r=this.read(e);return n(Xn,this,Qn).call(this,t),r}},{key:"readBytes",value:function(e){for(var t=new Uint8Array(e),n=0;n<e;n+=1)t[n]=this.read(8);return t}},{key:"peekBytes",value:function(e){var t=n(Xn,this,$n).call(this),r=this.readBytes(e);return n(Xn,this,Qn).call(this,t),r}}])}();function Jn(){if(d(Kn,this,u(Vn,this)[u(Fn,this)]),2===u(zn,this)&&3===u(Kn,this))return d(zn,this,0),d(Fn,this,u(Fn,this)+1),void n(Xn,this,Jn).call(this);0===u(Kn,this)?d(zn,this,u(zn,this)+1):d(zn,this,0)}function Zn(){if(u(Fn,this)>=u(jn,this)&&u(qn,this)<u(Hn,this))throw new Error("Bit index out of bounds")}function $n(){return{zeroCount:u(zn,this),bytePosition:u(Fn,this),bitPosition:u(qn,this),byte:u(Kn,this)}}function Qn(e){d(zn,this,e.zeroCount),d(Fn,this,e.bytePosition),d(qn,this,e.bitPosition),d(Kn,this,e.byte)}function er(e){var t=function(e){var t,n,r,i=v(Un(e));try{for(i.s();!(r=i.n()).done;){var o=r.value;switch(31&o[0]){case 7:if(t=o,n)return{sequenceParameterSet:t,pictureParameterSet:n};break;case 8:if(n=o,t)return{sequenceParameterSet:t,pictureParameterSet:n}}}}catch(e){i.e(e)}finally{i.f()}throw new Error("Invalid data")}(e),n=t.sequenceParameterSet,r=t.pictureParameterSet,i=function(e){var t=new Yn(e);if(0!==t.next())throw new Error("Invalid data");var n=t.read(2);if(7!==t.read(5))throw new Error("Invalid data");if(0===n)throw new Error("Invalid data");var r=t.read(8),i=t.peek(8),o=!!t.next(),a=!!t.next(),s=!!t.next(),c=!!t.next(),u=!!t.next(),l=!!t.next();if(0!==t.read(2))throw new Error("Invalid data");var d=t.read(8),f=t.decodeExponentialGolombNumber();if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||139===r||134===r){var h=t.decodeExponentialGolombNumber();if(3===h&&t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber(),t.next(),t.next())for(var p=[],v=0;v<(3!==h?8:12);v+=1)p[v]=!!t.next(),p[v]}t.decodeExponentialGolombNumber();var _=t.decodeExponentialGolombNumber();if(0===_)t.decodeExponentialGolombNumber();else if(1===_){t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber();for(var m=t.decodeExponentialGolombNumber(),y=[],b=0;b<m;b+=1)y[b]=t.decodeExponentialGolombNumber()}t.decodeExponentialGolombNumber(),t.next();var g=t.decodeExponentialGolombNumber(),w=t.decodeExponentialGolombNumber(),E=t.next();E||t.next(),t.next();var x,k,C,S,O=!!t.next();return O?(x=t.decodeExponentialGolombNumber(),k=t.decodeExponentialGolombNumber(),C=t.decodeExponentialGolombNumber(),S=t.decodeExponentialGolombNumber()):(x=0,k=0,C=0,S=0),t.next(),{profile_idc:r,constraint_set:i,constraint_set0_flag:o,constraint_set1_flag:a,constraint_set2_flag:s,constraint_set3_flag:c,constraint_set4_flag:u,constraint_set5_flag:l,level_idc:d,seq_parameter_set_id:f,pic_width_in_mbs_minus1:g,pic_height_in_map_units_minus1:w,frame_mbs_only_flag:E,frame_cropping_flag:O,frame_crop_left_offset:x,frame_crop_right_offset:k,frame_crop_top_offset:C,frame_crop_bottom_offset:S}}(n),o=i.profile_idc,a=i.constraint_set,s=i.level_idc,c=16*(i.pic_width_in_mbs_minus1+1),u=(i.pic_height_in_map_units_minus1+1)*(2-i.frame_mbs_only_flag)*16,l=2*i.frame_crop_left_offset,d=2*i.frame_crop_right_offset,f=2*i.frame_crop_top_offset,h=2*i.frame_crop_bottom_offset;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:a,levelIndex:s,encodedWidth:c,encodedHeight:u,cropLeft:l,cropRight:d,cropTop:f,cropBottom:h,croppedWidth:c-l-d,croppedHeight:u-f-h}}function tr(e){var t=new Yn(e);if(0!==t.next())throw new Error("Invalid NALU header");return{nal_unit_type:t.read(6),nuh_layer_id:t.read(6),nuh_temporal_id_plus1:t.read(3)}}function nr(e){var t,n=new Yn(e),r=n.read(4),i=n.read(3),o=!!n.next(),a=ir(n,!0,i),s=n.decodeExponentialGolombNumber(),c=n.decodeExponentialGolombNumber();3===c&&(t=!!n.next());var u,l,d,f,h=n.decodeExponentialGolombNumber(),p=n.decodeExponentialGolombNumber(),v=!!n.next();v&&(u=n.decodeExponentialGolombNumber(),l=n.decodeExponentialGolombNumber(),d=n.decodeExponentialGolombNumber(),f=n.decodeExponentialGolombNumber());for(var _=n.decodeExponentialGolombNumber(),m=n.decodeExponentialGolombNumber(),y=n.decodeExponentialGolombNumber(),b=[],g=[],w=[],E=!!n.next(),x=E?0:i;x<=i;x+=1)b[x]=n.decodeExponentialGolombNumber(),g[x]=n.decodeExponentialGolombNumber(),w[x]=n.decodeExponentialGolombNumber();var k,C,S=n.decodeExponentialGolombNumber(),O=n.decodeExponentialGolombNumber(),N=n.decodeExponentialGolombNumber(),A=n.decodeExponentialGolombNumber(),T=n.decodeExponentialGolombNumber(),I=n.decodeExponentialGolombNumber(),R=!!n.next();R&&(k=!!n.next())&&(C=function(e){for(var t=[],n=0;n<4;n+=1){t[n]=[];for(var r=0;r<6;r+=3===n?3:1){if(!!e.next()){var i=8,o=Math.min(64,1<<4+(n<<1));if(n>1)i=e.decodeExponentialGolombNumber()+8;t[n][r]=[];for(var a=0;a<o;a+=1){i=(i+e.decodeExponentialGolombNumber()+256)%256,t[n][r][a]=i}}else e.decodeExponentialGolombNumber()}}return t}(n));var M,P,D,L,W,G=!!n.next(),B=!!n.next(),U=!!n.next();U&&(M=n.read(4),P=n.read(4),D=n.decodeExponentialGolombNumber(),L=n.decodeExponentialGolombNumber(),W=!!n.next());for(var V=n.decodeExponentialGolombNumber(),j=[],H=0;H<V;H+=1)j[H]=or(n,H,V,j);var z,F,q,K=!!n.next();if(K){z=n.decodeExponentialGolombNumber(),F=[],q=[];for(var X=0;X<z;X+=1)F[X]=n.read(y+4),q[X]=!!n.next()}var Y,J=!!n.next(),Z=!!n.next(),$=!!n.next();$&&(Y=function(e,t){var n,r,i,o=!!e.next();o&&(n=e.read(8))===ar.Extended&&(r=e.read(16),i=e.read(16));var a,s=!!e.next();s&&(a=!!e.next());var c,u,l,d,f,h,p=!!e.next();p&&(c=e.read(3),u=!!e.next(),(l=!!e.next())&&(d=e.read(8),f=e.read(8),h=e.read(8)));var v,_,m=!!e.next();m&&(v=e.decodeExponentialGolombNumber(),_=e.decodeExponentialGolombNumber());var y,b,g,w,E=!!e.next(),x=!!e.next(),k=!!e.next(),C=!!e.next();C&&(y=e.decodeExponentialGolombNumber(),b=e.decodeExponentialGolombNumber(),g=e.decodeExponentialGolombNumber(),w=e.decodeExponentialGolombNumber());var S,O,N,A,T,I,R=!!e.next();R&&(S=e.read(32),O=e.read(32),(N=!!e.next())&&(A=e.decodeExponentialGolombNumber()),(T=!!e.next())&&(I=sr(e,!0,t)));var M,P,D,L,W,G,B,U,V=!!e.next();V&&(M=!!e.next(),P=!!e.next(),D=!!e.next(),L=e.decodeExponentialGolombNumber(),W=e.decodeExponentialGolombNumber(),G=e.decodeExponentialGolombNumber(),B=e.decodeExponentialGolombNumber(),U=e.decodeExponentialGolombNumber());return{aspect_ratio_info_present_flag:o,aspect_ratio_idc:n,sar_width:r,sar_height:i,overscan_info_present_flag:s,overscan_appropriate_flag:a,video_signal_type_present_flag:p,video_format:c,video_full_range_flag:u,colour_description_present_flag:l,colour_primaries:d,transfer_characteristics:f,matrix_coeffs:h,chroma_loc_info_present_flag:m,chroma_sample_loc_type_top_field:v,chroma_sample_loc_type_bottom_field:_,neutral_chroma_indication_flag:E,field_seq_flag:x,frame_field_info_present_flag:k,default_display_window_flag:C,def_disp_win_left_offset:y,def_disp_win_right_offset:b,def_disp_win_top_offset:g,def_disp_win_bottom_offset:w,vui_timing_info_present_flag:R,vui_num_units_in_tick:S,vui_time_scale:O,vui_poc_proportional_to_timing_flag:N,vui_num_ticks_poc_diff_one_minus1:A,vui_hrd_parameters_present_flag:T,vui_hrd_parameters:I,bitstream_restriction_flag:V,tiles_fixed_structure_flag:M,motion_vectors_over_pic_boundaries_flag:P,restricted_ref_pic_lists_flag:D,min_spatial_segmentation_idc:L,max_bytes_per_pic_denom:W,max_bits_per_min_cu_denom:G,log2_max_mv_length_horizontal:B,log2_max_mv_length_vertical:U}}(n,i));var Q,ee,te,ne,re,ie,oe,ae,se=!!n.next();if(se&&(Q=!!n.next(),ee=!!n.next(),te=!!n.next(),ne=!!n.next(),re=n.read(4)),Q)throw new Error("Not implemented");if(ee&&(ie=function(e){var t=!!e.next();return{inter_view_mv_vert_constraint_flag:t}}(n)),te&&(oe=function(e){var t=[],n=[];t[0]=!!e.next(),n[0]=!!e.next();var r=e.decodeExponentialGolombNumber(),i=!!e.next(),o=!!e.next(),a=!!e.next(),s=!!e.next();t[1]=!!e.next(),n[1]=!!e.next();var c=!!e.next(),u=e.decodeExponentialGolombNumber(),l=!!e.next(),d=!!e.next(),f=!!e.next(),h=!!e.next(),p=!!e.next();return{iv_di_mc_enabled_flag:t,iv_mv_scal_enabled_flag:n,log2_ivmc_sub_pb_size_minus3:r,iv_res_pred_enabled_flag:i,depth_ref_enabled_flag:o,vsp_mc_enabled_flag:a,dbbp_enabled_flag:s,tex_mc_enabled_flag:c,log2_texmc_sub_pb_size_minus3:u,intra_contour_enabled_flag:l,intra_dc_only_wedge_enabled_flag:d,cqt_cu_part_pred_enabled_flag:f,inter_dc_only_enabled_flag:h,skip_intra_enabled_flag:p}}(n)),ne)throw new Error("Not implemented");if(re){ae=[];for(var ce=0;!n.ended;)ae[ce]=!!n.next(),ce+=1}return{sps_video_parameter_set_id:r,sps_max_sub_layers_minus1:i,sps_temporal_id_nesting_flag:o,profileTierLevel:a,sps_seq_parameter_set_id:s,chroma_format_idc:c,separate_colour_plane_flag:t,pic_width_in_luma_samples:h,pic_height_in_luma_samples:p,conformance_window_flag:v,conf_win_left_offset:u,conf_win_right_offset:l,conf_win_top_offset:d,conf_win_bottom_offset:f,bit_depth_luma_minus8:_,bit_depth_chroma_minus8:m,log2_max_pic_order_cnt_lsb_minus4:y,sps_sub_layer_ordering_info_present_flag:E,sps_max_dec_pic_buffering_minus1:b,sps_max_num_reorder_pics:g,sps_max_latency_increase_plus1:w,log2_min_luma_coding_block_size_minus3:S,log2_diff_max_min_luma_coding_block_size:O,log2_min_luma_transform_block_size_minus2:N,log2_diff_max_min_luma_transform_block_size:A,max_transform_hierarchy_depth_inter:T,max_transform_hierarchy_depth_intra:I,scaling_list_enabled_flag:R,sps_scaling_list_data_present_flag:k,scalingListData:C,amp_enabled_flag:G,sample_adaptive_offset_enabled_flag:B,pcm_enabled_flag:U,pcm_sample_bit_depth_luma_minus1:M,pcm_sample_bit_depth_chroma_minus1:P,log2_min_pcm_luma_coding_block_size_minus3:D,log2_diff_max_min_pcm_luma_coding_block_size:L,pcm_loop_filter_disabled_flag:W,num_short_term_ref_pic_sets:V,shortTermRefPicSets:j,long_term_ref_pics_present_flag:K,num_long_term_ref_pics_sps:z,lt_ref_pic_poc_lsb_sps:F,used_by_curr_pic_lt_sps_flag:q,sps_temporal_mvp_enabled_flag:J,strong_intra_smoothing_enabled_flag:Z,vui_parameters_present_flag:$,vuiParameters:Y,sps_extension_present_flag:se,sps_range_extension_flag:Q,sps_multilayer_extension_flag:ee,sps_3d_extension_flag:te,sps_scc_extension_flag:ne,sps_extension_4bits:re,spsMultilayerExtension:ie,sps3dExtension:oe,sps_extension_data_flag:ae}}function rr(e){for(var t=e.read(2),n=!!e.next(),r=e.read(5),i=e.peekBytes(4),o=[],a=0;a<32;a+=1)o[a]=!!e.next();var s,c,u,l,d,f,h,p,v,_,m,y=e.peekBytes(6),b=!!e.next(),g=!!e.next(),w=!!e.next(),E=!!e.next();return 4===r||o[4]||5===r||o[5]||6===r||o[6]||7===r||o[7]||8===r||o[8]||9===r||o[9]||10===r||o[10]||11===r||o[11]?(s=!!e.next(),c=!!e.next(),u=!!e.next(),l=!!e.next(),d=!!e.next(),f=!!e.next(),h=!!e.next(),p=!!e.next(),v=!!e.next(),5===r||o[5]||9===r||o[9]||10===r||o[10]||11===r||o[11]?(_=!!e.next(),e.skip(33)):e.skip(34)):2===r||o[2]?(e.skip(7),p=!!e.next(),e.skip(35)):e.skip(43),1===r||o[1]||2===r||o[2]||3===r||o[3]||4===r||o[4]||5===r||o[5]||9===r||o[9]||11===r||o[11]?m=!!e.next():e.skip(1),{profile_space:t,tier_flag:n,profile_idc:r,profileCompatibilitySet:i,profile_compatibility_flag:o,constraintSet:y,progressive_source_flag:b,interlaced_source_flag:g,non_packed_constraint_flag:w,frame_only_constraint_flag:E,max_12bit_constraint_flag:s,max_10bit_constraint_flag:c,max_8bit_constraint_flag:u,max_422chroma_constraint_flag:l,max_420chroma_constraint_flag:d,max_monochrome_constraint_flag:f,intra_constraint_flag:h,one_picture_only_constraint_flag:p,lower_bit_rate_constraint_flag:v,max_14bit_constraint_flag:_,inbld_flag:m}}function ir(e,t,n){var r;r=rr(e);for(var i=e.read(8),o=[],a=[],s=0;s<n;s+=1)o[s]=!!e.next(),a[s]=!!e.next();if(n>0)for(var c=n;c<8;c+=1)e.read(2);for(var u=[],l=[],d=0;d<n;d+=1)o[d]&&(u[d]=rr(e)),a[d]&&(l[d]=e.read(8));return{generalProfileTier:r,general_level_idc:i,sub_layer_profile_present_flag:o,sub_layer_level_present_flag:a,subLayerProfileTier:u,sub_layer_level_idc:l}}function or(e,t,n,r){var i=!1;0!==t&&(i=!!e.next());var o=0,a=!1,s=0,c=[],u=[],l=0,d=0,f=[],h=[],p=[],v=[];if(i){t===n&&(o=e.decodeExponentialGolombNumber()),a=!!e.next(),s=e.decodeExponentialGolombNumber();for(var _=r[t-(o+1)],m=_.num_negative_pics+_.num_positive_pics,y=0;y<=m;y+=1)c[y]=!!e.next(),c[y]?u[y]=!0:u[y]=!!e.next();for(var b=(1-2*Number(a))*(s+1),g=[],w=[],E=[],x=[],k=0,C=0;C<_.num_negative_pics;C+=1)k-=_.delta_poc_s0_minus1[C]+1,g[C]=k;k=0;for(var S=0;S<_.num_positive_pics;S+=1)k+=_.delta_poc_s1_minus1[S]+1,w[S]=k;var O=0;if(_.num_positive_pics>0)for(var N=_.num_positive_pics-1;N>=0;N-=1)(k=w[N]+b)<0&&u[_.num_negative_pics+N]&&(E[O]=k,h[O]=c[_.num_negative_pics+N],O+=1);b<0&&u[m]&&(E[O]=b,h[O]=c[m],O+=1);for(var A=0;A<_.num_negative_pics;A+=1)(k=g[A]+b)<0&&u[A]&&(E[O]=k,h[O]=c[A],O+=1);l=O;var T=0;for(O=0;O<l;O+=1){var I=E[O];f[O]=-(I-T-1),T=I}if(O=0,_.num_negative_pics>0)for(var R=_.num_negative_pics-1;R>=0;R-=1)(k=g[R]+b)>0&&u[R]&&(x[O]=k,v[O]=c[R],O+=1);b>0&&u[m]&&(x[O]=b,v[O]=c[m],O+=1);for(var M=0;M<_.num_positive_pics;M+=1)(k=w[M]+b)>0&&u[_.num_negative_pics+M]&&(x[O]=k,v[O]=c[_.num_negative_pics+M],O+=1);for(d=O,T=0,O=0;O<d;O+=1){var P=x[O];p[O]=P-T-1,T=P}}else{l=e.decodeExponentialGolombNumber(),d=e.decodeExponentialGolombNumber();for(var D=0;D<l;D+=1)f[D]=e.decodeExponentialGolombNumber(),h[D]=!!e.next();for(var L=0;L<d;L+=1)p[L]=e.decodeExponentialGolombNumber(),v[L]=!!e.next()}return{stRpsIdx:t,num_short_term_ref_pic_sets:n,inter_ref_pic_set_prediction_flag:i,delta_idx_minus1:o,delta_rps_sign:a,abs_delta_rps_minus1:s,used_by_curr_pic_flag:c,use_delta_flag:u,num_negative_pics:l,num_positive_pics:d,delta_poc_s0_minus1:f,used_by_curr_pic_s0_flag:h,delta_poc_s1_minus1:p,used_by_curr_pic_s1_flag:v}}var ar={Extended:255};function sr(e,t,n){var r,i,o,a,s,c,u,l,d,f,h,p,v;t&&(r=!!e.next(),i=!!e.next(),(r||i)&&((o=!!e.next())&&(a=e.read(8),s=e.read(5),c=!!e.next(),u=e.read(5)),l=e.read(4),d=e.read(4),o&&(f=e.read(4)),h=e.read(5),p=e.read(5),v=e.read(5)));for(var _=[],m=[],y=[],b=[],g=[],w=[],E=[],x=0;x<=n;x+=1)_[x]=!!e.next(),_[x]||(m[x]=!!e.next()),m[x]?y[x]=e.decodeExponentialGolombNumber():b[x]=!!e.next(),b[x]||(g[x]=e.decodeExponentialGolombNumber()),r&&(w[x]=cr(e,x,ur(g[x]))),i&&(E[x]=cr(e,x,ur(g[x])));return{nal_hrd_parameters_present_flag:r,vcl_hrd_parameters_present_flag:i,sub_pic_hrd_params_present_flag:o,tick_divisor_minus2:a,du_cpb_removal_delay_increment_length_minus1:s,sub_pic_cpb_params_in_pic_timing_sei_flag:c,dpb_output_delay_du_length_minus1:u,bit_rate_scale:l,cpb_size_scale:d,cpb_size_du_scale:f,initial_cpb_removal_delay_length_minus1:h,au_cpb_removal_delay_length_minus1:p,dpb_output_delay_length_minus1:v,fixed_pic_rate_general_flag:_,fixed_pic_rate_within_cvs_flag:m,elemental_duration_in_tc_minus1:y,low_delay_hrd_flag:b,cpb_cnt_minus1:g,nalHrdParameters:w,vclHrdParameters:E}}function cr(e,t,n){for(var r=[],i=[],o=[],a=0;a<n;a+=1)r[a]=e.decodeExponentialGolombNumber(),i[a]=e.decodeExponentialGolombNumber(),t>0&&(o[a]=!!e.next());return{bit_rate_value_minus1:r,cpb_size_value_minus1:i,cpb_size_du_value_minus1:[],bit_rate_du_value_minus1:[],cbr_flag:o}}function ur(e){return e+1}function lr(e){var t=function(e){var t,n,r,i,o=0,a=v(Un(e));try{for(a.s();!(i=a.n()).done;){var s=i.value,c=tr(s),u=E(E({},c),{},{data:s,rbsp:s.subarray(2)});switch(c.nal_unit_type){case 32:t=u;break;case 33:n=u;break;case 34:r=u;break;default:continue}if(3===(o+=1))return{videoParameterSet:t,sequenceParameterSet:n,pictureParameterSet:r}}}catch(e){a.e(e)}finally{a.f()}throw new Error("Invalid data")}(e),n=t.videoParameterSet,r=t.sequenceParameterSet,i=t.pictureParameterSet,o=function(e){var t=new Yn(e),n=t.read(4),r=!!t.next(),i=!!t.next(),o=t.read(6),a=t.read(3),s=!!t.next();t.skip(16);for(var c=ir(t,0,a),u=!!t.next(),l=[],d=[],f=[],h=u?0:a;h<=a;h+=1)l[h]=t.decodeExponentialGolombNumber(),d[h]=t.decodeExponentialGolombNumber(),f[h]=t.decodeExponentialGolombNumber();for(var p=t.read(6),v=t.decodeExponentialGolombNumber(),_=[],m=1;m<=v;m+=1){_[m]=[];for(var y=0;y<=p;y+=1)_[m][y]=!!t.next()}var b,g,w,E,x,k,C,S,O=!!t.next();if(O){b=t.read(32),g=t.read(32),(w=!!t.next())&&(E=t.decodeExponentialGolombNumber()),x=t.decodeExponentialGolombNumber(),k=[],C=[!0],S=[];for(var N=0;N<x;N+=1)k[N]=t.decodeExponentialGolombNumber(),N>0&&(C[N]=!!t.next()),S[N]=sr(t,C[N],a)}return{vps_video_parameter_set_id:n,vps_base_layer_internal_flag:r,vps_base_layer_available_flag:i,vps_max_layers_minus1:o,vps_max_sub_layers_minus1:a,vps_temporal_id_nesting_flag:s,profileTierLevel:c,vps_sub_layer_ordering_info_present_flag:u,vps_max_dec_pic_buffering_minus1:l,vps_max_num_reorder_pics:d,vps_max_latency_increase_plus1:f,vps_max_layer_id:p,vps_num_layer_sets_minus1:v,layer_id_included_flag:_,vps_timing_info_present_flag:O,vps_num_units_in_tick:b,vps_time_scale:g,vps_poc_proportional_to_timing_flag:w,vps_num_ticks_poc_diff_one_minus1:E,vps_num_hrd_parameters:x,hrd_layer_set_idx:k,cprms_present_flag:C,hrdParameters:S,vps_extension_flag:!!t.next()}}(n.rbsp).profileTierLevel,a=o.generalProfileTier,s=a.profile_space,c=a.tier_flag,u=a.profile_idc,l=a.profileCompatibilitySet,d=a.constraintSet,f=o.general_level_idc,h=nr(r.rbsp),p=h.chroma_format_idc,_=h.pic_width_in_luma_samples,m=h.pic_height_in_luma_samples,y=h.conf_win_left_offset,b=void 0===y?0:y,g=h.conf_win_right_offset,w=void 0===g?0:g,x=h.conf_win_top_offset,k=void 0===x?0:x,C=h.conf_win_bottom_offset,S=void 0===C?0:C,O=function(e){switch(e){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}(p),N=function(e){switch(e){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}(p);return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:i,generalProfileSpace:s,generalProfileIndex:u,generalProfileCompatibilitySet:l,generalTierFlag:c,generalLevelIndex:f,generalConstraintSet:d,encodedWidth:_,encodedHeight:m,cropLeft:b,cropRight:w,cropTop:k,cropBottom:S,croppedWidth:_-O*(b+w),croppedHeight:m-N*(k+S)}}function dr(e){return e.toString(16).toUpperCase()}function fr(e){return e.toString(16).toUpperCase().padStart(2,"0")}function hr(e){return e.toString(10).padStart(2,"0")}var pr=new WeakMap,vr=new WeakMap,_r=new WeakMap,mr=new WeakSet,yr=function(){return p(function e(t,n,r){c(this,e),f(this,mr),l(this,pr,void 0),l(this,vr,void 0),l(this,_r,void 0),d(pr,this,t),d(vr,this,n),d(_r,this,r)},[{key:"decode",value:function(e){"configuration"!==e.type&&(n(mr,this,br).call(this,e.data),u(pr,this).decode(new EncodedVideoChunk({type:!1===e.keyframe?"delta":"key",timestamp:0,data:e.data})))}}])}();function br(e){var t,n,r=new Gn(e).searchSequenceHeaderObu();if(r){var i,o,a,s,c=r.seq_profile,l=O(r.seq_level_idx,1)[0],d=void 0===l?0:l,f=r.max_frame_width_minus_1,h=r.max_frame_height_minus_1,p=r.color_config,v=p.BitDepth,_=p.mono_chrome,m=p.subsampling_x,y=p.subsampling_y,b=p.chroma_sample_position;if(p.color_description_present_flag){var g=r.color_config;i=g.color_primaries,o=g.transfer_characteristics,a=g.matrix_coefficients,s=g.color_range}else i=Gn.ColorPrimaries.Bt709,o=Gn.TransferCharacteristics.Bt709,a=Gn.MatrixCoefficients.Bt709,s=!1;var w=f+1,E=h+1;u(vr,this).call(this,w,E);var x=["av01",c.toString(16),hr(d)+(r.seq_tier[0]?"H":"M"),hr(v),_?"1":"0",(m?"1":"0")+(y?"1":"0")+b.toString(),hr(i),hr(o),hr(a),s?"1":"0"].join(".");u(pr,this).configure({codec:x,hardwareAcceleration:null!==(t=null===(n=u(_r,this))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0})}}var gr=new WeakMap,wr=new WeakMap,Er=function(){return p(function e(t){c(this,e),l(this,gr,void 0),l(this,wr,void 0),d(wr,this,t)},[{key:"decode",value:function(e){if("configuration"===e.type)return d(gr,this,e.data),void this.configure(e.data);var t;void 0!==u(gr,this)?((t=new Uint8Array(u(gr,this).length+e.data.length)).set(u(gr,this),0),t.set(e.data,u(gr,this).length),d(gr,this,void 0)):t=e.data,u(wr,this).decode(new EncodedVideoChunk({type:!1===e.keyframe?"delta":"key",timestamp:0,data:t}))}}])}(),xr=new WeakMap,kr=new WeakMap,Cr=new WeakMap,Sr=function(){function e(t,n,r){var i;return c(this,e),l(i=a(this,e,[t]),xr,void 0),l(i,kr,void 0),l(i,Cr,void 0),d(xr,i,t),d(kr,i,n),d(Cr,i,r),i}return b(e,Er),p(e,[{key:"configure",value:function(e){var t,n,r=er(e),i=r.profileIndex,o=r.constraintSet,a=r.levelIndex,s=r.croppedWidth,c=r.croppedHeight;u(kr,this).call(this,s,c);var l="avc1."+fr(i)+fr(o)+fr(a);u(xr,this).configure({codec:l,hardwareAcceleration:null!==(t=null===(n=u(Cr,this))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0})}}])}(),Or=new WeakMap,Nr=new WeakMap,Ar=new WeakMap,Tr=function(){function e(t,n,r){var i;return c(this,e),l(i=a(this,e,[t]),Or,void 0),l(i,Nr,void 0),l(i,Ar,void 0),d(Or,i,t),d(Nr,i,n),d(Ar,i,r),i}return b(e,Er),p(e,[{key:"configure",value:function(e){var t,n,r=lr(e),i=r.generalProfileSpace,o=r.generalProfileIndex,a=r.generalProfileCompatibilitySet,s=r.generalTierFlag,c=r.generalLevelIndex,l=r.generalConstraintSet,d=r.croppedWidth,f=r.croppedHeight;u(Nr,this).call(this,d,f);var h=["hev1",["","A","B","C"][i]+o.toString(),dr(We(a,0)),(s?"H":"L")+c.toString()].concat(A(Array.from(l,dr))).join(".");u(Or,this).configure({codec:h,codedWidth:d,codedHeight:f,hardwareAcceleration:null!==(t=null===(n=u(Ar,this))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0})}}])}(),Ir=function(){return p(function e(){var t=this;c(this,e),_(this,"listeners",[]),_(this,"event",function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];var a={listener:e,thisArg:n,args:i};return t.addEventListener(a)}),this.event=this.event.bind(this)},[{key:"addEventListener",value:function(e){var t=this;this.listeners.push(e);var n=function(){var n=t.listeners.indexOf(e);-1!==n&&t.listeners.splice(n,1)};return n.dispose=n,n}},{key:"fire",value:function(e){var t,n=v(this.listeners.slice());try{for(n.s();!(t=n.n()).done;){var r,i=t.value;(r=i.listener).call.apply(r,[i.thisArg,e].concat(A(i.args)))}}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.listeners.length=0}}])}(),Rr=Symbol("undefined"),Mr=new WeakMap,Pr=function(){function e(){var t;c(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return l(t=a(this,e,[].concat(r)),Mr,Rr),t}return b(e,Ir),p(e,[{key:"addEventListener",value:function(t){var n;u(Mr,this)!==Rr&&(n=t.listener).call.apply(n,[t.thisArg,u(Mr,this)].concat(A(t.args)));return N(e,"addEventListener",this,3)([t])}},{key:"fire",value:function(t){d(Mr,this,t),N(e,"fire",this,3)([t])}}])}(),Dr=new WeakMap,Lr=new WeakMap,Wr=new WeakMap,Gr=new WeakMap,Br=new WeakMap,Ur=new WeakMap,Vr=function(){return p(function e(t,n){var r=this;c(this,e),l(this,Dr,void 0),l(this,Lr,new ReadableStream({start:function(e){d(Dr,r,e)},pull:function(e){e.enqueue(u(Gr,r).call(r))}},{highWaterMark:0})),l(this,Wr,u(Lr,this).getReader()),l(this,Gr,void 0),l(this,Br,0),l(this,Ur,void 0),d(Gr,this,t),d(Ur,this,n)},[{key:"borrow",value:(e=i(x().m(function e(){var t;return x().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,u(Wr,this).read();case 1:return t=e.v,e.a(2,t.value)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"return",value:function(e){u(Br,this)<u(Ur,this)&&(u(Dr,this).enqueue(e),d(Br,this,u(Br,this)+1))}}]);var e}(),jr=new WeakMap,Hr=new WeakMap,zr=function(){return p(function e(){c(this,e),l(this,jr,void 0),l(this,Hr,void 0),"undefined"!=typeof OffscreenCanvas?d(jr,this,new OffscreenCanvas(1,1)):(d(jr,this,document.createElement("canvas")),u(jr,this).width=1,u(jr,this).height=1),d(Hr,this,u(jr,this).getContext("bitmaprenderer",{alpha:!1}))},[{key:"capture",value:(e=i(x().m(function e(t){var n,r=this;return x().w(function(e){for(;;)switch(e.n){case 0:return u(jr,this).width=t.displayWidth,u(jr,this).height=t.displayHeight,e.n=1,createImageBitmap(t);case 1:if(n=e.v,u(Hr,this).transferFromImageBitmap(n),!(u(jr,this)instanceof OffscreenCanvas)){e.n=3;break}return e.n=2,u(jr,this).convertToBlob({type:"image/png"});case 2:return e.a(2,e.v);case 3:return e.a(2,new Promise(function(e,t){u(jr,r).toBlob(function(n){n?e(n):t(new Error("Failed to convert canvas to blob"))},"image/png")}));case 4:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}(),Fr=["codec","renderer"],qr=new Vr(function(){return new zr},4),Kr=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,$r=new WeakMap,Qr=new WeakMap,ei=new WeakMap,ti=new WeakMap,ni=new WeakMap,ri=new WeakMap,ii=new WeakMap,oi=new WeakMap,ai=new WeakMap,si=new WeakMap,ci=new WeakMap,ui=new WeakMap,li=new WeakMap,di=new WeakSet,fi=new WeakMap,hi=new WeakMap,pi=function(){return p(function e(t){var r=this,i=t.codec,o=t.renderer,a=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,Fr);switch(c(this,e),f(this,di),l(this,Kr,void 0),l(this,Xr,void 0),l(this,Yr,void 0),l(this,Jr,void 0),l(this,Zr,void 0),l(this,$r,void 0),l(this,Qr,void 0),l(this,ei,0),l(this,ti,0),l(this,ni,0),l(this,ri,new Pr),l(this,ii,0),l(this,oi,0),l(this,ai,void 0),l(this,si,!1),l(this,ci,void 0),l(this,ui,void 0),l(this,li,0),l(this,fi,function(e,t){u(Xr,r).setSize(e,t),d(ii,r,e),d(oi,r,t),u(ri,r).fire({width:e,height:t})}),l(this,hi,function(){u(ei,r)>0&&(d(ti,r,u(ti,r)+1),d(ni,r,u(ni,r)+(u(ei,r)-1)),d(ei,r,0)),d(li,r,requestAnimationFrame(u(hi,r)))}),d(Kr,this,i),d(Xr,this,o),d(Yr,this,a),d(ai,this,new VideoDecoder({output:function(e){var t;if(null===(t=u(ui,r))||void 0===t||t.close(),d(ui,r,e.clone()),u(si,r))return u(ci,r)&&(u(ci,r).close(),d(ni,r,u(ni,r)+1)),void d(ci,r,e);n(di,r,_i).call(r,e)},error:function(e){n(di,r,vi).call(r,e)}})),u(Kr,this)){case pe:d(Jr,this,new Sr(u(ai,this),u(fi,this),u(Yr,this)));break;case ve:d(Jr,this,new Tr(u(ai,this),u(fi,this),u(Yr,this)));break;case _e:d(Jr,this,new yr(u(ai,this),u(fi,this),u(Yr,this)));break;default:throw new Error("Unsupported codec: ".concat(u(Kr,this)))}d(Zr,this,new nt({start:function(e){u($r,r)?e.error(u($r,r)):d(Qr,r,e)},write:function(e){u(Jr,r).decode(e)}})),u(hi,this).call(this)},[{key:"codec",get:function(){return u(Kr,this)}},{key:"renderer",get:function(){return u(Xr,this)}},{key:"writable",get:function(){return u(Zr,this)}},{key:"framesRendered",get:function(){return u(ti,this)}},{key:"framesSkipped",get:function(){return u(ni,this)}},{key:"sizeChanged",get:function(){return u(ri,this).event}},{key:"width",get:function(){return u(ii,this)}},{key:"height",get:function(){return u(oi,this)}},{key:"snapshot",value:(e=i(x().m(function e(){var t,n,r;return x().w(function(e){for(;;)switch(e.n){case 0:if(t=u(ui,this)){e.n=1;break}return e.a(2,void 0);case 1:return e.n=2,qr.borrow();case 2:return n=e.v,e.n=3,n.capture(t);case 3:return r=e.v,qr.return(n),e.a(2,r)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"dispose",value:function(){var e,t;cancelAnimationFrame(u(li,this)),"closed"!==u(ai,this).state&&u(ai,this).close(),null===(e=u(ci,this))||void 0===e||e.close(),null===(t=u(ui,this))||void 0===t||t.close()}}],[{key:"isSupported",get:function(){return void 0!==globalThis.VideoDecoder}}]);var e}();function vi(e){if(u(Qr,this))try{u(Qr,this).error(e)}catch(e){}else d($r,this,e)}function _i(e){return mi.apply(this,arguments)}function mi(){return(mi=i(x().m(function e(t){var r,i;return x().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,d(si,this,!0),u(fi,this).call(this,t.displayWidth,t.displayHeight),e.n=1,u(Xr,this).draw(t);case 1:if(d(ei,this,u(ei,this)+1),t.close(),!u(ci,this)){e.n=2;break}return r=u(ci,this),d(ci,this,void 0),e.n=2,n(di,this,_i).call(this,r);case 2:d(si,this,!1),e.n=4;break;case 3:e.p=3,i=e.v,n(di,this,vi).call(this,i);case 4:return e.a(2)}},e,this,[[0,3]])}))).apply(this,arguments)}_(pi,"capabilities",{h264:{},h265:{},av1:{}});var yi=function(){function e(e,t){this.program=null,this.texture=null,this.vertexBuffer=null,this.canvas=e;var n={alpha:!1,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,powerPreference:null!=t?t:"low-power",failIfMajorPerformanceCaveat:!0},r=e.getContext("webgl2",n)||e.getContext("webgl",n);if(!r)throw new Error("WebGL not supported");this.gl=r,this.initGL()}return Object.defineProperty(e,"isSupported",{get:function(){try{var e=new OffscreenCanvas(1,1);return!(!e.getContext("webgl2")&&!e.getContext("webgl"))}catch(e){return!1}},enumerable:!1,configurable:!0}),e.prototype.initGL=function(){var e=this.gl,t=this.createShader(e.VERTEX_SHADER,"\n attribute vec2 a_pos;\n varying highp vec2 v_texCoord;\n void main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n // Map [-1, 1] to [0, 1] and flip Y for texture\n v_texCoord = vec2((a_pos.x + 1.0) * 0.5, (1.0 - a_pos.y) * 0.5);\n }\n "),n=this.createShader(e.FRAGMENT_SHADER,"\n varying highp vec2 v_texCoord;\n uniform sampler2D u_sampler;\n void main() {\n gl_FragColor = texture2D(u_sampler, v_texCoord);\n }\n ");this.program=this.createProgram(t,n),e.useProgram(this.program);var r=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.vertexBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW);var i=e.getAttribLocation(this.program,"a_pos");e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.clearColor(1,1,1,1),e.clear(e.COLOR_BUFFER_BIT)},e.prototype.setSize=function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)},e.prototype.draw=function(e){var t=this.gl;t&&this.program&&(t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.drawArrays(t.TRIANGLE_STRIP,0,4))},e.prototype.createShader=function(e,t){var n=this.gl,r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS)){var i=n.getShaderInfoLog(r);throw n.deleteShader(r),new Error("Shader compile error: "+i)}return r},e.prototype.createProgram=function(e,t){var n=this.gl,r=n.createProgram();if(n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),!n.getProgramParameter(r,n.LINK_STATUS)){var i=n.getProgramInfoLog(r);throw n.deleteProgram(r),new Error("Program link error: "+i)}return n.detachShader(r,e),n.detachShader(r,t),n.deleteShader(e),n.deleteShader(t),r},e.prototype.dispose=function(){var e,t=this.gl;this.texture&&t.deleteTexture(this.texture),this.vertexBuffer&&t.deleteBuffer(this.vertexBuffer),this.program&&t.deleteProgram(this.program),null===(e=t.getExtension("WEBGL_lose_context"))||void 0===e||e.loseContext()},e}(),bi=function(){function e(e){if(this.canvas=e,this.ctx=null,this.ctx=e.getContext("2d",{alpha:!1,desynchronized:!0}),!this.ctx)throw new Error("Canvas 2D not supported")}return e.prototype.setSize=function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)},e.prototype.draw=function(e){this.ctx&&this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height)},e.prototype.dispose=function(){this.ctx=null,this.canvas.width=0,this.canvas.height=0},e}(),gi=function(){function e(){this.listeners=new Map}return e.prototype.on=function(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)},e.prototype.once=function(e,t){var n=this,r=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];t.apply(void 0,H([],j(i),!1)),n.off(e,r)};this.on(e,r)},e.prototype.off=function(e,t){var n;null===(n=this.listeners.get(e))||void 0===n||n.delete(t)},e.prototype.emit=function(e){for(var t,n,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=this.listeners.get(e);if(o)try{for(var a=V(o),s=a.next();!s.done;s=a.next()){var c=s.value;try{c.apply(void 0,H([],j(r),!1))}catch(t){console.error("EventEmitter '".concat(e,"' listener error"),t)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},e.prototype.clear=function(e){e?this.listeners.delete(e):this.listeners.clear()},e}(),wi=function(e){function t(t){var n,r=e.call(this)||this;return r.sockets={video:null,audio:null,touch:null},r.subscribers={video:new Set,audio:new Set,touch:new Set},r.deviceId=t.deviceId,r.ip=t.ip,r.ports=null!==(n=t.ports)&&void 0!==n?n:{},r}return L(t,e),t.prototype.getUrl=function(e){var t=this.ports[e];return"ws://".concat(this.ip,":").concat(t)},t.prototype.getChannelStatus=function(e){var t=this.sockets[e];if(!t)return"disconnected";switch(t.readyState){case WebSocket.CONNECTING:return"connecting";case WebSocket.OPEN:return"connected";case WebSocket.CLOSING:case WebSocket.CLOSED:default:return"disconnected"}},t.prototype.getAllChannelsStatus=function(){return{video:this.getChannelStatus("video"),audio:this.getChannelStatus("audio"),touch:this.getChannelStatus("touch")}},t.prototype.emitChannelStatus=function(e,t){var n=this.getAllChannelsStatus();this.emit(t,e,n)},t.prototype.ensureChannel=function(e){var t=this;if(this.sockets[e]){var n=this.sockets[e].readyState;if(n===WebSocket.OPEN||n===WebSocket.CONNECTING)return;this.sockets[e]=null}var r=new WebSocket(this.getUrl(e));r.binaryType="arraybuffer",r.onopen=function(){console.log("[".concat(t.deviceId,":").concat(e,"] connected")),t.emitChannelStatus(e,"open")},r.onmessage=function(n){var r,i;try{try{for(var o=V(t.subscribers[e]),a=o.next();!a.done;a=o.next()){(0,a.value)(n.data)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}catch(n){console.error("[".concat(t.deviceId,":").concat(e,"] message error"),n)}},r.onerror=function(n){console.error("[".concat(t.deviceId,":").concat(e,"] error"),n),t.emit("error",e,n)},r.onclose=function(n){console.warn("[".concat(t.deviceId,":").concat(e,"] closed"),n),t.sockets[e]=null,t.emit("close",e,n)},this.sockets[e]=r},t.prototype.subscribe=function(e,t){this.subscribers[e].add(t),this.sockets[e]||this.ensureChannel(e)},t.prototype.unsubscribe=function(e,t){var n;t?this.subscribers[e].delete(t):this.subscribers[e].clear(),0===this.subscribers[e].size&&(console.log("[".concat(this.deviceId,":").concat(e,"] no subscribers, closing")),null===(n=this.sockets[e])||void 0===n||n.close(),this.sockets[e]=null)},t.prototype.send=function(e,t){var n=this.sockets[e];if(n&&n.readyState===WebSocket.OPEN)try{t instanceof ArrayBuffer||t instanceof Uint8Array?n.send(t):n.send(JSON.stringify(t))}catch(t){console.error("[".concat(e,"] send error"),t)}},t.prototype.sendTouch=function(e){this.send("touch",e)},t.prototype.destroy=function(){var e=this;["video","audio","touch"].forEach(function(t){console.log("[".concat(e.deviceId,":").concat(t,"] destroying"));var n=e.sockets[t];n&&(n.onopen=null,n.onmessage=null,n.onerror=null,n.onclose=null,n.close(),e.sockets[t]=null),e.subscribers[t].clear()}),this.clear()},t}(gi),Ei="focus",xi="blur",ki="input",Ci="delete",Si="enter",Oi="arrow-up",Ni="arrow-down",Ai="arrow-left",Ti="arrow-right",Ii=function(){function e(e){this.emitter=new gi,this.isComposing=!1,this.el=document.createElement("textarea"),this.el.style.cssText="\n position:absolute;\n top:0;\n left:0;\n pointer-events:none;\n opacity:0.01;\n width:100%;\n max-width:95%;\n height: 40px;\n resize: none;\n overflow: hidden;\n ",this.el.autocomplete="off",e.appendChild(this.el),this.bindEvents()}return e.prototype.on=function(e,t){var n;null===(n=this.emitter)||void 0===n||n.on(e,t)},e.prototype.off=function(e,t){var n;null===(n=this.emitter)||void 0===n||n.off(e,t)},e.prototype.bindEvents=function(){var e=this;this.el.addEventListener("focus",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(Ei)}),this.el.addEventListener("blur",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(xi)}),this.el.addEventListener("compositionstart",function(){e.isComposing=!0}),this.el.addEventListener("compositionend",function(t){var n;e.isComposing=!1;var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(ki,r.value),e.el.value=""}),this.el.addEventListener("input",function(t){var n;if(!e.isComposing){var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(ki,r.value),e.el.value=""}}),this.el.addEventListener("keydown",function(t){var n,r,i,o,a,s;switch(t.key){case"Backspace":case"Delete":null===(n=e.emitter)||void 0===n||n.emit(Ci);break;case"Enter":null===(r=e.emitter)||void 0===r||r.emit(Si),e.el.blur();break;case"ArrowUp":null===(i=e.emitter)||void 0===i||i.emit(Oi);break;case"ArrowDown":null===(o=e.emitter)||void 0===o||o.emit(Ni);break;case"ArrowLeft":null===(a=e.emitter)||void 0===a||a.emit(Ai);break;case"ArrowRight":null===(s=e.emitter)||void 0===s||s.emit(Ti)}})},e.prototype.focus=function(){this.el.focus()},e.prototype.blur=function(){this.el.blur()},e.prototype.moveTo=function(e,t,n){this.el.style.left="".concat(e,"px"),this.el.style.top="".concat(t,"px"),n&&(this.el.style.width="".concat(n,"px"))},e.prototype.destroy=function(){var e;null===(e=this.emitter)||void 0===e||e.clear(),this.emitter=null,this.el.remove()},e}(),Ri={AndroidHome:3,AndroidBack:4,AndroidCall:5,AndroidEndCall:6,Digit0:7,Digit1:8,Digit2:9,Digit3:10,Digit4:11,Digit5:12,Digit6:13,Digit7:14,Digit8:15,Digit9:16,Star:17,Pound:18,ArrowUp:19,ArrowDown:20,ArrowLeft:21,ArrowRight:22,AndroidDPadCenter:23,VolumeUp:24,VolumeDown:25,Power:26,AndroidCamera:27,Clear:28,KeyA:29,KeyB:30,KeyC:31,KeyD:32,KeyE:33,KeyF:34,KeyG:35,KeyH:36,KeyI:37,KeyJ:38,KeyK:39,KeyL:40,KeyM:41,KeyN:42,KeyO:43,KeyP:44,KeyQ:45,KeyR:46,KeyS:47,KeyT:48,KeyU:49,KeyV:50,KeyW:51,KeyX:52,KeyY:53,KeyZ:54,Comma:55,Period:56,AltLeft:57,AltRight:58,ShiftLeft:59,ShiftRight:60,Tab:61,Space:62,AndroidSymbol:63,AndroidExplorer:64,AndroidEnvelope:65,Enter:66,Backspace:67,Backquote:68,Minus:69,Equal:70,BracketLeft:71,BracketRight:72,Backslash:73,Semicolon:74,Quote:75,Slash:76,At:77,AndroidNum:78,AndroidHeadsetHook:79,AndroidFocus:80,Plus:81,ContextMenu:82,AndroidNotification:83,AndroidSearch:84,PageUp:92,PageDown:93,Escape:111,Delete:112,ControlLeft:113,ControlRight:114,CapsLock:115,ScrollLock:116,MetaLeft:117,MetaRight:118,AndroidFunction:119,PrintScreen:120,Pause:121,Home:122,End:123,Insert:124,AndroidForward:125,F1:131,F2:132,F3:133,F4:134,F5:135,F6:136,F7:137,F8:138,F9:139,F10:140,F11:141,F12:142,NumLock:143,Numpad0:144,Numpad1:145,Numpad2:146,Numpad3:147,Numpad4:148,Numpad5:149,Numpad6:150,Numpad7:151,Numpad8:152,Numpad9:153,NumpadDivide:154,NumpadMultiply:155,NumpadSubtract:156,NumpadAdd:157,NumpadDecimal:158,NumpadComma:159,NumpadEnter:160,NumpadEquals:161,NumpadLeftParen:162,NumpadRightParen:163,VolumeMute:164,AndroidAppSwitch:187,AndroidCut:277,AndroidCopy:278,AndroidPaste:279};Object.fromEntries(Object.entries(Ri).map(function(e){var t=j(e,2),n=t[0];return[t[1],n]}));var Mi,Pi,Di={Down:0,Up:1},Li={Down:0,Up:1,Move:2,Cancel:3,Outside:4,PointerDown:5,PointerUp:6,HoverMove:7,Scroll:8,HoverEnter:9,HoverExit:10,ButtonPress:11,ButtonRelease:12},Wi={None:0,Primary:1,Secondary:2,Tertiary:4,Back:8,Forward:16,StylusPrimary:32,StylusSecondary:64};function Gi(e,t,n){return e.setUint16(t,n),t+2}function Bi(e,t,n){return e.setUint32(t,n),t+4}function Ui(e,t,n){return e.setInt32(t,n),t+4}function Vi(e,t,n){var r=Math.round(n/16*32767);return e.setInt16(t,r),t+2}function ji(e,t,n){return e.setUint8(t,n),t+1}function Hi(e,t,n){return e.setBigInt64(t,n),t+8}!function(e){e[e.injectKeyCode=0]="injectKeyCode",e[e.injectText=1]="injectText",e[e.injectTouchEvent=2]="injectTouchEvent",e[e.injectScrollEvent=3]="injectScrollEvent",e[e.backOrScreenOn=4]="backOrScreenOn",e[e.expandNotificationPanel=5]="expandNotificationPanel",e[e.expandSettingsPanel=6]="expandSettingsPanel",e[e.collapsePanels=7]="collapsePanels",e[e.getClipboard=8]="getClipboard",e[e.setClipboard=9]="setClipboard",e[e.setDisplayPower=10]="setDisplayPower",e[e.rotateDevice=11]="rotateDevice",e[e.uhidCreate=12]="uhidCreate",e[e.uhidInput=13]="uhidInput",e[e.uhidDestroy=14]="uhidDestroy",e[e.openHardKeyboardSettings=15]="openHardKeyboardSettings",e[e.startApp=16]="startApp",e[e.resetVideo=17]="resetVideo"}(Mi||(Mi={})),function(e){e[e.Clipboard=0]="Clipboard",e[e.AckClipboard=1]="AckClipboard",e[e.UhidOutput=2]="UhidOutput"}(Pi||(Pi={}));var zi=function(){function e(){}return e.injectKeyCode=function(e){var t=e.action,n=e.keyCode,r=e.repeat,i=void 0===r?0:r,o=e.metaState,a=void 0===o?0:o,s=new ArrayBuffer(14),c=new DataView(s),u=0;return u=ji(c,u,Mi.injectKeyCode),u=Ui(c,u=ji(c,u,t),n),u=Ui(c,u,i),u=Ui(c,u,a),new Uint8Array(s)},e.injectText=function(e){var t=e.text,n=this.encoder.encode(t),r=new ArrayBuffer(5+n.length),i=new DataView(r),o=0;return o=Bi(i,o=ji(i,o,Mi.injectText),n.length),new Uint8Array(r,o).set(n),new Uint8Array(r)},e.injectTouch=function(e){var t=e.action,n=e.pointerId,r=e.pointerX,i=e.pointerY,o=e.screenWidth,a=e.screenHeight,s=e.pressure,c=e.actionButton,u=e.buttons,l=new ArrayBuffer(32),d=new DataView(l),f=0;return f=ji(d,f,Mi.injectTouchEvent),f=Ui(d,f=Hi(d,f=ji(d,f,t),BigInt(n)),r),f=Gi(d,f=Ui(d,f,i),o),f=function(e,t,n){var r=65535*Math.max(0,Math.min(1,n));return e.setUint16(t,r),t+2}(d,f=Gi(d,f,a),s),f=Ui(d,f,c),f=Ui(d,f,u),new Uint8Array(l)},e.injectScroll=function(e){var t=e.pointerX,n=e.pointerY,r=e.screenWidth,i=e.screenHeight,o=e.scrollX,a=e.scrollY,s=e.buttons,c=new ArrayBuffer(21),u=new DataView(c),l=0;return l=Ui(u,l=ji(u,l,Mi.injectScrollEvent),t),l=Gi(u,l=Ui(u,l,n),r),l=Vi(u,l=Gi(u,l,i),o),l=Ui(u,l=Vi(u,l,a),s),new Uint8Array(c)},e.setClipboard=function(e){var t=e.sequence,n=e.text,r=e.paste,i=void 0!==r&&r,o=this.encoder.encode(n),a=new ArrayBuffer(14+o.length),s=new DataView(a),c=0;return c=ji(s,c,Mi.setClipboard),c=Bi(s,c=ji(s,c=Hi(s,c,BigInt(t)),i?1:0),o.length),new Uint8Array(a,c).set(o),new Uint8Array(a)},e.encoder=new TextEncoder,e}(),Fi=function(){function e(){}return e.parse=function(e){var t=new DataView(e instanceof Uint8Array?e.buffer:e,e instanceof Uint8Array?e.byteOffset:0,e.byteLength);if(t.byteLength<1)return null;var n=function(e,t){return e.getUint8(t)}(t,0);switch(n){case Pi.Clipboard:return this.parseClipboard(t);case Pi.AckClipboard:return this.parseAckClipboard(t);default:return null}},e.parseClipboard=function(e){if(e.byteLength<5)return null;var t=function(e,t){return e.getUint32(t)}(e,1);if(e.byteLength<5+t)return null;var n=new Uint8Array(e.buffer,e.byteOffset+5,t),r=this.decoder.decode(n);return{type:Pi.Clipboard,content:r}},e.parseAckClipboard=function(e){if(e.byteLength<9)return null;var t=function(e,t){return e.getBigInt64(t)}(e,1);return{type:Pi.AckClipboard,sequence:t}},e.decoder=new TextDecoder,e}();function qi(e,t,n){return Math.max(t,Math.min(n,e))}var Ki,Xi,Yi={SIZE_CHANGED:"size-changed",ERROR:"error",STARTED:"started",STOPPED:"stopped",CLIPBOARD_CHANGED:"clipboard-changed",CHANNEL_CONNECTED:"channel-connected",GROUP_CONTROL_JOINED:"group-control-joined",GROUP_CONTROL_LEAVE:"group-control-leave"};exports.VmosEdgeErrorType=void 0,(Ki=exports.VmosEdgeErrorType||(exports.VmosEdgeErrorType={})).CONNECTION="connection",Ki.VIDEO="video",Ki.AUDIO="audio",Ki.TOUCH="touch",Ki.DECODER="decoder",Ki.RENDERER="renderer",exports.VmosEdgeErrorCode=void 0,(Xi=exports.VmosEdgeErrorCode||(exports.VmosEdgeErrorCode={})).CONNECTION_FAILED="CONNECTION_FAILED",Xi.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",Xi.CONNECTION_LOST="CONNECTION_LOST",Xi.VIDEO_CHANNEL_CONNECTION_FAILED="VIDEO_CHANNEL_CONNECTION_FAILED",Xi.VIDEO_CHANNEL_CLOSED="VIDEO_CHANNEL_CLOSED",Xi.VIDEO_STREAM_ERROR="VIDEO_STREAM_ERROR",Xi.VIDEO_PIPELINE_ERROR="VIDEO_PIPELINE_ERROR",Xi.AUDIO_CHANNEL_CONNECTION_FAILED="AUDIO_CHANNEL_CONNECTION_FAILED",Xi.AUDIO_STREAM_ERROR="AUDIO_STREAM_ERROR",Xi.TOUCH_CHANNEL_CONNECTION_FAILED="TOUCH_CHANNEL_CONNECTION_FAILED",Xi.TOUCH_MESSAGE_PARSE_ERROR="TOUCH_MESSAGE_PARSE_ERROR",Xi.DECODER_INIT_FAILED="DECODER_INIT_FAILED",Xi.DECODER_ERROR="DECODER_ERROR",Xi.RENDERER_INIT_FAILED="RENDERER_INIT_FAILED",Xi.RENDERER_ERROR="RENDERER_ERROR",Xi.UNKNOWN_ERROR="UNKNOWN_ERROR";var Ji=function(e){function t(t){var n,r,i,o,a,s=e.call(this)||this;return s.canvas=null,s.canvasContainer=null,s.device=null,s.isGroupControl=!1,s.deviceTouchGroupMap=new Map,s.config=null,s.renderer=null,s.videoCodecPreference="no-preference",s.renderPreference="default",s.decoder=null,s.textareaManager=null,s.videoWidth=0,s.videoHeight=0,s.isRunning=!1,s.rotation=0,s.manualRotation=!1,s.currentRotationAngle=0,s.resizeObserver=null,s.pointerMoveThrottleMap=new Map,s.touchMoveInterval=1e3/60,s.retryCount=0,s.maxRetries=0,s.retryInterval=1e3,s.stopVideoSubscription=null,s.container=t.container,s.config=t.config,s.device=new wi(s.config),s.maxRetries=null!==(n=t.retryCount)&&void 0!==n?n:0,s.retryInterval=null!==(r=t.retryInterval)&&void 0!==r?r:1e3,s.isGroupControl=null!==(i=t.isGroupControl)&&void 0!==i&&i,s.videoCodecPreference=null!==(o=t.videoCodecPreference)&&void 0!==o?o:"no-preference",s.renderPreference=null!==(a=t.renderPreference)&&void 0!==a?a:"default",t.touchMoveFrequency&&(s.touchMoveInterval=1e3/t.touchMoveFrequency),s.initCanvas(),s.handlePointerEvent=s.handlePointerEvent.bind(s),s.handleWheelEvent=s.handleWheelEvent.bind(s),s.handleContextMenu=s.handleContextMenu.bind(s),s.initTextareaManager(),s.observeContainerResize(),s}return L(t,e),t.prototype.setupChannelStatusListener=function(){var e,t,n=this;null===(e=this.device)||void 0===e||e.on("open",function(e,t){var r,i=null===(r=n.config)||void 0===r?void 0:r.ports[e];n.emit(Yi.CHANNEL_CONNECTED,{channel:e,port:i,allChannelsStatus:t})}),null===(t=this.device)||void 0===t||t.on("error",function(e,t){var r,i=n.extractErrorMessage(t);i||(i="WebSocket ".concat(e," channel connection failed"));var o=n.getErrorCodeForChannel(e,"connection_failed");n.emit(Yi.ERROR,{type:n.channelToErrorType(e),code:o,message:i,port:null===(r=n.config)||void 0===r?void 0:r.ports[e]})})},t.prototype.extractErrorMessage=function(e){if(e instanceof Error)return e.message||e.toString();if(e instanceof Event)return"".concat(e.type||"unknown");if("string"==typeof e)return e;if(e&&"object"===I(e))return e.message||e.reason||String(e);var t=String(e);return"[object Object]"===t||"[object Event]"===t?"":t},t.prototype.channelToErrorType=function(e){switch(e){case"video":return exports.VmosEdgeErrorType.VIDEO;case"audio":return exports.VmosEdgeErrorType.AUDIO;case"touch":return exports.VmosEdgeErrorType.TOUCH;default:return exports.VmosEdgeErrorType.CONNECTION}},t.prototype.getErrorCodeForChannel=function(e,t){if("video"===e)switch(t){case"connection_failed":return exports.VmosEdgeErrorCode.VIDEO_CHANNEL_CONNECTION_FAILED;case"connection_closed":return exports.VmosEdgeErrorCode.VIDEO_CHANNEL_CLOSED;default:return exports.VmosEdgeErrorCode.VIDEO_STREAM_ERROR}else{if("audio"===e)return"connection_failed"===t?exports.VmosEdgeErrorCode.AUDIO_CHANNEL_CONNECTION_FAILED:exports.VmosEdgeErrorCode.AUDIO_STREAM_ERROR;switch(t){case"connection_failed":default:return exports.VmosEdgeErrorCode.TOUCH_CHANNEL_CONNECTION_FAILED;case"parse_error":return exports.VmosEdgeErrorCode.TOUCH_MESSAGE_PARSE_ERROR}}},t.prototype.initCanvas=function(){this.canvasContainer=document.createElement("div"),this.canvasContainer.className="vmos-canvas-container",this.container.appendChild(this.canvasContainer),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),this.canvasContainer.appendChild(this.canvas),this.container.appendChild(this.canvasContainer)},t.prototype.replaceCanvas=function(){var e;this.canvas&&this.canvasContainer&&this.canvasContainer.removeChild(this.canvas),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),null===(e=this.canvasContainer)||void 0===e||e.appendChild(this.canvas)},t.prototype.applyCanvasStyle=function(e){e.style.width="100%",e.style.height="100%",e.style.outline="none",e.style.userSelect="none",e.style.backgroundColor="transparent",e.style.touchAction="none"},t.prototype.initTextareaManager=function(){var e=this;this.textareaManager=new Ii(this.container),this.textareaManager.on(ki,function(t){e.sendText(t)}),this.textareaManager.on(Ci,function(){e.sendKeyCode(Ri.Backspace,Di.Down),e.sendKeyCode(Ri.Backspace,Di.Up)}),this.textareaManager.on(Si,function(){e.sendKeyCode(Ri.Enter,Di.Down),e.sendKeyCode(Ri.Enter,Di.Up)}),this.textareaManager.on(Oi,function(){e.sendKeyCode(Ri.ArrowUp,Di.Down),e.sendKeyCode(Ri.ArrowUp,Di.Up)}),this.textareaManager.on(Ni,function(){e.sendKeyCode(Ri.ArrowDown,Di.Down),e.sendKeyCode(Ri.ArrowDown,Di.Up)}),this.textareaManager.on(Ai,function(){e.sendKeyCode(Ri.ArrowLeft,Di.Down),e.sendKeyCode(Ri.ArrowLeft,Di.Up)}),this.textareaManager.on(Ti,function(){e.sendKeyCode(Ri.ArrowRight,Di.Down),e.sendKeyCode(Ri.ArrowRight,Di.Up)})},t.prototype.observeContainerResize=function(){var e=this;"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(function(){e.updateCanvasSize()}),this.resizeObserver.observe(this.container))},t.prototype.on=function(t,n){return e.prototype.on.call(this,t,n),this},t.prototype.once=function(t,n){return e.prototype.once.call(this,t,n),this},t.prototype.off=function(t,n){return n?e.prototype.off.call(this,t,n):e.prototype.clear.call(this,t),this},t.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];e.prototype.emit.apply(this,H([t],j(n),!1))},t.prototype.start=function(){return B(this,void 0,void 0,function(){return U(this,function(e){switch(e.label){case 0:if(this.isRunning)return[2];this.isRunning=!0,this.retryCount=0,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.connectWithRetry()];case 2:return e.sent(),this.setupChannelStatusListener(),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}})})},t.prototype.connectWithRetry=function(){return B(this,void 0,void 0,function(){var e=this;return U(this,function(t){return[2,new Promise(function(t,n){var r=function(){return B(e,void 0,void 0,function(){var e,i,o,a=this;return U(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.internalStart()];case 1:return s.sent(),t(),[3,3];case 2:return e=s.sent(),console.error("[VmosEdgeClient] Connection failed (Attempt ".concat(this.retryCount+1,"/").concat(this.maxRetries+1,"):"),e),this.retryCount<this.maxRetries&&this.isRunning?(this.retryCount++,i=Math.min(this.retryInterval*Math.pow(2,this.retryCount-1),1e4),console.log("[VmosEdgeClient] Retrying in ".concat(i,"ms...")),setTimeout(function(){a.isRunning?r():n(new Error("Stopped"))},i)):(o=this.extractErrorMessage(e)||"连接失败",this.emit(Yi.ERROR,{type:exports.VmosEdgeErrorType.CONNECTION,code:exports.VmosEdgeErrorCode.CONNECTION_FAILED,message:o}),this.stop(),n(e)),[3,3];case 3:return[2]}})})};r()})]})})},t.prototype.internalStart=function(){return B(this,void 0,void 0,function(){var e,t,n,r,i,o,a,s,c,u,l=this;return U(this,function(d){switch(d.label){case 0:this.canvas&&this.canvasContainer||this.initCanvas(),this.stopVideoSubscription&&(this.stopVideoSubscription(),this.stopVideoSubscription=null),e=new Tn({sendFrameMeta:!0,sendCodecMeta:!0,sendDeviceMeta:!0}),t=null,n=null,d.label=1;case 1:return d.trys.push([1,3,,4]),r=this.createVideoStream(),i=r.videoStream,o=r.stopVideoSubscription,t=o,[4,this.performHandshake(e,i)];case 2:return a=d.sent(),s=a.metadata,c=a.stream,n=this.setupTouch(),this.createRenderer(),this.decoder=new pi({codec:s.codec,renderer:this.renderer,hardwareAcceleration:this.videoCodecPreference}),this.decoder.sizeChanged(function(e){var t=e.width,n=e.height,r=l.videoWidth,i=l.videoHeight;if(t!==r||n!==i){l.videoWidth=t,l.videoHeight=n;var o=t>n;0!==r&&0!==i&&r>i!==o&&(l.manualRotation=!1),l.manualRotation||(l.rotation=o?1:0),l.emitSizeChanged()}}),c.pipeThrough(e.createMediaStreamTransformer()).pipeTo(this.decoder.writable).catch(function(e){var t,n;console.error("[VmosEdgeClient] Video pipeline error:",e),null===(t=l.stopVideoSubscription)||void 0===t||t.call(l);var r=null===(n=l.config)||void 0===n?void 0:n.ports.video,i=l.extractErrorMessage(e)||"视频管道处理错误";l.emit(Yi.ERROR,{type:exports.VmosEdgeErrorType.VIDEO,code:exports.VmosEdgeErrorCode.VIDEO_PIPELINE_ERROR,message:i,port:r})}),this.bindInputEvents(),this.emit(Yi.STARTED),[3,4];case 3:throw u=d.sent(),null==t||t(),null==n||n(),u;case 4:return[2]}})})},t.prototype.createVideoStream=function(){var e,t,n=this,r=new ReadableStream({start:function(e){t=e},cancel:function(){var e;null===(e=n.stopVideoSubscription)||void 0===e||e.call(n)}}),i=function(e){var r,i;if(null!==t.desiredSize)try{var o=e instanceof Uint8Array?e:new Uint8Array(e);t.enqueue(o)}catch(e){null===(i=n.stopVideoSubscription)||void 0===i||i.call(n);var a=n.extractErrorMessage(e)||"视频流数据处理错误";n.emit(Yi.ERROR,{type:exports.VmosEdgeErrorType.VIDEO,code:exports.VmosEdgeErrorCode.VIDEO_STREAM_ERROR,message:a})}else null===(r=n.stopVideoSubscription)||void 0===r||r.call(n)};return null===(e=this.device)||void 0===e||e.subscribe("video",i),this.stopVideoSubscription=function(){var e;null===(e=n.device)||void 0===e||e.unsubscribe("video",i),n.stopVideoSubscription=null;try{t&&null!==t.desiredSize&&t.close()}catch(e){console.error("[VmosEdgeClient] stopVideoSubscription error:",e)}},{videoStream:r,stopVideoSubscription:this.stopVideoSubscription}},t.prototype.setupTouch=function(){var e,t=this,n=function(e){var n;try{var r=Fi.parse(e);(null==r?void 0:r.type)===Pi.Clipboard&&t.emit(Yi.CLIPBOARD_CHANGED,null!==(n=null==r?void 0:r.content)&&void 0!==n?n:"")}catch(e){console.error("[VmosEdgeClient] Touch channel error:",e)}};return null===(e=this.device)||void 0===e||e.subscribe("touch",n),function(){var e;return null===(e=t.device)||void 0===e?void 0:e.unsubscribe("touch",n)}},t.prototype.performHandshake=function(e,t){return B(this,void 0,void 0,function(){var n,r,i=this;return U(this,function(o){switch(o.label){case 0:n=null,r=new Promise(function(e,t){var r,o,a=!1,s=function(e){a||(a=!0,t(e))},c=function(e,t){console.error("[VmosEdgeClient] Handshake error on ".concat(e,":"),t),"video"===e&&s(new Error("Video channel connection failed"))},u=function(e){"video"===e&&s(new Error("Video channel closed unexpectedly during handshake"))};null===(r=i.device)||void 0===r||r.on("error",c),null===(o=i.device)||void 0===o||o.on("close",u),n=function(){var e,t;null===(e=i.device)||void 0===e||e.off("error",c),null===(t=i.device)||void 0===t||t.off("close",u)}}),o.label=1;case 1:return o.trys.push([1,,3,4]),[4,Promise.race([e.parseVideoStreamMetadata(t),r])];case 2:return[2,o.sent()];case 3:return n&&n(),[7];case 4:return[2]}})})},t.prototype.setGroupControlMode=function(e){var t,n;if(this.isGroupControl=e,!e){try{for(var r=V(this.deviceTouchGroupMap.values()),i=r.next();!i.done;i=r.next()){i.value.destroy()}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.deviceTouchGroupMap.clear()}},t.prototype.joinGroupControl=function(e){var t,n,r=this;if(this.isGroupControl){console.log("[VmosEdgeClient] joinGroupControl start",e);var i=function(e){if(!e.deviceId)return"continue";if(o.deviceTouchGroupMap.has(e.deviceId))return"continue";var t=new wi(e);t.subscribe("touch",function(){}),t.on("open",function(){r.emit(Yi.GROUP_CONTROL_JOINED,e)}),t.on("close",function(){t.destroy(),r.deviceTouchGroupMap.delete(e.deviceId),r.emit(Yi.GROUP_CONTROL_LEAVE,e)}),o.deviceTouchGroupMap.set(e.deviceId,t)},o=this;try{for(var a=V(e),s=a.next();!s.done;s=a.next()){i(s.value)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}},t.prototype.leaveGroupControl=function(e){var t,n,r;if(this.isGroupControl)try{for(var i=V(e),o=i.next();!o.done;o=i.next()){var a=o.value;a.deviceId&&(this.deviceTouchGroupMap.has(a.deviceId)&&(null===(r=this.deviceTouchGroupMap.get(a.deviceId))||void 0===r||r.destroy(),this.deviceTouchGroupMap.delete(a.deviceId)))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},t.prototype.stop=function(){var e,t,n,r;if(this.isRunning){if(this.isRunning=!1,null===(n=this.stopVideoSubscription)||void 0===n||n.call(this),this.unbindInputEvents(),this.emit(Yi.STOPPED),this.isGroupControl){try{for(var i=V(this.deviceTouchGroupMap.values()),o=i.next();!o.done;o=i.next()){o.value.destroy()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}this.deviceTouchGroupMap.clear()}if(this.clear(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.canvasContainer&&this.canvasContainer.parentNode&&(this.canvasContainer.parentNode.removeChild(this.canvasContainer),this.canvasContainer=null,this.canvas=null),null===(r=this.device)||void 0===r||r.destroy(),this.renderer){try{this.renderer.dispose()}catch(e){console.warn("[VmosEdgeClient] Renderer dispose error:",e)}this.renderer=null}if(this.decoder){if("function"==typeof this.decoder.dispose)try{this.decoder.dispose()}catch(e){console.warn("[VmosEdgeClient] Decoder dispose error:",e)}this.decoder=null}}},t.prototype.emitSizeChanged=function(){var e=this.updateCanvasSize(),t={idealWidth:e.idealWidth,idealHeight:e.idealHeight,videoWidth:e.videoWidth,videoHeight:e.videoHeight,rotation:this.rotation};this.emit(Yi.SIZE_CHANGED,t)},t.prototype.mapCoordinates=function(e,t){var n,r;switch(this.currentRotationAngle){case 90:n=t*this.videoWidth,r=(1-e)*this.videoHeight;break;case 270:n=(1-t)*this.videoWidth,r=e*this.videoHeight;break;default:n=e*this.videoWidth,r=t*this.videoHeight}return{x:n,y:r}},t.prototype.updateCanvasSize=function(){if(!this.canvasContainer||!this.videoWidth||!this.videoHeight)return{idealWidth:0,idealHeight:0,videoWidth:0,videoHeight:0};var e,t,n=this.container,r=n.clientWidth,i=n.clientHeight,o=this,a=o.videoWidth,s=o.videoHeight,c=o.rotation,u=r,l=i,d=Math.max(u,l),f=Math.min(u,l);1===c?(e=d,t=f):(e=f,t=d);var h=Math.min(r/e,i/t,1),p=e*h,v=t*h,_=a>s,m=0,y=90===(m=1===c?_?0:270:_?90:0)||270===m,b=y?s:a,g=y?a:s,w=Math.min(p/b,v/g),E=b*w,x=g*w,k=this.canvasContainer.style;k.width="".concat(Math.ceil(E),"px"),k.height="".concat(Math.ceil(x),"px"),k.display="block",k.position="relative",k.transform="none";var C=this.canvas,S=C.style;C.width!==a&&(C.width=a),C.height!==s&&(C.height=s);var O=y?x:E,N=y?E:x;S.width="".concat(Math.ceil(O),"px"),S.height="".concat(Math.ceil(N),"px"),S.position="absolute",S.top="50%",S.left="50%",S.transformOrigin="center center",S.transform="translate(-50%, -50%) rotate(".concat(m,"deg)"),this.currentRotationAngle=m;var A=Math.min(e/b,t/g);return{idealWidth:b*A,idealHeight:g*A,videoWidth:a,videoHeight:s}},t.prototype.createRenderer=function(){try{if(!yi.isSupported)throw new Error("WebGL not supported check");console.log("[VmosEdgeClient] Using WebGLVideoFrameRenderer"),this.renderer=new yi(this.canvas,this.renderPreference)}catch(e){console.warn("[VmosEdgeClient] WebGL initialization failed, falling back to Canvas2DRenderer:",e),this.replaceCanvas(),this.renderer=new bi(this.canvas)}},t.prototype.bindInputEvents=function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.addEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.addEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.addEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.addEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.addEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.addEventListener("wheel",this.handleWheelEvent,{passive:!1}),null===(a=this.canvas)||void 0===a||a.addEventListener("contextmenu",this.handleContextMenu)},t.prototype.unbindInputEvents=function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.removeEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.removeEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.removeEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.removeEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.removeEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.removeEventListener("wheel",this.handleWheelEvent),null===(a=this.canvas)||void 0===a||a.removeEventListener("contextmenu",this.handleContextMenu)},t.prototype.handleContextMenu=function(e){e.preventDefault(),e.stopPropagation()},t.prototype.handlePointerEvent=function(e){var n;if(this.videoWidth&&this.videoHeight){e.preventDefault(),e.stopPropagation();var r,i=this.canvas,o=e.type,a=e.clientX,s=e.clientY,c=e.button,u=e.buttons,l=e.pointerId;if("pointermove"===o){var d=Date.now();if(d-(this.pointerMoveThrottleMap.get(l)||0)<this.touchMoveInterval)return;this.pointerMoveThrottleMap.set(l,d)}if("pointerdown"===o){if(2===c)return void this.back();if(1===c)return void this.home()}else if("pointerup"===o){if(2===c||1===c)return}else if("pointermove"===o&&(2&u||4&u))return;switch(o){case"pointerdown":r=Li.Down,i.setPointerCapture(l),null===(n=this.textareaManager)||void 0===n||n.focus();break;case"pointermove":r=0===u?Li.HoverMove:Li.Move;break;case"pointerup":case"pointercancel":case"pointerleave":r=Li.Up,i.releasePointerCapture(l),this.pointerMoveThrottleMap.delete(l);break;default:return}var f=i.getBoundingClientRect(),h=qi((a-f.x)/f.width,0,1),p=qi((s-f.y)/f.height,0,1),v=this.mapCoordinates(h,p),_=v.x,m=v.y,y=zi.injectTouch({action:r,pointerId:BigInt(l),pointerX:_,pointerY:m,screenWidth:this.videoWidth,screenHeight:this.videoHeight,pressure:0===u?0:1,actionButton:t.PointerEventButtonToAndroidButton[c]||Wi.Primary,buttons:u});this.sendTouch(y)}},t.prototype.sendTouch=function(e){var t,n,r;if(null===(r=this.device)||void 0===r||r.sendTouch(e),this.isGroupControl)try{for(var i=V(this.deviceTouchGroupMap.values()),o=i.next();!o.done;o=i.next()){o.value.sendTouch(e)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},t.prototype.handleWheelEvent=function(e){if(this.videoWidth&&this.videoHeight&&this.device){e.preventDefault(),e.stopPropagation();var t=this.canvas.getBoundingClientRect(),n=qi((e.clientX-t.x)/t.width,0,1),r=qi((e.clientY-t.y)/t.height,0,1),i=this.mapCoordinates(n,r),o=i.x,a=i.y,s=zi.injectScroll({pointerX:o,pointerY:a,screenWidth:this.videoWidth,screenHeight:this.videoHeight,scrollX:-e.deltaX,scrollY:-e.deltaY,buttons:0});this.sendTouch(s)}},t.prototype.sendText=function(e){this.device&&this.sendTouch(zi.injectText({text:e}))},t.prototype.sendKeyCode=function(e,t,n){void 0===n&&(n=0),this.device&&this.sendTouch(zi.injectKeyCode({keyCode:e,action:t,repeat:0,metaState:n}))},t.prototype.clickKey=function(e,t){void 0===t&&(t=0),this.sendKeyCode(e,Di.Down,t),this.sendKeyCode(e,Di.Up,t)},t.prototype.volumeUp=function(){this.clickKey(Ri.VolumeUp)},t.prototype.volumeDown=function(){this.clickKey(Ri.VolumeDown)},t.prototype.home=function(){this.clickKey(Ri.AndroidHome)},t.prototype.back=function(){this.clickKey(Ri.AndroidBack)},t.prototype.menu=function(){this.clickKey(Ri.AndroidAppSwitch)},t.prototype.setRotation=function(e){this.rotation!==e&&(this.manualRotation=!0,this.rotation=e,this.emitSizeChanged())},t.prototype.getRotation=function(){return this.rotation},t.prototype.getRunningState=function(){return this.isRunning},t.prototype.getVideoSize=function(){return{width:this.videoWidth,height:this.videoHeight}},t.prototype.getConfig=function(){return this.config?G({},this.config):null},t.prototype.getScale=function(){return this.canvas&&this.videoWidth?this.canvas.getBoundingClientRect().width/this.videoWidth:1},t.PointerEventButtonToAndroidButton=[Wi.Primary,Wi.Tertiary,Wi.Secondary,Wi.Back,Wi.Forward],t}(gi);exports.AndroidKeyCode=Ri,exports.AndroidKeyEventAction=Di,exports.AndroidMetaState={None:0,AltOn:2,AltLeftOn:16,AltRightOn:32,ShiftOn:1,ShiftLeftOn:64,ShiftRightOn:128,SymOn:4,FunctionOn:8,CtrlOn:4096,CtrlLeftOn:8192,CtrlRightOn:16384,MetaOn:65536,MetaLeftOn:131072,MetaRightOn:262144,CapsLockOn:1048576,NumLockOn:2097152,ScrollLockOn:4194304},exports.AndroidMotionEventAction=Li,exports.AndroidMotionEventButton=Wi,exports.VmosEdgeClient=Ji,exports.VmosEdgeClientEvents=Yi;
|