398 lines
257 KiB
JavaScript
398 lines
257 KiB
JavaScript
var nt=Object.defineProperty;var it=(f,e,t)=>e in f?nt(f,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[e]=t;var ae=(f,e,t)=>it(f,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const S of o.addedNodes)S.tagName==="LINK"&&S.rel==="modulepreload"&&n(S)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();var _e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rt(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var qe={},De={},X={};Object.defineProperty(X,"__esModule",{value:!0});X.NOISEREDUCTION3D_MODE=X.WIDEDYNAMICRANGE_MODE=X.WHITEBALANCE_MODE=X.ANTIFLICKER=X.IRIS=X.GAIN=X.SHUTTER=X.EXPOSURE_MODE=X.FOCUS_MODE=X.FOCUS_COMMAND=X.ZOOM_COMMAND=X.HOME_COMMAND=X.MOVE_COMMAND=void 0;X.MOVE_COMMAND={up:{on:1,off:0},down:{on:2,off:0},left:{on:3,off:0},right:{on:4,off:0}};X.HOME_COMMAND=5;X.ZOOM_COMMAND={in:{on:1,off:0},out:{on:2,off:0}};X.FOCUS_COMMAND={near:{on:1,off:0},far:{on:2,off:0}};X.FOCUS_MODE=["auto","manual"];X.EXPOSURE_MODE=["auto","manual","iris priority","shutter priority","brightness priority"];X.SHUTTER={"1/25":5,"1/50":6,"1/75":7,"1/100":8,"1/120":9,"1/150":10,"1/215":11,"1/300":12,"1/425":13,"1/600":14,"1/1000":15,"1/1250":16,"1/1750":17,"1/2500":18,"1/3500":19,"1/6000":20,"1/10000":21};X.GAIN={"0dB":0,"2dB":1,"4dB":2,"6dB":3,"8dB":4,"10dB":5,"12dB":6,"14dB":7,"16dB":8,"18dB":9,"20dB":10,"22dB":11,"24dB":12,"26dB":13,"28dB":14,"30dB":15};X.IRIS={Close:0,"F14.0":1,"F11.0":2,"F9.6":3,"F8.0":4,"F6.8":5,"F5.6":6,"F4.8":7,"F4.0":8,"F3.4":9,"F2.8":10,"F2.4":11,"F2.0":12,"F1.8":13};X.ANTIFLICKER={Off:0,"50Hz":1,"60Hz":2};X.WHITEBALANCE_MODE=["auto","indoor","outdoor","one push","auto tracking","manual","temperature"];X.WIDEDYNAMICRANGE_MODE=["Off",1,2,3,4,5,6];X.NOISEREDUCTION3D_MODE={Off:5,Auto:0,1:1,2:2,3:3,4:4};var Ie={},st=_e&&_e.__awaiter||function(f,e,t,n){function i(o){return o instanceof t?o:new t(function(S){S(o)})}return new(t||(t=Promise))(function(o,S){function E(m){try{x(n.next(m))}catch(h){S(h)}}function y(m){try{x(n.throw(m))}catch(h){S(h)}}function x(m){m.done?o(m.value):i(m.value).then(E,y)}x((n=n.apply(f,e||[])).next())})},ot=_e&&_e.__generator||function(f,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,S;return S={next:E(0),throw:E(1),return:E(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function E(x){return function(m){return y([x,m])}}function y(x){if(n)throw new TypeError("Generator is already executing.");for(;S&&(S=0,x[0]&&(t=0)),t;)try{if(n=1,i&&(o=x[0]&2?i.return:x[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,x[1])).done)return o;switch(i=0,o&&(x=[x[0]&2,o.value]),x[0]){case 0:case 1:o=x;break;case 4:return t.label++,{value:x[1],done:!1};case 5:t.label++,i=x[1],x=[0];continue;case 7:x=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(x[0]===6||x[0]===2)){t=0;continue}if(x[0]===3&&(!o||x[1]>o[0]&&x[1]<o[3])){t.label=x[1];break}if(x[0]===6&&t.label<o[1]){t.label=o[1],o=x;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(x);break}o[2]&&t.ops.pop(),t.trys.pop();continue}x=e.call(f,t)}catch(m){x=[6,m],i=0}finally{n=o=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.requestToken=void 0;function at(f,e,t){return st(this,void 0,void 0,function(){var n,i,o,S,E;return ot(this,function(y){switch(y.label){case 0:return n="http://".concat(f,"/cgi-bin/web.fcgi?func=get"),i={key:null,system:{login:"".concat(e,":").concat(t)}},[4,fetch(n,{method:"POST",body:JSON.stringify(i)})];case 1:return o=y.sent(),[4,o.json()];case 2:return S=y.sent(),E=(S==null?void 0:S.key)!==!1&&(S==null?void 0:S.system)!==!1&&(S==null?void 0:S.status)!==!1,E?[2,{valid:!0,login:S.system.login}]:[2,{valid:!1}]}})})}Ie.requestToken=at;var Ne=_e&&_e.__assign||function(){return Ne=Object.assign||function(f){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(f[i]=e[i])}return f},Ne.apply(this,arguments)},F=_e&&_e.__awaiter||function(f,e,t,n){function i(o){return o instanceof t?o:new t(function(S){S(o)})}return new(t||(t=Promise))(function(o,S){function E(m){try{x(n.next(m))}catch(h){S(h)}}function y(m){try{x(n.throw(m))}catch(h){S(h)}}function x(m){m.done?o(m.value):i(m.value).then(E,y)}x((n=n.apply(f,e||[])).next())})},U=_e&&_e.__generator||function(f,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,S;return S={next:E(0),throw:E(1),return:E(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function E(x){return function(m){return y([x,m])}}function y(x){if(n)throw new TypeError("Generator is already executing.");for(;S&&(S=0,x[0]&&(t=0)),t;)try{if(n=1,i&&(o=x[0]&2?i.return:x[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,x[1])).done)return o;switch(i=0,o&&(x=[x[0]&2,o.value]),x[0]){case 0:case 1:o=x;break;case 4:return t.label++,{value:x[1],done:!1};case 5:t.label++,i=x[1],x=[0];continue;case 7:x=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(x[0]===6||x[0]===2)){t=0;continue}if(x[0]===3&&(!o||x[1]>o[0]&&x[1]<o[3])){t.label=x[1];break}if(x[0]===6&&t.label<o[1]){t.label=o[1],o=x;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(x);break}o[2]&&t.ops.pop(),t.trys.pop();continue}x=e.call(f,t)}catch(m){x=[6,m],i=0}finally{n=o=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}};Object.defineProperty(De,"__esModule",{value:!0});De.EveretPTZ=void 0;var ee=X,lt=Ie,ut=function(){function f(e,t,n){var i=this;this.ip=e,this.ready=!1,this._onError=null,this.ip=e,(0,lt.requestToken)(e,t,n).then(function(o){var S=o.valid,E=o.login;S||i.throwError(new Error("Invalid login credentials")),i.token=E,i.ready=!0})}return f.prototype.getInfo=function(){return F(this,void 0,void 0,function(){var e,t;return U(this,function(n){switch(n.label){case 0:return e={system:{app_version:!0,bootloader_version:!0,device_name:!0,serial_number:!0,system_version:!0}},[4,this.request("get",e)];case 1:return t=n.sent(),[2,t==null?void 0:t.system]}})})},f.prototype.home=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{ptz:[ee.HOME_COMMAND,0]}},[4,this.request("set",t)];case 1:return n=i.sent(),[2,((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.ptz)===!0]}})})},f.prototype.move=function(e,t,n){var i;return n===void 0&&(n=10),F(this,void 0,void 0,function(){var o,S;return U(this,function(E){switch(E.label){case 0:return o={image:{ptz:[ee.MOVE_COMMAND[e][t?"on":"off"],n]}},[4,this.request("set",o)];case 1:return S=E.sent(),[2,((i=S==null?void 0:S.image)===null||i===void 0?void 0:i.ptz)===!0]}})})},f.prototype.zoom=function(e,t,n){var i;return n===void 0&&(n=7),F(this,void 0,void 0,function(){var o,S;return U(this,function(E){switch(E.label){case 0:return o={image:{zoom:[ee.ZOOM_COMMAND[e][t?"on":"off"],n]}},[4,this.request("set",o)];case 1:return S=E.sent(),[2,((i=S==null?void 0:S.image)===null||i===void 0?void 0:i.zoom)===!0]}})})},f.prototype.focus=function(e,t,n){var i;return n===void 0&&(n=7),F(this,void 0,void 0,function(){var o,S;return U(this,function(E){switch(E.label){case 0:return o={image:{focus:[ee.FOCUS_COMMAND[e][t?"on":"off"],n]}},[4,this.request("set",o)];case 1:return S=E.sent(),[2,((i=S==null?void 0:S.image)===null||i===void 0?void 0:i.focus)===!0]}})})},f.prototype.setFocusMode=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{focus_mode:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.focus_mode)===e]}})})},f.prototype.getFocusMode=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{focus_mode:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.focus_mode]}})})},f.prototype.setExposureMode=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{exposure_mode:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.exposure_mode)===e]}})})},f.prototype.getExposureMode=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{exposure_mode:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.exposure_mode]}})})},f.prototype.setShutter=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{shutter:ee.SHUTTER[e]}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.shutter)===ee.SHUTTER[e]]}})})},f.prototype.getShutter=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{shutter:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),isNaN((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.shutter)?[2,null]:[2,Object.keys(ee.SHUTTER).find(function(o){return ee.SHUTTER[o]===n.image.shutter})]}})})},f.prototype.setExposureGain=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{gain:ee.GAIN[e]}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.gain)===ee.GAIN[e]]}})})},f.prototype.getExposureGain=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{gain:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),isNaN((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.gain)?[2,null]:[2,Object.keys(ee.GAIN).find(function(o){return ee.GAIN[o]===n.image.gain})]}})})},f.prototype.setIris=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{iris:ee.IRIS[e]}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.iris)===ee.IRIS[e]]}})})},f.prototype.getIris=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{iris:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),isNaN((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.iris)?[2,null]:[2,Object.keys(ee.IRIS).find(function(o){return ee.IRIS[o]===n.image.iris})]}})})},f.prototype.setExposureBrightness=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{exposure_brightness:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.exposure_brightness)===e]}})})},f.prototype.getExposureBrightness=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{exposure_brightness:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.exposure_brightness]}})})},f.prototype.setAntiFlicker=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{anti_flicker:ee.ANTIFLICKER[e]}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.anti_flicker)===ee.ANTIFLICKER[e]]}})})},f.prototype.getAntiFlicker=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{anti_flicker:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),isNaN((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.anti_flicker)?[2,null]:[2,Object.keys(ee.ANTIFLICKER).find(function(o){return ee.ANTIFLICKER[o]===n.image.anti_flicker})]}})})},f.prototype.setWhiteBalanceMode=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{WB_mode:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.WB_mode)===e]}})})},f.prototype.getWhiteBalanceMode=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{WB_mode:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.WB_mode]}})})},f.prototype.setRedGain=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{R_gain:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.R_gain)===e]}})})},f.prototype.getRedGain=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{R_gain:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.R_gain]}})})},f.prototype.setBlueGain=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{B_gain:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.B_gain)===e]}})})},f.prototype.getBlueGain=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{B_gain:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.B_gain]}})})},f.prototype.setColorTemperature=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return(e<1800||e>1e4)&&this.throwError(new Error("Color temperature must be between 1800 and 10000")),n={image:{color_temperature:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.color_temperature)===e]}})})},f.prototype.getColorTemperature=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{color_temperature:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.color_temperature]}})})},f.prototype.setMirror=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{mirror:e?1:0}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.mirror)===(e?1:0)]}})})},f.prototype.getMirror=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{mirror:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.mirror)===1]}})})},f.prototype.setFlip=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{flip:e?1:0}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.flip)===(e?1:0)]}})})},f.prototype.getFlip=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{flip:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.flip)===1]}})})},f.prototype.setBacklightCompensation=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{backlight_compensation:e?1:0}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.backlight_compensation)===(e?1:0)]}})})},f.prototype.getBacklightCompensation=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{backlight_compensation:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.backlight_compensation)===1]}})})},f.prototype.setGamma=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{gamma:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.gamma)===e]}})})},f.prototype.getGamma=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{gamma:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.gamma]}})})},f.prototype.setWideDynamicRange=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:e=="Off"?{WDR_enable:0,WDR_level:1}:{WDR_enable:1,WDR_level:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.WDR_mode)===e]}})})},f.prototype.getWideDynamicRange=function(){var e,t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{WDR_enable:!0,WDR_level:!0}},[4,this.request("get",n)];case 1:return i=o.sent(),((e=i==null?void 0:i.image)===null||e===void 0?void 0:e.WDR_enable)===0?[2,"Off"]:[2,(t=i==null?void 0:i.image)===null||t===void 0?void 0:t.WDR_level]}})})},f.prototype.setBrightness=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{brightness:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.brightness)===e]}})})},f.prototype.getBrightness=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{brightness:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.brightness]}})})},f.prototype.setSharpness=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{sharpness:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.sharpness)===e]}})})},f.prototype.getSharpness=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{sharpness:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.sharpness]}})})},f.prototype.setContrast=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{contrast:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.contrast)===e]}})})},f.prototype.getContrast=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{contrast:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.contrast]}})})},f.prototype.setSaturation=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{saturation:e}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.saturation)===e]}})})},f.prototype.getSaturation=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{saturation:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,(e=n==null?void 0:n.image)===null||e===void 0?void 0:e.saturation]}})})},f.prototype.set2dNoiseReduction=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{noise_reduction_2D:e?1:0}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.noise_reduction_2D)===(e?1:0)]}})})},f.prototype.get2dNoiseReduction=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{noise_reduction_2D:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),[2,((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.noise_reduction_2D)===1]}})})},f.prototype.set3dNoiseReduction=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{noise_reduction_3D:ee.NOISEREDUCTION3D_MODE[e]}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.noise_reduction_3D)===ee.NOISEREDUCTION3D_MODE[e]]}})})},f.prototype.get3dNoiseReduction=function(){var e;return F(this,void 0,void 0,function(){var t,n;return U(this,function(i){switch(i.label){case 0:return t={image:{noise_reduction_3D:!0}},[4,this.request("get",t)];case 1:return n=i.sent(),isNaN((e=n==null?void 0:n.image)===null||e===void 0?void 0:e.noise_reduction_3D)?[2,null]:[2,Object.keys(ee.NOISEREDUCTION3D_MODE).find(function(o){return ee.NOISEREDUCTION3D_MODE[o]===n.image.noise_reduction_3D})]}})})},f.prototype.getRTSPUrl=function(e){var t,n;return e===void 0&&(e="main"),F(this,void 0,void 0,function(){var i,o;return U(this,function(S){switch(S.label){case 0:return i={venc:{main:e==="main",sub:e==="sub"}},[4,this.request("get",i)];case 1:return o=S.sent(),[2,(n=(t=o==null?void 0:o.venc)===null||t===void 0?void 0:t[e])===null||n===void 0?void 0:n.rtspUrl]}})})},f.prototype.getRTMPUrl=function(e){var t,n;return e===void 0&&(e="main"),F(this,void 0,void 0,function(){var i,o;return U(this,function(S){switch(S.label){case 0:return i={venc:{main:e==="main",sub:e==="sub"}},[4,this.request("get",i)];case 1:return o=S.sent(),[2,(n=(t=o==null?void 0:o.venc)===null||t===void 0?void 0:t[e])===null||n===void 0?void 0:n.rtmpUrl]}})})},f.prototype.getFLVUrl=function(e){var t,n;return e===void 0&&(e="main"),F(this,void 0,void 0,function(){var i,o;return U(this,function(S){switch(S.label){case 0:return i={venc:{main:e==="main",sub:e==="sub"}},[4,this.request("get",i)];case 1:return o=S.sent(),[2,(n=(t=o==null?void 0:o.venc)===null||t===void 0?void 0:t[e])===null||n===void 0?void 0:n.httpFlvUrl]}})})},f.prototype.getWebRTCUrl=function(e){var t,n;return e===void 0&&(e="main"),F(this,void 0,void 0,function(){var i,o;return U(this,function(S){switch(S.label){case 0:return i={venc:{main:e==="main",sub:e==="sub"}},[4,this.request("get",i)];case 1:return o=S.sent(),[2,(n=(t=o==null?void 0:o.venc)===null||t===void 0?void 0:t[e])===null||n===void 0?void 0:n.webRtcUrl]}})})},f.prototype.recallPreset=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{preset:{call:e}}},[4,this.request("set",n)];case 1:return i=o.sent(),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.preset)===!0]}})})},f.prototype.setPreset=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{preset:{add:e}}},[4,this.request("set",n)];case 1:return i=o.sent(),console.log("Set preset response:",i),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.preset)===!0]}})})},f.prototype.clearPreset=function(e){var t;return F(this,void 0,void 0,function(){var n,i;return U(this,function(o){switch(o.label){case 0:return n={image:{preset:{del:e}}},[4,this.request("set",n)];case 1:return i=o.sent(),console.log("Set preset response:",i),[2,((t=i==null?void 0:i.image)===null||t===void 0?void 0:t.preset)===!0]}})})},f.prototype.throwError=function(e){if(typeof this._onError=="function")return this._onError(e);throw e},f.prototype.onError=function(e){return F(this,void 0,void 0,function(){return U(this,function(t){return this._onError=e,[2]})})},f.prototype.whenReady=function(){return F(this,void 0,void 0,function(){var e=this;return U(this,function(t){return this.ready?[2]:[2,new Promise(function(n){var i=setInterval(function(){e.ready&&(clearInterval(i),n())},100)})]})})},f.prototype.request=function(e,t){return F(this,void 0,void 0,function(){var n,i,o,S;return U(this,function(E){switch(E.label){case 0:return E.trys.push([0,3,,4]),n="http://".concat(this.ip,"/cgi-bin/web.fcgi?func=").concat(e),i=Ne({key:this.token},t),[4,fetch(n,{method:"POST",body:JSON.stringify(i)})];case 1:return o=E.sent(),[4,o.json()];case 2:return[2,E.sent()];case 3:return S=E.sent(),this.throwError(S),[2,null];case 4:return[2]}})})},f}();De.EveretPTZ=ut;(function(f){Object.defineProperty(f,"__esModule",{value:!0}),f.EveretPTZ=void 0;var e=De;Object.defineProperty(f,"EveretPTZ",{enumerable:!0,get:function(){return e.EveretPTZ}})})(qe);const Me=(f,e)=>{const t=e.x-f.x,n=e.y-f.y;return Math.sqrt(t*t+n*n)},ct=(f,e)=>{const t=e.x-f.x,n=e.y-f.y;return ft(Math.atan2(n,t))},dt=(f,e,t)=>{const n={x:0,y:0};return t=je(t),n.x=f.x-e*Math.cos(t),n.y=f.y-e*Math.sin(t),n},je=f=>f*(Math.PI/180),ft=f=>f*(180/Math.PI),ht=f=>isNaN(f.buttons)?f.pressure!==0:f.buttons!==0,Fe=new Map,We=f=>{Fe.has(f)&&clearTimeout(Fe.get(f)),Fe.set(f,setTimeout(f,100))},Pe=(f,e,t)=>{const n=e.split(/[ ,]+/g);let i;for(let o=0;o<n.length;o+=1)i=n[o],f.addEventListener?f.addEventListener(i,t,!1):f.attachEvent&&f.attachEvent(i,t)},Ve=(f,e,t)=>{const n=e.split(/[ ,]+/g);let i;for(let o=0;o<n.length;o+=1)i=n[o],f.removeEventListener?f.removeEventListener(i,t):f.detachEvent&&f.detachEvent(i,t)},Xe=f=>(f.preventDefault(),f.type.match(/^touch/)?f.changedTouches:f),Ke=()=>{const f=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:f,y:e}},ze=(f,e)=>{e.top||e.right||e.bottom||e.left?(f.style.top=e.top,f.style.right=e.right,f.style.bottom=e.bottom,f.style.left=e.left):(f.style.left=e.x+"px",f.style.top=e.y+"px")},Ge=(f,e,t)=>{const n=Ye(f);for(let i in n)if(n.hasOwnProperty(i))if(typeof e=="string")n[i]=e+" "+t;else{let o="";for(let S=0,E=e.length;S<E;S+=1)o+=e[S]+" "+t+", ";n[i]=o.slice(0,-2)}return n},pt=(f,e)=>{const t=Ye(f);for(let n in t)t.hasOwnProperty(n)&&(t[n]=e);return t},Ye=f=>{const e={};return e[f]="",["webkit","Moz","o"].forEach(function(n){e[n+f.charAt(0).toUpperCase()+f.slice(1)]=""}),e},Ue=(f,e)=>{for(let t in e)e.hasOwnProperty(t)&&(f[t]=e[t]);return f},_t=(f,e)=>{const t={};for(let n in f)f.hasOwnProperty(n)&&e.hasOwnProperty(n)?t[n]=e[n]:f.hasOwnProperty(n)&&(t[n]=f[n]);return t},$e=(f,e)=>{if(f.length)for(let t=0,n=f.length;t<n;t+=1)e(f[t]);else e(f)},mt=(f,e,t)=>({x:Math.min(Math.max(f.x,e.x-t),e.x+t),y:Math.min(Math.max(f.y,e.y-t),e.y+t)});var vt="ontouchstart"in window,gt=!!window.PointerEvent,yt=!!window.MSPointerEvent,Ce={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Le,Oe={};gt?Le=Ce.pointer:yt?Le=Ce.MSPointer:vt?(Le=Ce.touch,Oe=Ce.mouse):Le=Ce.mouse;function ge(){}ge.prototype.on=function(f,e){var t=this,n=f.split(/[ ,]+/g),i;t._handlers_=t._handlers_||{};for(var o=0;o<n.length;o+=1)i=n[o],t._handlers_[i]=t._handlers_[i]||[],t._handlers_[i].push(e);return t};ge.prototype.off=function(f,e){var t=this;return t._handlers_=t._handlers_||{},f===void 0?t._handlers_={}:e===void 0?t._handlers_[f]=null:t._handlers_[f]&&t._handlers_[f].indexOf(e)>=0&&t._handlers_[f].splice(t._handlers_[f].indexOf(e),1),t};ge.prototype.trigger=function(f,e){var t=this,n=f.split(/[ ,]+/g),i;t._handlers_=t._handlers_||{};for(var o=0;o<n.length;o+=1)i=n[o],t._handlers_[i]&&t._handlers_[i].length&&t._handlers_[i].forEach(function(S){S.call(t,{type:i,target:t},e)})};ge.prototype.config=function(f){var e=this;e.options=e.defaults||{},f&&(e.options=_t(e.options,f))};ge.prototype.bindEvt=function(f,e){var t=this;return t._domHandlers_=t._domHandlers_||{},t._domHandlers_[e]=function(){typeof t["on"+e]=="function"?t["on"+e].apply(t,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},Pe(f,Le[e],t._domHandlers_[e]),Oe[e]&&Pe(f,Oe[e],t._domHandlers_[e]),t};ge.prototype.unbindEvt=function(f,e){var t=this;return t._domHandlers_=t._domHandlers_||{},Ve(f,Le[e],t._domHandlers_[e]),Oe[e]&&Ve(f,Oe[e],t._domHandlers_[e]),delete t._domHandlers_[e],this};function ne(f,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=f,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=ne.id,ne.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}ne.prototype=new ge;ne.constructor=ne;ne.id=0;ne.prototype.buildEl=function(f){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};ne.prototype.stylize=function(){if(this.options.dataOnly)return this;var f=this.options.fadeTime+"ms",e=pt("borderRadius","50%"),t=Ge("transition","opacity",f),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",left:0,marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:this.options.color,opacity:".5"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",left:0,marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:this.options.color,opacity:".5",transform:"translate(0px, 0px)"},Ue(n.el,t),this.options.shape==="circle"&&Ue(n.back,e),Ue(n.front,e),this.applyStyles(n),this};ne.prototype.applyStyles=function(f){for(var e in this.ui)if(this.ui.hasOwnProperty(e))for(var t in f[e])this.ui[e].style[t]=f[e][t];return this};ne.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};ne.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};ne.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};ne.prototype.show=function(f){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof f=="function"&&f.call(this)},e.options.fadeTime)),e};ne.prototype.hide=function(f){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var t=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=t,typeof f=="function"&&f.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){const t=e.options.restJoystick,n={};n.x=t===!0||t.x!==!1?0:e.instance.frontPosition.x,n.y=t===!0||t.y!==!1?0:e.instance.frontPosition.y,e.setPosition(f,n)}return e};ne.prototype.setPosition=function(f,e){var t=this;t.frontPosition={x:e.x,y:e.y};var n=t.options.fadeTime+"ms",i={};i.front=Ge("transition",["transform"],n);var o={front:{}};o.front={transform:"translate("+t.frontPosition.x+"px,"+t.frontPosition.y+"px)"},t.applyStyles(i),t.applyStyles(o),t.restTimeout=setTimeout(function(){typeof f=="function"&&f.call(t),t.restCallback()},t.options.fadeTime)};ne.prototype.restCallback=function(){var f=this,e={};e.front=Ge("transition","none",""),f.applyStyles(e),f.trigger("rested",f.instance)};ne.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};ne.prototype.computeDirection=function(f){var e=f.angle.radian,t=Math.PI/4,n=Math.PI/2,i,o,S;if(e>t&&e<t*3&&!f.lockX?i="up":e>-t&&e<=t&&!f.lockY?i="left":e>-t*3&&e<=-t&&!f.lockX?i="down":f.lockY||(i="right"),f.lockY||(e>-n&&e<n?o="left":o="right"),f.lockX||(e>0?S="up":S="down"),f.force>this.options.threshold){var E={},y;for(y in this.direction)this.direction.hasOwnProperty(y)&&(E[y]=this.direction[y]);var x={};this.direction={x:o,y:S,angle:i},f.direction=this.direction;for(y in E)E[y]===this.direction[y]&&(x[y]=!0);if(x.x&&x.y&&x.angle)return f;(!x.x||!x.y)&&this.trigger("plain",f),x.x||this.trigger("plain:"+o,f),x.y||this.trigger("plain:"+S,f),x.angle||this.trigger("dir dir:"+i,f)}else this.resetDirection();return f};function te(f,e){var t=this;t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.pressureIntervals={},t.manager=f,t.id=te.id,te.id+=1,t.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},t.config(e),(t.options.mode==="static"||t.options.mode==="semi")&&(t.options.multitouch=!1),t.options.multitouch||(t.options.maxNumberOfNipples=1);const n=getComputedStyle(t.options.zone.parentElement);return n&&n.display==="flex"&&(t.parentIsFlex=!0),t.updateBox(),t.prepareNipples(),t.bindings(),t.begin(),t.nipples}te.prototype=new ge;te.constructor=te;te.id=0;te.prototype.prepareNipples=function(){var f=this,e=f.nipples;e.on=f.on.bind(f),e.off=f.off.bind(f),e.options=f.options,e.destroy=f.destroy.bind(f),e.ids=f.ids,e.id=f.id,e.processOnMove=f.processOnMove.bind(f),e.processOnEnd=f.processOnEnd.bind(f),e.get=function(t){if(t===void 0)return e[0];for(var n=0,i=e.length;n<i;n+=1)if(e[n].identifier===t)return e[n];return!1}};te.prototype.bindings=function(){var f=this;f.bindEvt(f.options.zone,"start"),f.options.zone.style.touchAction="none",f.options.zone.style.msTouchAction="none"};te.prototype.begin=function(){var f=this,e=f.options;if(e.mode==="static"){var t=f.createNipple(e.position,f.manager.getIdentifier());t.add(),f.idles.push(t)}};te.prototype.createNipple=function(f,e){var t=this,n=t.manager.scroll,i={},o=t.options,S={x:t.parentIsFlex?n.x:n.x+t.box.left,y:t.parentIsFlex?n.y:n.y+t.box.top};if(f.x&&f.y)i={x:f.x-S.x,y:f.y-S.y};else if(f.top||f.right||f.bottom||f.left){var E=document.createElement("DIV");E.style.display="hidden",E.style.top=f.top,E.style.right=f.right,E.style.bottom=f.bottom,E.style.left=f.left,E.style.position="absolute",o.zone.appendChild(E);var y=E.getBoundingClientRect();o.zone.removeChild(E),i=f,f={x:y.left+n.x,y:y.top+n.y}}var x=new ne(t,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:e,position:f,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(ze(x.ui.el,i),ze(x.ui.front,x.frontPosition)),t.nipples.push(x),t.trigger("added "+x.identifier+":added",x),t.manager.trigger("added "+x.identifier+":added",x),t.bindNipple(x),x};te.prototype.updateBox=function(){var f=this;f.box=f.options.zone.getBoundingClientRect()};te.prototype.bindNipple=function(f){var e=this,t,n=function(i,o){t=i.type+" "+o.id+":"+i.type,e.trigger(t,o)};f.on("destroyed",e.onDestroyed.bind(e)),f.on("shown hidden rested dir plain",n),f.on("dir:up dir:right dir:down dir:left",n),f.on("plain:up plain:right plain:down plain:left",n)};te.prototype.pressureFn=function(f,e,t){var n=this,i=0;clearInterval(n.pressureIntervals[t]),n.pressureIntervals[t]=setInterval((function(){var o=f.force||f.pressure||f.webkitForce||0;o!==i&&(e.trigger("pressure",o),n.trigger("pressure "+e.identifier+":pressure",o),i=o)}).bind(n),100)};te.prototype.onstart=function(f){var e=this,t=e.options,n=f;f=Xe(f),e.updateBox();var i=function(o){e.actives.length<t.maxNumberOfNipples?e.processOnStart(o):n.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(S){if(Object.values(n.touches).findIndex(function(y){return y.identifier===S})<0){var E=[f[0]];E.identifier=S,e.processOnEnd(E)}}),e.actives.length<t.maxNumberOfNipples&&e.processOnStart(o))};return $e(f,i),e.manager.bindDocument(),!1};te.prototype.processOnStart=function(f){var e=this,t=e.options,n,i=e.manager.getIdentifier(f),o=f.force||f.pressure||f.webkitForce||0,S={x:f.pageX,y:f.pageY},E=e.getOrCreate(i,S);E.identifier!==i&&e.manager.removeIdentifier(E.identifier),E.identifier=i;var y=function(m){m.trigger("start",m),e.trigger("start "+m.id+":start",m),m.show(),o>0&&e.pressureFn(f,m,m.identifier),e.processOnMove(f)};if((n=e.idles.indexOf(E))>=0&&e.idles.splice(n,1),e.actives.push(E),e.ids.push(E.identifier),t.mode!=="semi")y(E);else{var x=Me(S,E.position);if(x<=t.catchDistance)y(E);else{E.destroy(),e.processOnStart(f);return}}return E};te.prototype.getOrCreate=function(f,e){var t=this,n=t.options,i;return/(semi|static)/.test(n.mode)?(i=t.idles[0],i?(t.idles.splice(0,1),i):n.mode==="semi"?t.createNipple(e,f):(console.warn("Coudln't find the needed nipple."),!1)):(i=t.createNipple(e,f),i)};te.prototype.processOnMove=function(f){var e=this,t=e.options,n=e.manager.getIdentifier(f),i=e.nipples.get(n),o=e.manager.scroll;if(!ht(f)){this.processOnEnd(f);return}if(!i){console.error("Found zombie joystick with ID "+n),e.manager.removeIdentifier(n);return}if(t.dynamicPage){var S=i.el.getBoundingClientRect();i.position={x:o.x+S.left,y:o.y+S.top}}i.identifier=n;var E=i.options.size/2,y={x:f.pageX,y:f.pageY};t.lockX&&(y.y=i.position.y),t.lockY&&(y.x=i.position.x);var x=Me(y,i.position),m=ct(y,i.position),h=je(m),c=x/E,_={distance:x,position:y},a,p;if(i.options.shape==="circle"?(a=Math.min(x,E),p=dt(i.position,a,m)):(p=mt(y,i.position,E),a=Me(p,i.position)),t.follow){if(x>E){let d=y.x-p.x,u=y.y-p.y;i.position.x+=d,i.position.y+=u,i.el.style.top=i.position.y-(e.box.top+o.y)+"px",i.el.style.left=i.position.x-(e.box.left+o.x)+"px",x=Me(y,i.position)}}else y=p,x=a;var v=y.x-i.position.x,l=y.y-i.position.y;i.frontPosition={x:v,y:l},t.dataOnly||(i.ui.front.style.transform="translate("+v+"px,"+l+"px)");var s={identifier:i.identifier,position:y,force:c,pressure:f.force||f.pressure||f.webkitForce||0,distance:x,angle:{radian:h,degree:m},vector:{x:v/E,y:-l/E},raw:_,instance:i,lockX:t.lockX,lockY:t.lockY};s=i.computeDirection(s),s.angle={radian:je(180-m),degree:180-m},i.trigger("move",s),e.trigger("move "+i.id+":move",s)};te.prototype.processOnEnd=function(f){var e=this,t=e.options,n=e.manager.getIdentifier(f),i=e.nipples.get(n),o=e.manager.removeIdentifier(i.identifier);i&&(t.dataOnly||i.hide(function(){t.mode==="dynamic"&&(i.trigger("removed",i),e.trigger("removed "+i.id+":removed",i),e.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(e.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),e.trigger("end "+i.id+":end",i),e.ids.indexOf(i.identifier)>=0&&e.ids.splice(e.ids.indexOf(i.identifier),1),e.actives.indexOf(i)>=0&&e.actives.splice(e.actives.indexOf(i),1),/(semi|static)/.test(t.mode)?e.idles.push(i):e.nipples.indexOf(i)>=0&&e.nipples.splice(e.nipples.indexOf(i),1),e.manager.unbindDocument(),/(semi|static)/.test(t.mode)&&(e.manager.ids[o.id]=o.identifier))};te.prototype.onDestroyed=function(f,e){var t=this;t.nipples.indexOf(e)>=0&&t.nipples.splice(t.nipples.indexOf(e),1),t.actives.indexOf(e)>=0&&t.actives.splice(t.actives.indexOf(e),1),t.idles.indexOf(e)>=0&&t.idles.splice(t.idles.indexOf(e),1),t.ids.indexOf(e.identifier)>=0&&t.ids.splice(t.ids.indexOf(e.identifier),1),t.manager.removeIdentifier(e.identifier),t.manager.unbindDocument()};te.prototype.destroy=function(){var f=this;f.unbindEvt(f.options.zone,"start"),f.nipples.forEach(function(t){t.destroy()});for(var e in f.pressureIntervals)f.pressureIntervals.hasOwnProperty(e)&&clearInterval(f.pressureIntervals[e]);f.trigger("destroyed",f.nipples),f.manager.unbindDocument(),f.off()};function re(f){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=Ke(),e.config(f),e.prepareCollections();var t=function(){var i;e.collections.forEach(function(o){o.forEach(function(S){i=S.el.getBoundingClientRect(),S.position={x:e.scroll.x+i.left,y:e.scroll.y+i.top}})})};Pe(window,"resize",function(){We(t)});var n=function(){e.scroll=Ke()};return Pe(window,"scroll",function(){We(n)}),e.collections}re.prototype=new ge;re.constructor=re;re.prototype.prepareCollections=function(){var f=this;f.collections.create=f.create.bind(f),f.collections.on=f.on.bind(f),f.collections.off=f.off.bind(f),f.collections.destroy=f.destroy.bind(f),f.collections.get=function(e){var t;return f.collections.every(function(n){return t=n.get(e),!t}),t}};re.prototype.create=function(f){return this.createCollection(f)};re.prototype.createCollection=function(f){var e=this,t=new te(e,f);return e.bindCollection(t),e.collections.push(t),t};re.prototype.bindCollection=function(f){var e=this,t,n=function(i,o){t=i.type+" "+o.id+":"+i.type,e.trigger(t,o)};f.on("destroyed",e.onDestroyed.bind(e)),f.on("shown hidden rested dir plain",n),f.on("dir:up dir:right dir:down dir:left",n),f.on("plain:up plain:right plain:down plain:left",n)};re.prototype.bindDocument=function(){var f=this;f.binded||(f.bindEvt(document,"move").bindEvt(document,"end"),f.binded=!0)};re.prototype.unbindDocument=function(f){var e=this;(!Object.keys(e.ids).length||f===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)};re.prototype.getIdentifier=function(f){var e;return f?(e=f.identifier===void 0?f.pointerId:f.identifier,e===void 0&&(e=this.latest||0)):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]};re.prototype.removeIdentifier=function(f){var e={};for(var t in this.ids)if(this.ids[t]===f){e.id=t,e.identifier=this.ids[t],delete this.ids[t];break}return e};re.prototype.onmove=function(f){var e=this;return e.onAny("move",f),!1};re.prototype.onend=function(f){var e=this;return e.onAny("end",f),!1};re.prototype.oncancel=function(f){var e=this;return e.onAny("end",f),!1};re.prototype.onAny=function(f,e){var t=this,n,i="processOn"+f.charAt(0).toUpperCase()+f.slice(1);e=Xe(e);var o=function(E,y,x){x.ids.indexOf(y)>=0&&(x[i](E),E._found_=!0)},S=function(E){n=t.getIdentifier(E),$e(t.collections,o.bind(null,E,n)),E._found_||t.removeIdentifier(n)};return $e(e,S),!1};re.prototype.destroy=function(){var f=this;f.unbindDocument(!0),f.ids={},f.index=0,f.collections.forEach(function(e){e.destroy()}),f.off()};re.prototype.onDestroyed=function(f,e){var t=this;if(t.collections.indexOf(e)<0)return!1;t.collections.splice(t.collections.indexOf(e),1)};const He=new re,xt={create:function(f){return He.create(f)},factory:He};var Ze={exports:{}};(function(f,e){(function(n,i){f.exports=i()})(self,function(){return function(){var t={"./node_modules/es6-promise/dist/es6-promise.js":function(S,E,y){/*!
|
||
* @overview es6-promise - a tiny implementation of Promises/A+.
|
||
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
||
* @license Licensed under MIT license
|
||
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
||
* @version v4.2.8+1e68dce6
|
||
*/(function(x,m){S.exports=m()})(this,function(){function x(M){var I=typeof M;return M!==null&&(I==="object"||I==="function")}function m(M){return typeof M=="function"}var h=void 0;Array.isArray?h=Array.isArray:h=function(M){return Object.prototype.toString.call(M)==="[object Array]"};var c=h,_=0,a=void 0,p=void 0,v=function(I,k){C[_]=I,C[_+1]=k,_+=2,_===2&&(p?p(T):P())};function l(M){p=M}function s(M){v=M}var d=typeof window<"u"?window:void 0,u=d||{},r=u.MutationObserver||u.WebKitMutationObserver,g=typeof self>"u"&&typeof process<"u"&&{}.toString.call(process)==="[object process]",b=typeof Uint8ClampedArray<"u"&&typeof importScripts<"u"&&typeof MessageChannel<"u";function L(){return function(){return process.nextTick(T)}}function A(){return typeof a<"u"?function(){a(T)}:w()}function R(){var M=0,I=new r(T),k=document.createTextNode("");return I.observe(k,{characterData:!0}),function(){k.data=M=++M%2}}function O(){var M=new MessageChannel;return M.port1.onmessage=T,function(){return M.port2.postMessage(0)}}function w(){var M=setTimeout;return function(){return M(T,1)}}var C=new Array(1e3);function T(){for(var M=0;M<_;M+=2){var I=C[M],k=C[M+1];I(k),C[M]=void 0,C[M+1]=void 0}_=0}function D(){try{var M=Function("return this")().require("vertx");return a=M.runOnLoop||M.runOnContext,A()}catch{return w()}}var P=void 0;g?P=L():r?P=R():b?P=O():d===void 0?P=D():P=w();function B(M,I){var k=this,N=new this.constructor(G);N[K]===void 0&&be(N);var W=k._state;if(W){var z=arguments[W-1];v(function(){return xe(W,N,z,k._result)})}else ue(k,N,M,I);return N}function V(M){var I=this;if(M&&typeof M=="object"&&M.constructor===I)return M;var k=new I(G);return le(k,M),k}var K=Math.random().toString(36).substring(2);function G(){}var H=void 0,Z=1,$=2;function q(){return new TypeError("You cannot resolve a promise with itself")}function fe(){return new TypeError("A promises callback cannot return that same promise.")}function Y(M,I,k,N){try{M.call(I,k,N)}catch(W){return W}}function J(M,I,k){v(function(N){var W=!1,z=Y(k,I,function(ie){W||(W=!0,I!==ie?le(N,ie):Q(N,ie))},function(ie){W||(W=!0,j(N,ie))},"Settle: "+(N._label||" unknown promise"));!W&&z&&(W=!0,j(N,z))},M)}function ce(M,I){I._state===Z?Q(M,I._result):I._state===$?j(M,I._result):ue(I,void 0,function(k){return le(M,k)},function(k){return j(M,k)})}function se(M,I,k){I.constructor===M.constructor&&k===B&&I.constructor.resolve===V?ce(M,I):k===void 0?Q(M,I):m(k)?J(M,I,k):Q(M,I)}function le(M,I){if(M===I)j(M,q());else if(x(I)){var k=void 0;try{k=I.then}catch(N){j(M,N);return}se(M,I,k)}else Q(M,I)}function me(M){M._onerror&&M._onerror(M._result),he(M)}function Q(M,I){M._state===H&&(M._result=I,M._state=Z,M._subscribers.length!==0&&v(he,M))}function j(M,I){M._state===H&&(M._state=$,M._result=I,v(me,M))}function ue(M,I,k,N){var W=M._subscribers,z=W.length;M._onerror=null,W[z]=I,W[z+Z]=k,W[z+$]=N,z===0&&M._state&&v(he,M)}function he(M){var I=M._subscribers,k=M._state;if(I.length!==0){for(var N=void 0,W=void 0,z=M._result,ie=0;ie<I.length;ie+=3)N=I[ie],W=I[ie+k],N?xe(k,N,W,z):W(z);M._subscribers.length=0}}function xe(M,I,k,N){var W=m(k),z=void 0,ie=void 0,Se=!0;if(W){try{z=k(N)}catch(Te){Se=!1,ie=Te}if(I===z){j(I,fe());return}}else z=N;I._state!==H||(W&&Se?le(I,z):Se===!1?j(I,ie):M===Z?Q(I,z):M===$&&j(I,z))}function ve(M,I){try{I(function(N){le(M,N)},function(N){j(M,N)})}catch(k){j(M,k)}}var ye=0;function Ee(){return ye++}function be(M){M[K]=ye++,M._state=void 0,M._result=void 0,M._subscribers=[]}function pe(){return new Error("Array Methods must be provided an Array")}var de=function(){function M(I,k){this._instanceConstructor=I,this.promise=new I(G),this.promise[K]||be(this.promise),c(k)?(this.length=k.length,this._remaining=k.length,this._result=new Array(this.length),this.length===0?Q(this.promise,this._result):(this.length=this.length||0,this._enumerate(k),this._remaining===0&&Q(this.promise,this._result))):j(this.promise,pe())}return M.prototype._enumerate=function(k){for(var N=0;this._state===H&&N<k.length;N++)this._eachEntry(k[N],N)},M.prototype._eachEntry=function(k,N){var W=this._instanceConstructor,z=W.resolve;if(z===V){var ie=void 0,Se=void 0,Te=!1;try{ie=k.then}catch(Be){Te=!0,Se=Be}if(ie===B&&k._state!==H)this._settledAt(k._state,N,k._result);else if(typeof ie!="function")this._remaining--,this._result[N]=k;else if(W===oe){var ke=new W(G);Te?j(ke,Se):se(ke,k,ie),this._willSettleAt(ke,N)}else this._willSettleAt(new W(function(Be){return Be(k)}),N)}else this._willSettleAt(z(k),N)},M.prototype._settledAt=function(k,N,W){var z=this.promise;z._state===H&&(this._remaining--,k===$?j(z,W):this._result[N]=W),this._remaining===0&&Q(z,this._result)},M.prototype._willSettleAt=function(k,N){var W=this;ue(k,void 0,function(z){return W._settledAt(Z,N,z)},function(z){return W._settledAt($,N,z)})},M}();function we(M){return new de(this,M).promise}function Re(M){var I=this;return c(M)?new I(function(k,N){for(var W=M.length,z=0;z<W;z++)I.resolve(M[z]).then(k,N)}):new I(function(k,N){return N(new TypeError("You must pass an array to race."))})}function Je(M){var I=this,k=new I(G);return j(k,M),k}function Qe(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function et(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var oe=function(){function M(I){this[K]=Ee(),this._result=this._state=void 0,this._subscribers=[],G!==I&&(typeof I!="function"&&Qe(),this instanceof M?ve(this,I):et())}return M.prototype.catch=function(k){return this.then(null,k)},M.prototype.finally=function(k){var N=this,W=N.constructor;return m(k)?N.then(function(z){return W.resolve(k()).then(function(){return z})},function(z){return W.resolve(k()).then(function(){throw z})}):N.then(k,k)},M}();oe.prototype.then=B,oe.all=we,oe.race=Re,oe.resolve=V,oe.reject=Je,oe._setScheduler=l,oe._setAsap=s,oe._asap=v;function tt(){var M=void 0;if(typeof y.g<"u")M=y.g;else if(typeof self<"u")M=self;else try{M=Function("return this")()}catch{throw new Error("polyfill failed because global object is unavailable in this environment")}var I=M.Promise;if(I){var k=null;try{k=Object.prototype.toString.call(I.resolve())}catch{}if(k==="[object Promise]"&&!I.cast)return}M.Promise=oe}return oe.polyfill=tt,oe.Promise=oe,oe})},"./node_modules/events/events.js":function(S){var E=typeof Reflect=="object"?Reflect:null,y=E&&typeof E.apply=="function"?E.apply:function(w,C,T){return Function.prototype.apply.call(w,C,T)},x;E&&typeof E.ownKeys=="function"?x=E.ownKeys:Object.getOwnPropertySymbols?x=function(w){return Object.getOwnPropertyNames(w).concat(Object.getOwnPropertySymbols(w))}:x=function(w){return Object.getOwnPropertyNames(w)};function m(O){console&&console.warn&&console.warn(O)}var h=Number.isNaN||function(w){return w!==w};function c(){c.init.call(this)}S.exports=c,S.exports.once=L,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var _=10;function a(O){if(typeof O!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof O)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return _},set:function(O){if(typeof O!="number"||O<0||h(O))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+O+".");_=O}}),c.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(w){if(typeof w!="number"||w<0||h(w))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+w+".");return this._maxListeners=w,this};function p(O){return O._maxListeners===void 0?c.defaultMaxListeners:O._maxListeners}c.prototype.getMaxListeners=function(){return p(this)},c.prototype.emit=function(w){for(var C=[],T=1;T<arguments.length;T++)C.push(arguments[T]);var D=w==="error",P=this._events;if(P!==void 0)D=D&&P.error===void 0;else if(!D)return!1;if(D){var B;if(C.length>0&&(B=C[0]),B instanceof Error)throw B;var V=new Error("Unhandled error."+(B?" ("+B.message+")":""));throw V.context=B,V}var K=P[w];if(K===void 0)return!1;if(typeof K=="function")y(K,this,C);else for(var G=K.length,H=r(K,G),T=0;T<G;++T)y(H[T],this,C);return!0};function v(O,w,C,T){var D,P,B;if(a(C),P=O._events,P===void 0?(P=O._events=Object.create(null),O._eventsCount=0):(P.newListener!==void 0&&(O.emit("newListener",w,C.listener?C.listener:C),P=O._events),B=P[w]),B===void 0)B=P[w]=C,++O._eventsCount;else if(typeof B=="function"?B=P[w]=T?[C,B]:[B,C]:T?B.unshift(C):B.push(C),D=p(O),D>0&&B.length>D&&!B.warned){B.warned=!0;var V=new Error("Possible EventEmitter memory leak detected. "+B.length+" "+String(w)+" listeners added. Use emitter.setMaxListeners() to increase limit");V.name="MaxListenersExceededWarning",V.emitter=O,V.type=w,V.count=B.length,m(V)}return O}c.prototype.addListener=function(w,C){return v(this,w,C,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(w,C){return v(this,w,C,!0)};function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function s(O,w,C){var T={fired:!1,wrapFn:void 0,target:O,type:w,listener:C},D=l.bind(T);return D.listener=C,T.wrapFn=D,D}c.prototype.once=function(w,C){return a(C),this.on(w,s(this,w,C)),this},c.prototype.prependOnceListener=function(w,C){return a(C),this.prependListener(w,s(this,w,C)),this},c.prototype.removeListener=function(w,C){var T,D,P,B,V;if(a(C),D=this._events,D===void 0)return this;if(T=D[w],T===void 0)return this;if(T===C||T.listener===C)--this._eventsCount===0?this._events=Object.create(null):(delete D[w],D.removeListener&&this.emit("removeListener",w,T.listener||C));else if(typeof T!="function"){for(P=-1,B=T.length-1;B>=0;B--)if(T[B]===C||T[B].listener===C){V=T[B].listener,P=B;break}if(P<0)return this;P===0?T.shift():g(T,P),T.length===1&&(D[w]=T[0]),D.removeListener!==void 0&&this.emit("removeListener",w,V||C)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(w){var C,T,D;if(T=this._events,T===void 0)return this;if(T.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):T[w]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete T[w]),this;if(arguments.length===0){var P=Object.keys(T),B;for(D=0;D<P.length;++D)B=P[D],B!=="removeListener"&&this.removeAllListeners(B);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(C=T[w],typeof C=="function")this.removeListener(w,C);else if(C!==void 0)for(D=C.length-1;D>=0;D--)this.removeListener(w,C[D]);return this};function d(O,w,C){var T=O._events;if(T===void 0)return[];var D=T[w];return D===void 0?[]:typeof D=="function"?C?[D.listener||D]:[D]:C?b(D):r(D,D.length)}c.prototype.listeners=function(w){return d(this,w,!0)},c.prototype.rawListeners=function(w){return d(this,w,!1)},c.listenerCount=function(O,w){return typeof O.listenerCount=="function"?O.listenerCount(w):u.call(O,w)},c.prototype.listenerCount=u;function u(O){var w=this._events;if(w!==void 0){var C=w[O];if(typeof C=="function")return 1;if(C!==void 0)return C.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?x(this._events):[]};function r(O,w){for(var C=new Array(w),T=0;T<w;++T)C[T]=O[T];return C}function g(O,w){for(;w+1<O.length;w++)O[w]=O[w+1];O.pop()}function b(O){for(var w=new Array(O.length),C=0;C<w.length;++C)w[C]=O[C].listener||O[C];return w}function L(O,w){return new Promise(function(C,T){function D(B){O.removeListener(w,P),T(B)}function P(){typeof O.removeListener=="function"&&O.removeListener("error",D),C([].slice.call(arguments))}R(O,w,P,{once:!0}),w!=="error"&&A(O,D,{once:!0})})}function A(O,w,C){typeof O.on=="function"&&R(O,"error",w,C)}function R(O,w,C,T){if(typeof O.on=="function")T.once?O.once(w,C):O.on(w,C);else if(typeof O.addEventListener=="function")O.addEventListener(w,function D(P){T.once&&O.removeEventListener(w,D),C(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof O)}},"./node_modules/webworkify-webpack/index.js":function(S,E,y){function x(l){var s={};function d(r){if(s[r])return s[r].exports;var g=s[r]={i:r,l:!1,exports:{}};return l[r].call(g.exports,g,g.exports,d),g.l=!0,g.exports}d.m=l,d.c=s,d.i=function(r){return r},d.d=function(r,g,b){d.o(r,g)||Object.defineProperty(r,g,{configurable:!1,enumerable:!0,get:b})},d.r=function(r){Object.defineProperty(r,"__esModule",{value:!0})},d.n=function(r){var g=r&&r.__esModule?function(){return r.default}:function(){return r};return d.d(g,"a",g),g},d.o=function(r,g){return Object.prototype.hasOwnProperty.call(r,g)},d.p="/",d.oe=function(r){throw console.error(r),r};var u=d(d.s=ENTRY_MODULE);return u.default||u}var m="[\\.|\\-|\\+|\\w|/|@]+",h="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+m+").*?\\)";function c(l){return(l+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function _(l){return!isNaN(1*l)}function a(l,s,d){var u={};u[d]=[];var r=s.toString(),g=r.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!g)return u;for(var b=g[1],L=new RegExp("(\\\\n|\\W)"+c(b)+h,"g"),A;A=L.exec(r);)A[3]!=="dll-reference"&&u[d].push(A[3]);for(L=new RegExp("\\("+c(b)+'\\("(dll-reference\\s('+m+'))"\\)\\)'+h,"g");A=L.exec(r);)l[A[2]]||(u[d].push(A[1]),l[A[2]]=y(A[1]).m),u[A[2]]=u[A[2]]||[],u[A[2]].push(A[4]);for(var R=Object.keys(u),O=0;O<R.length;O++)for(var w=0;w<u[R[O]].length;w++)_(u[R[O]][w])&&(u[R[O]][w]=1*u[R[O]][w]);return u}function p(l){var s=Object.keys(l);return s.reduce(function(d,u){return d||l[u].length>0},!1)}function v(l,s){for(var d={main:[s]},u={main:[]},r={main:{}};p(d);)for(var g=Object.keys(d),b=0;b<g.length;b++){var L=g[b],A=d[L],R=A.pop();if(r[L]=r[L]||{},!(r[L][R]||!l[L][R])){r[L][R]=!0,u[L]=u[L]||[],u[L].push(R);for(var O=a(l,l[L][R],L),w=Object.keys(O),C=0;C<w.length;C++)d[w[C]]=d[w[C]]||[],d[w[C]]=d[w[C]].concat(O[w[C]])}}return u}S.exports=function(l,s){s=s||{};var d={main:y.m},u=s.all?{main:Object.keys(d.main)}:v(d,l),r="";Object.keys(u).filter(function(R){return R!=="main"}).forEach(function(R){for(var O=0;u[R][O];)O++;u[R].push(O),d[R][O]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",r=r+"var "+R+" = ("+x.toString().replace("ENTRY_MODULE",JSON.stringify(O))+")({"+u[R].map(function(w){return""+JSON.stringify(w)+": "+d[R][w].toString()}).join(",")+`});
|
||
`}),r=r+"new (("+x.toString().replace("ENTRY_MODULE",JSON.stringify(l))+")({"+u.main.map(function(R){return""+JSON.stringify(R)+": "+d.main[R].toString()}).join(",")+"}))(self);";var g=new window.Blob([r],{type:"text/javascript"});if(s.bare)return g;var b=window.URL||window.webkitURL||window.mozURL||window.msURL,L=b.createObjectURL(g),A=new window.Worker(L);return A.objectURL=L,A}},"./src/config.js":function(S,E,y){y.r(E),y.d(E,{defaultConfig:function(){return x},createDefaultConfig:function(){return m}});var x={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:3*60,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:3*60,autoCleanupMinBackwardDuration:2*60,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function m(){return Object.assign({},x)}},"./src/core/features.js":function(S,E,y){y.r(E);var x=y("./src/io/io-controller.js"),m=y("./src/config.js"),h=function(){function c(){}return c.supportMSEH264Playback=function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')},c.supportNetworkStreamIO=function(){var _=new x.default({},(0,m.createDefaultConfig)()),a=_.loaderType;return _.destroy(),a=="fetch-stream-loader"||a=="xhr-moz-chunked-loader"},c.getNetworkLoaderTypeName=function(){var _=new x.default({},(0,m.createDefaultConfig)()),a=_.loaderType;return _.destroy(),a},c.supportNativeMediaPlayback=function(_){c.videoElement==null&&(c.videoElement=window.document.createElement("video"));var a=c.videoElement.canPlayType(_);return a==="probably"||a=="maybe"},c.getFeatureList=function(){var _={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return _.mseFlvPlayback=c.supportMSEH264Playback(),_.networkStreamIO=c.supportNetworkStreamIO(),_.networkLoaderName=c.getNetworkLoaderTypeName(),_.mseLiveFlvPlayback=_.mseFlvPlayback&&_.networkStreamIO,_.nativeMP4H264Playback=c.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),_.nativeWebmVP8Playback=c.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),_.nativeWebmVP9Playback=c.supportNativeMediaPlayback('video/webm; codecs="vp9"'),_},c}();E.default=h},"./src/core/media-info.js":function(S,E,y){y.r(E);var x=function(){function m(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return m.prototype.isComplete=function(){var h=this.hasAudio===!1||this.hasAudio===!0&&this.audioCodec!=null&&this.audioSampleRate!=null&&this.audioChannelCount!=null,c=this.hasVideo===!1||this.hasVideo===!0&&this.videoCodec!=null&&this.width!=null&&this.height!=null&&this.fps!=null&&this.profile!=null&&this.level!=null&&this.refFrames!=null&&this.chromaFormat!=null&&this.sarNum!=null&&this.sarDen!=null;return this.mimeType!=null&&this.duration!=null&&this.metadata!=null&&this.hasKeyframesIndex!=null&&h&&c},m.prototype.isSeekable=function(){return this.hasKeyframesIndex===!0},m.prototype.getNearestKeyframe=function(h){if(this.keyframesIndex==null)return null;var c=this.keyframesIndex,_=this._search(c.times,h);return{index:_,milliseconds:c.times[_],fileposition:c.filepositions[_]}},m.prototype._search=function(h,c){var _=0,a=h.length-1,p=0,v=0,l=a;for(c<h[0]&&(_=0,v=l+1);v<=l;)if(p=v+Math.floor((l-v)/2),p===a||c>=h[p]&&c<h[p+1]){_=p;break}else h[p]<c?v=p+1:l=p-1;return _},m}();E.default=x},"./src/core/media-segment-info.js":function(S,E,y){y.r(E),y.d(E,{SampleInfo:function(){return x},MediaSegmentInfo:function(){return m},IDRSampleList:function(){return h},MediaSegmentInfoList:function(){return c}});var x=function(){function _(a,p,v,l,s){this.dts=a,this.pts=p,this.duration=v,this.originalDts=l,this.isSyncPoint=s,this.fileposition=null}return _}(),m=function(){function _(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return _.prototype.appendSyncPoint=function(a){a.isSyncPoint=!0,this.syncPoints.push(a)},_}(),h=function(){function _(){this._list=[]}return _.prototype.clear=function(){this._list=[]},_.prototype.appendArray=function(a){var p=this._list;a.length!==0&&(p.length>0&&a[0].originalDts<p[p.length-1].originalDts&&this.clear(),Array.prototype.push.apply(p,a))},_.prototype.getLastSyncPointBeforeDts=function(a){if(this._list.length==0)return null;var p=this._list,v=0,l=p.length-1,s=0,d=0,u=l;for(a<p[0].dts&&(v=0,d=u+1);d<=u;)if(s=d+Math.floor((u-d)/2),s===l||a>=p[s].dts&&a<p[s+1].dts){v=s;break}else p[s].dts<a?d=s+1:u=s-1;return this._list[v]},_}(),c=function(){function _(a){this._type=a,this._list=[],this._lastAppendLocation=-1}return Object.defineProperty(_.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"length",{get:function(){return this._list.length},enumerable:!1,configurable:!0}),_.prototype.isEmpty=function(){return this._list.length===0},_.prototype.clear=function(){this._list=[],this._lastAppendLocation=-1},_.prototype._searchNearestSegmentBefore=function(a){var p=this._list;if(p.length===0)return-2;var v=p.length-1,l=0,s=0,d=v,u=0;if(a<p[0].originalBeginDts)return u=-1,u;for(;s<=d;)if(l=s+Math.floor((d-s)/2),l===v||a>p[l].lastSample.originalDts&&a<p[l+1].originalBeginDts){u=l;break}else p[l].originalBeginDts<a?s=l+1:d=l-1;return u},_.prototype._searchNearestSegmentAfter=function(a){return this._searchNearestSegmentBefore(a)+1},_.prototype.append=function(a){var p=this._list,v=a,l=this._lastAppendLocation,s=0;l!==-1&&l<p.length&&v.originalBeginDts>=p[l].lastSample.originalDts&&(l===p.length-1||l<p.length-1&&v.originalBeginDts<p[l+1].originalBeginDts)?s=l+1:p.length>0&&(s=this._searchNearestSegmentBefore(v.originalBeginDts)+1),this._lastAppendLocation=s,this._list.splice(s,0,v)},_.prototype.getLastSegmentBefore=function(a){var p=this._searchNearestSegmentBefore(a);return p>=0?this._list[p]:null},_.prototype.getLastSampleBefore=function(a){var p=this.getLastSegmentBefore(a);return p!=null?p.lastSample:null},_.prototype.getLastSyncPointBefore=function(a){for(var p=this._searchNearestSegmentBefore(a),v=this._list[p].syncPoints;v.length===0&&p>0;)p--,v=this._list[p].syncPoints;return v.length>0?v[v.length-1]:null},_}()},"./src/core/mse-controller.js":function(S,E,y){y.r(E);var x=y("./node_modules/events/events.js"),m=y.n(x),h=y("./src/utils/logger.js"),c=y("./src/utils/browser.js"),_=y("./src/core/mse-events.js"),a=y("./src/core/media-segment-info.js"),p=y("./src/utils/exception.js"),v=function(){function l(s){this.TAG="MSEController",this._config=s,this._emitter=new(m()),this._config.isLive&&this._config.autoCleanupSourceBuffer==null&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new a.IDRSampleList}return l.prototype.destroy=function(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null},l.prototype.on=function(s,d){this._emitter.addListener(s,d)},l.prototype.off=function(s,d){this._emitter.removeListener(s,d)},l.prototype.attachMediaElement=function(s){if(this._mediaSource)throw new p.IllegalStateException("MediaSource has been attached to an HTMLMediaElement!");var d=this._mediaSource=new window.MediaSource;d.addEventListener("sourceopen",this.e.onSourceOpen),d.addEventListener("sourceended",this.e.onSourceEnded),d.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=s,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),s.src=this._mediaSourceObjectURL},l.prototype.detachMediaElement=function(){if(this._mediaSource){var s=this._mediaSource;for(var d in this._sourceBuffers){var u=this._pendingSegments[d];u.splice(0,u.length),this._pendingSegments[d]=null,this._pendingRemoveRanges[d]=null,this._lastInitSegments[d]=null;var r=this._sourceBuffers[d];if(r){if(s.readyState!=="closed"){try{s.removeSourceBuffer(r)}catch(g){h.default.e(this.TAG,g.message)}r.removeEventListener("error",this.e.onSourceBufferError),r.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[d]=null,this._sourceBuffers[d]=null}}if(s.readyState==="open")try{s.endOfStream()}catch(g){h.default.e(this.TAG,g.message)}s.removeEventListener("sourceopen",this.e.onSourceOpen),s.removeEventListener("sourceended",this.e.onSourceEnded),s.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)},l.prototype.appendInitSegment=function(s,d){if(!this._mediaSource||this._mediaSource.readyState!=="open"){this._pendingSourceBufferInit.push(s),this._pendingSegments[s.type].push(s);return}var u=s,r=""+u.container;u.codec&&u.codec.length>0&&(r+=";codecs="+u.codec);var g=!1;if(h.default.v(this.TAG,"Received Initialization Segment, mimeType: "+r),this._lastInitSegments[u.type]=u,r!==this._mimeTypes[u.type]){if(this._mimeTypes[u.type])h.default.v(this.TAG,"Notice: "+u.type+" mimeType changed, origin: "+this._mimeTypes[u.type]+", target: "+r);else{g=!0;try{var b=this._sourceBuffers[u.type]=this._mediaSource.addSourceBuffer(r);b.addEventListener("error",this.e.onSourceBufferError),b.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(L){h.default.e(this.TAG,L.message),this._emitter.emit(_.default.ERROR,{code:L.code,msg:L.message});return}}this._mimeTypes[u.type]=r}d||this._pendingSegments[u.type].push(u),g||this._sourceBuffers[u.type]&&!this._sourceBuffers[u.type].updating&&this._doAppendSegments(),c.default.safari&&u.container==="audio/mpeg"&&u.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=u.mediaDuration/1e3,this._updateMediaSourceDuration())},l.prototype.appendMediaSegment=function(s){var d=s;this._pendingSegments[d.type].push(d),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var u=this._sourceBuffers[d.type];u&&!u.updating&&!this._hasPendingRemoveRanges()&&this._doAppendSegments()},l.prototype.seek=function(s){for(var d in this._sourceBuffers)if(this._sourceBuffers[d]){var u=this._sourceBuffers[d];if(this._mediaSource.readyState==="open")try{u.abort()}catch(R){h.default.e(this.TAG,R.message)}this._idrList.clear();var r=this._pendingSegments[d];if(r.splice(0,r.length),this._mediaSource.readyState!=="closed"){for(var g=0;g<u.buffered.length;g++){var b=u.buffered.start(g),L=u.buffered.end(g);this._pendingRemoveRanges[d].push({start:b,end:L})}if(u.updating||this._doRemoveRanges(),c.default.safari){var A=this._lastInitSegments[d];A&&(this._pendingSegments[d].push(A),u.updating||this._doAppendSegments())}}}},l.prototype.endOfStream=function(){var s=this._mediaSource,d=this._sourceBuffers;if(!s||s.readyState!=="open"){s&&s.readyState==="closed"&&this._hasPendingSegments()&&(this._hasPendingEos=!0);return}d.video&&d.video.updating||d.audio&&d.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,s.endOfStream())},l.prototype.getNearestKeyframe=function(s){return this._idrList.getLastSyncPointBeforeDts(s)},l.prototype._needCleanupSourceBuffer=function(){if(!this._config.autoCleanupSourceBuffer)return!1;var s=this._mediaElement.currentTime;for(var d in this._sourceBuffers){var u=this._sourceBuffers[d];if(u){var r=u.buffered;if(r.length>=1&&s-r.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},l.prototype._doCleanupSourceBuffer=function(){var s=this._mediaElement.currentTime;for(var d in this._sourceBuffers){var u=this._sourceBuffers[d];if(u){for(var r=u.buffered,g=!1,b=0;b<r.length;b++){var L=r.start(b),A=r.end(b);if(L<=s&&s<A+3){if(s-L>=this._config.autoCleanupMaxBackwardDuration){g=!0;var R=s-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[d].push({start:L,end:R})}}else A<s&&(g=!0,this._pendingRemoveRanges[d].push({start:L,end:A}))}g&&!u.updating&&this._doRemoveRanges()}}},l.prototype._updateMediaSourceDuration=function(){var s=this._sourceBuffers;if(!(this._mediaElement.readyState===0||this._mediaSource.readyState!=="open")&&!(s.video&&s.video.updating||s.audio&&s.audio.updating)){var d=this._mediaSource.duration,u=this._pendingMediaDuration;u>0&&(isNaN(d)||u>d)&&(h.default.v(this.TAG,"Update MediaSource duration from "+d+" to "+u),this._mediaSource.duration=u),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},l.prototype._doRemoveRanges=function(){for(var s in this._pendingRemoveRanges)if(!(!this._sourceBuffers[s]||this._sourceBuffers[s].updating))for(var d=this._sourceBuffers[s],u=this._pendingRemoveRanges[s];u.length&&!d.updating;){var r=u.shift();d.remove(r.start,r.end)}},l.prototype._doAppendSegments=function(){var s=this._pendingSegments;for(var d in s)if(!(!this._sourceBuffers[d]||this._sourceBuffers[d].updating)&&s[d].length>0){var u=s[d].shift();if(u.timestampOffset){var r=this._sourceBuffers[d].timestampOffset,g=u.timestampOffset/1e3,b=Math.abs(r-g);b>.1&&(h.default.v(this.TAG,"Update MPEG audio timestampOffset from "+r+" to "+g),this._sourceBuffers[d].timestampOffset=g),delete u.timestampOffset}if(!u.data||u.data.byteLength===0)continue;try{this._sourceBuffers[d].appendBuffer(u.data),this._isBufferFull=!1,d==="video"&&u.hasOwnProperty("info")&&this._idrList.appendArray(u.info.syncPoints)}catch(L){this._pendingSegments[d].unshift(u),L.code===22?(this._isBufferFull||this._emitter.emit(_.default.BUFFER_FULL),this._isBufferFull=!0):(h.default.e(this.TAG,L.message),this._emitter.emit(_.default.ERROR,{code:L.code,msg:L.message}))}}},l.prototype._onSourceOpen=function(){if(h.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var s=this._pendingSourceBufferInit;s.length;){var d=s.shift();this.appendInitSegment(d,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(_.default.SOURCE_OPEN)},l.prototype._onSourceEnded=function(){h.default.v(this.TAG,"MediaSource onSourceEnded")},l.prototype._onSourceClose=function(){h.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&this.e!=null&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))},l.prototype._hasPendingSegments=function(){var s=this._pendingSegments;return s.video.length>0||s.audio.length>0},l.prototype._hasPendingRemoveRanges=function(){var s=this._pendingRemoveRanges;return s.video.length>0||s.audio.length>0},l.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(_.default.UPDATE_END)},l.prototype._onSourceBufferError=function(s){h.default.e(this.TAG,"SourceBuffer Error: "+s)},l}();E.default=v},"./src/core/mse-events.js":function(S,E,y){y.r(E);var x={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};E.default=x},"./src/core/transmuxer.js":function(S,E,y){y.r(E);var x=y("./node_modules/events/events.js"),m=y.n(x),h=y("./node_modules/webworkify-webpack/index.js"),c=y.n(h),_=y("./src/utils/logger.js"),a=y("./src/utils/logging-control.js"),p=y("./src/core/transmuxing-controller.js"),v=y("./src/core/transmuxing-events.js"),l=y("./src/core/media-info.js"),s=function(){function d(u,r){if(this.TAG="Transmuxer",this._emitter=new(m()),r.enableWorker&&typeof Worker<"u")try{this._worker=c()("./src/core/transmuxing-worker.js"),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[u,r]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},a.default.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:a.default.getConfig()})}catch{_.default.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new p.default(u,r)}else this._controller=new p.default(u,r);if(this._controller){var g=this._controller;g.on(v.default.IO_ERROR,this._onIOError.bind(this)),g.on(v.default.DEMUX_ERROR,this._onDemuxError.bind(this)),g.on(v.default.INIT_SEGMENT,this._onInitSegment.bind(this)),g.on(v.default.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),g.on(v.default.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),g.on(v.default.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),g.on(v.default.MEDIA_INFO,this._onMediaInfo.bind(this)),g.on(v.default.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),g.on(v.default.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),g.on(v.default.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),g.on(v.default.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return d.prototype.destroy=function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),a.default.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null},d.prototype.on=function(u,r){this._emitter.addListener(u,r)},d.prototype.off=function(u,r){this._emitter.removeListener(u,r)},d.prototype.hasWorker=function(){return this._worker!=null},d.prototype.open=function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()},d.prototype.close=function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()},d.prototype.seek=function(u){this._worker?this._worker.postMessage({cmd:"seek",param:u}):this._controller.seek(u)},d.prototype.pause=function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()},d.prototype.resume=function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()},d.prototype._onInitSegment=function(u,r){var g=this;Promise.resolve().then(function(){g._emitter.emit(v.default.INIT_SEGMENT,u,r)})},d.prototype._onMediaSegment=function(u,r){var g=this;Promise.resolve().then(function(){g._emitter.emit(v.default.MEDIA_SEGMENT,u,r)})},d.prototype._onLoadingComplete=function(){var u=this;Promise.resolve().then(function(){u._emitter.emit(v.default.LOADING_COMPLETE)})},d.prototype._onRecoveredEarlyEof=function(){var u=this;Promise.resolve().then(function(){u._emitter.emit(v.default.RECOVERED_EARLY_EOF)})},d.prototype._onMediaInfo=function(u){var r=this;Promise.resolve().then(function(){r._emitter.emit(v.default.MEDIA_INFO,u)})},d.prototype._onMetaDataArrived=function(u){var r=this;Promise.resolve().then(function(){r._emitter.emit(v.default.METADATA_ARRIVED,u)})},d.prototype._onScriptDataArrived=function(u){var r=this;Promise.resolve().then(function(){r._emitter.emit(v.default.SCRIPTDATA_ARRIVED,u)})},d.prototype._onStatisticsInfo=function(u){var r=this;Promise.resolve().then(function(){r._emitter.emit(v.default.STATISTICS_INFO,u)})},d.prototype._onIOError=function(u,r){var g=this;Promise.resolve().then(function(){g._emitter.emit(v.default.IO_ERROR,u,r)})},d.prototype._onDemuxError=function(u,r){var g=this;Promise.resolve().then(function(){g._emitter.emit(v.default.DEMUX_ERROR,u,r)})},d.prototype._onRecommendSeekpoint=function(u){var r=this;Promise.resolve().then(function(){r._emitter.emit(v.default.RECOMMEND_SEEKPOINT,u)})},d.prototype._onLoggingConfigChanged=function(u){this._worker&&this._worker.postMessage({cmd:"logging_config",param:u})},d.prototype._onWorkerMessage=function(u){var r=u.data,g=r.data;if(r.msg==="destroyed"||this._workerDestroying){this._workerDestroying=!1,this._worker.terminate(),this._worker=null;return}switch(r.msg){case v.default.INIT_SEGMENT:case v.default.MEDIA_SEGMENT:this._emitter.emit(r.msg,g.type,g.data);break;case v.default.LOADING_COMPLETE:case v.default.RECOVERED_EARLY_EOF:this._emitter.emit(r.msg);break;case v.default.MEDIA_INFO:Object.setPrototypeOf(g,l.default.prototype),this._emitter.emit(r.msg,g);break;case v.default.METADATA_ARRIVED:case v.default.SCRIPTDATA_ARRIVED:case v.default.STATISTICS_INFO:this._emitter.emit(r.msg,g);break;case v.default.IO_ERROR:case v.default.DEMUX_ERROR:this._emitter.emit(r.msg,g.type,g.info);break;case v.default.RECOMMEND_SEEKPOINT:this._emitter.emit(r.msg,g);break;case"logcat_callback":_.default.emitter.emit("log",g.type,g.logcat);break}},d}();E.default=s},"./src/core/transmuxing-controller.js":function(S,E,y){y.r(E);var x=y("./node_modules/events/events.js"),m=y.n(x),h=y("./src/utils/logger.js"),c=y("./src/utils/browser.js"),_=y("./src/core/media-info.js"),a=y("./src/demux/flv-demuxer.js"),p=y("./src/remux/mp4-remuxer.js"),v=y("./src/demux/demux-errors.js"),l=y("./src/io/io-controller.js"),s=y("./src/core/transmuxing-events.js"),d=function(){function u(r,g){this.TAG="TransmuxingController",this._emitter=new(m()),this._config=g,r.segments||(r.segments=[{duration:r.duration,filesize:r.filesize,url:r.url}]),typeof r.cors!="boolean"&&(r.cors=!0),typeof r.withCredentials!="boolean"&&(r.withCredentials=!1),this._mediaDataSource=r,this._currentSegmentIndex=0;var b=0;this._mediaDataSource.segments.forEach(function(L){L.timestampBase=b,b+=L.duration,L.cors=r.cors,L.withCredentials=r.withCredentials,g.referrerPolicy&&(L.referrerPolicy=g.referrerPolicy)}),!isNaN(b)&&this._mediaDataSource.duration!==b&&(this._mediaDataSource.duration=b),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}return u.prototype.destroy=function(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null},u.prototype.on=function(r,g){this._emitter.addListener(r,g)},u.prototype.off=function(r,g){this._emitter.removeListener(r,g)},u.prototype.start=function(){this._loadSegment(0),this._enableStatisticsReporter()},u.prototype._loadSegment=function(r,g){this._currentSegmentIndex=r;var b=this._mediaDataSource.segments[r],L=this._ioctl=new l.default(b,this._config,r);L.onError=this._onIOException.bind(this),L.onSeeked=this._onIOSeeked.bind(this),L.onComplete=this._onIOComplete.bind(this),L.onRedirect=this._onIORedirect.bind(this),L.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),g?this._demuxer.bindDataSource(this._ioctl):L.onDataArrival=this._onInitChunkArrival.bind(this),L.open(g)},u.prototype.stop=function(){this._internalAbort(),this._disableStatisticsReporter()},u.prototype._internalAbort=function(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)},u.prototype.pause=function(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())},u.prototype.resume=function(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())},u.prototype.seek=function(r){if(!(this._mediaInfo==null||!this._mediaInfo.isSeekable())){var g=this._searchSegmentIndexContains(r);if(g===this._currentSegmentIndex){var b=this._mediaInfo.segments[g];if(b==null)this._pendingSeekTime=r;else{var L=b.getNearestKeyframe(r);this._remuxer.seek(L.milliseconds),this._ioctl.seek(L.fileposition),this._pendingResolveSeekPoint=L.milliseconds}}else{var A=this._mediaInfo.segments[g];if(A==null)this._pendingSeekTime=r,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(g);else{var L=A.getNearestKeyframe(r);this._internalAbort(),this._remuxer.seek(r),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[g].timestampBase,this._loadSegment(g,L.fileposition),this._pendingResolveSeekPoint=L.milliseconds,this._reportSegmentMediaInfo(g)}}this._enableStatisticsReporter()}},u.prototype._searchSegmentIndexContains=function(r){for(var g=this._mediaDataSource.segments,b=g.length-1,L=0;L<g.length;L++)if(r<g[L].timestampBase){b=L-1;break}return b},u.prototype._onInitChunkArrival=function(r,g){var b=this,L=null,A=0;if(g>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,A=this._demuxer.parseChunks(r,g);else if((L=a.default.probe(r)).match){this._demuxer=new a.default(L,this._config),this._remuxer||(this._remuxer=new p.default(this._config));var R=this._mediaDataSource;R.duration!=null&&!isNaN(R.duration)&&(this._demuxer.overridedDuration=R.duration),typeof R.hasAudio=="boolean"&&(this._demuxer.overridedHasAudio=R.hasAudio),typeof R.hasVideo=="boolean"&&(this._demuxer.overridedHasVideo=R.hasVideo),this._demuxer.timestampBase=R.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),A=this._demuxer.parseChunks(r,g)}else L=null,h.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(function(){b._internalAbort()}),this._emitter.emit(s.default.DEMUX_ERROR,v.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),A=0;return A},u.prototype._onMediaInfo=function(r){var g=this;this._mediaInfo==null&&(this._mediaInfo=Object.assign({},r),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,_.default.prototype));var b=Object.assign({},r);Object.setPrototypeOf(b,_.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=b,this._reportSegmentMediaInfo(this._currentSegmentIndex),this._pendingSeekTime!=null&&Promise.resolve().then(function(){var L=g._pendingSeekTime;g._pendingSeekTime=null,g.seek(L)})},u.prototype._onMetaDataArrived=function(r){this._emitter.emit(s.default.METADATA_ARRIVED,r)},u.prototype._onScriptDataArrived=function(r){this._emitter.emit(s.default.SCRIPTDATA_ARRIVED,r)},u.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},u.prototype._onIOComplete=function(r){var g=r,b=g+1;b<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(b)):(this._remuxer.flushStashedSamples(),this._emitter.emit(s.default.LOADING_COMPLETE),this._disableStatisticsReporter())},u.prototype._onIORedirect=function(r){var g=this._ioctl.extraData;this._mediaDataSource.segments[g].redirectedURL=r},u.prototype._onIORecoveredEarlyEof=function(){this._emitter.emit(s.default.RECOVERED_EARLY_EOF)},u.prototype._onIOException=function(r,g){h.default.e(this.TAG,"IOException: type = "+r+", code = "+g.code+", msg = "+g.msg),this._emitter.emit(s.default.IO_ERROR,r,g),this._disableStatisticsReporter()},u.prototype._onDemuxException=function(r,g){h.default.e(this.TAG,"DemuxException: type = "+r+", info = "+g),this._emitter.emit(s.default.DEMUX_ERROR,r,g)},u.prototype._onRemuxerInitSegmentArrival=function(r,g){this._emitter.emit(s.default.INIT_SEGMENT,r,g)},u.prototype._onRemuxerMediaSegmentArrival=function(r,g){if(this._pendingSeekTime==null&&(this._emitter.emit(s.default.MEDIA_SEGMENT,r,g),this._pendingResolveSeekPoint!=null&&r==="video")){var b=g.info.syncPoints,L=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,c.default.safari&&b.length>0&&b[0].originalDts===L&&(L=b[0].pts),this._emitter.emit(s.default.RECOMMEND_SEEKPOINT,L)}},u.prototype._enableStatisticsReporter=function(){this._statisticsReporter==null&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},u.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},u.prototype._reportSegmentMediaInfo=function(r){var g=this._mediaInfo.segments[r],b=Object.assign({},g);b.duration=this._mediaInfo.duration,b.segmentCount=this._mediaInfo.segmentCount,delete b.segments,delete b.keyframesIndex,this._emitter.emit(s.default.MEDIA_INFO,b)},u.prototype._reportStatisticsInfo=function(){var r={};r.url=this._ioctl.currentURL,r.hasRedirect=this._ioctl.hasRedirect,r.hasRedirect&&(r.redirectedURL=this._ioctl.currentRedirectedURL),r.speed=this._ioctl.currentSpeed,r.loaderType=this._ioctl.loaderType,r.currentSegmentIndex=this._currentSegmentIndex,r.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(s.default.STATISTICS_INFO,r)},u}();E.default=d},"./src/core/transmuxing-events.js":function(S,E,y){y.r(E);var x={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};E.default=x},"./src/core/transmuxing-worker.js":function(S,E,y){y.r(E);var x=y("./src/utils/logging-control.js"),m=y("./src/utils/polyfill.js"),h=y("./src/core/transmuxing-controller.js"),c=y("./src/core/transmuxing-events.js"),_=function(a){var p=null,v=w.bind(this);m.default.install(),a.addEventListener("message",function(C){switch(C.data.cmd){case"init":p=new h.default(C.data.param[0],C.data.param[1]),p.on(c.default.IO_ERROR,A.bind(this)),p.on(c.default.DEMUX_ERROR,R.bind(this)),p.on(c.default.INIT_SEGMENT,l.bind(this)),p.on(c.default.MEDIA_SEGMENT,s.bind(this)),p.on(c.default.LOADING_COMPLETE,d.bind(this)),p.on(c.default.RECOVERED_EARLY_EOF,u.bind(this)),p.on(c.default.MEDIA_INFO,r.bind(this)),p.on(c.default.METADATA_ARRIVED,g.bind(this)),p.on(c.default.SCRIPTDATA_ARRIVED,b.bind(this)),p.on(c.default.STATISTICS_INFO,L.bind(this)),p.on(c.default.RECOMMEND_SEEKPOINT,O.bind(this));break;case"destroy":p&&(p.destroy(),p=null),a.postMessage({msg:"destroyed"});break;case"start":p.start();break;case"stop":p.stop();break;case"seek":p.seek(C.data.param);break;case"pause":p.pause();break;case"resume":p.resume();break;case"logging_config":{var T=C.data.param;x.default.applyConfig(T),T.enableCallback===!0?x.default.addLogListener(v):x.default.removeLogListener(v);break}}});function l(C,T){var D={msg:c.default.INIT_SEGMENT,data:{type:C,data:T}};a.postMessage(D,[T.data])}function s(C,T){var D={msg:c.default.MEDIA_SEGMENT,data:{type:C,data:T}};a.postMessage(D,[T.data])}function d(){var C={msg:c.default.LOADING_COMPLETE};a.postMessage(C)}function u(){var C={msg:c.default.RECOVERED_EARLY_EOF};a.postMessage(C)}function r(C){var T={msg:c.default.MEDIA_INFO,data:C};a.postMessage(T)}function g(C){var T={msg:c.default.METADATA_ARRIVED,data:C};a.postMessage(T)}function b(C){var T={msg:c.default.SCRIPTDATA_ARRIVED,data:C};a.postMessage(T)}function L(C){var T={msg:c.default.STATISTICS_INFO,data:C};a.postMessage(T)}function A(C,T){a.postMessage({msg:c.default.IO_ERROR,data:{type:C,info:T}})}function R(C,T){a.postMessage({msg:c.default.DEMUX_ERROR,data:{type:C,info:T}})}function O(C){a.postMessage({msg:c.default.RECOMMEND_SEEKPOINT,data:C})}function w(C,T){a.postMessage({msg:"logcat_callback",data:{type:C,logcat:T}})}};E.default=_},"./src/demux/amf-parser.js":function(S,E,y){y.r(E);var x=y("./src/utils/logger.js"),m=y("./src/utils/utf8-conv.js"),h=y("./src/utils/exception.js"),c=function(){var a=new ArrayBuffer(2);return new DataView(a).setInt16(0,256,!0),new Int16Array(a)[0]===256}(),_=function(){function a(){}return a.parseScriptData=function(p,v,l){var s={};try{var d=a.parseValue(p,v,l),u=a.parseValue(p,v+d.size,l-d.size);s[d.data]=u.data}catch(r){x.default.e("AMF",r.toString())}return s},a.parseObject=function(p,v,l){if(l<3)throw new h.IllegalStateException("Data not enough when parse ScriptDataObject");var s=a.parseString(p,v,l),d=a.parseValue(p,v+s.size,l-s.size),u=d.objectEnd;return{data:{name:s.data,value:d.data},size:s.size+d.size,objectEnd:u}},a.parseVariable=function(p,v,l){return a.parseObject(p,v,l)},a.parseString=function(p,v,l){if(l<2)throw new h.IllegalStateException("Data not enough when parse String");var s=new DataView(p,v,l),d=s.getUint16(0,!c),u;return d>0?u=(0,m.default)(new Uint8Array(p,v+2,d)):u="",{data:u,size:2+d}},a.parseLongString=function(p,v,l){if(l<4)throw new h.IllegalStateException("Data not enough when parse LongString");var s=new DataView(p,v,l),d=s.getUint32(0,!c),u;return d>0?u=(0,m.default)(new Uint8Array(p,v+4,d)):u="",{data:u,size:4+d}},a.parseDate=function(p,v,l){if(l<10)throw new h.IllegalStateException("Data size invalid when parse Date");var s=new DataView(p,v,l),d=s.getFloat64(0,!c),u=s.getInt16(8,!c);return d+=u*60*1e3,{data:new Date(d),size:10}},a.parseValue=function(p,v,l){if(l<1)throw new h.IllegalStateException("Data not enough when parse Value");var s=new DataView(p,v,l),d=1,u=s.getUint8(0),r,g=!1;try{switch(u){case 0:r=s.getFloat64(1,!c),d+=8;break;case 1:{var b=s.getUint8(1);r=!!b,d+=1;break}case 2:{var L=a.parseString(p,v+1,l-1);r=L.data,d+=L.size;break}case 3:{r={};var A=0;for((s.getUint32(l-4,!c)&16777215)===9&&(A=3);d<l-4;){var R=a.parseObject(p,v+d,l-d-A);if(R.objectEnd)break;r[R.data.name]=R.data.value,d+=R.size}if(d<=l-3){var O=s.getUint32(d-1,!c)&16777215;O===9&&(d+=3)}break}case 8:{r={},d+=4;var A=0;for((s.getUint32(l-4,!c)&16777215)===9&&(A=3);d<l-8;){var w=a.parseVariable(p,v+d,l-d-A);if(w.objectEnd)break;r[w.data.name]=w.data.value,d+=w.size}if(d<=l-3){var O=s.getUint32(d-1,!c)&16777215;O===9&&(d+=3)}break}case 9:r=void 0,d=1,g=!0;break;case 10:{r=[];var C=s.getUint32(1,!c);d+=4;for(var T=0;T<C;T++){var D=a.parseValue(p,v+d,l-d);r.push(D.data),d+=D.size}break}case 11:{var P=a.parseDate(p,v+1,l-1);r=P.data,d+=P.size;break}case 12:{var B=a.parseString(p,v+1,l-1);r=B.data,d+=B.size;break}default:d=l,x.default.w("AMF","Unsupported AMF value type "+u)}}catch(V){x.default.e("AMF",V.toString())}return{data:r,size:d,objectEnd:g}},a}();E.default=_},"./src/demux/demux-errors.js":function(S,E,y){y.r(E);var x={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};E.default=x},"./src/demux/exp-golomb.js":function(S,E,y){y.r(E);var x=y("./src/utils/exception.js"),m=function(){function h(c){this.TAG="ExpGolomb",this._buffer=c,this._buffer_index=0,this._total_bytes=c.byteLength,this._total_bits=c.byteLength*8,this._current_word=0,this._current_word_bits_left=0}return h.prototype.destroy=function(){this._buffer=null},h.prototype._fillCurrentWord=function(){var c=this._total_bytes-this._buffer_index;if(c<=0)throw new x.IllegalStateException("ExpGolomb: _fillCurrentWord() but no bytes available");var _=Math.min(4,c),a=new Uint8Array(4);a.set(this._buffer.subarray(this._buffer_index,this._buffer_index+_)),this._current_word=new DataView(a.buffer).getUint32(0,!1),this._buffer_index+=_,this._current_word_bits_left=_*8},h.prototype.readBits=function(c){if(c>32)throw new x.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(c<=this._current_word_bits_left){var _=this._current_word>>>32-c;return this._current_word<<=c,this._current_word_bits_left-=c,_}var a=this._current_word_bits_left?this._current_word:0;a=a>>>32-this._current_word_bits_left;var p=c-this._current_word_bits_left;this._fillCurrentWord();var v=Math.min(p,this._current_word_bits_left),l=this._current_word>>>32-v;return this._current_word<<=v,this._current_word_bits_left-=v,a=a<<v|l,a},h.prototype.readBool=function(){return this.readBits(1)===1},h.prototype.readByte=function(){return this.readBits(8)},h.prototype._skipLeadingZero=function(){var c;for(c=0;c<this._current_word_bits_left;c++)if(this._current_word&2147483648>>>c)return this._current_word<<=c,this._current_word_bits_left-=c,c;return this._fillCurrentWord(),c+this._skipLeadingZero()},h.prototype.readUEG=function(){var c=this._skipLeadingZero();return this.readBits(c+1)-1},h.prototype.readSEG=function(){var c=this.readUEG();return c&1?c+1>>>1:-1*(c>>>1)},h}();E.default=m},"./src/demux/flv-demuxer.js":function(S,E,y){y.r(E);var x=y("./src/utils/logger.js"),m=y("./src/demux/amf-parser.js"),h=y("./src/demux/sps-parser.js"),c=y("./src/demux/demux-errors.js"),_=y("./src/core/media-info.js"),a=y("./src/utils/exception.js");function p(l,s){return l[s]<<24|l[s+1]<<16|l[s+2]<<8|l[s+3]}var v=function(){function l(s,d){this.TAG="FLVDemuxer",this._config=d,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=s.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=s.hasAudioTrack,this._hasVideo=s.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new _.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var u=new ArrayBuffer(2);return new DataView(u).setInt16(0,256,!0),new Int16Array(u)[0]===256}()}return l.prototype.destroy=function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null},l.probe=function(s){var d=new Uint8Array(s),u={match:!1};if(d[0]!==70||d[1]!==76||d[2]!==86||d[3]!==1)return u;var r=(d[4]&4)>>>2!==0,g=(d[4]&1)!==0,b=p(d,5);return b<9?u:{match:!0,consumed:b,dataOffset:b,hasAudioTrack:r,hasVideoTrack:g}},l.prototype.bindDataSource=function(s){return s.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(l.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(s){this._onTrackMetadata=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(s){this._onMediaInfo=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(s){this._onMetaDataArrived=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(s){this._onScriptDataArrived=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"onError",{get:function(){return this._onError},set:function(s){this._onError=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(s){this._onDataAvailable=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(s){this._timestampBase=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"overridedDuration",{get:function(){return this._duration},set:function(s){this._durationOverrided=!0,this._duration=s,this._mediaInfo.duration=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"overridedHasAudio",{set:function(s){this._hasAudioFlagOverrided=!0,this._hasAudio=s,this._mediaInfo.hasAudio=s},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"overridedHasVideo",{set:function(s){this._hasVideoFlagOverrided=!0,this._hasVideo=s,this._mediaInfo.hasVideo=s},enumerable:!1,configurable:!0}),l.prototype.resetMediaInfo=function(){this._mediaInfo=new _.default},l.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!this._hasAudio&&this._hasVideo?this._videoInitialMetadataDispatched:!1},l.prototype.parseChunks=function(s,d){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new a.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var u=0,r=this._littleEndian;if(d===0)if(s.byteLength>13){var g=l.probe(s);u=g.dataOffset}else return 0;if(this._firstParse){this._firstParse=!1,d+u!==this._dataOffset&&x.default.w(this.TAG,"First time parsing but chunk byteStart invalid!");var b=new DataView(s,u),L=b.getUint32(0,!r);L!==0&&x.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),u+=4}for(;u<s.byteLength;){this._dispatch=!0;var b=new DataView(s,u);if(u+11+4>s.byteLength)break;var A=b.getUint8(0),R=b.getUint32(0,!r)&16777215;if(u+11+R+4>s.byteLength)break;if(A!==8&&A!==9&&A!==18){x.default.w(this.TAG,"Unsupported tag type "+A+", skipped"),u+=11+R+4;continue}var O=b.getUint8(4),w=b.getUint8(5),C=b.getUint8(6),T=b.getUint8(7),D=C|w<<8|O<<16|T<<24,P=b.getUint32(7,!r)&16777215;P!==0&&x.default.w(this.TAG,"Meet tag which has StreamID != 0!");var B=u+11;switch(A){case 8:this._parseAudioData(s,B,R,D);break;case 9:this._parseVideoData(s,B,R,D,d+u);break;case 18:this._parseScriptData(s,B,R);break}var V=b.getUint32(11+R,!r);V!==11+R&&x.default.w(this.TAG,"Invalid PrevTagSize "+V),u+=11+R+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),u},l.prototype._parseScriptData=function(s,d,u){var r=m.default.parseScriptData(s,d,u);if(r.hasOwnProperty("onMetaData")){if(r.onMetaData==null||typeof r.onMetaData!="object"){x.default.w(this.TAG,"Invalid onMetaData structure!");return}this._metadata&&x.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=r;var g=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},g)),typeof g.hasAudio=="boolean"&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=g.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),typeof g.hasVideo=="boolean"&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=g.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),typeof g.audiodatarate=="number"&&(this._mediaInfo.audioDataRate=g.audiodatarate),typeof g.videodatarate=="number"&&(this._mediaInfo.videoDataRate=g.videodatarate),typeof g.width=="number"&&(this._mediaInfo.width=g.width),typeof g.height=="number"&&(this._mediaInfo.height=g.height),typeof g.duration=="number"){if(!this._durationOverrided){var b=Math.floor(g.duration*this._timescale);this._duration=b,this._mediaInfo.duration=b}}else this._mediaInfo.duration=0;if(typeof g.framerate=="number"){var L=Math.floor(g.framerate*1e3);if(L>0){var A=L/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=A,this._referenceFrameRate.fps_num=L,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=A}}if(typeof g.keyframes=="object"){this._mediaInfo.hasKeyframesIndex=!0;var R=g.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(R),g.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=g,x.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(r).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},r))},l.prototype._parseKeyframesIndex=function(s){for(var d=[],u=[],r=1;r<s.times.length;r++){var g=this._timestampBase+Math.floor(s.times[r]*1e3);d.push(g),u.push(s.filepositions[r])}return{times:d,filepositions:u}},l.prototype._parseAudioData=function(s,d,u,r){if(u<=1){x.default.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");return}if(!(this._hasAudioFlagOverrided===!0&&this._hasAudio===!1)){this._littleEndian;var g=new DataView(s,d,u),b=g.getUint8(0),L=b>>>4;if(L!==2&&L!==10){this._onError(c.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+L);return}var A=0,R=(b&12)>>>2;if(R>=0&&R<=4)A=this._flvSoundRateTable[R];else{this._onError(c.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+R);return}var O=b&1,w=this._audioMetadata,C=this._audioTrack;if(w||(this._hasAudio===!1&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),w=this._audioMetadata={},w.type="audio",w.id=C.id,w.timescale=this._timescale,w.duration=this._duration,w.audioSampleRate=A,w.channelCount=O===0?1:2),L===10){var T=this._parseAACAudioData(s,d+1,u-1);if(T==null)return;if(T.packetType===0){w.config&&x.default.w(this.TAG,"Found another AudioSpecificConfig!");var D=T.data;w.audioSampleRate=D.samplingRate,w.channelCount=D.channelCount,w.codec=D.codec,w.originalCodec=D.originalCodec,w.config=D.config,w.refSampleDuration=1024/w.audioSampleRate*w.timescale,x.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",w);var P=this._mediaInfo;P.audioCodec=w.originalCodec,P.audioSampleRate=w.audioSampleRate,P.audioChannelCount=w.channelCount,P.hasVideo?P.videoCodec!=null&&(P.mimeType='video/x-flv; codecs="'+P.videoCodec+","+P.audioCodec+'"'):P.mimeType='video/x-flv; codecs="'+P.audioCodec+'"',P.isComplete()&&this._onMediaInfo(P)}else if(T.packetType===1){var B=this._timestampBase+r,V={unit:T.data,length:T.data.byteLength,dts:B,pts:B};C.samples.push(V),C.length+=T.data.length}else x.default.e(this.TAG,"Flv: Unsupported AAC data type "+T.packetType)}else if(L===2){if(!w.codec){var D=this._parseMP3AudioData(s,d+1,u-1,!0);if(D==null)return;w.audioSampleRate=D.samplingRate,w.channelCount=D.channelCount,w.codec=D.codec,w.originalCodec=D.originalCodec,w.refSampleDuration=1152/w.audioSampleRate*w.timescale,x.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",w);var P=this._mediaInfo;P.audioCodec=w.codec,P.audioSampleRate=w.audioSampleRate,P.audioChannelCount=w.channelCount,P.audioDataRate=D.bitRate,P.hasVideo?P.videoCodec!=null&&(P.mimeType='video/x-flv; codecs="'+P.videoCodec+","+P.audioCodec+'"'):P.mimeType='video/x-flv; codecs="'+P.audioCodec+'"',P.isComplete()&&this._onMediaInfo(P)}var K=this._parseMP3AudioData(s,d+1,u-1,!1);if(K==null)return;var B=this._timestampBase+r,G={unit:K,length:K.byteLength,dts:B,pts:B};C.samples.push(G),C.length+=K.length}}},l.prototype._parseAACAudioData=function(s,d,u){if(u<=1){x.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");return}var r={},g=new Uint8Array(s,d,u);return r.packetType=g[0],g[0]===0?r.data=this._parseAACAudioSpecificConfig(s,d+1,u-1):r.data=g.subarray(1),r},l.prototype._parseAACAudioSpecificConfig=function(s,d,u){var r=new Uint8Array(s,d,u),g=null,b=0,L=0,A=0,R=null;if(b=L=r[0]>>>3,A=(r[0]&7)<<1|r[1]>>>7,A<0||A>=this._mpegSamplingRates.length){this._onError(c.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");return}var O=this._mpegSamplingRates[A],w=(r[1]&120)>>>3;if(w<0||w>=8){this._onError(c.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration");return}b===5&&(R=(r[1]&7)<<1|r[2]>>>7,(r[2]&124)>>>2);var C=self.navigator.userAgent.toLowerCase();return C.indexOf("firefox")!==-1?A>=6?(b=5,g=new Array(4),R=A-3):(b=2,g=new Array(2),R=A):C.indexOf("android")!==-1?(b=2,g=new Array(2),R=A):(b=5,R=A,g=new Array(4),A>=6?R=A-3:w===1&&(b=2,g=new Array(2),R=A)),g[0]=b<<3,g[0]|=(A&15)>>>1,g[1]=(A&15)<<7,g[1]|=(w&15)<<3,b===5&&(g[1]|=(R&15)>>>1,g[2]=(R&1)<<7,g[2]|=8,g[3]=0),{config:g,samplingRate:O,channelCount:w,codec:"mp4a.40."+b,originalCodec:"mp4a.40."+L}},l.prototype._parseMP3AudioData=function(s,d,u,r){if(u<4){x.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");return}this._littleEndian;var g=new Uint8Array(s,d,u),b=null;if(r){if(g[0]!==255)return;var L=g[1]>>>3&3,A=(g[1]&6)>>1,R=(g[2]&240)>>>4,O=(g[2]&12)>>>2,w=g[3]>>>6&3,C=w!==3?2:1,T=0,D=0,P="mp3";switch(L){case 0:T=this._mpegAudioV25SampleRateTable[O];break;case 2:T=this._mpegAudioV20SampleRateTable[O];break;case 3:T=this._mpegAudioV10SampleRateTable[O];break}switch(A){case 1:R<this._mpegAudioL3BitRateTable.length&&(D=this._mpegAudioL3BitRateTable[R]);break;case 2:R<this._mpegAudioL2BitRateTable.length&&(D=this._mpegAudioL2BitRateTable[R]);break;case 3:R<this._mpegAudioL1BitRateTable.length&&(D=this._mpegAudioL1BitRateTable[R]);break}b={bitRate:D,samplingRate:T,channelCount:C,codec:P,originalCodec:P}}else b=g;return b},l.prototype._parseVideoData=function(s,d,u,r,g){if(u<=1){x.default.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");return}if(!(this._hasVideoFlagOverrided===!0&&this._hasVideo===!1)){var b=new Uint8Array(s,d,u)[0],L=(b&240)>>>4,A=b&15;if(A!==7){this._onError(c.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+A);return}this._parseAVCVideoPacket(s,d+1,u-1,r,g,L)}},l.prototype._parseAVCVideoPacket=function(s,d,u,r,g,b){if(u<4){x.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");return}var L=this._littleEndian,A=new DataView(s,d,u),R=A.getUint8(0),O=A.getUint32(0,!L)&16777215,w=O<<8>>8;if(R===0)this._parseAVCDecoderConfigurationRecord(s,d+4,u-4);else if(R===1)this._parseAVCVideoData(s,d+4,u-4,r,g,b,w);else if(R!==2){this._onError(c.default.FORMAT_ERROR,"Flv: Invalid video packet type "+R);return}},l.prototype._parseAVCDecoderConfigurationRecord=function(s,d,u){if(u<7){x.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");return}var r=this._videoMetadata,g=this._videoTrack,b=this._littleEndian,L=new DataView(s,d,u);r?typeof r.avcc<"u"&&x.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(this._hasVideo===!1&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),r=this._videoMetadata={},r.type="video",r.id=g.id,r.timescale=this._timescale,r.duration=this._duration);var A=L.getUint8(0),R=L.getUint8(1);if(L.getUint8(2),L.getUint8(3),A!==1||R===0){this._onError(c.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");return}if(this._naluLengthSize=(L.getUint8(4)&3)+1,this._naluLengthSize!==3&&this._naluLengthSize!==4){this._onError(c.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));return}var O=L.getUint8(5)&31;if(O===0){this._onError(c.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");return}else O>1&&x.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+O);for(var w=6,C=0;C<O;C++){var T=L.getUint16(w,!b);if(w+=2,T!==0){var D=new Uint8Array(s,d+w,T);w+=T;var P=h.default.parseSPS(D);if(C===0){r.codecWidth=P.codec_size.width,r.codecHeight=P.codec_size.height,r.presentWidth=P.present_size.width,r.presentHeight=P.present_size.height,r.profile=P.profile_string,r.level=P.level_string,r.bitDepth=P.bit_depth,r.chromaFormat=P.chroma_format,r.sarRatio=P.sar_ratio,r.frameRate=P.frame_rate,(P.frame_rate.fixed===!1||P.frame_rate.fps_num===0||P.frame_rate.fps_den===0)&&(r.frameRate=this._referenceFrameRate);var B=r.frameRate.fps_den,V=r.frameRate.fps_num;r.refSampleDuration=r.timescale*(B/V);for(var K=D.subarray(1,4),G="avc1.",H=0;H<3;H++){var Z=K[H].toString(16);Z.length<2&&(Z="0"+Z),G+=Z}r.codec=G;var $=this._mediaInfo;$.width=r.codecWidth,$.height=r.codecHeight,$.fps=r.frameRate.fps,$.profile=r.profile,$.level=r.level,$.refFrames=P.ref_frames,$.chromaFormat=P.chroma_format_string,$.sarNum=r.sarRatio.width,$.sarDen=r.sarRatio.height,$.videoCodec=G,$.hasAudio?$.audioCodec!=null&&($.mimeType='video/x-flv; codecs="'+$.videoCodec+","+$.audioCodec+'"'):$.mimeType='video/x-flv; codecs="'+$.videoCodec+'"',$.isComplete()&&this._onMediaInfo($)}}}var q=L.getUint8(w);if(q===0){this._onError(c.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS");return}else q>1&&x.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+q);w++;for(var C=0;C<q;C++){var T=L.getUint16(w,!b);w+=2,T!==0&&(w+=T)}r.avcc=new Uint8Array(u),r.avcc.set(new Uint8Array(s,d,u),0),x.default.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",r)},l.prototype._parseAVCVideoData=function(s,d,u,r,g,b,L){for(var A=this._littleEndian,R=new DataView(s,d,u),O=[],w=0,C=0,T=this._naluLengthSize,D=this._timestampBase+r,P=b===1;C<u;){if(C+4>=u){x.default.w(this.TAG,"Malformed Nalu near timestamp "+D+", offset = "+C+", dataSize = "+u);break}var B=R.getUint32(C,!A);if(T===3&&(B>>>=8),B>u-T){x.default.w(this.TAG,"Malformed Nalus near timestamp "+D+", NaluSize > DataSize!");return}var V=R.getUint8(C+T)&31;V===5&&(P=!0);var K=new Uint8Array(s,d+C,T+B),G={type:V,data:K};O.push(G),w+=K.byteLength,C+=T+B}if(O.length){var H=this._videoTrack,Z={units:O,length:w,isKeyframe:P,dts:D,cts:L,pts:D+L};P&&(Z.fileposition=g),H.samples.push(Z),H.length+=w}},l}();E.default=v},"./src/demux/sps-parser.js":function(S,E,y){y.r(E);var x=y("./src/demux/exp-golomb.js"),m=function(){function h(){}return h._ebsp2rbsp=function(c){for(var _=c,a=_.byteLength,p=new Uint8Array(a),v=0,l=0;l<a;l++)l>=2&&_[l]===3&&_[l-1]===0&&_[l-2]===0||(p[v]=_[l],v++);return new Uint8Array(p.buffer,0,v)},h.parseSPS=function(c){var _=h._ebsp2rbsp(c),a=new x.default(_);a.readByte();var p=a.readByte();a.readByte();var v=a.readByte();a.readUEG();var l=h.getProfileString(p),s=h.getLevelString(v),d=1,u=420,r=[0,420,422,444],g=8;if((p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128||p===138||p===144)&&(d=a.readUEG(),d===3&&a.readBits(1),d<=3&&(u=r[d]),g=a.readUEG()+8,a.readUEG(),a.readBits(1),a.readBool()))for(var b=d!==3?8:12,L=0;L<b;L++)a.readBool()&&(L<6?h._skipScalingList(a,16):h._skipScalingList(a,64));a.readUEG();var A=a.readUEG();if(A===0)a.readUEG();else if(A===1){a.readBits(1),a.readSEG(),a.readSEG();for(var R=a.readUEG(),L=0;L<R;L++)a.readSEG()}var O=a.readUEG();a.readBits(1);var w=a.readUEG(),C=a.readUEG(),T=a.readBits(1);T===0&&a.readBits(1),a.readBits(1);var D=0,P=0,B=0,V=0,K=a.readBool();K&&(D=a.readUEG(),P=a.readUEG(),B=a.readUEG(),V=a.readUEG());var G=1,H=1,Z=0,$=!0,q=0,fe=0,Y=a.readBool();if(Y){if(a.readBool()){var J=a.readByte(),ce=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],se=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];J>0&&J<16?(G=ce[J-1],H=se[J-1]):J===255&&(G=a.readByte()<<8|a.readByte(),H=a.readByte()<<8|a.readByte())}if(a.readBool()&&a.readBool(),a.readBool()&&(a.readBits(4),a.readBool()&&a.readBits(24)),a.readBool()&&(a.readUEG(),a.readUEG()),a.readBool()){var le=a.readBits(32),me=a.readBits(32);$=a.readBool(),q=me,fe=le*2,Z=q/fe}}var Q=1;(G!==1||H!==1)&&(Q=G/H);var j=0,ue=0;if(d===0)j=1,ue=2-T;else{var he=d===3?1:2,xe=d===1?2:1;j=he,ue=xe*(2-T)}var ve=(w+1)*16,ye=(2-T)*((C+1)*16);ve-=(D+P)*j,ye-=(B+V)*ue;var Ee=Math.ceil(ve*Q);return a.destroy(),a=null,{profile_string:l,level_string:s,bit_depth:g,ref_frames:O,chroma_format:u,chroma_format_string:h.getChromaFormatString(u),frame_rate:{fixed:$,fps:Z,fps_den:fe,fps_num:q},sar_ratio:{width:G,height:H},codec_size:{width:ve,height:ye},present_size:{width:Ee,height:ye}}},h._skipScalingList=function(c,_){for(var a=8,p=8,v=0,l=0;l<_;l++)p!==0&&(v=c.readSEG(),p=(a+v+256)%256),a=p===0?a:p},h.getProfileString=function(c){switch(c){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}},h.getLevelString=function(c){return(c/10).toFixed(1)},h.getChromaFormatString=function(c){switch(c){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}},h}();E.default=m},"./src/flv.js":function(S,E,y){y.r(E);var x=y("./src/utils/polyfill.js"),m=y("./src/core/features.js"),h=y("./src/io/loader.js"),c=y("./src/player/flv-player.js"),_=y("./src/player/native-player.js"),a=y("./src/player/player-events.js"),p=y("./src/player/player-errors.js"),v=y("./src/utils/logging-control.js"),l=y("./src/utils/exception.js");x.default.install();function s(g,b){var L=g;if(L==null||typeof L!="object")throw new l.InvalidArgumentException("MediaDataSource must be an javascript object!");if(!L.hasOwnProperty("type"))throw new l.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");switch(L.type){case"flv":return new c.default(L,b);default:return new _.default(L,b)}}function d(){return m.default.supportMSEH264Playback()}function u(){return m.default.getFeatureList()}var r={};r.createPlayer=s,r.isSupported=d,r.getFeatureList=u,r.BaseLoader=h.BaseLoader,r.LoaderStatus=h.LoaderStatus,r.LoaderErrors=h.LoaderErrors,r.Events=a.default,r.ErrorTypes=p.ErrorTypes,r.ErrorDetails=p.ErrorDetails,r.FlvPlayer=c.default,r.NativePlayer=_.default,r.LoggingControl=v.default,Object.defineProperty(r,"version",{enumerable:!0,get:function(){return"1.6.2"}}),E.default=r},"./src/index.js":function(S,E,y){S.exports=y("./src/flv.js").default},"./src/io/fetch-stream-loader.js":function(S,E,y){y.r(E);var x=y("./src/utils/browser.js"),m=y("./src/io/loader.js"),h=y("./src/utils/exception.js"),c=function(){var a=function(p,v){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,s){l.__proto__=s}||function(l,s){for(var d in s)Object.prototype.hasOwnProperty.call(s,d)&&(l[d]=s[d])},a(p,v)};return function(p,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");a(p,v);function l(){this.constructor=p}p.prototype=v===null?Object.create(v):(l.prototype=v.prototype,new l)}}(),_=function(a){c(p,a);function p(v,l){var s=a.call(this,"fetch-stream-loader")||this;return s.TAG="FetchStreamLoader",s._seekHandler=v,s._config=l,s._needStash=!0,s._requestAbort=!1,s._contentLength=null,s._receivedLength=0,s}return p.isSupported=function(){try{var v=x.default.msedge&&x.default.version.minor>=15048,l=x.default.msedge?v:!0;return self.fetch&&self.ReadableStream&&l}catch{return!1}},p.prototype.destroy=function(){this.isWorking()&&this.abort(),a.prototype.destroy.call(this)},p.prototype.open=function(v,l){var s=this;this._dataSource=v,this._range=l;var d=v.url;this._config.reuseRedirectedURL&&v.redirectedURL!=null&&(d=v.redirectedURL);var u=this._seekHandler.getConfig(d,l),r=new self.Headers;if(typeof u.headers=="object"){var g=u.headers;for(var b in g)g.hasOwnProperty(b)&&r.append(b,g[b])}var L={method:"GET",headers:r,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if(typeof this._config.headers=="object")for(var b in this._config.headers)r.append(b,this._config.headers[b]);v.cors===!1&&(L.mode="same-origin"),v.withCredentials&&(L.credentials="include"),v.referrerPolicy&&(L.referrerPolicy=v.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,L.signal=this._abortController.signal),this._status=m.LoaderStatus.kConnecting,self.fetch(u.url,L).then(function(A){if(s._requestAbort){s._status=m.LoaderStatus.kIdle,A.body.cancel();return}if(A.ok&&A.status>=200&&A.status<=299){if(A.url!==u.url&&s._onURLRedirect){var R=s._seekHandler.removeURLParameters(A.url);s._onURLRedirect(R)}var O=A.headers.get("Content-Length");return O!=null&&(s._contentLength=parseInt(O),s._contentLength!==0&&s._onContentLengthKnown&&s._onContentLengthKnown(s._contentLength)),s._pump.call(s,A.body.getReader())}else if(s._status=m.LoaderStatus.kError,s._onError)s._onError(m.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:A.status,msg:A.statusText});else throw new h.RuntimeException("FetchStreamLoader: Http code invalid, "+A.status+" "+A.statusText)}).catch(function(A){if(!(s._abortController&&s._abortController.signal.aborted))if(s._status=m.LoaderStatus.kError,s._onError)s._onError(m.LoaderErrors.EXCEPTION,{code:-1,msg:A.message});else throw A})},p.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==m.LoaderStatus.kBuffering||!x.default.chrome)&&this._abortController)try{this._abortController.abort()}catch{}},p.prototype._pump=function(v){var l=this;return v.read().then(function(s){if(s.done)if(l._contentLength!==null&&l._receivedLength<l._contentLength){l._status=m.LoaderStatus.kError;var d=m.LoaderErrors.EARLY_EOF,u={code:-1,msg:"Fetch stream meet Early-EOF"};if(l._onError)l._onError(d,u);else throw new h.RuntimeException(u.msg)}else l._status=m.LoaderStatus.kComplete,l._onComplete&&l._onComplete(l._range.from,l._range.from+l._receivedLength-1);else{if(l._abortController&&l._abortController.signal.aborted){l._status=m.LoaderStatus.kComplete;return}else if(l._requestAbort===!0)return l._status=m.LoaderStatus.kComplete,v.cancel();l._status=m.LoaderStatus.kBuffering;var r=s.value.buffer,g=l._range.from+l._receivedLength;l._receivedLength+=r.byteLength,l._onDataArrival&&l._onDataArrival(r,g,l._receivedLength),l._pump(v)}}).catch(function(s){if(l._abortController&&l._abortController.signal.aborted){l._status=m.LoaderStatus.kComplete;return}if(!(s.code===11&&x.default.msedge)){l._status=m.LoaderStatus.kError;var d=0,u=null;if((s.code===19||s.message==="network error")&&(l._contentLength===null||l._contentLength!==null&&l._receivedLength<l._contentLength)?(d=m.LoaderErrors.EARLY_EOF,u={code:s.code,msg:"Fetch stream meet Early-EOF"}):(d=m.LoaderErrors.EXCEPTION,u={code:s.code,msg:s.message}),l._onError)l._onError(d,u);else throw new h.RuntimeException(u.msg)}})},p}(m.BaseLoader);E.default=_},"./src/io/io-controller.js":function(S,E,y){y.r(E);var x=y("./src/utils/logger.js"),m=y("./src/io/speed-sampler.js"),h=y("./src/io/loader.js"),c=y("./src/io/fetch-stream-loader.js"),_=y("./src/io/xhr-moz-chunked-loader.js"),a=y("./src/io/xhr-range-loader.js"),p=y("./src/io/websocket-loader.js"),v=y("./src/io/range-seek-handler.js"),l=y("./src/io/param-seek-handler.js"),s=y("./src/utils/exception.js"),d=function(){function u(r,g,b){this.TAG="IOController",this._config=g,this._extraData=b,this._stashInitialSize=1024*384,g.stashInitialSize!=null&&g.stashInitialSize>0&&(this._stashInitialSize=g.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=1024*1024*3,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,g.enableStashBuffer===!1&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=r,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(r.url),this._refTotalLength=r.filesize?r.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new m.default,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return u.prototype.destroy=function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null},u.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},u.prototype.isPaused=function(){return this._paused},Object.defineProperty(u.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"extraData",{get:function(){return this._extraData},set:function(r){this._extraData=r},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(r){this._onDataArrival=r},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(r){this._onSeeked=r},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"onError",{get:function(){return this._onError},set:function(r){this._onError=r},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"onComplete",{get:function(){return this._onComplete},set:function(r){this._onComplete=r},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(r){this._onRedirect=r},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(r){this._onRecoveredEarlyEof=r},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"hasRedirect",{get:function(){return this._redirectedURL!=null||this._dataSource.redirectedURL!=null},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"currentSpeed",{get:function(){return this._loaderClass===a.default?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),u.prototype._selectSeekHandler=function(){var r=this._config;if(r.seekType==="range")this._seekHandler=new v.default(this._config.rangeLoadZeroStart);else if(r.seekType==="param"){var g=r.seekParamStart||"bstart",b=r.seekParamEnd||"bend";this._seekHandler=new l.default(g,b)}else if(r.seekType==="custom"){if(typeof r.customSeekHandler!="function")throw new s.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new r.customSeekHandler}else throw new s.InvalidArgumentException("Invalid seekType in config: "+r.seekType)},u.prototype._selectLoader=function(){if(this._config.customLoader!=null)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=p.default;else if(c.default.isSupported())this._loaderClass=c.default;else if(_.default.isSupported())this._loaderClass=_.default;else if(a.default.isSupported())this._loaderClass=a.default;else throw new s.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!")},u.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),this._loader.needStashBuffer===!1&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)},u.prototype.open=function(r){this._currentRange={from:0,to:-1},r&&(this._currentRange.from=r),this._speedSampler.reset(),r||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},u.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},u.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),this._stashUsed!==0?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)},u.prototype.resume=function(){if(this._paused){this._paused=!1;var r=this._resumeFrom;this._resumeFrom=0,this._internalSeek(r,!0)}},u.prototype.seek=function(r){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(r,!0)},u.prototype._internalSeek=function(r,g){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(g),this._loader.destroy(),this._loader=null;var b={from:r,to:-1};this._currentRange={from:b.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,b),this._onSeeked&&this._onSeeked()},u.prototype.updateUrl=function(r){if(!r||typeof r!="string"||r.length===0)throw new s.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=r},u.prototype._expandBuffer=function(r){for(var g=this._stashSize;g+1024*1024*1<r;)g*=2;if(g+=1024*1024*1,g!==this._bufferSize){var b=new ArrayBuffer(g);if(this._stashUsed>0){var L=new Uint8Array(this._stashBuffer,0,this._stashUsed),A=new Uint8Array(b,0,g);A.set(L,0)}this._stashBuffer=b,this._bufferSize=g}},u.prototype._normalizeSpeed=function(r){var g=this._speedNormalizeList,b=g.length-1,L=0,A=0,R=b;if(r<g[0])return g[0];for(;A<=R;){if(L=A+Math.floor((R-A)/2),L===b||r>=g[L]&&r<g[L+1])return g[L];g[L]<r?A=L+1:R=L-1}},u.prototype._adjustStashSize=function(r){var g=0;this._config.isLive||r<512?g=r:r>=512&&r<=1024?g=Math.floor(r*1.5):g=r*2,g>8192&&(g=8192);var b=g*1024+1024*1024*1;this._bufferSize<b&&this._expandBuffer(b),this._stashSize=g*1024},u.prototype._dispatchChunks=function(r,g){return this._currentRange.to=g+r.byteLength-1,this._onDataArrival(r,g)},u.prototype._onURLRedirect=function(r){this._redirectedURL=r,this._onRedirect&&this._onRedirect(r)},u.prototype._onContentLengthKnown=function(r){r&&this._fullRequestFlag&&(this._totalLength=r,this._fullRequestFlag=!1)},u.prototype._onLoaderChunkArrival=function(r,g,b){if(!this._onDataArrival)throw new s.IllegalStateException("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused){this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(r.byteLength);var L=this._speedSampler.lastSecondKBps;if(L!==0){var A=this._normalizeSpeed(L);this._speedNormalized!==A&&(this._speedNormalized=A,this._adjustStashSize(A))}if(this._enableStash)if(this._stashUsed===0&&this._stashByteStart===0&&(this._stashByteStart=g),this._stashUsed+r.byteLength<=this._stashSize){var w=new Uint8Array(this._stashBuffer,0,this._stashSize);w.set(new Uint8Array(r),this._stashUsed),this._stashUsed+=r.byteLength}else{var w=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){var T=this._stashBuffer.slice(0,this._stashUsed),R=this._dispatchChunks(T,this._stashByteStart);if(R<T.byteLength){if(R>0){var C=new Uint8Array(T,R);w.set(C,0),this._stashUsed=C.byteLength,this._stashByteStart+=R}}else this._stashUsed=0,this._stashByteStart+=R;this._stashUsed+r.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+r.byteLength),w=new Uint8Array(this._stashBuffer,0,this._bufferSize)),w.set(new Uint8Array(r),this._stashUsed),this._stashUsed+=r.byteLength}else{var R=this._dispatchChunks(r,g);if(R<r.byteLength){var O=r.byteLength-R;O>this._bufferSize&&(this._expandBuffer(O),w=new Uint8Array(this._stashBuffer,0,this._bufferSize)),w.set(new Uint8Array(r,R),0),this._stashUsed+=O,this._stashByteStart=g+R}}}else if(this._stashUsed===0){var R=this._dispatchChunks(r,g);if(R<r.byteLength){var O=r.byteLength-R;O>this._bufferSize&&this._expandBuffer(O);var w=new Uint8Array(this._stashBuffer,0,this._bufferSize);w.set(new Uint8Array(r,R),0),this._stashUsed+=O,this._stashByteStart=g+R}}else{this._stashUsed+r.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+r.byteLength);var w=new Uint8Array(this._stashBuffer,0,this._bufferSize);w.set(new Uint8Array(r),this._stashUsed),this._stashUsed+=r.byteLength;var R=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(R<this._stashUsed&&R>0){var C=new Uint8Array(this._stashBuffer,R);w.set(C,0)}this._stashUsed-=R,this._stashByteStart+=R}}},u.prototype._flushStashBuffer=function(r){if(this._stashUsed>0){var g=this._stashBuffer.slice(0,this._stashUsed),b=this._dispatchChunks(g,this._stashByteStart),L=g.byteLength-b;if(b<g.byteLength)if(r)x.default.w(this.TAG,L+" bytes unconsumed data remain when flush buffer, dropped");else{if(b>0){var A=new Uint8Array(this._stashBuffer,0,this._bufferSize),R=new Uint8Array(g,b);A.set(R,0),this._stashUsed=R.byteLength,this._stashByteStart+=b}return 0}return this._stashUsed=0,this._stashByteStart=0,L}return 0},u.prototype._onLoaderComplete=function(r,g){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},u.prototype._onLoaderError=function(r,g){switch(x.default.e(this.TAG,"Loader error, code = "+g.code+", msg = "+g.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,r=h.LoaderErrors.UNRECOVERABLE_EARLY_EOF),r){case h.LoaderErrors.EARLY_EOF:{if(!this._config.isLive&&this._totalLength){var b=this._currentRange.to+1;b<this._totalLength&&(x.default.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(b,!1));return}r=h.LoaderErrors.UNRECOVERABLE_EARLY_EOF;break}case h.LoaderErrors.UNRECOVERABLE_EARLY_EOF:case h.LoaderErrors.CONNECTING_TIMEOUT:case h.LoaderErrors.HTTP_STATUS_CODE_INVALID:case h.LoaderErrors.EXCEPTION:break}if(this._onError)this._onError(r,g);else throw new s.RuntimeException("IOException: "+g.msg)},u}();E.default=d},"./src/io/loader.js":function(S,E,y){y.r(E),y.d(E,{LoaderStatus:function(){return m},LoaderErrors:function(){return h},BaseLoader:function(){return c}});var x=y("./src/utils/exception.js"),m={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},h={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},c=function(){function _(a){this._type=a||"undefined",this._status=m.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return _.prototype.destroy=function(){this._status=m.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},_.prototype.isWorking=function(){return this._status===m.kConnecting||this._status===m.kBuffering},Object.defineProperty(_.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(a){this._onContentLengthKnown=a},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(a){this._onURLRedirect=a},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(a){this._onDataArrival=a},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"onError",{get:function(){return this._onError},set:function(a){this._onError=a},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"onComplete",{get:function(){return this._onComplete},set:function(a){this._onComplete=a},enumerable:!1,configurable:!0}),_.prototype.open=function(a,p){throw new x.NotImplementedException("Unimplemented abstract function!")},_.prototype.abort=function(){throw new x.NotImplementedException("Unimplemented abstract function!")},_}()},"./src/io/param-seek-handler.js":function(S,E,y){y.r(E);var x=function(){function m(h,c){this._startName=h,this._endName=c}return m.prototype.getConfig=function(h,c){var _=h;if(c.from!==0||c.to!==-1){var a=!0;_.indexOf("?")===-1&&(_+="?",a=!1),a&&(_+="&"),_+=this._startName+"="+c.from.toString(),c.to!==-1&&(_+="&"+this._endName+"="+c.to.toString())}return{url:_,headers:{}}},m.prototype.removeURLParameters=function(h){var c=h.split("?")[0],_=void 0,a=h.indexOf("?");a!==-1&&(_=h.substring(a+1));var p="";if(_!=null&&_.length>0)for(var v=_.split("&"),l=0;l<v.length;l++){var s=v[l].split("="),d=l>0;s[0]!==this._startName&&s[0]!==this._endName&&(d&&(p+="&"),p+=v[l])}return p.length===0?c:c+"?"+p},m}();E.default=x},"./src/io/range-seek-handler.js":function(S,E,y){y.r(E);var x=function(){function m(h){this._zeroStart=h||!1}return m.prototype.getConfig=function(h,c){var _={};if(c.from!==0||c.to!==-1){var a=void 0;c.to!==-1?a="bytes="+c.from.toString()+"-"+c.to.toString():a="bytes="+c.from.toString()+"-",_.Range=a}else this._zeroStart&&(_.Range="bytes=0-");return{url:h,headers:_}},m.prototype.removeURLParameters=function(h){return h},m}();E.default=x},"./src/io/speed-sampler.js":function(S,E,y){y.r(E);var x=function(){function m(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return m.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},m.prototype.addBytes=function(h){this._firstCheckpoint===0?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=h,this._totalBytes+=h):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=h,this._totalBytes+=h):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=h,this._totalBytes+=h,this._lastCheckpoint=this._now())},Object.defineProperty(m.prototype,"currentKBps",{get:function(){this.addBytes(0);var h=(this._now()-this._lastCheckpoint)/1e3;return h==0&&(h=1),this._intervalBytes/h/1024},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),this._lastSecondBytes!==0?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"averageKBps",{get:function(){var h=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/h/1024},enumerable:!1,configurable:!0}),m}();E.default=x},"./src/io/websocket-loader.js":function(S,E,y){y.r(E);var x=y("./src/io/loader.js"),m=y("./src/utils/exception.js"),h=function(){var _=function(a,p){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,l){v.__proto__=l}||function(v,l){for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&(v[s]=l[s])},_(a,p)};return function(a,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");_(a,p);function v(){this.constructor=a}a.prototype=p===null?Object.create(p):(v.prototype=p.prototype,new v)}}(),c=function(_){h(a,_);function a(){var p=_.call(this,"websocket-loader")||this;return p.TAG="WebSocketLoader",p._needStash=!0,p._ws=null,p._requestAbort=!1,p._receivedLength=0,p}return a.isSupported=function(){try{return typeof self.WebSocket<"u"}catch{return!1}},a.prototype.destroy=function(){this._ws&&this.abort(),_.prototype.destroy.call(this)},a.prototype.open=function(p){try{var v=this._ws=new self.WebSocket(p.url);v.binaryType="arraybuffer",v.onopen=this._onWebSocketOpen.bind(this),v.onclose=this._onWebSocketClose.bind(this),v.onmessage=this._onWebSocketMessage.bind(this),v.onerror=this._onWebSocketError.bind(this),this._status=x.LoaderStatus.kConnecting}catch(s){this._status=x.LoaderStatus.kError;var l={code:s.code,msg:s.message};if(this._onError)this._onError(x.LoaderErrors.EXCEPTION,l);else throw new m.RuntimeException(l.msg)}},a.prototype.abort=function(){var p=this._ws;p&&(p.readyState===0||p.readyState===1)&&(this._requestAbort=!0,p.close()),this._ws=null,this._status=x.LoaderStatus.kComplete},a.prototype._onWebSocketOpen=function(p){this._status=x.LoaderStatus.kBuffering},a.prototype._onWebSocketClose=function(p){if(this._requestAbort===!0){this._requestAbort=!1;return}this._status=x.LoaderStatus.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)},a.prototype._onWebSocketMessage=function(p){var v=this;if(p.data instanceof ArrayBuffer)this._dispatchArrayBuffer(p.data);else if(p.data instanceof Blob){var l=new FileReader;l.onload=function(){v._dispatchArrayBuffer(l.result)},l.readAsArrayBuffer(p.data)}else{this._status=x.LoaderStatus.kError;var s={code:-1,msg:"Unsupported WebSocket message type: "+p.data.constructor.name};if(this._onError)this._onError(x.LoaderErrors.EXCEPTION,s);else throw new m.RuntimeException(s.msg)}},a.prototype._dispatchArrayBuffer=function(p){var v=p,l=this._receivedLength;this._receivedLength+=v.byteLength,this._onDataArrival&&this._onDataArrival(v,l,this._receivedLength)},a.prototype._onWebSocketError=function(p){this._status=x.LoaderStatus.kError;var v={code:p.code,msg:p.message};if(this._onError)this._onError(x.LoaderErrors.EXCEPTION,v);else throw new m.RuntimeException(v.msg)},a}(x.BaseLoader);E.default=c},"./src/io/xhr-moz-chunked-loader.js":function(S,E,y){y.r(E);var x=y("./src/utils/logger.js"),m=y("./src/io/loader.js"),h=y("./src/utils/exception.js"),c=function(){var a=function(p,v){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,s){l.__proto__=s}||function(l,s){for(var d in s)Object.prototype.hasOwnProperty.call(s,d)&&(l[d]=s[d])},a(p,v)};return function(p,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");a(p,v);function l(){this.constructor=p}p.prototype=v===null?Object.create(v):(l.prototype=v.prototype,new l)}}(),_=function(a){c(p,a);function p(v,l){var s=a.call(this,"xhr-moz-chunked-loader")||this;return s.TAG="MozChunkedLoader",s._seekHandler=v,s._config=l,s._needStash=!0,s._xhr=null,s._requestAbort=!1,s._contentLength=null,s._receivedLength=0,s}return p.isSupported=function(){try{var v=new XMLHttpRequest;return v.open("GET","https://example.com",!0),v.responseType="moz-chunked-arraybuffer",v.responseType==="moz-chunked-arraybuffer"}catch(l){return x.default.w("MozChunkedLoader",l.message),!1}},p.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),a.prototype.destroy.call(this)},p.prototype.open=function(v,l){this._dataSource=v,this._range=l;var s=v.url;this._config.reuseRedirectedURL&&v.redirectedURL!=null&&(s=v.redirectedURL);var d=this._seekHandler.getConfig(s,l);this._requestURL=d.url;var u=this._xhr=new XMLHttpRequest;if(u.open("GET",d.url,!0),u.responseType="moz-chunked-arraybuffer",u.onreadystatechange=this._onReadyStateChange.bind(this),u.onprogress=this._onProgress.bind(this),u.onloadend=this._onLoadEnd.bind(this),u.onerror=this._onXhrError.bind(this),v.withCredentials&&(u.withCredentials=!0),typeof d.headers=="object"){var r=d.headers;for(var g in r)r.hasOwnProperty(g)&&u.setRequestHeader(g,r[g])}if(typeof this._config.headers=="object"){var r=this._config.headers;for(var g in r)r.hasOwnProperty(g)&&u.setRequestHeader(g,r[g])}this._status=m.LoaderStatus.kConnecting,u.send()},p.prototype.abort=function(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=m.LoaderStatus.kComplete},p.prototype._onReadyStateChange=function(v){var l=v.target;if(l.readyState===2){if(l.responseURL!=null&&l.responseURL!==this._requestURL&&this._onURLRedirect){var s=this._seekHandler.removeURLParameters(l.responseURL);this._onURLRedirect(s)}if(l.status!==0&&(l.status<200||l.status>299))if(this._status=m.LoaderStatus.kError,this._onError)this._onError(m.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:l.status,msg:l.statusText});else throw new h.RuntimeException("MozChunkedLoader: Http code invalid, "+l.status+" "+l.statusText);else this._status=m.LoaderStatus.kBuffering}},p.prototype._onProgress=function(v){if(this._status!==m.LoaderStatus.kError){this._contentLength===null&&v.total!==null&&v.total!==0&&(this._contentLength=v.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var l=v.target.response,s=this._range.from+this._receivedLength;this._receivedLength+=l.byteLength,this._onDataArrival&&this._onDataArrival(l,s,this._receivedLength)}},p.prototype._onLoadEnd=function(v){if(this._requestAbort===!0){this._requestAbort=!1;return}else if(this._status===m.LoaderStatus.kError)return;this._status=m.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)},p.prototype._onXhrError=function(v){this._status=m.LoaderStatus.kError;var l=0,s=null;if(this._contentLength&&v.loaded<this._contentLength?(l=m.LoaderErrors.EARLY_EOF,s={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(l=m.LoaderErrors.EXCEPTION,s={code:-1,msg:v.constructor.name+" "+v.type}),this._onError)this._onError(l,s);else throw new h.RuntimeException(s.msg)},p}(m.BaseLoader);E.default=_},"./src/io/xhr-range-loader.js":function(S,E,y){y.r(E);var x=y("./src/utils/logger.js"),m=y("./src/io/speed-sampler.js"),h=y("./src/io/loader.js"),c=y("./src/utils/exception.js"),_=function(){var p=function(v,l){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,d){s.__proto__=d}||function(s,d){for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(s[u]=d[u])},p(v,l)};return function(v,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");p(v,l);function s(){this.constructor=v}v.prototype=l===null?Object.create(l):(s.prototype=l.prototype,new s)}}(),a=function(p){_(v,p);function v(l,s){var d=p.call(this,"xhr-range-loader")||this;return d.TAG="RangeLoader",d._seekHandler=l,d._config=s,d._needStash=!1,d._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],d._currentChunkSizeKB=384,d._currentSpeedNormalized=0,d._zeroSpeedChunkCount=0,d._xhr=null,d._speedSampler=new m.default,d._requestAbort=!1,d._waitForTotalLength=!1,d._totalLengthReceived=!1,d._currentRequestURL=null,d._currentRedirectedURL=null,d._currentRequestRange=null,d._totalLength=null,d._contentLength=null,d._receivedLength=0,d._lastTimeLoaded=0,d}return v.isSupported=function(){try{var l=new XMLHttpRequest;return l.open("GET","https://example.com",!0),l.responseType="arraybuffer",l.responseType==="arraybuffer"}catch(s){return x.default.w("RangeLoader",s.message),!1}},v.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),p.prototype.destroy.call(this)},Object.defineProperty(v.prototype,"currentSpeed",{get:function(){return this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),v.prototype.open=function(l,s){this._dataSource=l,this._range=s,this._status=h.LoaderStatus.kConnecting;var d=!1;this._dataSource.filesize!=null&&this._dataSource.filesize!==0&&(d=!0,this._totalLength=this._dataSource.filesize),!this._totalLengthReceived&&!d?(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1})):this._openSubRange()},v.prototype._openSubRange=function(){var l=this._currentChunkSizeKB*1024,s=this._range.from+this._receivedLength,d=s+l;this._contentLength!=null&&d-this._range.from>=this._contentLength&&(d=this._range.from+this._contentLength-1),this._currentRequestRange={from:s,to:d},this._internalOpen(this._dataSource,this._currentRequestRange)},v.prototype._internalOpen=function(l,s){this._lastTimeLoaded=0;var d=l.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?d=this._currentRedirectedURL:l.redirectedURL!=null&&(d=l.redirectedURL));var u=this._seekHandler.getConfig(d,s);this._currentRequestURL=u.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",u.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),l.withCredentials&&(r.withCredentials=!0),typeof u.headers=="object"){var g=u.headers;for(var b in g)g.hasOwnProperty(b)&&r.setRequestHeader(b,g[b])}if(typeof this._config.headers=="object"){var g=this._config.headers;for(var b in g)g.hasOwnProperty(b)&&r.setRequestHeader(b,g[b])}r.send()},v.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=h.LoaderStatus.kComplete},v.prototype._internalAbort=function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)},v.prototype._onReadyStateChange=function(l){var s=l.target;if(s.readyState===2){if(s.responseURL!=null){var d=this._seekHandler.removeURLParameters(s.responseURL);s.responseURL!==this._currentRequestURL&&d!==this._currentRedirectedURL&&(this._currentRedirectedURL=d,this._onURLRedirect&&this._onURLRedirect(d))}if(s.status>=200&&s.status<=299){if(this._waitForTotalLength)return;this._status=h.LoaderStatus.kBuffering}else if(this._status=h.LoaderStatus.kError,this._onError)this._onError(h.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:s.status,msg:s.statusText});else throw new c.RuntimeException("RangeLoader: Http code invalid, "+s.status+" "+s.statusText)}},v.prototype._onProgress=function(l){if(this._status!==h.LoaderStatus.kError){if(this._contentLength===null){var s=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,s=!0;var d=l.total;this._internalAbort(),d!=null&d!==0&&(this._totalLength=d)}if(this._range.to===-1?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,s){this._openSubRange();return}this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var u=l.loaded-this._lastTimeLoaded;this._lastTimeLoaded=l.loaded,this._speedSampler.addBytes(u)}},v.prototype._normalizeSpeed=function(l){var s=this._chunkSizeKBList,d=s.length-1,u=0,r=0,g=d;if(l<s[0])return s[0];for(;r<=g;){if(u=r+Math.floor((g-r)/2),u===d||l>=s[u]&&l<s[u+1])return s[u];s[u]<l?r=u+1:g=u-1}},v.prototype._onLoad=function(l){if(this._status!==h.LoaderStatus.kError){if(this._waitForTotalLength){this._waitForTotalLength=!1;return}this._lastTimeLoaded=0;var s=this._speedSampler.lastSecondKBps;if(s===0&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(s=this._speedSampler.currentKBps)),s!==0){var d=this._normalizeSpeed(s);this._currentSpeedNormalized!==d&&(this._currentSpeedNormalized=d,this._currentChunkSizeKB=d)}var u=l.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=u.byteLength;var g=!1;this._contentLength!=null&&this._receivedLength<this._contentLength?this._openSubRange():g=!0,this._onDataArrival&&this._onDataArrival(u,r,this._receivedLength),g&&(this._status=h.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}},v.prototype._onXhrError=function(l){this._status=h.LoaderStatus.kError;var s=0,d=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(s=h.LoaderErrors.EARLY_EOF,d={code:-1,msg:"RangeLoader meet Early-Eof"}):(s=h.LoaderErrors.EXCEPTION,d={code:-1,msg:l.constructor.name+" "+l.type}),this._onError)this._onError(s,d);else throw new c.RuntimeException(d.msg)},v}(h.BaseLoader);E.default=a},"./src/player/flv-player.js":function(S,E,y){y.r(E);var x=y("./node_modules/events/events.js"),m=y.n(x),h=y("./src/utils/logger.js"),c=y("./src/utils/browser.js"),_=y("./src/player/player-events.js"),a=y("./src/core/transmuxer.js"),p=y("./src/core/transmuxing-events.js"),v=y("./src/core/mse-controller.js"),l=y("./src/core/mse-events.js"),s=y("./src/player/player-errors.js"),d=y("./src/config.js"),u=y("./src/utils/exception.js"),r=function(){function g(b,L){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new(m()),this._config=(0,d.createDefaultConfig)(),typeof L=="object"&&Object.assign(this._config,L),b.type.toLowerCase()!=="flv")throw new u.InvalidArgumentException("FlvPlayer requires an flv MediaDataSource input!");b.isLive===!0&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=b,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var A=c.default.chrome&&(c.default.version.major<50||c.default.version.major===50&&c.default.version.build<2661);this._alwaysSeekKeyframe=!!(A||c.default.msedge||c.default.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return g.prototype.destroy=function(){this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},g.prototype.on=function(b,L){var A=this;b===_.default.MEDIA_INFO?this._mediaInfo!=null&&Promise.resolve().then(function(){A._emitter.emit(_.default.MEDIA_INFO,A.mediaInfo)}):b===_.default.STATISTICS_INFO&&this._statisticsInfo!=null&&Promise.resolve().then(function(){A._emitter.emit(_.default.STATISTICS_INFO,A.statisticsInfo)}),this._emitter.addListener(b,L)},g.prototype.off=function(b,L){this._emitter.removeListener(b,L)},g.prototype.attachMediaElement=function(b){var L=this;if(this._mediaElement=b,b.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),b.addEventListener("seeking",this.e.onvSeeking),b.addEventListener("canplay",this.e.onvCanPlay),b.addEventListener("stalled",this.e.onvStalled),b.addEventListener("progress",this.e.onvProgress),this._msectl=new v.default(this._config),this._msectl.on(l.default.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(l.default.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(l.default.SOURCE_OPEN,function(){L._mseSourceOpened=!0,L._hasPendingLoad&&(L._hasPendingLoad=!1,L.load())}),this._msectl.on(l.default.ERROR,function(A){L._emitter.emit(_.default.ERROR,s.ErrorTypes.MEDIA_ERROR,s.ErrorDetails.MEDIA_MSE_ERROR,A)}),this._msectl.attachMediaElement(b),this._pendingSeekTime!=null)try{b.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch{}},g.prototype.detachMediaElement=function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)},g.prototype.load=function(){var b=this;if(!this._mediaElement)throw new u.IllegalStateException("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new u.IllegalStateException("FlvPlayer.load() has been called, please call unload() first!");if(!this._hasPendingLoad){if(this._config.deferLoadAfterSourceOpen&&this._mseSourceOpened===!1){this._hasPendingLoad=!0;return}this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new a.default(this._mediaDataSource,this._config),this._transmuxer.on(p.default.INIT_SEGMENT,function(L,A){b._msectl.appendInitSegment(A)}),this._transmuxer.on(p.default.MEDIA_SEGMENT,function(L,A){if(b._msectl.appendMediaSegment(A),b._config.lazyLoad&&!b._config.isLive){var R=b._mediaElement.currentTime;A.info.endDts>=(R+b._config.lazyLoadMaxDuration)*1e3&&b._progressChecker==null&&(h.default.v(b.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),b._suspendTransmuxer())}}),this._transmuxer.on(p.default.LOADING_COMPLETE,function(){b._msectl.endOfStream(),b._emitter.emit(_.default.LOADING_COMPLETE)}),this._transmuxer.on(p.default.RECOVERED_EARLY_EOF,function(){b._emitter.emit(_.default.RECOVERED_EARLY_EOF)}),this._transmuxer.on(p.default.IO_ERROR,function(L,A){b._emitter.emit(_.default.ERROR,s.ErrorTypes.NETWORK_ERROR,L,A)}),this._transmuxer.on(p.default.DEMUX_ERROR,function(L,A){b._emitter.emit(_.default.ERROR,s.ErrorTypes.MEDIA_ERROR,L,{code:-1,msg:A})}),this._transmuxer.on(p.default.MEDIA_INFO,function(L){b._mediaInfo=L,b._emitter.emit(_.default.MEDIA_INFO,Object.assign({},L))}),this._transmuxer.on(p.default.METADATA_ARRIVED,function(L){b._emitter.emit(_.default.METADATA_ARRIVED,L)}),this._transmuxer.on(p.default.SCRIPTDATA_ARRIVED,function(L){b._emitter.emit(_.default.SCRIPTDATA_ARRIVED,L)}),this._transmuxer.on(p.default.STATISTICS_INFO,function(L){b._statisticsInfo=b._fillStatisticsInfo(L),b._emitter.emit(_.default.STATISTICS_INFO,Object.assign({},b._statisticsInfo))}),this._transmuxer.on(p.default.RECOMMEND_SEEKPOINT,function(L){b._mediaElement&&!b._config.accurateSeek&&(b._requestSetTime=!0,b._mediaElement.currentTime=L/1e3)}),this._transmuxer.open()}},g.prototype.unload=function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)},g.prototype.play=function(){return this._mediaElement.play()},g.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(g.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(b){this._mediaElement.volume=b},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(b){this._mediaElement.muted=b},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(b){this._mediaElement?this._internalSeek(b):this._pendingSeekTime=b},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"mediaInfo",{get:function(){return Object.assign({},this._mediaInfo)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"statisticsInfo",{get:function(){return this._statisticsInfo==null&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)},enumerable:!1,configurable:!0}),g.prototype._fillStatisticsInfo=function(b){if(b.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return b;var L=!0,A=0,R=0;if(this._mediaElement.getVideoPlaybackQuality){var O=this._mediaElement.getVideoPlaybackQuality();A=O.totalVideoFrames,R=O.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(A=this._mediaElement.webkitDecodedFrameCount,R=this._mediaElement.webkitDroppedFrameCount):L=!1;return L&&(b.decodedFrames=A,b.droppedFrames=R),b},g.prototype._onmseUpdateEnd=function(){if(!(!this._config.lazyLoad||this._config.isLive)){for(var b=this._mediaElement.buffered,L=this._mediaElement.currentTime,A=0,R=0;R<b.length;R++){var O=b.start(R),w=b.end(R);if(O<=L&&L<w){A=w;break}}A>=L+this._config.lazyLoadMaxDuration&&this._progressChecker==null&&(h.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}},g.prototype._onmseBufferFull=function(){h.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._progressChecker==null&&this._suspendTransmuxer()},g.prototype._suspendTransmuxer=function(){this._transmuxer&&(this._transmuxer.pause(),this._progressChecker==null&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))},g.prototype._checkProgressAndResume=function(){for(var b=this._mediaElement.currentTime,L=this._mediaElement.buffered,A=!1,R=0;R<L.length;R++){var O=L.start(R),w=L.end(R);if(b>=O&&b<w){b>=w-this._config.lazyLoadRecoverDuration&&(A=!0);break}}A&&(window.clearInterval(this._progressChecker),this._progressChecker=null,A&&(h.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))},g.prototype._isTimepointBuffered=function(b){for(var L=this._mediaElement.buffered,A=0;A<L.length;A++){var R=L.start(A),O=L.end(A);if(b>=R&&b<O)return!0}return!1},g.prototype._internalSeek=function(b){var L=this._isTimepointBuffered(b),A=!1,R=0;if(b<1&&this._mediaElement.buffered.length>0){var O=this._mediaElement.buffered.start(0);(O<1&&b<O||c.default.safari)&&(A=!0,R=c.default.safari?.1:O)}if(A)this._requestSetTime=!0,this._mediaElement.currentTime=R;else if(L){if(!this._alwaysSeekKeyframe)this._requestSetTime=!0,this._mediaElement.currentTime=b;else{var w=this._msectl.getNearestKeyframe(Math.floor(b*1e3));this._requestSetTime=!0,w!=null?this._mediaElement.currentTime=w.dts/1e3:this._mediaElement.currentTime=b}this._progressChecker!=null&&this._checkProgressAndResume()}else this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(b),this._transmuxer.seek(Math.floor(b*1e3)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=b)},g.prototype._checkAndApplyUnbufferedSeekpoint=function(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){var b=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(b)||(this._progressChecker!=null&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(b),this._transmuxer.seek(Math.floor(b*1e3)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=b))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)},g.prototype._checkAndResumeStuckPlayback=function(b){var L=this._mediaElement;if(b||!this._receivedCanPlay||L.readyState<2){var A=L.buffered;A.length>0&&L.currentTime<A.start(0)&&(h.default.w(this.TAG,"Playback seems stuck at "+L.currentTime+", seek to "+A.start(0)),this._requestSetTime=!0,this._mediaElement.currentTime=A.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)},g.prototype._onvLoadedMetadata=function(b){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)},g.prototype._onvSeeking=function(b){var L=this._mediaElement.currentTime,A=this._mediaElement.buffered;if(this._requestSetTime){this._requestSetTime=!1;return}if(L<1&&A.length>0){var R=A.start(0);if(R<1&&L<R||c.default.safari){this._requestSetTime=!0,this._mediaElement.currentTime=c.default.safari?.1:R;return}}if(this._isTimepointBuffered(L)){if(this._alwaysSeekKeyframe){var O=this._msectl.getNearestKeyframe(Math.floor(L*1e3));O!=null&&(this._requestSetTime=!0,this._mediaElement.currentTime=O.dts/1e3)}this._progressChecker!=null&&this._checkProgressAndResume();return}this._seekpointRecord={seekPoint:L,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)},g.prototype._onvCanPlay=function(b){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)},g.prototype._onvStalled=function(b){this._checkAndResumeStuckPlayback(!0)},g.prototype._onvProgress=function(b){this._checkAndResumeStuckPlayback()},g}();E.default=r},"./src/player/native-player.js":function(S,E,y){y.r(E);var x=y("./node_modules/events/events.js"),m=y.n(x),h=y("./src/player/player-events.js"),c=y("./src/config.js"),_=y("./src/utils/exception.js"),a=function(){function p(v,l){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new(m()),this._config=(0,c.createDefaultConfig)(),typeof l=="object"&&Object.assign(this._config,l),v.type.toLowerCase()==="flv")throw new _.InvalidArgumentException("NativePlayer does't support flv MediaDataSource input!");if(v.hasOwnProperty("segments"))throw new _.InvalidArgumentException("NativePlayer("+v.type+") doesn't support multipart playback!");this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=v,this._mediaElement=null}return p.prototype.destroy=function(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},p.prototype.on=function(v,l){var s=this;v===h.default.MEDIA_INFO?this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(function(){s._emitter.emit(h.default.MEDIA_INFO,s.mediaInfo)}):v===h.default.STATISTICS_INFO&&this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(function(){s._emitter.emit(h.default.STATISTICS_INFO,s.statisticsInfo)}),this._emitter.addListener(v,l)},p.prototype.off=function(v,l){this._emitter.removeListener(v,l)},p.prototype.attachMediaElement=function(v){if(this._mediaElement=v,v.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._pendingSeekTime!=null)try{v.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch{}},p.prototype.detachMediaElement=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},p.prototype.load=function(){if(!this._mediaElement)throw new _.IllegalStateException("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},p.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},p.prototype.play=function(){return this._mediaElement.play()},p.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(p.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(v){this._mediaElement.volume=v},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(v){this._mediaElement.muted=v},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(v){this._mediaElement?this._mediaElement.currentTime=v:this._pendingSeekTime=v},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"mediaInfo",{get:function(){var v=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",l={mimeType:v+this._mediaDataSource.type};return this._mediaElement&&(l.duration=Math.floor(this._mediaElement.duration*1e3),this._mediaElement instanceof HTMLVideoElement&&(l.width=this._mediaElement.videoWidth,l.height=this._mediaElement.videoHeight)),l},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"statisticsInfo",{get:function(){var v={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return v;var l=!0,s=0,d=0;if(this._mediaElement.getVideoPlaybackQuality){var u=this._mediaElement.getVideoPlaybackQuality();s=u.totalVideoFrames,d=u.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(s=this._mediaElement.webkitDecodedFrameCount,d=this._mediaElement.webkitDroppedFrameCount):l=!1;return l&&(v.decodedFrames=s,v.droppedFrames=d),v},enumerable:!1,configurable:!0}),p.prototype._onvLoadedMetadata=function(v){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(h.default.MEDIA_INFO,this.mediaInfo)},p.prototype._reportStatisticsInfo=function(){this._emitter.emit(h.default.STATISTICS_INFO,this.statisticsInfo)},p}();E.default=a},"./src/player/player-errors.js":function(S,E,y){y.r(E),y.d(E,{ErrorTypes:function(){return h},ErrorDetails:function(){return c}});var x=y("./src/io/loader.js"),m=y("./src/demux/demux-errors.js"),h={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},c={NETWORK_EXCEPTION:x.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:x.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:x.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:x.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:m.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:m.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:m.default.CODEC_UNSUPPORTED}},"./src/player/player-events.js":function(S,E,y){y.r(E);var x={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};E.default=x},"./src/remux/aac-silent.js":function(S,E,y){y.r(E);var x=function(){function m(){}return m.getSilentFrame=function(h,c){if(h==="mp4a.40.2"){if(c===1)return new Uint8Array([0,200,0,128,35,128]);if(c===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(c===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(c===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(c===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(c===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(c===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(c===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(c===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null},m}();E.default=x},"./src/remux/mp4-generator.js":function(S,E,y){y.r(E);var x=function(){function m(){}return m.init=function(){m.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(var h in m.types)m.types.hasOwnProperty(h)&&(m.types[h]=[h.charCodeAt(0),h.charCodeAt(1),h.charCodeAt(2),h.charCodeAt(3)]);var c=m.constants={};c.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),c.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),c.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),c.STSC=c.STCO=c.STTS,c.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),c.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),c.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),c.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),c.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),c.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},m.box=function(h){for(var c=8,_=null,a=Array.prototype.slice.call(arguments,1),p=a.length,v=0;v<p;v++)c+=a[v].byteLength;_=new Uint8Array(c),_[0]=c>>>24&255,_[1]=c>>>16&255,_[2]=c>>>8&255,_[3]=c&255,_.set(h,4);for(var l=8,v=0;v<p;v++)_.set(a[v],l),l+=a[v].byteLength;return _},m.generateInitSegment=function(h){var c=m.box(m.types.ftyp,m.constants.FTYP),_=m.moov(h),a=new Uint8Array(c.byteLength+_.byteLength);return a.set(c,0),a.set(_,c.byteLength),a},m.moov=function(h){var c=m.mvhd(h.timescale,h.duration),_=m.trak(h),a=m.mvex(h);return m.box(m.types.moov,c,_,a)},m.mvhd=function(h,c){return m.box(m.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,h>>>24&255,h>>>16&255,h>>>8&255,h&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))},m.trak=function(h){return m.box(m.types.trak,m.tkhd(h),m.mdia(h))},m.tkhd=function(h){var c=h.id,_=h.duration,a=h.presentWidth,p=h.presentHeight;return m.box(m.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,c>>>24&255,c>>>16&255,c>>>8&255,c&255,0,0,0,0,_>>>24&255,_>>>16&255,_>>>8&255,_&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>>8&255,a&255,0,0,p>>>8&255,p&255,0,0]))},m.mdia=function(h){return m.box(m.types.mdia,m.mdhd(h),m.hdlr(h),m.minf(h))},m.mdhd=function(h){var c=h.timescale,_=h.duration;return m.box(m.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,c>>>24&255,c>>>16&255,c>>>8&255,c&255,_>>>24&255,_>>>16&255,_>>>8&255,_&255,85,196,0,0]))},m.hdlr=function(h){var c=null;return h.type==="audio"?c=m.constants.HDLR_AUDIO:c=m.constants.HDLR_VIDEO,m.box(m.types.hdlr,c)},m.minf=function(h){var c=null;return h.type==="audio"?c=m.box(m.types.smhd,m.constants.SMHD):c=m.box(m.types.vmhd,m.constants.VMHD),m.box(m.types.minf,c,m.dinf(),m.stbl(h))},m.dinf=function(){var h=m.box(m.types.dinf,m.box(m.types.dref,m.constants.DREF));return h},m.stbl=function(h){var c=m.box(m.types.stbl,m.stsd(h),m.box(m.types.stts,m.constants.STTS),m.box(m.types.stsc,m.constants.STSC),m.box(m.types.stsz,m.constants.STSZ),m.box(m.types.stco,m.constants.STCO));return c},m.stsd=function(h){return h.type==="audio"?h.codec==="mp3"?m.box(m.types.stsd,m.constants.STSD_PREFIX,m.mp3(h)):m.box(m.types.stsd,m.constants.STSD_PREFIX,m.mp4a(h)):m.box(m.types.stsd,m.constants.STSD_PREFIX,m.avc1(h))},m.mp3=function(h){var c=h.channelCount,_=h.audioSampleRate,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,c,0,16,0,0,0,0,_>>>8&255,_&255,0,0]);return m.box(m.types[".mp3"],a)},m.mp4a=function(h){var c=h.channelCount,_=h.audioSampleRate,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,c,0,16,0,0,0,0,_>>>8&255,_&255,0,0]);return m.box(m.types.mp4a,a,m.esds(h))},m.esds=function(h){var c=h.config||[],_=c.length,a=new Uint8Array([0,0,0,0,3,23+_,0,1,0,4,15+_,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([_]).concat(c).concat([6,1,2]));return m.box(m.types.esds,a)},m.avc1=function(h){var c=h.avcc,_=h.codecWidth,a=h.codecHeight,p=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_>>>8&255,_&255,a>>>8&255,a&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return m.box(m.types.avc1,p,m.box(m.types.avcC,c))},m.mvex=function(h){return m.box(m.types.mvex,m.trex(h))},m.trex=function(h){var c=h.id,_=new Uint8Array([0,0,0,0,c>>>24&255,c>>>16&255,c>>>8&255,c&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return m.box(m.types.trex,_)},m.moof=function(h,c){return m.box(m.types.moof,m.mfhd(h.sequenceNumber),m.traf(h,c))},m.mfhd=function(h){var c=new Uint8Array([0,0,0,0,h>>>24&255,h>>>16&255,h>>>8&255,h&255]);return m.box(m.types.mfhd,c)},m.traf=function(h,c){var _=h.id,a=m.box(m.types.tfhd,new Uint8Array([0,0,0,0,_>>>24&255,_>>>16&255,_>>>8&255,_&255])),p=m.box(m.types.tfdt,new Uint8Array([0,0,0,0,c>>>24&255,c>>>16&255,c>>>8&255,c&255])),v=m.sdtp(h),l=m.trun(h,v.byteLength+16+16+8+16+8+8);return m.box(m.types.traf,a,p,l,v)},m.sdtp=function(h){for(var c=h.samples||[],_=c.length,a=new Uint8Array(4+_),p=0;p<_;p++){var v=c[p].flags;a[p+4]=v.isLeading<<6|v.dependsOn<<4|v.isDependedOn<<2|v.hasRedundancy}return m.box(m.types.sdtp,a)},m.trun=function(h,c){var _=h.samples||[],a=_.length,p=12+16*a,v=new Uint8Array(p);c+=8+p,v.set([0,0,15,1,a>>>24&255,a>>>16&255,a>>>8&255,a&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255],0);for(var l=0;l<a;l++){var s=_[l].duration,d=_[l].size,u=_[l].flags,r=_[l].cts;v.set([s>>>24&255,s>>>16&255,s>>>8&255,s&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.isNonSync,0,0,r>>>24&255,r>>>16&255,r>>>8&255,r&255],12+16*l)}return m.box(m.types.trun,v)},m.mdat=function(h){return m.box(m.types.mdat,h)},m}();x.init(),E.default=x},"./src/remux/mp4-remuxer.js":function(S,E,y){y.r(E);var x=y("./src/utils/logger.js"),m=y("./src/remux/mp4-generator.js"),h=y("./src/remux/aac-silent.js"),c=y("./src/utils/browser.js"),_=y("./src/core/media-segment-info.js"),a=y("./src/utils/exception.js"),p=function(){function v(l){this.TAG="MP4Remuxer",this._config=l,this._isLive=l.isLive===!0,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new _.MediaSegmentInfoList("audio"),this._videoSegmentInfoList=new _.MediaSegmentInfoList("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!!(c.default.chrome&&(c.default.version.major<50||c.default.version.major===50&&c.default.version.build<2661)),this._fillSilentAfterSeek=c.default.msedge||c.default.msie,this._mp3UseMpegAudio=!c.default.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return v.prototype.destroy=function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null},v.prototype.bindDataSource=function(l){return l.onDataAvailable=this.remux.bind(this),l.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(v.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(l){this._onInitSegment=l},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(l){this._onMediaSegment=l},enumerable:!1,configurable:!0}),v.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},v.prototype.seek=function(l){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},v.prototype.remux=function(l,s){if(!this._onMediaSegment)throw new a.IllegalStateException("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(l,s),this._remuxVideo(s),this._remuxAudio(l)},v.prototype._onTrackMetadataReceived=function(l,s){var d=null,u="mp4",r=s.codec;if(l==="audio")this._audioMeta=s,s.codec==="mp3"&&this._mp3UseMpegAudio?(u="mpeg",r="",d=new Uint8Array):d=m.default.generateInitSegment(s);else if(l==="video")this._videoMeta=s,d=m.default.generateInitSegment(s);else return;if(!this._onInitSegment)throw new a.IllegalStateException("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(l,{type:l,data:d.buffer,codec:r,container:l+"/"+u,mediaDuration:s.duration})},v.prototype._calculateDtsBase=function(l,s){this._dtsBaseInited||(l.samples&&l.samples.length&&(this._audioDtsBase=l.samples[0].dts),s.samples&&s.samples.length&&(this._videoDtsBase=s.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)},v.prototype.flushStashedSamples=function(){var l=this._videoStashedLastSample,s=this._audioStashedLastSample,d={type:"video",id:1,sequenceNumber:0,samples:[],length:0};l!=null&&(d.samples.push(l),d.length=l.length);var u={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};s!=null&&(u.samples.push(s),u.length=s.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(d,!0),this._remuxAudio(u,!0)},v.prototype._remuxAudio=function(l,s){if(this._audioMeta!=null){var d=l,u=d.samples,r=void 0,g=-1,b=-1,L=this._audioMeta.refSampleDuration,A=this._audioMeta.codec==="mp3"&&this._mp3UseMpegAudio,R=this._dtsBaseInited&&this._audioNextDts===void 0,O=!1;if(!(!u||u.length===0)&&!(u.length===1&&!s)){var w=0,C=null,T=0;A?(w=0,T=d.length):(w=8,T=8+d.length);var D=null;if(u.length>1&&(D=u.pop(),T-=D.length),this._audioStashedLastSample!=null){var P=this._audioStashedLastSample;this._audioStashedLastSample=null,u.unshift(P),T+=P.length}D!=null&&(this._audioStashedLastSample=D);var B=u[0].dts-this._dtsBase;if(this._audioNextDts)r=B-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())r=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&this._audioMeta.originalCodec!=="mp3"&&(O=!0);else{var V=this._audioSegmentInfoList.getLastSampleBefore(B);if(V!=null){var K=B-(V.originalDts+V.duration);K<=3&&(K=0);var G=V.dts+V.duration+K;r=B-G}else r=0}if(O){var H=B-r,Z=this._videoSegmentInfoList.getLastSegmentBefore(B);if(Z!=null&&Z.beginDts<H){var $=h.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if($){var q=Z.beginDts,fe=H-Z.beginDts;x.default.v(this.TAG,"InsertPrefixSilentAudio: dts: "+q+", duration: "+fe),u.unshift({unit:$,dts:q,pts:q}),T+=$.byteLength}}else O=!1}for(var Y=[],J=0;J<u.length;J++){var P=u[J],ce=P.unit,se=P.dts-this._dtsBase,q=se,le=!1,me=null,Q=0;if(!(se<-.001)){if(this._audioMeta.codec!=="mp3"){var j=se,ue=3;if(this._audioNextDts&&(j=this._audioNextDts),r=se-j,r<=-ue*L){x.default.w(this.TAG,"Dropping 1 audio frame (originalDts: "+se+" ms ,curRefDts: "+j+" ms) due to dtsCorrection: "+r+" ms overlap.");continue}else if(r>=ue*L&&this._fillAudioTimestampGap&&!c.default.safari){le=!0;var he=Math.floor(r/L);x.default.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.
|
||
`+("originalDts: "+se+" ms, curRefDts: "+j+" ms, ")+("dtsCorrection: "+Math.round(r)+" ms, generate: "+he+" frames")),q=Math.floor(j),Q=Math.floor(j+L)-q;var $=h.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);$==null&&(x.default.w(this.TAG,"Unable to generate silent frame for "+(this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame")),$=ce),me=[];for(var xe=0;xe<he;xe++){j=j+L;var ve=Math.floor(j),ye=Math.floor(j+L)-ve,Ee={dts:ve,pts:ve,cts:0,unit:$,size:$.byteLength,duration:ye,originalDts:se,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};me.push(Ee),T+=Ee.size}this._audioNextDts=j+L}else q=Math.floor(j),Q=Math.floor(j+L)-q,this._audioNextDts=j+L}else{if(q=se-r,J!==u.length-1){var be=u[J+1].dts-this._dtsBase-r;Q=be-q}else if(D!=null){var be=D.dts-this._dtsBase-r;Q=be-q}else Y.length>=1?Q=Y[Y.length-1].duration:Q=Math.floor(L);this._audioNextDts=q+Q}g===-1&&(g=q),Y.push({dts:q,pts:q,cts:0,unit:P.unit,size:P.unit.byteLength,duration:Q,originalDts:se,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),le&&Y.push.apply(Y,me)}}if(Y.length===0){d.samples=[],d.length=0;return}A?C=new Uint8Array(T):(C=new Uint8Array(T),C[0]=T>>>24&255,C[1]=T>>>16&255,C[2]=T>>>8&255,C[3]=T&255,C.set(m.default.types.mdat,4));for(var J=0;J<Y.length;J++){var ce=Y[J].unit;C.set(ce,w),w+=ce.byteLength}var pe=Y[Y.length-1];b=pe.dts+pe.duration;var de=new _.MediaSegmentInfo;de.beginDts=g,de.endDts=b,de.beginPts=g,de.endPts=b,de.originalBeginDts=Y[0].originalDts,de.originalEndDts=pe.originalDts+pe.duration,de.firstSample=new _.SampleInfo(Y[0].dts,Y[0].pts,Y[0].duration,Y[0].originalDts,!1),de.lastSample=new _.SampleInfo(pe.dts,pe.pts,pe.duration,pe.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(de),d.samples=Y,d.sequenceNumber++;var we=null;A?we=new Uint8Array:we=m.default.moof(d,g),d.samples=[],d.length=0;var Re={type:"audio",data:this._mergeBoxes(we,C).buffer,sampleCount:Y.length,info:de};A&&R&&(Re.timestampOffset=g),this._onMediaSegment("audio",Re)}}},v.prototype._remuxVideo=function(l,s){if(this._videoMeta!=null){var d=l,u=d.samples,r=void 0,g=-1,b=-1,L=-1,A=-1;if(!(!u||u.length===0)&&!(u.length===1&&!s)){var R=8,O=null,w=8+l.length,C=null;if(u.length>1&&(C=u.pop(),w-=C.length),this._videoStashedLastSample!=null){var T=this._videoStashedLastSample;this._videoStashedLastSample=null,u.unshift(T),w+=T.length}C!=null&&(this._videoStashedLastSample=C);var D=u[0].dts-this._dtsBase;if(this._videoNextDts)r=D-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())r=0;else{var P=this._videoSegmentInfoList.getLastSampleBefore(D);if(P!=null){var B=D-(P.originalDts+P.duration);B<=3&&(B=0);var V=P.dts+P.duration+B;r=D-V}else r=0}for(var K=new _.MediaSegmentInfo,G=[],H=0;H<u.length;H++){var T=u[H],Z=T.dts-this._dtsBase,$=T.isKeyframe,q=Z-r,fe=T.cts,Y=q+fe;g===-1&&(g=q,L=Y);var J=0;if(H!==u.length-1){var ce=u[H+1].dts-this._dtsBase-r;J=ce-q}else if(C!=null){var ce=C.dts-this._dtsBase-r;J=ce-q}else G.length>=1?J=G[G.length-1].duration:J=Math.floor(this._videoMeta.refSampleDuration);if($){var se=new _.SampleInfo(q,Y,J,T.dts,!0);se.fileposition=T.fileposition,K.appendSyncPoint(se)}G.push({dts:q,pts:Y,cts:fe,units:T.units,size:T.length,isKeyframe:$,duration:J,originalDts:Z,flags:{isLeading:0,dependsOn:$?2:1,isDependedOn:$?1:0,hasRedundancy:0,isNonSync:$?0:1}})}O=new Uint8Array(w),O[0]=w>>>24&255,O[1]=w>>>16&255,O[2]=w>>>8&255,O[3]=w&255,O.set(m.default.types.mdat,4);for(var H=0;H<G.length;H++)for(var le=G[H].units;le.length;){var me=le.shift(),Q=me.data;O.set(Q,R),R+=Q.byteLength}var j=G[G.length-1];if(b=j.dts+j.duration,A=j.pts+j.duration,this._videoNextDts=b,K.beginDts=g,K.endDts=b,K.beginPts=L,K.endPts=A,K.originalBeginDts=G[0].originalDts,K.originalEndDts=j.originalDts+j.duration,K.firstSample=new _.SampleInfo(G[0].dts,G[0].pts,G[0].duration,G[0].originalDts,G[0].isKeyframe),K.lastSample=new _.SampleInfo(j.dts,j.pts,j.duration,j.originalDts,j.isKeyframe),this._isLive||this._videoSegmentInfoList.append(K),d.samples=G,d.sequenceNumber++,this._forceFirstIDR){var ue=G[0].flags;ue.dependsOn=2,ue.isNonSync=0}var he=m.default.moof(d,g);d.samples=[],d.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(he,O).buffer,sampleCount:G.length,info:K})}}},v.prototype._mergeBoxes=function(l,s){var d=new Uint8Array(l.byteLength+s.byteLength);return d.set(l,0),d.set(s,l.byteLength),d},v}();E.default=p},"./src/utils/browser.js":function(S,E,y){y.r(E);var x={};function m(){var h=self.navigator.userAgent.toLowerCase(),c=/(edge)\/([\w.]+)/.exec(h)||/(opr)[\/]([\w.]+)/.exec(h)||/(chrome)[ \/]([\w.]+)/.exec(h)||/(iemobile)[\/]([\w.]+)/.exec(h)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(h)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(h)||/(webkit)[ \/]([\w.]+)/.exec(h)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(h)||/(msie) ([\w.]+)/.exec(h)||h.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(h)||h.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(h)||[],_=/(ipad)/.exec(h)||/(ipod)/.exec(h)||/(windows phone)/.exec(h)||/(iphone)/.exec(h)||/(kindle)/.exec(h)||/(android)/.exec(h)||/(windows)/.exec(h)||/(mac)/.exec(h)||/(linux)/.exec(h)||/(cros)/.exec(h)||[],a={browser:c[5]||c[3]||c[1]||"",version:c[2]||c[4]||"0",majorVersion:c[4]||c[2]||"0",platform:_[0]||""},p={};if(a.browser){p[a.browser]=!0;var v=a.majorVersion.split(".");p.version={major:parseInt(a.majorVersion,10),string:a.version},v.length>1&&(p.version.minor=parseInt(v[1],10)),v.length>2&&(p.version.build=parseInt(v[2],10))}if(a.platform&&(p[a.platform]=!0),(p.chrome||p.opr||p.safari)&&(p.webkit=!0),p.rv||p.iemobile){p.rv&&delete p.rv;var l="msie";a.browser=l,p[l]=!0}if(p.edge){delete p.edge;var s="msedge";a.browser=s,p[s]=!0}if(p.opr){var d="opera";a.browser=d,p[d]=!0}if(p.safari&&p.android){var u="android";a.browser=u,p[u]=!0}p.name=a.browser,p.platform=a.platform;for(var r in x)x.hasOwnProperty(r)&&delete x[r];Object.assign(x,p)}m(),E.default=x},"./src/utils/exception.js":function(S,E,y){y.r(E),y.d(E,{RuntimeException:function(){return m},IllegalStateException:function(){return h},InvalidArgumentException:function(){return c},NotImplementedException:function(){return _}});var x=function(){var a=function(p,v){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,s){l.__proto__=s}||function(l,s){for(var d in s)Object.prototype.hasOwnProperty.call(s,d)&&(l[d]=s[d])},a(p,v)};return function(p,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");a(p,v);function l(){this.constructor=p}p.prototype=v===null?Object.create(v):(l.prototype=v.prototype,new l)}}(),m=function(){function a(p){this._message=p}return Object.defineProperty(a.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),a.prototype.toString=function(){return this.name+": "+this.message},a}(),h=function(a){x(p,a);function p(v){return a.call(this,v)||this}return Object.defineProperty(p.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),p}(m),c=function(a){x(p,a);function p(v){return a.call(this,v)||this}return Object.defineProperty(p.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),p}(m),_=function(a){x(p,a);function p(v){return a.call(this,v)||this}return Object.defineProperty(p.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),p}(m)},"./src/utils/logger.js":function(S,E,y){y.r(E);var x=y("./node_modules/events/events.js"),m=y.n(x),h=function(){function c(){}return c.e=function(_,a){(!_||c.FORCE_GLOBAL_TAG)&&(_=c.GLOBAL_TAG);var p="["+_+"] > "+a;c.ENABLE_CALLBACK&&c.emitter.emit("log","error",p),c.ENABLE_ERROR&&(console.error?console.error(p):console.warn?console.warn(p):console.log(p))},c.i=function(_,a){(!_||c.FORCE_GLOBAL_TAG)&&(_=c.GLOBAL_TAG);var p="["+_+"] > "+a;c.ENABLE_CALLBACK&&c.emitter.emit("log","info",p),c.ENABLE_INFO&&(console.info?console.info(p):console.log(p))},c.w=function(_,a){(!_||c.FORCE_GLOBAL_TAG)&&(_=c.GLOBAL_TAG);var p="["+_+"] > "+a;c.ENABLE_CALLBACK&&c.emitter.emit("log","warn",p),c.ENABLE_WARN&&(console.warn?console.warn(p):console.log(p))},c.d=function(_,a){(!_||c.FORCE_GLOBAL_TAG)&&(_=c.GLOBAL_TAG);var p="["+_+"] > "+a;c.ENABLE_CALLBACK&&c.emitter.emit("log","debug",p),c.ENABLE_DEBUG&&(console.debug?console.debug(p):console.log(p))},c.v=function(_,a){(!_||c.FORCE_GLOBAL_TAG)&&(_=c.GLOBAL_TAG);var p="["+_+"] > "+a;c.ENABLE_CALLBACK&&c.emitter.emit("log","verbose",p),c.ENABLE_VERBOSE&&console.log(p)},c}();h.GLOBAL_TAG="flv.js",h.FORCE_GLOBAL_TAG=!1,h.ENABLE_ERROR=!0,h.ENABLE_INFO=!0,h.ENABLE_WARN=!0,h.ENABLE_DEBUG=!0,h.ENABLE_VERBOSE=!0,h.ENABLE_CALLBACK=!1,h.emitter=new(m()),E.default=h},"./src/utils/logging-control.js":function(S,E,y){y.r(E);var x=y("./node_modules/events/events.js"),m=y.n(x),h=y("./src/utils/logger.js"),c=function(){function _(){}return Object.defineProperty(_,"forceGlobalTag",{get:function(){return h.default.FORCE_GLOBAL_TAG},set:function(a){h.default.FORCE_GLOBAL_TAG=a,_._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(_,"globalTag",{get:function(){return h.default.GLOBAL_TAG},set:function(a){h.default.GLOBAL_TAG=a,_._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(_,"enableAll",{get:function(){return h.default.ENABLE_VERBOSE&&h.default.ENABLE_DEBUG&&h.default.ENABLE_INFO&&h.default.ENABLE_WARN&&h.default.ENABLE_ERROR},set:function(a){h.default.ENABLE_VERBOSE=a,h.default.ENABLE_DEBUG=a,h.default.ENABLE_INFO=a,h.default.ENABLE_WARN=a,h.default.ENABLE_ERROR=a,_._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(_,"enableDebug",{get:function(){return h.default.ENABLE_DEBUG},set:function(a){h.default.ENABLE_DEBUG=a,_._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(_,"enableVerbose",{get:function(){return h.default.ENABLE_VERBOSE},set:function(a){h.default.ENABLE_VERBOSE=a,_._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(_,"enableInfo",{get:function(){return h.default.ENABLE_INFO},set:function(a){h.default.ENABLE_INFO=a,_._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(_,"enableWarn",{get:function(){return h.default.ENABLE_WARN},set:function(a){h.default.ENABLE_WARN=a,_._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(_,"enableError",{get:function(){return h.default.ENABLE_ERROR},set:function(a){h.default.ENABLE_ERROR=a,_._notifyChange()},enumerable:!1,configurable:!0}),_.getConfig=function(){return{globalTag:h.default.GLOBAL_TAG,forceGlobalTag:h.default.FORCE_GLOBAL_TAG,enableVerbose:h.default.ENABLE_VERBOSE,enableDebug:h.default.ENABLE_DEBUG,enableInfo:h.default.ENABLE_INFO,enableWarn:h.default.ENABLE_WARN,enableError:h.default.ENABLE_ERROR,enableCallback:h.default.ENABLE_CALLBACK}},_.applyConfig=function(a){h.default.GLOBAL_TAG=a.globalTag,h.default.FORCE_GLOBAL_TAG=a.forceGlobalTag,h.default.ENABLE_VERBOSE=a.enableVerbose,h.default.ENABLE_DEBUG=a.enableDebug,h.default.ENABLE_INFO=a.enableInfo,h.default.ENABLE_WARN=a.enableWarn,h.default.ENABLE_ERROR=a.enableError,h.default.ENABLE_CALLBACK=a.enableCallback},_._notifyChange=function(){var a=_.emitter;if(a.listenerCount("change")>0){var p=_.getConfig();a.emit("change",p)}},_.registerListener=function(a){_.emitter.addListener("change",a)},_.removeListener=function(a){_.emitter.removeListener("change",a)},_.addLogListener=function(a){h.default.emitter.addListener("log",a),h.default.emitter.listenerCount("log")>0&&(h.default.ENABLE_CALLBACK=!0,_._notifyChange())},_.removeLogListener=function(a){h.default.emitter.removeListener("log",a),h.default.emitter.listenerCount("log")===0&&(h.default.ENABLE_CALLBACK=!1,_._notifyChange())},_}();c.emitter=new(m()),E.default=c},"./src/utils/polyfill.js":function(S,E,y){y.r(E);var x=function(){function m(){}return m.install=function(){Object.setPrototypeOf=Object.setPrototypeOf||function(h,c){return h.__proto__=c,h},Object.assign=Object.assign||function(h){if(h==null)throw new TypeError("Cannot convert undefined or null to object");for(var c=Object(h),_=1;_<arguments.length;_++){var a=arguments[_];if(a!=null)for(var p in a)a.hasOwnProperty(p)&&(c[p]=a[p])}return c},typeof self.Promise!="function"&&y("./node_modules/es6-promise/dist/es6-promise.js").polyfill()},m}();x.install(),E.default=x},"./src/utils/utf8-conv.js":function(S,E,y){y.r(E);function x(h,c,_){var a=h;if(c+_<a.length){for(;_--;)if((a[++c]&192)!==128)return!1;return!0}else return!1}function m(h){for(var c=[],_=h,a=0,p=h.length;a<p;){if(_[a]<128){c.push(String.fromCharCode(_[a])),++a;continue}else if(!(_[a]<192)){if(_[a]<224){if(x(_,a,1)){var v=(_[a]&31)<<6|_[a+1]&63;if(v>=128){c.push(String.fromCharCode(v&65535)),a+=2;continue}}}else if(_[a]<240){if(x(_,a,2)){var v=(_[a]&15)<<12|(_[a+1]&63)<<6|_[a+2]&63;if(v>=2048&&(v&63488)!==55296){c.push(String.fromCharCode(v&65535)),a+=3;continue}}}else if(_[a]<248&&x(_,a,3)){var v=(_[a]&7)<<18|(_[a+1]&63)<<12|(_[a+2]&63)<<6|_[a+3]&63;if(v>65536&&v<1114112){v-=65536,c.push(String.fromCharCode(v>>>10|55296)),c.push(String.fromCharCode(v&1023|56320)),a+=4;continue}}}c.push("<22>"),++a}return c.join("")}E.default=m}},n={};function i(S){var E=n[S];if(E!==void 0)return E.exports;var y=n[S]={exports:{}};return t[S].call(y.exports,y,y.exports,i),y.exports}i.m=t,function(){i.n=function(S){var E=S&&S.__esModule?function(){return S.default}:function(){return S};return i.d(E,{a:E}),E}}(),function(){i.d=function(S,E){for(var y in E)i.o(E,y)&&!i.o(S,y)&&Object.defineProperty(S,y,{enumerable:!0,get:E[y]})}}(),function(){i.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}()}(),function(){i.o=function(S,E){return Object.prototype.hasOwnProperty.call(S,E)}}(),function(){i.r=function(S){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(S,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(S,"__esModule",{value:!0})}}();var o=i("./src/index.js");return o}()})})(Ze);var Et=Ze.exports;const Ae=rt(Et);class bt{constructor(e){ae(this,"cameras",new Map);ae(this,"activeMovements",new Map);ae(this,"lastSpeeds",new Map);ae(this,"numberOfCameras",3);ae(this,"pendingSliderUpdates",new Map);ae(this,"sliderUpdateTimer",null);ae(this,"ptzUpdateInterval",null);ae(this,"ptzUpdateRate",100);ae(this,"inertiaFactor",.9);ae(this,"currentSpeeds",new Map);ae(this,"targetSpeeds",new Map);ae(this,"isJoystickActive",new Map);ae(this,"lastMovements",new Map);this.loadConfiguration(),e&&e>0&&(this.numberOfCameras=e),this.startPtzUpdateLoop(),this.initializeApplication()}loadConfiguration(){try{const e=localStorage.getItem("ptz-camera-config");if(e){const t=JSON.parse(e);if(this.numberOfCameras=t.numberOfCameras||3,setTimeout(()=>{const n=document.getElementById("camera-count"),i=document.getElementById("config-info");n&&(n.value=this.numberOfCameras.toString()),t.configured&&i&&(i.style.display="block")},100),t.configured){this.showMainInterface(),this.initializeApplication(),setTimeout(()=>{this.restoreConnectedCameras(t)},1e3);return}}}catch(e){console.warn("Failed to load configuration from localStorage:",e)}}async restoreConnectedCameras(e){if(!e.connectedCameras)return;const t=Object.keys(e.connectedCameras).filter(n=>e.connectedCameras[n].connected);if(t.length!==0){console.log("🔄 Restoring connected cameras from previous session..."),this.showRestorationNotification(t.length);for(const[n,i]of Object.entries(e.connectedCameras)){const o=parseInt(n);if(i.connected&&i.ip){console.log(`📡 Attempting to restore connection to camera ${o} at ${i.ip}`);const S=document.getElementById(`cam${o}-ip`);S&&(S.value=i.ip);const E=this.cameras.get(o);E&&(E.ip=i.ip,E.username=i.username||"admin",E.password=i.password||"234Tgb999!"),setTimeout(()=>{this.toggleConnection(o)},o*2e3)}}setTimeout(()=>{this.hideRestorationNotification()},(t.length+1)*2e3)}}showRestorationNotification(e){const t=document.createElement("div");t.id="restoration-notification",t.style.cssText=`
|
||
position: fixed;
|
||
top: 60px;
|
||
right: 20px;
|
||
background: var(--accent-blue);
|
||
color: white;
|
||
padding: 0.5rem 1rem;
|
||
border-radius: 4px;
|
||
font-size: 0.9rem;
|
||
z-index: 1000;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
||
`,t.textContent=`🔄 Restoring ${e} connected camera${e>1?"s":""}...`,document.body.appendChild(t)}hideRestorationNotification(){const e=document.getElementById("restoration-notification");e&&e.remove()}resetConfiguration(){try{localStorage.removeItem("ptz-camera-config");const e=document.getElementById("camera-count"),t=document.getElementById("config-info");e&&(e.value="3"),t&&(t.style.display="none"),this.numberOfCameras=3,this.cameras.clear(),this.activeMovements.clear(),this.lastSpeeds.clear();const n=document.getElementById("config-section"),i=document.getElementById("main-header"),o=document.getElementById("main-content");n&&(n.style.display="flex"),i&&(i.style.display="none"),o&&(o.style.display="none"),alert("Configuration has been reset. Please configure your cameras again.")}catch(e){console.warn("Failed to reset configuration:",e),alert("Failed to reset configuration. Please refresh the page.")}}saveConfiguration(){try{const e={numberOfCameras:this.numberOfCameras,configured:!0,cameraIPs:this.getCameraIPs(),connectedCameras:this.getConnectedCameras(),timestamp:Date.now()};localStorage.setItem("ptz-camera-config",JSON.stringify(e))}catch(e){console.warn("Failed to save configuration to localStorage:",e)}}getConnectedCameras(){const e={};for(let t=1;t<=this.numberOfCameras;t++){const n=this.cameras.get(t);n&&n.connected&&(e[t]={ip:n.ip,username:n.username,password:n.password,connected:!0})}return e}getCameraIPs(){const e={};for(let t=1;t<=this.numberOfCameras;t++){const n=document.getElementById(`cam${t}-ip`);n&&(e[t]=n.value)}return e}applySavedIPs(){try{const e=localStorage.getItem("ptz-camera-config");if(e){const t=JSON.parse(e);if(t.cameraIPs)for(let n=1;n<=this.numberOfCameras;n++){const i=document.getElementById(`cam${n}-ip`);i&&t.cameraIPs[n]&&(i.value=t.cameraIPs[n])}}}catch(e){console.warn("Failed to apply saved IPs:",e)}}showMainInterface(){const e=document.getElementById("config-section"),t=document.getElementById("main-header"),n=document.getElementById("main-content");e&&(e.style.display="none"),t&&(t.style.display="flex"),n&&(n.style.display="flex")}initializeApplication(){this.initializeUI(),this.initializeCameras(),this.setupEventListeners(),this.updateSliderValues(),this.setupGlobalControls(),setTimeout(()=>{this.applySavedIPs()},100)}initializeUI(){this.generateCameraUI(),this.generateSettingsUI()}initializeCameras(){for(let e=1;e<=this.numberOfCameras;e++)this.cameras.set(e,{id:e,ip:"",username:"admin",password:"234Tgb999!",connected:!1,connecting:!1}),this.activeMovements.set(e,new Set),this.currentSpeeds.set(e,{pan:0,tilt:0}),this.targetSpeeds.set(e,{pan:0,tilt:0}),this.isJoystickActive.set(e,!1),this.lastMovements.set(e,{pan:"",tilt:""})}setupEventListeners(){for(let e=1;e<=this.numberOfCameras;e++){const t=document.getElementById(`cam${e}-connect`),n=document.getElementById(`cam${e}-ip`);t&&n&&(t.addEventListener("click",()=>this.toggleConnection(e)),n.addEventListener("keypress",i=>{i.key==="Enter"&&this.toggleConnection(e)}),n.addEventListener("blur",()=>{this.saveConfiguration()}),n.addEventListener("input",()=>{clearTimeout(n.saveTimeout),n.saveTimeout=setTimeout(()=>{this.saveConfiguration()},1e3)})),this.setupJoystick(e),this.setupPanTiltSpeedControls(e),this.setupHomeButton(e),this.setupSmoothingControls(e),this.setupDynamicZoomControl(e),this.setupDynamicFocusControl(e),this.setupPresetControls(e),this.setupQuickPresetControls(e),this.setupImageSettings(e)}this.setupCameraTabs()}setupJoystick(e){const t=document.getElementById(`cam${e}-ptz`);if(!t)return;const n=xt.create({zone:t,mode:"static",position:{left:"50%",top:"50%"},color:"#4488ff",size:100,threshold:.1,fadeTime:150,multitouch:!1,maxNumberOfNipples:1,dataOnly:!1,restJoystick:!0,restOpacity:.3,lockX:!1,lockY:!1}),i=this.cameras.get(e);i&&(i.joystick=n),n.on("start",()=>{t.style.borderColor="#4488ff",t.style.boxShadow="0 0 15px rgba(68, 136, 255, 0.4)",this.isJoystickActive.set(e,!0)}),n.on("move",(o,S)=>{var E;(E=this.cameras.get(e))!=null&&E.connected&&this.updateTargetSpeeds(e,S)}),n.on("end",()=>{t.style.borderColor="#555555",t.style.boxShadow="none",this.isJoystickActive.set(e,!1),this.targetSpeeds.set(e,{pan:0,tilt:0})})}applySensitivityCurve(e){return e*e}updateTargetSpeeds(e,t){const{force:n,angle:i}=t;if(n<.1){this.targetSpeeds.set(e,{pan:0,tilt:0});return}const S=document.getElementById(`cam${e}-pan-tilt-speed`),E=S?parseInt(S.value):12,y=document.getElementById(`cam${e}-speedup`),x=y?parseInt(y.value)/100:1,m=this.applySensitivityCurve(n),h=i.radian,c=Math.cos(h)*m*E*x,_=-Math.sin(h)*m*E*x;this.targetSpeeds.set(e,{pan:c,tilt:_})}lerp(e,t,n){return(1-n)*e+n*t}startPtzUpdateLoop(){this.ptzUpdateInterval&&clearInterval(this.ptzUpdateInterval),this.ptzUpdateInterval=window.setInterval(()=>{this.cameras.forEach((e,t)=>{this.updatePtzMovement(t)})},this.ptzUpdateRate)}async updatePtzMovement(e){const t=this.cameras.get(e);if(!(t!=null&&t.instance)||!t.connected)return;const n=this.currentSpeeds.get(e),i=this.targetSpeeds.get(e),o=this.lastMovements.get(e),S=document.getElementById(`cam${e}-damping`),y=.5/(S?parseInt(S.value):20);n.pan=this.lerp(n.pan,i.pan,y),n.tilt=this.lerp(n.tilt,i.tilt,y),this.isJoystickActive.get(e)||(n.pan*=this.inertiaFactor,n.tilt*=this.inertiaFactor);const x=.5;Math.abs(n.pan)<x&&(n.pan=0),Math.abs(n.tilt)<x&&(n.tilt=0);const m=Math.round(Math.abs(n.pan)),h=Math.round(Math.abs(n.tilt)),c=n.pan>0?"right":n.pan<0?"left":"",_=n.tilt>0?"down":n.tilt<0?"up":"";try{c!==o.pan?(o.pan&&await t.instance.move(o.pan,!1),c&&await t.instance.move(c,!0,m),o.pan=c):c&&await t.instance.move(c,!0,m),_!==o.tilt?(o.tilt&&await t.instance.move(o.tilt,!1),_&&await t.instance.move(_,!0,h),o.tilt=_):_&&await t.instance.move(_,!0,h)}catch(a){console.error(`Error sending PTZ command to camera ${e}:`,a)}}async stopAllMovement(e){const t=this.cameras.get(e),n=this.lastMovements.get(e);if(!(t!=null&&t.instance)||!n)return;try{n.pan&&(await t.instance.move(n.pan,!1),n.pan=""),n.tilt&&(await t.instance.move(n.tilt,!1),n.tilt="")}catch(S){console.error(`Error stopping movements for camera ${e}:`,S)}const i=this.currentSpeeds.get(e),o=this.targetSpeeds.get(e);i&&(i.pan=0,i.tilt=0),o&&(o.pan=0,o.tilt=0)}setupPanTiltSpeedControls(e){var i;const t=document.getElementById(`cam${e}-pan-tilt-speed`),n=(i=t==null?void 0:t.parentElement)==null?void 0:i.querySelector(".pan-tilt-speed-value");t&&n&&(n.textContent=t.value,t.addEventListener("input",()=>{n.textContent=t.value}))}setupHomeButton(e){const t=document.getElementById(`cam${e}-home`);t&&t.addEventListener("click",async()=>{const n=this.cameras.get(e);if(!(n!=null&&n.instance)||!n.connected){alert(`Camera ${e} is not connected.`);return}try{t.disabled=!0,t.textContent="⏳",await n.instance.home()?(console.log(`✅ Camera ${e} returned to home position.`),t.textContent="✓",setTimeout(()=>{t.textContent="🏠"},1e3)):(console.warn(`⚠️ Camera ${e} home command returned false.`),t.textContent="✗",setTimeout(()=>{t.textContent="🏠"},1e3))}catch(i){console.error(`Error sending home command to camera ${e}:`,i),t.textContent="✗",setTimeout(()=>{t.textContent="🏠"},1e3)}finally{t.disabled=!1}})}setupSmoothingControls(e){var S,E;const t=document.getElementById(`cam${e}-damping`),n=(S=t==null?void 0:t.parentElement)==null?void 0:S.querySelector(".pan-tilt-speed-value");t&&n&&(n.textContent=t.value,t.addEventListener("input",()=>{n.textContent=t.value}));const i=document.getElementById(`cam${e}-speedup`),o=(E=i==null?void 0:i.parentElement)==null?void 0:E.querySelector(".pan-tilt-speed-value");i&&o&&(o.textContent=i.value+"%",i.addEventListener("input",()=>{o.textContent=i.value+"%"}))}updateStreamStatus(e,t){const n=document.getElementById(`cam${e}-video`);if(n)switch(t.toLowerCase()){case"connecting":n.style.border="2px solid #ffaa00",n.title="Connecting to stream...";break;case"live":n.style.border="2px solid #00aa00",n.title="Live stream active";break;case"error":n.style.border="2px solid #aa0000",n.title="Stream error - retrying...";break;default:n.style.border="1px solid var(--border-color)",n.title=""}}async startVideoStream(e){const t=this.cameras.get(e);if(!(t!=null&&t.instance)||!t.connected)return this.updateStreamStatus(e,"Error"),console.warn(`Camera ${e} not connected`),!1;const n=document.getElementById(`cam${e}-video`);if(!n)return!1;this.updateStreamStatus(e,"Connecting");try{this.stopVideoStream(e);const i="sub";console.log(`🚀 Starting FLV ${i} stream for camera ${e}...`);let o;try{o=await t.instance.getFLVUrl(i)}catch{console.log(`Failed to get ${i} FLV URL, trying main stream...`),o=await t.instance.getFLVUrl("main")}if(!o||o.trim()==="")throw new Error("No FLV stream URL received");if(console.log("📺 FLV Stream URL:",o),!Ae.isSupported())throw new Error("FLV.js not supported in this browser");const S=Ae.createPlayer({type:"flv",url:o,isLive:!0,hasAudio:!1,hasVideo:!0},{enableStashBuffer:!1,stashInitialSize:128,enableWorker:!1,lazyLoad:!1,autoCleanupSourceBuffer:!0,reuseRedirectedURL:!0});t.flvPlayer=S,n.crossOrigin="anonymous",n.muted=!0,n.playsInline=!0,S.attachMediaElement(n),S.on(Ae.Events.ERROR,(E,y,x)=>{console.error(`🚨 FLV Player Error for camera ${e}:`,{type:E,detail:y,info:x});let m="Stream Error";E==="NetworkError"?m="Network Error":E==="MediaError"&&(m="Media Error"),this.updateStreamStatus(e,m),setTimeout(()=>{console.log(`🔄 Retrying camera ${e} stream...`),this.startVideoStream(e)},2e3)}),S.on(Ae.Events.LOADING_COMPLETE,()=>{console.log(`📡 Camera ${e} stream loaded`),this.updateStreamStatus(e,"Live")}),S.on(Ae.Events.MEDIA_INFO,E=>{console.log(`📹 Camera ${e} media info:`,E)}),S.load();try{return await n.play(),this.updateStreamStatus(e,"Live"),console.log(`✅ Camera ${e} stream started successfully!`),!0}catch{return console.warn(`Auto-play prevented for camera ${e}. Click to play manually.`),this.updateStreamStatus(e,"Ready"),!0}}catch(i){return console.error(`❌ Error starting FLV stream for camera ${e}:`,i),this.updateStreamStatus(e,"Error"),this.stopVideoStream(e),!1}}stopVideoStream(e){const t=this.cameras.get(e),n=document.getElementById(`cam${e}-video`);if(t!=null&&t.flvPlayer)try{t.flvPlayer.pause(),t.flvPlayer.unload(),t.flvPlayer.detachMediaElement(),t.flvPlayer.destroy(),t.flvPlayer=null}catch(i){console.warn(`Error stopping FLV player for camera ${e}:`,i)}n&&(n.pause(),n.src="",n.load()),this.updateStreamStatus(e,"Ready"),console.log(`🛑 Camera ${e} stream stopped`)}setupZoomControls(e){var S;const t=document.getElementById(`cam${e}-zoom-dynamic`),n=document.getElementById(`cam${e}-zoom-sensitivity`),i=(S=n==null?void 0:n.parentElement)==null?void 0:S.querySelector(".sensitivity-value");if(!t)return;n&&i&&(i.textContent=n.value,n.addEventListener("input",()=>{i.textContent=n.value}));let o=!1;t.addEventListener("input",async()=>{const E=parseInt(t.value),y=this.cameras.get(e);if(!(y!=null&&y.instance)||!y.connected)return;if(E===50){o&&(await y.instance.zoom("in",!1),await y.instance.zoom("out",!1),o=!1);return}const x=E>50?"in":"out",m=Math.abs(E-50),c=(n?parseInt(n.value):5)/5,_=m*c,a=Math.max(0,Math.min(7,Math.floor(_/7)));try{const p=x==="in"?"out":"in";await y.instance.zoom(p,!1),await y.instance.zoom(x,!0,a),o=!0}catch(p){console.error(`Error controlling zoom for camera ${e}:`,p)}}),t.addEventListener("change",async()=>{t.value="50";const E=this.cameras.get(e);if(!(!(E!=null&&E.instance)||!E.connected))try{await E.instance.zoom("in",!1),await E.instance.zoom("out",!1),o=!1}catch(y){console.error(`Error stopping zoom for camera ${e}:`,y)}})}setupDynamicZoomControl(e){this.setupZoomControls(e)}setupFocusControls(e){var E;const t=document.getElementById(`cam${e}-focus-dynamic`),n=document.getElementById(`cam${e}-focus-sensitivity`),i=(E=n==null?void 0:n.parentElement)==null?void 0:E.querySelector(".sensitivity-value");if(!t)return;n&&i&&(i.textContent=n.value,n.addEventListener("input",()=>{i.textContent=n.value}));let o=!1;t.addEventListener("input",async()=>{const y=parseInt(t.value),x=this.cameras.get(e);if(!(x!=null&&x.instance)||!x.connected)return;if(y===50){o&&(await x.instance.setFocusMode("manual"),await x.instance.focus("near",!1),await x.instance.focus("far",!1),o=!1);return}const m=y<50?"near":"far",h=Math.abs(y-50),_=(n?parseInt(n.value):5)/5,a=h*_,p=Math.max(0,Math.min(7,Math.floor(a/7)));try{await x.instance.setFocusMode("manual");const v=m==="near"?"far":"near";await x.instance.focus(v,!1),await x.instance.focus(m,!0,p),o=!0}catch(v){console.error(`Error controlling focus for camera ${e}:`,v)}}),t.addEventListener("change",async()=>{t.value="50";const y=this.cameras.get(e);if(!(!(y!=null&&y.instance)||!y.connected))try{await y.instance.focus("near",!1),await y.instance.focus("far",!1),o=!1}catch(x){console.error(`Error stopping focus for camera ${e}:`,x)}});const S=document.querySelector(`[data-action="focus-auto"][data-camera="${e}"]`);S&&S.addEventListener("click",()=>this.setAutoFocus(e))}setupDynamicFocusControl(e){this.setupFocusControls(e)}setupPresetControls(e){const t=document.querySelector(`[data-action="set-preset"][data-camera="${e}"]`),n=document.querySelector(`[data-action="recall-preset"][data-camera="${e}"]`),i=document.getElementById(`cam${e}-preset`);t&&i&&t.addEventListener("click",()=>{const o=parseInt(i.value);this.setPreset(e,o)}),n&&i&&n.addEventListener("click",()=>{const o=parseInt(i.value);this.recallPreset(e,o)})}setupQuickPresetControls(e){const t=document.getElementById(`cam${e}-quick-presets`);t&&(this.loadPresetLabels(e),t.addEventListener("click",n=>{const i=n.target,o=i.closest(".quick-preset-item");if(!o)return;const S=parseInt(o.getAttribute("data-preset-id"));i.matches('[data-action="quick-set"]')&&this.setPreset(e,S),i.matches('[data-action="quick-recall"]')&&this.recallPreset(e,S)}),t.addEventListener("input",n=>{const i=n.target;if(i.matches(".quick-preset-label")){const o=parseInt(i.getAttribute("data-preset-id"));this.savePresetLabel(e,o,i.value)}}))}getPresetLabelKey(e,t){return`ptz-preset-label-${e}-${t}`}savePresetLabel(e,t,n){try{localStorage.setItem(this.getPresetLabelKey(e,t),n)}catch(i){console.warn(`Failed to save preset label for cam ${e}, preset ${t}:`,i)}}loadPresetLabels(e){const t=document.getElementById(`cam${e}-quick-presets`);if(t)for(let n=0;n<15;n++)try{const i=localStorage.getItem(this.getPresetLabelKey(e,n));if(i!==null){const o=t.querySelector(`.quick-preset-label[data-preset-id="${n}"]`);o&&(o.value=i)}}catch(i){console.warn(`Failed to load preset label for cam ${e}, preset ${n}:`,i)}}async setPreset(e,t){const n=this.cameras.get(e);if(!(n!=null&&n.instance)||!n.connected){alert(`Camera ${e} is not connected.`);return}try{await n.instance.setPreset(t)?(console.log(`✅ Preset ${t+1} saved for camera ${e}.`),this.showTemporaryFeedback(e,`Preset ${t+1} Set!`)):(console.warn(`⚠️ Camera ${e} returned false when setting preset ${t+1}.`),alert(`Camera ${e} could not set preset ${t+1}. Check camera status.`))}catch(i){console.error(`Error setting preset for camera ${e}:`,i),alert(`Failed to set preset ${t+1} for camera ${e}.`)}}async recallPreset(e,t){const n=this.cameras.get(e);if(!(n!=null&&n.instance)||!n.connected){alert(`Camera ${e} is not connected.`);return}try{await n.instance.recallPreset(t)?(console.log(`✅ Recalling preset ${t+1} for camera ${e}.`),this.showTemporaryFeedback(e,`Recalling Preset ${t+1}...`)):(console.warn(`⚠️ Camera ${e} returned false when recalling preset ${t+1}.`),alert(`Preset ${t+1} may not exist or camera ${e} could not recall it.`))}catch(i){console.error(`Error recalling preset for camera ${e}:`,i),alert(`Failed to recall preset ${t+1} for camera ${e}.`)}}showTemporaryFeedback(e,t){var o;const n=(o=document.querySelector(`#cam${e}-video`))==null?void 0:o.parentElement;if(!n)return;const i=document.createElement("div");i.className="preset-feedback",i.textContent=t,n.appendChild(i),setTimeout(()=>{i.remove()},2e3)}async setAutoFocus(e){const t=this.cameras.get(e);if(!(!(t!=null&&t.instance)||!t.connected))try{await t.instance.setFocusMode("auto"),this.updateFocusButtons(e,"auto")}catch(n){console.error(`Error setting auto focus for camera ${e}:`,n)}}updateFocusButtons(e,t){const n=document.getElementById(`cam${e}-focus-auto`),i=document.getElementById(`cam${e}-focus-manual`);n&&i&&(n.classList.remove("active"),i.classList.remove("active"),t==="auto"?n.classList.add("active"):t==="manual"&&i.classList.add("active"))}setupCameraTabs(){document.querySelectorAll(".camera-tab").forEach(t=>{t.addEventListener("click",n=>{const o=n.target.getAttribute("data-camera");this.switchCameraTab(parseInt(o))})}),this.setupCopyCheckboxes()}setupCopyCheckboxes(){document.querySelectorAll(".copy-setting-checkbox[data-copy-group]").forEach(e=>{e.addEventListener("change",t=>{const n=t.target,i=n.getAttribute("data-copy-group");if(!n.closest(".camera-settings")||!i)return;const S=n.closest(".settings-group");if(!S)return;S.querySelectorAll(".copy-setting-checkbox[data-copy-setting]").forEach(y=>{y.checked=n.checked})})})}switchCameraTab(e){const t=document.querySelectorAll(".camera-tab"),n=document.querySelectorAll(".camera-settings");t.forEach(S=>S.classList.remove("active")),n.forEach(S=>S.classList.remove("active"));const i=document.querySelector(`[data-camera="${e}"].camera-tab`),o=document.getElementById(`cam${e}-settings`);i&&i.classList.add("active"),o&&o.classList.add("active")}setupImageSettings(e){const t=document.getElementById(`cam${e}-focus-auto`),n=document.getElementById(`cam${e}-focus-manual`);t&&t.addEventListener("click",async()=>{const _=this.cameras.get(e);if(!(!(_!=null&&_.instance)||!_.connected))try{await _.instance.setFocusMode("auto"),this.updateFocusButtons(e,"auto"),console.log(`Set camera ${e} focus mode to: auto`)}catch(a){console.error(`Error setting focus mode for camera ${e}:`,a)}}),n&&n.addEventListener("click",async()=>{const _=this.cameras.get(e);if(!(!(_!=null&&_.instance)||!_.connected))try{await _.instance.setFocusMode("manual"),this.updateFocusButtons(e,"manual"),console.log(`Set camera ${e} focus mode to: manual`)}catch(a){console.error(`Error setting focus mode for camera ${e}:`,a)}});const i=document.getElementById(`cam${e}-exposure`);i&&i.addEventListener("change",()=>{const _=i.value;this.setExposureMode(e,_),this.toggleExposureControls(e,_)});const o=document.getElementById(`cam${e}-wb-mode`);o&&o.addEventListener("change",()=>{const _=o.value;this.setWhiteBalanceMode(e,_),this.toggleWhiteBalanceControls(e,_)});const S=document.getElementById(`cam${e}-shutter`);S&&S.addEventListener("change",()=>{this.setImageParameter(e,"setShutter",S.value)});const E=document.getElementById(`cam${e}-iris`);E&&E.addEventListener("change",()=>{this.setImageParameter(e,"setIris",E.value)});const y=document.getElementById(`cam${e}-antiflicker`);y&&y.addEventListener("change",()=>{this.setImageParameter(e,"setAntiFlicker",y.value)});const x=document.getElementById(`cam${e}-wdr`);x&&x.addEventListener("change",()=>{const _=x.value,a=_==="Off"?"Off":parseInt(_);this.setImageParameter(e,"setWideDynamicRange",a)});const m=document.getElementById(`cam${e}-3d-nr`);m&&m.addEventListener("change",()=>{this.setImageParameter(e,"set3dNoiseReduction",m.value)}),[{id:`cam${e}-brightness`,method:"setBrightness"},{id:`cam${e}-exposure-brightness`,method:"setExposureBrightness"},{id:`cam${e}-gain`,method:"setExposureGain",transform:_=>`${_*2}dB`},{id:`cam${e}-red-gain`,method:"setRedGain"},{id:`cam${e}-blue-gain`,method:"setBlueGain"},{id:`cam${e}-color-temperature`,method:"setColorTemperature"},{id:`cam${e}-sharpness`,method:"setSharpness"},{id:`cam${e}-contrast`,method:"setContrast"},{id:`cam${e}-saturation`,method:"setSaturation"},{id:`cam${e}-gamma`,method:"setGamma"}].forEach(({id:_,method:a,transform:p,displayTransform:v})=>{const l=document.getElementById(_);l&&l.addEventListener("input",()=>{var r;const s=parseInt(l.value),d=p?p(s):s;this.queueSliderUpdate(`${e}-${a}`,e,a,d);const u=(r=l.parentElement)==null?void 0:r.querySelector(".slider-value");u&&(v?u.textContent=v(s):u.textContent=s.toString())})}),[{id:`cam${e}-mirror`,method:"setMirror"},{id:`cam${e}-flip`,method:"setFlip"},{id:`cam${e}-backlight`,method:"setBacklightCompensation"},{id:`cam${e}-2d-nr`,method:"set2dNoiseReduction"}].forEach(({id:_,method:a})=>{const p=document.getElementById(_);p&&p.addEventListener("change",()=>{this.setBooleanParameter(e,a,p.checked)})})}async setExposureMode(e,t){const n=this.cameras.get(e);if(!(!(n!=null&&n.instance)||!n.connected)){n.lastSettingChangeTime=Date.now();try{let i=t;switch(t){case"auto":i="auto";break;case"manual":i="manual";break;case"shutter":i="shutter priority";break;case"iris":i="iris priority";break;case"bright":i="brightness priority";break}await n.instance.setExposureMode(i),console.log(`Set camera ${e} exposure mode to: ${i}`)}catch(i){console.error(`Error setting exposure mode for camera ${e}:`,i)}}}async setWhiteBalanceMode(e,t){const n=this.cameras.get(e);if(!(!(n!=null&&n.instance)||!n.connected)){n.lastSettingChangeTime=Date.now();try{let i=t;switch(t){case"auto":i="auto";break;case"indoor":i="indoor";break;case"outdoor":i="outdoor";break;case"onepush":i="one push";break;case"autotracking":i="auto tracking";break;case"manual":i="manual";break;case"temperature":i="temperature";break}await n.instance.setWhiteBalanceMode(i),console.log(`Set camera ${e} white balance mode to: ${i}`)}catch(i){console.error(`Error setting white balance mode for camera ${e}:`,i)}}}toggleWhiteBalanceControls(e,t){const n=document.getElementById(`cam${e}-redgain-row`),i=document.getElementById(`cam${e}-bluegain-row`),o=document.getElementById(`cam${e}-colortemp-row`);n&&(n.style.display=t==="manual"?"flex":"none"),i&&(i.style.display=t==="manual"?"flex":"none"),o&&(o.style.display=t==="temperature"?"flex":"none")}async setImageParameter(e,t,n){const i=this.cameras.get(e);if(!(!(i!=null&&i.instance)||!i.connected)){i.lastSettingChangeTime=Date.now();try{typeof i.instance[t]=="function"?(await i.instance[t](n),console.log(`Set camera ${e} ${t} to: ${n}`)):console.warn(`Method ${t} not found on camera ${e} instance`)}catch(o){console.error(`Error setting ${t} for camera ${e}:`,o)}}}async setBooleanParameter(e,t,n){const i=this.cameras.get(e);if(!(!(i!=null&&i.instance)||!i.connected)){i.lastSettingChangeTime=Date.now();try{await i.instance[t](n)}catch(o){console.error(`Error setting ${t} for camera ${e}:`,o)}}}startSliderUpdateTimer(){this.sliderUpdateTimer===null&&(this.sliderUpdateTimer=window.setInterval(()=>{this.processPendingSliderUpdates()},100))}async processPendingSliderUpdates(){if(this.pendingSliderUpdates.size===0)return;const e=Array.from(this.pendingSliderUpdates.values());this.pendingSliderUpdates.clear(),await Promise.all(e.map(({cameraId:t,method:n,value:i})=>this.setImageParameter(t,n,i)))}queueSliderUpdate(e,t,n,i){this.pendingSliderUpdates.set(e,{cameraId:t,method:n,value:i}),this.startSliderUpdateTimer()}toggleExposureControls(e,t){const n=document.getElementById(`cam${e}-shutter-row`),i=document.getElementById(`cam${e}-gain-row`),o=document.getElementById(`cam${e}-iris-row`),S=document.getElementById(`cam${e}-exposure-brightness-row`),E=document.getElementById(`cam${e}-antiflicker-row`),y=document.getElementById(`cam${e}-brightness-row`);n&&(n.style.display=t==="manual"||t==="shutter"?"flex":"none"),i&&(i.style.display=t==="manual"?"flex":"none"),o&&(o.style.display=t==="manual"||t==="iris"?"flex":"none"),S&&(S.style.display=t==="bright"?"flex":"none"),E&&(E.style.display=t==="auto"||t==="iris"?"flex":"none"),y&&(y.style.display=t==="auto"||t==="iris"||t==="shutter"?"flex":"none")}updateSliderValues(){document.querySelectorAll(".setting-slider").forEach(e=>{var i;const t=e,n=(i=t.parentElement)==null?void 0:i.querySelector(".slider-value");n&&(n.textContent=t.value,t.addEventListener("input",()=>{n.textContent=t.value}))})}async toggleConnection(e){const t=this.cameras.get(e);if(!t)return;const n=document.getElementById(`cam${e}-connect`),i=document.getElementById(`cam${e}-ip`),o=document.getElementById(`cam${e}-status`);if(t.connected){this.stopVideoStream(e),this.stopSettingsPolling(e),t.connected=!1,t.instance=void 0,n.textContent="Connect",n.className="connect-btn",o==null||o.classList.remove("connected"),this.stopAllMovement(e),this.saveConfiguration(),console.log(`📴 Camera ${e} disconnected`);return}if(t.connecting)return;const S=i.value.trim();if(!S){alert("Please enter camera IP address");return}t.connecting=!0,n.textContent="Connecting...",n.className="connect-btn connecting",o==null||o.classList.add("connecting");const E=[{username:"admin",password:"234Tgb999!"}];let y=null;for(let x=0;x<Math.min(3,E.length);x++){const m=E[x];try{console.log(`Attempt ${x+1}/3: Connecting to camera ${e} at ${S} with ${m.username}/${m.password.length>0?"***":"(blank)"}`);const h=new qe.EveretPTZ(S,m.username,m.password);h.onError(_=>{console.error(`Camera ${e} error during attempt ${x+1}:`,_)}),console.log(`Waiting for camera ${e} to be ready (attempt ${x+1})...`);const c=new Promise((_,a)=>{setTimeout(()=>a(new Error("Connection timeout after 10 seconds")),1e4)});await Promise.race([h.whenReady(),c]),t.instance=h,t.connected=!0,t.connecting=!1,t.ip=S,t.username=m.username,t.password=m.password,n.textContent="Disconnect",n.className="connect-btn connected",o==null||o.classList.remove("connecting"),o==null||o.classList.add("connected"),console.log(`✅ Camera ${e} connected successfully with credentials: ${m.username}/${m.password}`),this.saveConfiguration(),await this.initializeCameraSettings(e),this.startSettingsPolling(e),console.log(`🎬 Auto-starting video stream for camera ${e}...`),setTimeout(()=>{this.startVideoStream(e)},1e3);return}catch(h){if(y=h,console.log(`❌ Attempt ${x+1} failed for camera ${e}:`,h),x<2){console.log("Trying next credential set...");continue}}}this.handleConnectionError(e,(y==null?void 0:y.message)||"All connection attempts failed")}handleConnectionError(e,t){const n=this.cameras.get(e);if(!n)return;n.connecting=!1,n.connected=!1,n.instance=void 0;const i=document.getElementById(`cam${e}-connect`),o=document.getElementById(`cam${e}-status`);i.textContent="Connect",i.className="connect-btn",o==null||o.classList.remove("connecting","connected"),console.error(`Camera ${e} connection failed:`,t);let S=t;t.includes("503")?S=`Camera responded but service unavailable. Try accessing http://${n.ip} in your browser to verify camera is working.`:t.includes("401")||t.includes("403")?S=`Authentication failed. Check camera web interface at http://${n.ip} for correct credentials.`:t.includes("timeout")||t.includes("network")?S=`Connection timeout. Check IP address (${n.ip}) and network connection.`:t.includes("All connection attempts failed")?S=`Authentication failed with admin/admin, admin/(blank), and custom credentials.
|
||
|
||
Please:
|
||
1. Check camera web interface at http://${n.ip}
|
||
2. Find correct username/password
|
||
3. Ensure camera supports PTZ API access`:S=`Connection failed: ${t}
|
||
|
||
Try accessing http://${n.ip} to verify camera is reachable.`,alert(`Camera ${e} connection failed: ${S}`)}async initializeCameraSettings(e){const t=this.cameras.get(e);if(t!=null&&t.instance)try{console.log(`📋 Reading current settings from camera ${e}...`),await this.syncCameraSettingsWithUI(e)}catch(n){console.error(`Error reading camera ${e} settings:`,n);try{await t.instance.setExposureMode("auto"),await t.instance.setFocusMode("auto"),await t.instance.setWhiteBalanceMode("auto"),await t.instance.setAntiFlicker("60Hz"),this.updateFocusButtons(e,"auto")}catch(i){console.error(`Error setting fallback settings for camera ${e}:`,i)}}}async syncCameraSettingsWithUI(e){const t=this.cameras.get(e);if(!(t!=null&&t.instance))return;const n=document.getElementById(`cam${e}-settings`);if(n)try{const[i,o,S,E,y,x,m,h,c,_,a,p,v,l,s,d,u,r,g,b,L,A]=await Promise.all([t.instance.getBrightness().catch(()=>8),t.instance.getContrast().catch(()=>8),t.instance.getSaturation().catch(()=>8),t.instance.getSharpness().catch(()=>8),t.instance.getExposureMode().catch(()=>"auto"),t.instance.getExposureBrightness().catch(()=>14),t.instance.getFocusMode().catch(()=>"auto"),t.instance.getWhiteBalanceMode().catch(()=>"auto"),t.instance.getAntiFlicker().catch(()=>"60Hz"),t.instance.getGamma().catch(()=>2),t.instance.getRedGain().catch(()=>128),t.instance.getBlueGain().catch(()=>128),t.instance.getColorTemperature().catch(()=>5600),t.instance.getWideDynamicRange().catch(()=>"Off"),t.instance.getMirror().catch(()=>!1),t.instance.getFlip().catch(()=>!1),t.instance.getBacklightCompensation().catch(()=>!1),t.instance.get2dNoiseReduction().catch(()=>!1),t.instance.get3dNoiseReduction().catch(()=>"Off"),t.instance.getExposureGain().catch(()=>"0dB"),t.instance.getShutter().catch(()=>"1/50"),t.instance.getIris().catch(()=>"F2.8")]);console.log(`📊 Camera ${e} current settings:`,{brightness:i,contrast:o,saturation:S,sharpness:E,exposureBrightness:x,exposureMode:y,focusMode:m,whiteBalanceMode:h,antiFlicker:c,gamma:_,redGain:a,blueGain:p,colorTemperature:v,wdr:l,mirror:s,flip:d,backlight:u,nr2d:r,nr3d:g,gain:b,shutter:L,iris:A});const R=this.mapApiToUIExposureMode(y),O=this.mapApiToUIWhiteBalanceMode(h),w=b?parseInt(b.replace("dB",""))/2:0;let C=parseInt((_==null?void 0:_.toString())||"2");(isNaN(C)||C<0||C>4)&&(console.warn(`Invalid gamma value "${_}", defaulting to 2`),C=2),this.updateSettingInput(n,"brightness",i),this.updateSettingInput(n,"exposureBrightness",x),this.updateSettingInput(n,"contrast",o),this.updateSettingInput(n,"saturation",S),this.updateSettingInput(n,"sharpness",E),this.updateSettingInput(n,"gamma",C),this.updateSettingInput(n,"gain",w),this.updateSettingInput(n,"redGain",a),this.updateSettingInput(n,"blueGain",p),this.updateSettingInput(n,"colorTemperature",v),this.updateSettingSelect(n,"exposureMode",R),this.updateSettingSelect(n,"whiteBalanceMode",O),this.updateSettingSelect(n,"antiFlicker",c);const T=l==="Off"||l==="off"?"Off":l.toString();this.updateSettingSelect(n,"wdr",T),this.updateSettingSelect(n,"3dNoiseReduction",g.toString()),this.updateSettingSelect(n,"shutterSpeed",L),this.updateSettingSelect(n,"iris",A),this.updateCheckbox(e,"mirror",s),this.updateCheckbox(e,"flip",d),this.updateCheckbox(e,"backlight",u),this.updateCheckbox(e,"2d-nr",r),this.updateFocusButtons(e,m),this.toggleExposureControls(e,R),this.toggleWhiteBalanceControls(e,O)}catch(i){console.error(`Error syncing camera ${e} settings with UI:`,i)}}updateCheckbox(e,t,n){const i=document.getElementById(`cam${e}-${t}`);i&&i.type==="checkbox"&&(i.checked=n)}updateSettingInput(e,t,n){const i=e.querySelector(`[data-setting="${t}"]`);if(i){i.value=n.toString();const o=e.querySelector(`[data-value="${t}"]`);o&&(t==="gain"?o.textContent=`${parseInt(n.toString())*2}dB`:t==="colorTemperature"?o.textContent=`${n}`:o.textContent=n.toString())}}updateSettingSelect(e,t,n){const i=e.querySelector(`[data-setting="${t}"]`);i&&(i.value=n)}mapApiToUIExposureMode(e){switch(e==null?void 0:e.toLowerCase()){case"auto":return"auto";case"manual":return"manual";case"shutter priority":return"shutter";case"iris priority":return"iris";case"brightness priority":return"bright";default:return console.warn(`Unknown exposure mode from API: ${e}, defaulting to auto`),"auto"}}mapApiToUIWhiteBalanceMode(e){switch(e==null?void 0:e.toLowerCase()){case"auto":return"auto";case"indoor":return"indoor";case"outdoor":return"outdoor";case"onepush":case"one push":return"onepush";case"autotracking":case"auto tracking":return"autotracking";case"manual":return"manual";case"temperature":case"colortemperature":return"temperature";default:return console.warn(`Unknown white balance mode from API: ${e}, defaulting to auto`),"auto"}}startSettingsPolling(e){const t=this.cameras.get(e);if(!t)return;this.stopSettingsPolling(e);const n=window.setInterval(async()=>{const i=this.cameras.get(e);if(!(i!=null&&i.connected)||!(i!=null&&i.instance)){this.stopSettingsPolling(e);return}const o=Date.now()-(i.lastSettingChangeTime||0);if(o<1e3){console.log(`⏸️ Skipping poll for camera ${e} - recent setting change (${o}ms ago)`);return}try{await this.syncCameraSettingsWithUI(e)}catch(S){console.warn(`Error polling settings for camera ${e}:`,S)}},2e3);t.pollInterval=n,console.log(`🔄 Started settings polling for camera ${e}`)}stopSettingsPolling(e){const t=this.cameras.get(e);t!=null&&t.pollInterval&&(clearInterval(t.pollInterval),t.pollInterval=void 0,console.log(`⏹️ Stopped settings polling for camera ${e}`))}generateCameraUI(){const e=document.getElementById("ptz-controllers");if(e){e.innerHTML="";for(let t=1;t<=this.numberOfCameras;t++){const n=this.createPTZController(t);e.appendChild(n)}}}generateSettingsUI(){const e=document.getElementById("status-indicators"),t=document.getElementById("camera-tabs"),n=document.getElementById("settings-content"),i=document.getElementById("camera-selector");if(!(!e||!t||!n)){if(e.innerHTML="",t.innerHTML="",n.innerHTML="",i){i.innerHTML="";for(let o=1;o<=this.numberOfCameras;o++){const S=document.createElement("label");S.className="camera-checkbox-label",S.innerHTML=`
|
||
<input type="checkbox" class="camera-copy-checkbox" data-target-camera="${o}" checked>
|
||
<span>Cam ${o}</span>
|
||
`,i.appendChild(S)}}for(let o=1;o<=this.numberOfCameras;o++){const S=document.createElement("div");S.className="status-item",S.innerHTML=`
|
||
<span class="status-label">CAM ${o}</span>
|
||
<div class="status-light" id="cam${o}-status"></div>
|
||
`,e.appendChild(S);const E=document.createElement("button");E.className=o===1?"camera-tab active":"camera-tab",E.setAttribute("data-camera",o.toString()),E.textContent=`Camera ${o}`,t.appendChild(E);const y=this.createSettingsPanel(o);n.appendChild(y)}this.setupCameraTabs();for(let o=1;o<=this.numberOfCameras;o++)this.setupImageSettings(o)}}createPTZController(e){const t=document.createElement("div");t.className="ptz-controller",t.setAttribute("data-camera",e.toString());const n=e===1?"10.99.0.118":"";return t.innerHTML=`
|
||
<div class="ptz-header">
|
||
<h3>Camera ${e}</h3>
|
||
<div class="connection-controls">
|
||
<input type="text" value="${n}" id="cam${e}-ip" class="ip-input" placeholder="Camera IP Address" title="Enter camera IP address (e.g., 192.168.1.100)">
|
||
<button class="connect-btn" id="cam${e}-connect">Connect</button>
|
||
</div>
|
||
</div>
|
||
<div class="video-preview">
|
||
<video id="cam${e}-video" class="preview-video" muted playsinline autoplay>
|
||
Your browser does not support the video tag.
|
||
</video>
|
||
</div>
|
||
<div class="ptz-joystick" id="cam${e}-ptz"></div>
|
||
<div class="ptz-controls-fixed">
|
||
<div class="home-button-container">
|
||
<button class="home-btn" id="cam${e}-home" title="Return camera to home position">🏠</button>
|
||
</div>
|
||
<div class="pan-tilt-section">
|
||
<label>Pan/Tilt Speed</label>
|
||
<input type="range" min="1" max="24" value="12" class="pan-tilt-speed-slider" id="cam${e}-pan-tilt-speed">
|
||
<span class="pan-tilt-speed-value">12</span>
|
||
</div>
|
||
<div class="pan-tilt-section">
|
||
<label>Damping (Smoothness)</label>
|
||
<input type="range" min="5" max="50" value="20" class="pan-tilt-speed-slider" id="cam${e}-damping">
|
||
<span class="pan-tilt-speed-value">20</span>
|
||
</div>
|
||
<div class="pan-tilt-section">
|
||
<label>Speedup (Acceleration)</label>
|
||
<input type="range" min="50" max="1000" value="100" class="pan-tilt-speed-slider" id="cam${e}-speedup">
|
||
<span class="pan-tilt-speed-value">100</span>
|
||
</div>
|
||
<div class="zoom-section">
|
||
<label>Zoom</label>
|
||
<div class="dynamic-slider-container">
|
||
<span class="dynamic-label">OUT</span>
|
||
<input type="range" min="0" max="100" value="50" class="dynamic-slider" id="cam${e}-zoom-dynamic">
|
||
<span class="dynamic-label">IN</span>
|
||
</div>
|
||
<div class="sensitivity-control">
|
||
<label>Sensitivity</label>
|
||
<input type="range" min="1" max="9" value="5" class="sensitivity-slider" id="cam${e}-zoom-sensitivity">
|
||
<span class="sensitivity-value">5</span>
|
||
</div>
|
||
</div>
|
||
<div class="focus-section">
|
||
<label>Focus</label>
|
||
<div class="dynamic-slider-container">
|
||
<span class="dynamic-label">NEAR</span>
|
||
<input type="range" min="0" max="100" value="50" class="dynamic-slider" id="cam${e}-focus-dynamic">
|
||
<span class="dynamic-label">FAR</span>
|
||
</div>
|
||
<div class="sensitivity-control">
|
||
<label>Sensitivity</label>
|
||
<input type="range" min="1" max="9" value="5" class="sensitivity-slider" id="cam${e}-focus-sensitivity">
|
||
<span class="sensitivity-value">5</span>
|
||
</div>
|
||
</div>
|
||
<div class="preset-section">
|
||
<label>Presets (1-40)</label>
|
||
<select class="preset-select" id="cam${e}-preset">
|
||
${Array.from({length:40},(i,o)=>`<option value="${o}">${o+1}</option>`).join("")}
|
||
</select>
|
||
<div class="preset-buttons">
|
||
<button class="preset-btn" data-action="set-preset" data-camera="${e}">SET</button>
|
||
<button class="preset-btn" data-action="recall-preset" data-camera="${e}">RECALL</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="ptz-controls">
|
||
<div class="quick-presets-section">
|
||
<label>Quick Presets</label>
|
||
<div class="quick-presets-grid" id="cam${e}-quick-presets">
|
||
${Array.from({length:15},(i,o)=>`
|
||
<div class="quick-preset-item" data-preset-id="${o}">
|
||
<button class="quick-recall-btn" data-action="quick-recall" data-preset-id="${o}">P${o+1}</button>
|
||
<input type="text" class="quick-preset-label" placeholder="Preset ${o+1}" data-preset-id="${o}">
|
||
<button class="quick-set-btn" data-action="quick-set" data-preset-id="${o}">Set</button>
|
||
</div>
|
||
`).join("")}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`,t}createSettingsPanel(e){const t=document.createElement("div");return t.className=e===1?"camera-settings active":"camera-settings",t.id=`cam${e}-settings`,t.innerHTML=`
|
||
<div class="settings-grid">
|
||
<!-- Focus -->
|
||
<div class="settings-group">
|
||
<h4>Focus
|
||
<label class="copy-checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-group="focus">
|
||
<span>Copy</span>
|
||
</label>
|
||
</h4>
|
||
<div class="setting-with-checkbox">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="focusMode">
|
||
<label>Focus Mode</label>
|
||
</div>
|
||
<div class="focus-controls">
|
||
<button class="focus-btn" id="cam${e}-focus-auto">Auto</button>
|
||
<button class="focus-btn" id="cam${e}-focus-manual">Manual</button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Exposure -->
|
||
<div class="settings-group">
|
||
<h4>Exposure
|
||
<label class="copy-checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-group="exposure">
|
||
<span>Copy</span>
|
||
</label>
|
||
</h4>
|
||
<div class="setting-with-checkbox">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="exposureMode">
|
||
<label>Exposure Mode</label>
|
||
</div>
|
||
<select class="setting-select" id="cam${e}-exposure" data-setting="exposureMode">
|
||
<option value="auto">Auto</option>
|
||
<option value="manual">Manual</option>
|
||
<option value="shutter">Shutter Priority</option>
|
||
<option value="iris">Iris Priority</option>
|
||
<option value="bright">Brightness Priority</option>
|
||
</select>
|
||
|
||
<!-- Shutter Speed (manual/shutter priority) -->
|
||
<div class="setting-row" id="cam${e}-shutter-row" style="display: none;">
|
||
<div class="setting-with-checkbox">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="shutterSpeed">
|
||
<label>Shutter Speed</label>
|
||
</div>
|
||
<select class="setting-select" id="cam${e}-shutter" data-setting="shutterSpeed">
|
||
<option value="1/25">1/25</option>
|
||
<option value="1/50" selected>1/50</option>
|
||
<option value="1/75">1/75</option>
|
||
<option value="1/100">1/100</option>
|
||
<option value="1/120">1/120</option>
|
||
<option value="1/150">1/150</option>
|
||
<option value="1/215">1/215</option>
|
||
<option value="1/300">1/300</option>
|
||
<option value="1/425">1/425</option>
|
||
<option value="1/600">1/600</option>
|
||
<option value="1/1000">1/1000</option>
|
||
<option value="1/1250">1/1250</option>
|
||
<option value="1/1750">1/1750</option>
|
||
<option value="1/2500">1/2500</option>
|
||
<option value="1/3500">1/3500</option>
|
||
<option value="1/6000">1/6000</option>
|
||
<option value="1/10000">1/10000</option>
|
||
</select>
|
||
</div>
|
||
|
||
<!-- Gain (manual only) -->
|
||
<div class="slider-row" id="cam${e}-gain-row" style="display: none;">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="gain">
|
||
<label>Gain</label>
|
||
<input type="range" min="0" max="15" value="0" class="setting-slider" id="cam${e}-gain" data-setting="gain">
|
||
<span class="slider-value" data-value="gain">0dB</span>
|
||
</div>
|
||
|
||
<!-- Iris (manual/iris priority) -->
|
||
<div class="setting-row" id="cam${e}-iris-row" style="display: none;">
|
||
<div class="setting-with-checkbox">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="iris">
|
||
<label>Iris</label>
|
||
</div>
|
||
<select class="setting-select" id="cam${e}-iris" data-setting="iris">
|
||
<option value="Close">Close</option>
|
||
<option value="F14.0">F14.0</option>
|
||
<option value="F11.0">F11.0</option>
|
||
<option value="F9.6">F9.6</option>
|
||
<option value="F8.0">F8.0</option>
|
||
<option value="F6.8">F6.8</option>
|
||
<option value="F5.6">F5.6</option>
|
||
<option value="F4.8">F4.8</option>
|
||
<option value="F4.0">F4.0</option>
|
||
<option value="F3.4">F3.4</option>
|
||
<option value="F2.8" selected>F2.8</option>
|
||
<option value="F2.4">F2.4</option>
|
||
<option value="F2.0">F2.0</option>
|
||
<option value="F1.8">F1.8</option>
|
||
</select>
|
||
</div>
|
||
|
||
<!-- Exposure Brightness (brightness priority only) -->
|
||
<div class="slider-row" id="cam${e}-exposure-brightness-row" style="display: none;">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="exposureBrightness">
|
||
<label>Exposure Brightness</label>
|
||
<input type="range" min="0" max="27" value="14" class="setting-slider" id="cam${e}-exposure-brightness" data-setting="exposureBrightness">
|
||
<span class="slider-value" data-value="exposureBrightness">14</span>
|
||
</div>
|
||
|
||
<!-- Anti-Flicker (auto/iris priority) -->
|
||
<div class="setting-row" id="cam${e}-antiflicker-row">
|
||
<div class="setting-with-checkbox">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="antiFlicker">
|
||
<label>Anti-Flicker</label>
|
||
</div>
|
||
<select class="setting-select" id="cam${e}-antiflicker" data-setting="antiFlicker">
|
||
<option value="Off">Off</option>
|
||
<option value="50Hz">50Hz</option>
|
||
<option value="60Hz" selected>60Hz</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- White Balance -->
|
||
<div class="settings-group">
|
||
<h4>White Balance
|
||
<label class="copy-checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-group="whitebalance">
|
||
<span>Copy</span>
|
||
</label>
|
||
</h4>
|
||
<div class="setting-with-checkbox">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="whiteBalanceMode">
|
||
<label>WB Mode</label>
|
||
</div>
|
||
<select class="setting-select" id="cam${e}-wb-mode" data-setting="whiteBalanceMode">
|
||
<option value="auto">Auto</option>
|
||
<option value="indoor">Indoor</option>
|
||
<option value="outdoor">Outdoor</option>
|
||
<option value="onepush">One Push</option>
|
||
<option value="autotracking">Auto Tracking</option>
|
||
<option value="manual">Manual</option>
|
||
<option value="temperature">Temperature</option>
|
||
</select>
|
||
|
||
<!-- Red/Blue Gain (manual only) -->
|
||
<div class="slider-row" id="cam${e}-redgain-row" style="display: none;">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="redGain">
|
||
<label>Red Gain</label>
|
||
<input type="range" min="0" max="255" value="128" class="setting-slider" id="cam${e}-red-gain" data-setting="redGain">
|
||
<span class="slider-value" data-value="redGain">128</span>
|
||
</div>
|
||
<div class="slider-row" id="cam${e}-bluegain-row" style="display: none;">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="blueGain">
|
||
<label>Blue Gain</label>
|
||
<input type="range" min="0" max="255" value="128" class="setting-slider" id="cam${e}-blue-gain" data-setting="blueGain">
|
||
<span class="slider-value" data-value="blueGain">128</span>
|
||
</div>
|
||
|
||
<!-- Color Temperature (temperature mode only) -->
|
||
<div class="slider-row" id="cam${e}-colortemp-row" style="display: none;">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="colorTemperature">
|
||
<label>Color Temperature</label>
|
||
<input type="range" min="1800" max="10000" value="5600" class="setting-slider" id="cam${e}-color-temperature" data-setting="colorTemperature">
|
||
<span class="slider-value" data-value="colorTemperature">5600</span>K
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Image -->
|
||
<div class="settings-group">
|
||
<h4>Image
|
||
<label class="copy-checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-group="image">
|
||
<span>Copy</span>
|
||
</label>
|
||
</h4>
|
||
<div class="checkbox-row">
|
||
<label class="checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="mirror">
|
||
<input type="checkbox" id="cam${e}-mirror"> Mirror
|
||
</label>
|
||
</div>
|
||
<div class="checkbox-row">
|
||
<label class="checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="flip">
|
||
<input type="checkbox" id="cam${e}-flip"> Flip
|
||
</label>
|
||
</div>
|
||
<div class="checkbox-row">
|
||
<label class="checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="backlight">
|
||
<input type="checkbox" id="cam${e}-backlight"> Backlight Compensation
|
||
</label>
|
||
</div>
|
||
<div class="slider-row">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="gamma">
|
||
<label>Gamma</label>
|
||
<input type="range" min="0" max="4" value="2" class="setting-slider" id="cam${e}-gamma" data-setting="gamma">
|
||
<span class="slider-value" data-value="gamma">2</span>
|
||
</div>
|
||
<div class="setting-with-checkbox">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="wdr">
|
||
<label>WDR (Wide Dynamic Range)</label>
|
||
</div>
|
||
<select class="setting-select" id="cam${e}-wdr" data-setting="wdr">
|
||
<option value="Off">Off</option>
|
||
<option value="1">1</option>
|
||
<option value="2">2</option>
|
||
<option value="3">3</option>
|
||
<option value="4">4</option>
|
||
<option value="5">5</option>
|
||
<option value="6">6</option>
|
||
</select>
|
||
</div>
|
||
|
||
<!-- Image Quality -->
|
||
<div class="settings-group">
|
||
<h4>Image Quality
|
||
<label class="copy-checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-group="imagequality">
|
||
<span>Copy</span>
|
||
</label>
|
||
</h4>
|
||
<!-- Brightness (auto/iris/shutter priority only) -->
|
||
<div class="slider-row" id="cam${e}-brightness-row">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="brightness">
|
||
<label>Brightness</label>
|
||
<input type="range" min="0" max="15" value="8" class="setting-slider" id="cam${e}-brightness" data-setting="brightness">
|
||
<span class="slider-value" data-value="brightness">8</span>
|
||
</div>
|
||
<div class="slider-row">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="sharpness">
|
||
<label>Sharpness</label>
|
||
<input type="range" min="0" max="15" value="8" class="setting-slider" id="cam${e}-sharpness" data-setting="sharpness">
|
||
<span class="slider-value" data-value="sharpness">8</span>
|
||
</div>
|
||
<div class="slider-row">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="contrast">
|
||
<label>Contrast</label>
|
||
<input type="range" min="0" max="15" value="8" class="setting-slider" id="cam${e}-contrast" data-setting="contrast">
|
||
<span class="slider-value" data-value="contrast">8</span>
|
||
</div>
|
||
<div class="slider-row">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="saturation">
|
||
<label>Saturation</label>
|
||
<input type="range" min="0" max="15" value="8" class="setting-slider" id="cam${e}-saturation" data-setting="saturation">
|
||
<span class="slider-value" data-value="saturation">8</span>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Noise Reduction -->
|
||
<div class="settings-group">
|
||
<h4>Noise Reduction
|
||
<label class="copy-checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-group="noisereduction">
|
||
<span>Copy</span>
|
||
</label>
|
||
</h4>
|
||
<div class="checkbox-row">
|
||
<label class="checkbox-label">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="2dNoiseReduction">
|
||
<input type="checkbox" id="cam${e}-2d-nr"> 2D Noise Reduction
|
||
</label>
|
||
</div>
|
||
<div class="setting-with-checkbox">
|
||
<input type="checkbox" class="copy-setting-checkbox" data-copy-setting="3dNoiseReduction">
|
||
<label>3D Noise Reduction</label>
|
||
</div>
|
||
<select class="setting-select" id="cam${e}-3d-nr" data-setting="3dNoiseReduction">
|
||
<option value="Off">Off</option>
|
||
<option value="Auto">Auto</option>
|
||
<option value="1">1</option>
|
||
<option value="2">2</option>
|
||
<option value="3">3</option>
|
||
<option value="4">4</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
`,t}setupGlobalControls(){const e=document.getElementById("apply-config");e&&e.addEventListener("click",()=>{const S=document.getElementById("camera-count");if(!S)return;const E=parseInt(S.value);if(E<1||E>12){alert("Please enter a valid number of cameras (1-12)");return}this.numberOfCameras=E,this.showMainInterface(),this.cameras.clear(),this.activeMovements.clear(),this.lastSpeeds.clear(),this.initializeCameras(),this.generateCameraUI(),this.generateSettingsUI(),this.setupEventListeners(),this.updateSliderValues(),this.saveConfiguration()});const t=document.getElementById("reset-config");t&&t.addEventListener("click",()=>{confirm("Are you sure you want to reset all settings? This will clear saved camera IPs and configuration.")&&this.resetConfiguration()});const n=document.getElementById("global-enable");n&&n.addEventListener("click",async()=>{if(n.classList.contains("enabled")){for(let E=1;E<=this.numberOfCameras;E++){const y=this.cameras.get(E);y!=null&&y.connected&&this.toggleConnection(E)}n.textContent="🔴 ALL OFF",n.classList.remove("enabled")}else{for(let E=1;E<=this.numberOfCameras;E++){const y=this.cameras.get(E);!(y!=null&&y.connected)&&!(y!=null&&y.connecting)&&this.toggleConnection(E)}n.textContent="🟢 ALL ON",n.classList.add("enabled")}});const i=document.getElementById("set-all-settings");i&&i.addEventListener("click",()=>{this.setToAllCameras()});const o=document.getElementById("restore-connections");o&&(o.addEventListener("click",()=>{this.manualRestoreConnections()}),this.checkForSavedConnections())}checkForSavedConnections(){try{const e=localStorage.getItem("ptz-camera-config");if(e){const t=JSON.parse(e),n=t.connectedCameras&&Object.keys(t.connectedCameras).length>0,i=document.getElementById("restore-connections");i&&n&&(i.style.display="inline-block")}}catch(e){console.warn("Failed to check for saved connections:",e)}}async manualRestoreConnections(){try{const e=localStorage.getItem("ptz-camera-config");if(!e){alert("No saved connections found.");return}const t=JSON.parse(e);if(!t.connectedCameras||Object.keys(t.connectedCameras).length===0){alert("No saved connections found.");return}confirm("Restore all previously connected cameras? This will attempt to reconnect all cameras from your last session.")&&await this.restoreConnectedCameras(t)}catch(e){console.error("Failed to restore connections:",e),alert("Failed to restore connections. Please check the console for details.")}}async setToAllCameras(){const e=document.querySelector(".camera-tab.active");if(!e)return;const t=parseInt(e.dataset.camera||"1"),n=this.cameras.get(t);if(!(n!=null&&n.connected)){alert("Source camera must be connected to copy settings");return}const i=document.querySelectorAll(".camera-copy-checkbox:checked");if(i.length===0){alert("Please select at least one camera to copy settings to");return}try{const o=await this.getCurrentCameraSettings(t);let S=0;i.forEach(async y=>{const x=parseInt(y.dataset.targetCamera||"0");if(x===t)return;const m=this.cameras.get(x);m!=null&&m.connected&&(await this.applyCameraSettings(x,o),S++)});const E=document.createElement("div");E.textContent=`Settings copied from Camera ${t} to ${S} selected camera(s)`,E.style.cssText=`
|
||
position: fixed; top: 60px; right: 20px; z-index: 1000;
|
||
background: var(--accent-green); color: white; padding: 0.5rem 1rem;
|
||
border-radius: 4px; font-size: 0.8rem; opacity: 0.9;
|
||
`,document.body.appendChild(E),setTimeout(()=>{document.body.removeChild(E)},3e3)}catch(o){console.error("Error copying settings to selected cameras:",o),alert("Failed to copy settings to selected cameras")}}async getCurrentCameraSettings(e){const t=document.getElementById(`cam${e}-settings`);if(!t)return{};const n={};return t.querySelectorAll(".copy-setting-checkbox[data-copy-setting]").forEach(o=>{if(o.checked){const S=o.getAttribute("data-copy-setting");if(!S)return;const E=t.querySelector(`[data-setting="${S}"]`);if(E)n[S]=E.value;else{const y=document.getElementById(`cam${e}-${S}`);y&&y.type==="checkbox"&&(n[S]=y.checked)}}}),console.log(`📋 Settings to copy from camera ${e}:`,n),n}async applyCameraSettings(e,t){const n=this.cameras.get(e);if(n!=null&&n.instance){console.log(`🔄 Applying settings to camera ${e}:`,t);try{if(t.exposureMode!==void 0&&(await n.instance.setExposureMode(t.exposureMode),console.log(` ✓ Exposure Mode: ${t.exposureMode}`)),t.shutterSpeed!==void 0&&(await n.instance.setShutter(t.shutterSpeed),console.log(` ✓ Shutter Speed: ${t.shutterSpeed}`)),t.gain!==void 0){const i=`${parseInt(t.gain)*2}dB`;await n.instance.setExposureGain(i),console.log(` ✓ Gain: ${i}`)}if(t.iris!==void 0&&(await n.instance.setIris(t.iris),console.log(` ✓ Iris: ${t.iris}`)),t.exposureBrightness!==void 0&&(await n.instance.setExposureBrightness(Math.max(0,Math.min(27,parseInt(t.exposureBrightness)))),console.log(` ✓ Exposure Brightness: ${t.exposureBrightness}`)),t.antiFlicker!==void 0&&(await n.instance.setAntiFlicker(t.antiFlicker),console.log(` ✓ Anti-Flicker: ${t.antiFlicker}`)),t.focusMode!==void 0&&(await n.instance.setFocusMode(t.focusMode),this.updateFocusButtons(e,t.focusMode),console.log(` ✓ Focus Mode: ${t.focusMode}`)),t.whiteBalanceMode!==void 0&&(await n.instance.setWhiteBalanceMode(t.whiteBalanceMode),console.log(` ✓ White Balance Mode: ${t.whiteBalanceMode}`)),t.redGain!==void 0&&(await n.instance.setRedGain(Math.max(0,Math.min(255,parseInt(t.redGain)))),console.log(` ✓ Red Gain: ${t.redGain}`)),t.blueGain!==void 0&&(await n.instance.setBlueGain(Math.max(0,Math.min(255,parseInt(t.blueGain)))),console.log(` ✓ Blue Gain: ${t.blueGain}`)),t.colorTemperature!==void 0&&(await n.instance.setColorTemperature(Math.max(1800,Math.min(1e4,parseInt(t.colorTemperature)))),console.log(` ✓ Color Temperature: ${t.colorTemperature}`)),t.mirror!==void 0&&(await n.instance.setMirror(t.mirror),console.log(` ✓ Mirror: ${t.mirror}`)),t.flip!==void 0&&(await n.instance.setFlip(t.flip),console.log(` ✓ Flip: ${t.flip}`)),t.backlight!==void 0&&(await n.instance.setBacklightCompensation(t.backlight),console.log(` ✓ Backlight: ${t.backlight}`)),t.gamma!==void 0){const i=Math.max(0,Math.min(4,parseInt(t.gamma)));await n.instance.setGamma(i),console.log(` ✓ Gamma: ${i}`)}if(t.wdr!==void 0){const i=t.wdr==="Off"?"Off":parseInt(t.wdr);await n.instance.setWideDynamicRange(i),console.log(` ✓ WDR: ${i}`)}t.brightness!==void 0&&(await n.instance.setBrightness(Math.max(0,Math.min(15,parseInt(t.brightness)))),console.log(` ✓ Brightness: ${t.brightness}`)),t.sharpness!==void 0&&(await n.instance.setSharpness(Math.max(0,Math.min(15,parseInt(t.sharpness)))),console.log(` ✓ Sharpness: ${t.sharpness}`)),t.contrast!==void 0&&(await n.instance.setContrast(Math.max(0,Math.min(15,parseInt(t.contrast)))),console.log(` ✓ Contrast: ${t.contrast}`)),t.saturation!==void 0&&(await n.instance.setSaturation(Math.max(0,Math.min(15,parseInt(t.saturation)))),console.log(` ✓ Saturation: ${t.saturation}`)),t["2dNoiseReduction"]!==void 0&&(await n.instance.set2dNoiseReduction(t["2dNoiseReduction"]),console.log(` ✓ 2D Noise Reduction: ${t["2dNoiseReduction"]}`)),t["3dNoiseReduction"]!==void 0&&(await n.instance.set3dNoiseReduction(t["3dNoiseReduction"]),console.log(` ✓ 3D Noise Reduction: ${t["3dNoiseReduction"]}`)),this.updateCameraUI(e,t),console.log(`✅ Successfully applied all settings to camera ${e}`)}catch(i){console.error(`❌ Error applying settings to camera ${e}:`,i)}}}updateCameraUI(e,t){const n=document.getElementById(`cam${e}-settings`);n&&Object.keys(t).forEach(i=>{const o=n.querySelector(`[data-setting="${i}"]`);if(o&&t[i]!==void 0){o.value=t[i];const S=n.querySelector(`[data-value="${i}"]`);if(S)if(i==="gamma"){const E=["0.45","0.50","0.55","0.60","1.0"];S.textContent=E[parseInt(t[i])]||t[i]}else S.textContent=t[i]}else{const S=document.getElementById(`cam${e}-${i}`);S&&S.type==="checkbox"&&typeof t[i]=="boolean"&&(S.checked=t[i])}})}}document.addEventListener("DOMContentLoaded",()=>{new bt});
|