mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-09 03:46:16 -08:00
8 lines
332 KiB
JavaScript
8 lines
332 KiB
JavaScript
|
||
/*!
|
||
* artplayer-proxy-webav.js v1.0.0
|
||
* Github: https://github.com/zhw2590582/ArtPlayer
|
||
* (c) 2017-2025 Harvey Zack
|
||
* Released under the MIT License.
|
||
*/
|
||
!function(t,e,r,n,s){var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},o="function"==typeof a[n]&&a[n],u=o.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function c(e,r){if(!u[e]){if(!t[e]){var s="function"==typeof a[n]&&a[n];if(!r&&s)return s(e,!0);if(o)return o(e,!0);if(l&&"string"==typeof e)return l(e);var h=Error("Cannot find module '"+e+"'");throw h.code="MODULE_NOT_FOUND",h}d.resolve=function(r){var n=t[e][1][r];return null!=n?n:r},d.cache={};var f=u[e]=new c.Module(e);t[e][0].call(f.exports,d,f,f.exports,this)}return u[e].exports;function d(t){var e=d.resolve(t);return!1===e?{}:c(e)}}c.isParcelRequire=!0,c.Module=function(t){this.id=t,this.bundle=c,this.exports={}},c.modules=t,c.cache=u,c.parent=o,c.register=function(e,r){t[e]=[function(t,e){e.exports=r},{}]},Object.defineProperty(c,"root",{get:function(){return a[n]}}),a[n]=c;for(var h=0;h<e.length;h++)c(e[h]);if(r){var f=c(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=f:"function"==typeof define&&define.amd&&define(function(){return f})}}({c4SNP:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",function(){return u});var s=t("@swc/helpers/_/_async_to_generator"),a=t("@swc/helpers/_/_ts_generator"),o=t("@webav/av-cliper");function u(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e){var r,n,u=e.option,l=e.constructor.utils,c=l.createElement,h=l.def,f=c("canvas"),d=f.getContext("2d"),p=null,m=null,_=null,y=null,g=0,v={playing:!1,duration:0,videoWidth:0,videoHeight:0,currentTime:0,playbackRate:1,paused:!0,ended:!1,readyState:0,buffered:0,muted:u.muted,volume:u.volume,autoplay:u.autoplay};function b(){_&&(clearInterval(_),_=null),m&&(m.stop(),m=null)}function w(){if(n){var t=v.muted?0:v.volume;n.gain.setValueAtTime(t,r.currentTime)}}function S(){return(S=(0,s._)(function(){var t,o,u,l;function c(){return h.apply(this,arguments)}function h(){return(h=(0,s._)(function(){var s,c,h,f,_,g,w,S;return(0,a._)(this,function(a){switch(a.label){case 0:if(!v.playing)return[2];return h=(c=performance.now())-l,l=c,null!==y?(t=1e6*y,y=null,u=!0):t+=1e3*h*v.playbackRate,v.currentTime=t/1e6,[4,p.tick(Math.round(t))];case 1:if(_=(f=a.sent()).state,g=f.video,w=f.audio,e.emit("video:timeupdate",{type:"timeupdate"}),"done"===_)return b(),v.ended=!0,v.playing=!1,v.paused=!0,e.emit("video:ended",{type:"ended"}),[2];return g&&"success"===_&&(d.clearRect(0,0,v.videoWidth,v.videoHeight),d.drawImage(g,0,0,v.videoWidth,v.videoHeight),g.close()),u?u=!1:(null==w?void 0:null===(s=w[0])||void 0===s?void 0:s.length)&&((S=r.createBuffer(2,w[0].length,48e3)).copyToChannel(w[0],0),S.copyToChannel(w[1],1),(m=r.createBufferSource()).buffer=S,m.connect(n),m.playbackRate.setValueAtTime(v.playbackRate,r.currentTime),o=Math.max(r.currentTime,o),m.start(o),o+=S.duration/v.playbackRate),[2]}})})).apply(this,arguments)}return(0,a._)(this,function(e){return r||(n=(r=new AudioContext).createGain()).connect(r.destination),t=1e6*v.currentTime,o=0,u=!0,l=performance.now(),b(),w(),v.playing=!0,v.paused=!1,_=setInterval(c,1e3/60),[2]})})).apply(this,arguments)}function x(t){return E.apply(this,arguments)}function E(){return(E=(0,s._)(function(t){var e;return(0,a._)(this,function(r){switch(r.label){case 0:return[4,p.tick(1e6*t)];case 1:return(e=r.sent().video)&&(d.clearRect(0,0,f.width,f.height),d.drawImage(e,0,0,f.width,f.height),e.close()),[2]}})})).apply(this,arguments)}function U(){var t,r=null===(t=e.template)||void 0===t?void 0:t.$player;if(r&&!u.autoSize){var n=f.videoWidth/f.videoHeight,s=r.clientWidth,a=r.clientHeight,o=0,l=0;s/a>n?o=(s-a*n)/2:l=(a-s/n)/2,Object.assign(f.style,{padding:"".concat(l,"px ").concat(o,"px")})}}function T(){return(T=(0,s._)(function(){var r,n,s;return(0,a._)(this,function(a){switch(a.label){case 0:return[4,(0,o.Combinator).isSupported()];case 1:if(!a.sent())throw e.notice.show="WebAV is not supported",Error("WebAV is not supported");b(),Object.assign(v,{playing:!1,duration:0,videoWidth:0,videoHeight:0,currentTime:0,playbackRate:1,paused:!0,ended:!1,readyState:0,buffered:0,muted:u.muted,volume:u.volume,autoplay:u.autoplay}),p&&(p.destroy(),e.emit("video:abort",{type:"abort"}),e.emit("video:emptied",{type:"emptied"})),a.label=2;case 2:return a.trys.push([2,5,,6]),[4,Promise.resolve()];case 3:return a.sent(),v.readyState=1,e.emit("video:loadstart",{type:"loadstart"}),[4,fetch(u.url)];case 4:if(!(r=a.sent()).body)throw Error("No response body");return p=new o.MP4Clip(r.body,t),[3,6];case 5:throw n=a.sent(),v.readyState=0,e.emit("video:error",n),n;case 6:return[4,p.ready];case 7:return Object.assign(v,{readyState:4,duration:Math.round((s=a.sent()).duration/1e6),videoWidth:s.width,videoHeight:s.height}),f.width=v.videoWidth,f.height=v.videoHeight,[4,x(.1)];case 8:return a.sent(),U(),e.emit("video:loadedmetadata",{type:"loadedmetadata"}),e.emit("video:durationchange",{type:"durationchange"}),e.emit("video:loadeddata",{type:"loadeddata"}),e.emit("video:canplay",{type:"canplay"}),e.emit("video:canplaythrough",{type:"canplaythrough"}),[2]}})})).apply(this,arguments)}return h(f,"duration",{get:function(){return v.duration}}),h(f,"videoWidth",{get:function(){return v.videoWidth}}),h(f,"videoHeight",{get:function(){return v.videoHeight}}),h(f,"volume",{get:function(){return v.volume},set:function(t){v.volume=Math.max(0,Math.min(1,t)),w(),e.emit("video:volumechange",{type:"volumechange"})}}),h(f,"currentTime",{get:function(){return v.currentTime},set:function(t){if(!(v.readyState<4)){var r=Math.max(0,Math.min(t,v.duration)),n=performance.now();n-g>16&&(g=n,y=r,v.currentTime=r,v.playing||x(r),e.emit("video:timeupdate",{type:"timeupdate"}))}}}),h(f,"autoplay",{get:function(){return v.autoplay},set:function(t){v.autoplay=t,t&&v.readyState>=4&&f.play()}}),h(f,"src",{get:function(){return u.url},set:function(t){u.url=t,(function(){return T.apply(this,arguments)})().then(function(){u.autoplay&&f.play()})}}),h(f,"playbackRate",{get:function(){return v.playbackRate},set:function(t){v.playbackRate=Math.max(.25,Math.min(2,t)),m&&m.playbackRate.setValueAtTime(v.playbackRate,r.currentTime),e.emit("video:ratechange",{type:"ratechange"})}}),h(f,"playing",{get:function(){return v.playing}}),h(f,"paused",{get:function(){return v.paused}}),h(f,"ended",{get:function(){return v.ended}}),h(f,"readyState",{get:function(){return v.readyState}}),h(f,"muted",{get:function(){return v.muted},set:function(t){v.muted=t,w(),e.emit("video:volumechange",{type:"volumechange"})}}),h(f,"buffered",{get:function(){return{start:function(){return 0},end:function(){return v.buffered},length:1}}}),h(f,"play",{value:/*#__PURE__*/(0,s._)(function(){return(0,a._)(this,function(t){switch(t.label){case 0:if(v.readyState<4)return[2,!1];return[4,function(){return S.apply(this,arguments)}()];case 1:return t.sent(),e.emit("video:play",{type:"play"}),e.emit("video:playing",{type:"playing"}),[2,!0]}})})}),h(f,"pause",{value:function(){b(),v.playing=!1,v.paused=!0,e.emit("video:pause",{type:"pause"})}}),e.on("destroy",function(){b(),p&&p.destroy()}),e.on("resize",U),f}}"undefined"!=typeof window&&(window.artplayerProxyWebAV=u)},{"@swc/helpers/_/_async_to_generator":"eONSn","@swc/helpers/_/_ts_generator":"6Xyd0","@webav/av-cliper":"4iON5","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],eONSn:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t,e,r,n,s,a,o){try{var u=t[a](o),l=u.value}catch(t){r(t);return}u.done?e(l):Promise.resolve(l).then(n,s)}function a(t){return function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function u(t){s(o,n,a,u,l,"next",t)}function l(t){s(o,n,a,u,l,"throw",t)}u(void 0)})}}n.defineInteropFlag(r),n.export(r,"_",function(){return a})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],iWrD0:[function(t,e,r){r.interopDefault=function(t){return t&&t.__esModule?t:{default:t}},r.defineInteropFlag=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.exportAll=function(t,e){return Object.keys(t).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})}),e},r.export=function(t,e,r){Object.defineProperty(t,e,{enumerable:!0,get:r})}},{}],"6Xyd0":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return s.__generator});var s=t("tslib")},{tslib:"c0d7h","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],c0d7h:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"__extends",function(){return o}),n.export(r,"__assign",function(){return u}),n.export(r,"__rest",function(){return l}),n.export(r,"__decorate",function(){return c}),n.export(r,"__param",function(){return h}),n.export(r,"__esDecorate",function(){return f}),n.export(r,"__runInitializers",function(){return d}),n.export(r,"__propKey",function(){return p}),n.export(r,"__setFunctionName",function(){return m}),n.export(r,"__metadata",function(){return _}),n.export(r,"__awaiter",function(){return y}),n.export(r,"__generator",function(){return g}),n.export(r,"__createBinding",function(){return v}),n.export(r,"__exportStar",function(){return b}),n.export(r,"__values",function(){return w}),n.export(r,"__read",function(){return S}),n.export(r,"__spread",function(){return x}),n.export(r,"__spreadArrays",function(){return E}),n.export(r,"__spreadArray",function(){return U}),n.export(r,"__await",function(){return T}),n.export(r,"__asyncGenerator",function(){return A}),n.export(r,"__asyncDelegator",function(){return I}),n.export(r,"__asyncValues",function(){return k}),n.export(r,"__makeTemplateObject",function(){return C}),n.export(r,"__importStar",function(){return P}),n.export(r,"__importDefault",function(){return R}),n.export(r,"__classPrivateFieldGet",function(){return F}),n.export(r,"__classPrivateFieldSet",function(){return D}),n.export(r,"__classPrivateFieldIn",function(){return z}),n.export(r,"__addDisposableResource",function(){return L}),n.export(r,"__disposeResources",function(){return M});var s=t("@swc/helpers/_/_type_of"),a=function(t,e){return(a=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var u=function(){return(u=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var s in e=arguments[r])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)};function l(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&0>e.indexOf(n)&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)0>e.indexOf(n[s])&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(r[n[s]]=t[n[s]]);return r}function c(t,e,r,n){var s,a=arguments.length,o=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(s=t[u])&&(o=(a<3?s(o):a>3?s(e,r,o):s(e,r))||o);return a>3&&o&&Object.defineProperty(e,r,o),o}function h(t,e){return function(r,n){e(r,n,t)}}function f(t,e,r,n,s,a){function o(t){if(void 0!==t&&"function"!=typeof t)throw TypeError("Function expected");return t}for(var u,l=n.kind,c="getter"===l?"get":"setter"===l?"set":"value",h=!e&&t?n.static?t:t.prototype:null,f=e||(h?Object.getOwnPropertyDescriptor(h,n.name):{}),d=!1,p=r.length-1;p>=0;p--){var m={};for(var _ in n)m[_]="access"===_?{}:n[_];for(var _ in n.access)m.access[_]=n.access[_];m.addInitializer=function(t){if(d)throw TypeError("Cannot add initializers after decoration has completed");a.push(o(t||null))};var y=(0,r[p])("accessor"===l?{get:f.get,set:f.set}:f[c],m);if("accessor"===l){if(void 0===y)continue;if(null===y||"object"!=typeof y)throw TypeError("Object expected");(u=o(y.get))&&(f.get=u),(u=o(y.set))&&(f.set=u),(u=o(y.init))&&s.unshift(u)}else(u=o(y))&&("field"===l?s.unshift(u):f[c]=u)}h&&Object.defineProperty(h,n.name,f),d=!0}function d(t,e,r){for(var n=arguments.length>2,s=0;s<e.length;s++)r=n?e[s].call(t,r):e[s].call(t);return n?r:void 0}function p(t){return(void 0===t?"undefined":(0,s._)(t))==="symbol"?t:"".concat(t)}function m(t,e,r){return(void 0===e?"undefined":(0,s._)(e))==="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function _(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function y(t,e,r,n){return new(r||(r=Promise))(function(s,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function u(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):((e=t.value)instanceof r?e:new r(function(t){t(e)})).then(o,u)}l((n=n.apply(t,e||[])).next())})}function g(t,e){var r,n,s,a,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(l){return function(u){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(s=2&u[0]?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(s=(s=o.trys).length>0&&s[s.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!s||u[1]>s[0]&&u[1]<s[3])){o.label=u[1];break}if(6===u[0]&&o.label<s[1]){o.label=s[1],s=u;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(u);break}s[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],n=0}finally{r=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}var v=Object.create?function(t,e,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,s)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]};function b(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||v(e,t,r)}function w(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function S(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,s,a=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(t){s={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(s)throw s.error}}return o}function x(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(S(arguments[e]));return t}function E(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var a=arguments[e],o=0,u=a.length;o<u;o++,s++)n[s]=a[o];return n}function U(t,e,r){if(r||2==arguments.length)for(var n,s=0,a=e.length;s<a;s++)!n&&s in e||(n||(n=Array.prototype.slice.call(e,0,s)),n[s]=e[s]);return t.concat(n||Array.prototype.slice.call(e))}function T(t){return this instanceof T?(this.v=t,this):new T(t)}function A(t,e,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n,s=r.apply(t,e||[]),a=[];return n={},o("next"),o("throw"),o("return",function(t){return function(e){return Promise.resolve(e).then(t,c)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(t,e){s[t]&&(n[t]=function(e){return new Promise(function(r,n){a.push([t,e,r,n])>1||u(t,e)})},e&&(n[t]=e(n[t])))}function u(t,e){try{var r;(r=s[t](e)).value instanceof T?Promise.resolve(r.value.v).then(l,c):h(a[0][2],r)}catch(t){h(a[0][3],t)}}function l(t){u("next",t)}function c(t){u("throw",t)}function h(t,e){t(e),a.shift(),a.length&&u(a[0][0],a[0][1])}}function I(t){var e,r;return e={},n("next"),n("throw",function(t){throw t}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,s){e[n]=t[n]?function(e){return(r=!r)?{value:T(t[n](e)),done:!1}:s?s(e):e}:s}}function k(t){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=w(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise(function(n,s){!function(t,e,r,n){Promise.resolve(n).then(function(e){t({value:e,done:r})},e)}(n,s,(e=t[r](e)).done,e.value)})}}}function C(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var B=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function P(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&v(e,t,r);return B(e,t),e}function R(t){return t&&t.__esModule?t:{default:t}}function F(t,e,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}function D(t,e,r,n,s){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!s)throw TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(t,r):s?s.value=r:e.set(t,r),r}function z(t,e){if(null===e||"object"!=typeof e&&"function"!=typeof e)throw TypeError("Cannot use 'in' operator on non-object");return"function"==typeof t?e===t:t.has(e)}function L(t,e,r){if(null!=e){var n,s;if("object"!=typeof e&&"function"!=typeof e)throw TypeError("Object expected.");if(r){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],r&&(s=n)}if("function"!=typeof n)throw TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:n,async:r})}else r&&t.stack.push({async:!0});return e}var O="function"==typeof SuppressedError?SuppressedError:function(t,e,r){var n=Error(r);return n.name="SuppressedError",n.error=t,n.suppressed=e,n};function M(t){function e(e){t.error=t.hasError?new O(e,t.error,"An error was suppressed during disposal."):e,t.hasError=!0}return function r(){for(;t.stack.length;){var n=t.stack.pop();try{var s=n.dispose&&n.dispose.call(n.value);if(n.async)return Promise.resolve(s).then(r,function(t){return e(t),r()})}catch(t){e(t)}}if(t.hasError)throw t.error}()}r.default={__extends:o,__assign:u,__rest:l,__decorate:c,__param:h,__metadata:_,__awaiter:y,__generator:g,__createBinding:v,__exportStar:b,__values:w,__read:S,__spread:x,__spreadArrays:E,__spreadArray:U,__await:T,__asyncGenerator:A,__asyncDelegator:I,__asyncValues:k,__makeTemplateObject:C,__importStar:P,__importDefault:R,__classPrivateFieldGet:F,__classPrivateFieldSet:D,__classPrivateFieldIn:z,__addDisposableResource:L,__disposeResources:M}},{"@swc/helpers/_/_type_of":"felZi","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],felZi:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"4iON5":[function(t,e,r){var n,s,a,o,u,l,c,h,f,d,p,m,_,y,g,v,b,w,S,x,E,U,T,A,I,k,C,B,P,R,F,D,z,L,O,M,N,j,G,Y,W,V,H,X,Z,K,q,Q,J,$,tt,te,tr,ti,tn,ts,ta,to,tu,tl,tc,th,tf,td,tp,tm,t_,ty,tg,tv,tb,tw,tS,tx,tE,tU,tT,tA,tI,tk,tC,tB,tP,tR,tF,tD,tz,tL,tO,tM,tN,tj,tG,tY,tW,tV,tH,tX,tZ,tK,tq,tQ,tJ,t$,t0,t1,t2,t3,t4,t6,t8,t5,t9,t7,et,ee,er,ei,en,es,ea,eo,eu,el,ec,eh,ef,ed,ep=t("@parcel/transformer-js/src/esmodule-helpers.js");ep.defineInteropFlag(r),ep.export(r,"AudioClip",function(){return ih}),ep.export(r,"Combinator",function(){return i9}),ep.export(r,"DEFAULT_AUDIO_CONF",function(){return r$}),ep.export(r,"EmbedSubtitlesClip",function(){return iv}),ep.export(r,"EventTool",function(){return iw}),ep.export(r,"ImgClip",function(){return il}),ep.export(r,"Log",function(){return rw}),ep.export(r,"MP4Clip",function(){return r8}),ep.export(r,"MediaStreamClip",function(){return iy}),ep.export(r,"OffscreenSprite",function(){return i3}),ep.export(r,"Rect",function(){return i0}),ep.export(r,"VisibleSprite",function(){return i4}),ep.export(r,"adjustAudioDataVolume",function(){return rN}),ep.export(r,"audioResample",function(){return rW}),ep.export(r,"autoReadStream",function(){return rZ}),ep.export(r,"concatAudioClip",function(){return id}),ep.export(r,"concatFloat32Array",function(){return rz}),ep.export(r,"concatPCMFragments",function(){return rL}),ep.export(r,"createChromakey",function(){return iJ}),ep.export(r,"createEl",function(){return eY}),ep.export(r,"createHLSLoader",function(){return iX}),ep.export(r,"decodeImg",function(){return rj}),ep.export(r,"extractPCM4AudioBuffer",function(){return rM}),ep.export(r,"extractPCM4AudioData",function(){return rO}),ep.export(r,"fastConcatMP4",function(){return iB}),ep.export(r,"file2stream",function(){return ik}),ep.export(r,"fixFMP4Duration",function(){return iF}),ep.export(r,"mixinMP4AndAudio",function(){return iz}),ep.export(r,"mixinPCM",function(){return rY}),ep.export(r,"recodemux",function(){return iA}),ep.export(r,"renderTxt2Img",function(){return eW}),ep.export(r,"renderTxt2ImgBitmap",function(){return eV}),ep.export(r,"ringSliceFloat32Array",function(){return rX}),ep.export(r,"workerTimer",function(){return rA});var em=t("@swc/helpers/_/_assert_this_initialized"),e_=t("@swc/helpers/_/_async_iterator"),ey=t("@swc/helpers/_/_async_to_generator"),eg=t("@swc/helpers/_/_class_call_check"),ev=t("@swc/helpers/_/_create_class"),eb=t("@swc/helpers/_/_define_property"),ew=t("@swc/helpers/_/_get"),eS=t("@swc/helpers/_/_get_prototype_of"),ex=t("@swc/helpers/_/_inherits"),eE=t("@swc/helpers/_/_object_spread"),eU=t("@swc/helpers/_/_object_spread_props"),eT=t("@swc/helpers/_/_possible_constructor_return"),eA=t("@swc/helpers/_/_sliced_to_array"),eI=t("@swc/helpers/_/_to_consumable_array"),ek=t("@swc/helpers/_/_type_of"),eC=t("@swc/helpers/_/_create_super"),eB=t("@swc/helpers/_/_ts_generator"),eP=t("@swc/helpers/_/_ts_values"),eR=arguments[3],eF=t("718a311db185ef08").Buffer,eD=Object.defineProperty,ez=function(t){throw TypeError(t)},eL=function(t,e,r){var n;return(n=(void 0===e?"undefined":(0,ek._)(e))!="symbol"?e+"":e)in t?eD(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r},eO=function(t,e,r){return e.has(t)||ez("Cannot "+r)},eM=function(t,e,r){return eO(t,e,"read from private field"),r?r.call(t):e.get(t)},eN=function(t,e,r){return e.has(t)?ez("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r)},ej=function(t,e,r,n){return eO(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r},eG=function(t,e,r){return eO(t,e,"access private method"),r};function eY(t){return document.createElement(t)}function eW(t,e){var r=eY("pre");r.style.cssText="margin: 0; ".concat(e,"; visibility: hidden; position: fixed;"),r.textContent=t,document.body.appendChild(r);var n=r.getBoundingClientRect(),s=n.width,a=n.height;r.remove(),r.style.visibility="visible";var o=new Image;o.width=s,o.height=a;var u='\n<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(s,'" height="').concat(a,'">\n<foreignObject width="100%" height="100%">\n<div xmlns="http://www.w3.org/1999/xhtml">').concat(r.outerHTML,"</div>\n</foreignObject>\n</svg>\n ").replace(/\t/g,"").replace(/#/g,"%23");return o.src="data:image/svg+xml;charset=utf-8,".concat(u),o}function eV(t,e){return eH.apply(this,arguments)}function eH(){return(eH=(0,ey._)(function(t,e){var r,n,s;return(0,eB._)(this,function(a){switch(a.label){case 0:return r=eW(t,e),[4,new Promise(function(t){r.onload=t})];case 1:return a.sent(),null==(s=(n=new OffscreenCanvas(r.width,r.height)).getContext("2d"))||s.drawImage(r,0,0,r.width,r.height),[4,createImageBitmap(n)];case 2:return[2,a.sent()]}})})).apply(this,arguments)}var eX=function(t){throw TypeError(t)},eZ=function(t,e,r){return e.has(t)||eX("Cannot "+r)},eK=function(t,e,r){return eZ(t,e,"read from private field"),r?r.call(t):e.get(t)},eq=function(t,e,r){return e.has(t)?eX("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r)},eQ=function(t,e,r,n){return eZ(t,e,"write to private field"),e.set(t,r),r},eJ="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHUobil7aWYobj09PSIvIilyZXR1cm57cGFyZW50Om51bGwsbmFtZToiIn07Y29uc3QgZT1uLnNwbGl0KCIvIikuZmlsdGVyKGk9PmkubGVuZ3RoPjApO2lmKGUubGVuZ3RoPT09MCl0aHJvdyBFcnJvcigiSW52YWxpZCBwYXRoIik7Y29uc3QgYT1lW2UubGVuZ3RoLTFdLHI9Ii8iK2Uuc2xpY2UoMCwtMSkuam9pbigiLyIpO3JldHVybntuYW1lOmEscGFyZW50OnJ9fWFzeW5jIGZ1bmN0aW9uIHcobixlKXtjb25zdHtwYXJlbnQ6YSxuYW1lOnJ9PXUobik7aWYoYT09bnVsbClyZXR1cm4gYXdhaXQgbmF2aWdhdG9yLnN0b3JhZ2UuZ2V0RGlyZWN0b3J5KCk7Y29uc3QgaT1hLnNwbGl0KCIvIikuZmlsdGVyKHQ9PnQubGVuZ3RoPjApO3RyeXtsZXQgdD1hd2FpdCBuYXZpZ2F0b3Iuc3RvcmFnZS5nZXREaXJlY3RvcnkoKTtmb3IoY29uc3QgcyBvZiBpKXQ9YXdhaXQgdC5nZXREaXJlY3RvcnlIYW5kbGUocyx7Y3JlYXRlOmUuY3JlYXRlfSk7aWYoZS5pc0ZpbGUpcmV0dXJuIGF3YWl0IHQuZ2V0RmlsZUhhbmRsZShyLHtjcmVhdGU6ZS5jcmVhdGV9KX1jYXRjaCh0KXtpZih0Lm5hbWU9PT0iTm90Rm91bmRFcnJvciIpcmV0dXJuIG51bGw7dGhyb3cgdH19Y29uc3QgZj17fTtzZWxmLm9ubWVzc2FnZT1hc3luYyBuPT57dmFyIGk7Y29uc3R7ZXZ0VHlwZTplLGFyZ3M6YX09bi5kYXRhO2xldCByPWZbYS5maWxlSWRdO3RyeXtsZXQgdDtjb25zdCBzPVtdO2lmKGU9PT0icmVnaXN0ZXIiKXtjb25zdCBsPWF3YWl0IHcoYS5maWxlUGF0aCx7Y3JlYXRlOiEwLGlzRmlsZTohMH0pO2lmKGw9PW51bGwpdGhyb3cgRXJyb3IoYG5vdCBmb3VuZCBmaWxlOiAke2EuZmlsZUlkfWApO3I9YXdhaXQgbC5jcmVhdGVTeW5jQWNjZXNzSGFuZGxlKHttb2RlOmEubW9kZX0pLGZbYS5maWxlSWRdPXJ9ZWxzZSBpZihlPT09ImNsb3NlIilhd2FpdCByLmNsb3NlKCksZGVsZXRlIGZbYS5maWxlSWRdO2Vsc2UgaWYoZT09PSJ0cnVuY2F0ZSIpYXdhaXQgci50cnVuY2F0ZShhLm5ld1NpemUpO2Vsc2UgaWYoZT09PSJ3cml0ZSIpe2NvbnN0e2RhdGE6bCxvcHRzOm99PW4uZGF0YS5hcmdzO3Q9YXdhaXQgci53cml0ZShsLG8pfWVsc2UgaWYoZT09PSJyZWFkIil7Y29uc3R7b2Zmc2V0Omwsc2l6ZTpvfT1uLmRhdGEuYXJncyxnPW5ldyBVaW50OEFycmF5KG8pLGQ9YXdhaXQgci5yZWFkKGcse2F0Omx9KSxjPWcuYnVmZmVyO3Q9ZD09PW8/YzooKGk9Yy50cmFuc2Zlcik9PW51bGw/dm9pZCAwOmkuY2FsbChjLGQpKT8/Yy5zbGljZSgwLGQpLHMucHVzaCh0KX1lbHNlIGU9PT0iZ2V0U2l6ZSI/dD1hd2FpdCByLmdldFNpemUoKTplPT09ImZsdXNoIiYmYXdhaXQgci5mbHVzaCgpO3NlbGYucG9zdE1lc3NhZ2Uoe2V2dFR5cGU6ImNhbGxiYWNrIixjYklkOm4uZGF0YS5jYklkLHJldHVyblZhbDp0fSxzKX1jYXRjaCh0KXtjb25zdCBzPXQ7c2VsZi5wb3N0TWVzc2FnZSh7ZXZ0VHlwZToidGhyb3dFcnJvciIsY2JJZDpuLmRhdGEuY2JJZCxlcnJNc2c6cy5uYW1lKyI6ICIrcy5tZXNzYWdlK2AKYCtKU09OLnN0cmluZ2lmeShuLmRhdGEpfSl9fX0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPW9wZnMtd29ya2VyLUY0UldscWNfLmpzLm1hcAo=",e$=("undefined"==typeof self?"undefined":(0,ek._)(self))<"u"&&self.Blob&&new Blob([Uint8Array.from(atob(eJ),function(t){return t.charCodeAt(0)})],{type:"text/javascript;charset=utf-8"});function e0(t){var e;try{if(!(e=e$&&(self.URL||self.webkitURL).createObjectURL(e$)))throw"";var r=new Worker(e,{name:null==t?void 0:t.name});return r.addEventListener("error",function(){(self.URL||self.webkitURL).revokeObjectURL(e)}),r}catch(e){return new Worker("data:text/javascript;base64,"+eJ,{name:null==t?void 0:t.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function e1(){return(e1=(0,ey._)(function(t,e,r){var n;return(0,eB._)(this,function(s){switch(s.label){case 0:return[4,(n=function(){if(e2.length<3){var t,e,r,n,s=(e=new e0,r=0,n={},e.onmessage=function(t){var e,r,s=t.data;"callback"===s.evtType?null==(e=n[s.cbId])||e.resolve(s.returnVal):"throwError"===s.evtType&&(null==(r=n[s.cbId])||r.reject(Error(s.errMsg))),delete n[s.cbId]},t=(0,ey._)(function(t,s){var a,o,u=arguments;return(0,eB._)(this,function(l){return a=u.length>2&&void 0!==u[2]?u[2]:[],r+=1,o=new Promise(function(t,e){n[r]={resolve:t,reject:e}}),[2,(e.postMessage({cbId:r,evtType:t,args:s},a),o)]})}),function(e,r){return t.apply(this,arguments)});return e2.push(s),s}var a=e2[e3];return e3=(e3+1)%e2.length,a}())("register",{fileId:t,filePath:e,mode:r})];case 1:var a,o,u;return[2,(s.sent(),{read:(a=(0,ey._)(function(e,r){return(0,eB._)(this,function(s){switch(s.label){case 0:return[4,n("read",{fileId:t,offset:e,size:r})];case 1:return[2,s.sent()]}})}),function(t,e){return a.apply(this,arguments)}),write:(o=(0,ey._)(function(e,r){return(0,eB._)(this,function(s){switch(s.label){case 0:return[4,n("write",{fileId:t,data:e,opts:r},[ArrayBuffer.isView(e)?e.buffer:e])];case 1:return[2,s.sent()]}})}),function(t,e){return o.apply(this,arguments)}),close:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,n("close",{fileId:t})];case 1:return[2,e.sent()]}})}),truncate:(u=(0,ey._)(function(e){return(0,eB._)(this,function(r){switch(r.label){case 0:return[4,n("truncate",{fileId:t,newSize:e})];case 1:return[2,r.sent()]}})}),function(t){return u.apply(this,arguments)}),getSize:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,n("getSize",{fileId:t})];case 1:return[2,e.sent()]}})}),flush:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,n("flush",{fileId:t})];case 1:return[2,e.sent()]}})})})]}})})).apply(this,arguments)}var e2=[],e3=0;function e4(t){if("/"===t)return{parent:null,name:""};var e=t.split("/").filter(function(t){return t.length>0});if(0===e.length)throw Error("Invalid path");return{name:e[e.length-1],parent:"/"+e.slice(0,-1).join("/")}}function e6(t,e){return e8.apply(this,arguments)}function e8(){return(e8=(0,ey._)(function(t,e){var r,n,s,a,o,u,l,c,h,f,d,p,m,_;return(0,eB._)(this,function(y){switch(y.label){case 0:if(n=(r=e4(t)).parent,s=r.name,null!=n)return[3,2];return[4,navigator.storage.getDirectory()];case 1:return[2,y.sent()];case 2:a=n.split("/").filter(function(t){return t.length>0}),y.label=3;case 3:return y.trys.push([3,17,,18]),[4,navigator.storage.getDirectory()];case 4:o=y.sent(),u=!0,l=!1,c=void 0,y.label=5;case 5:y.trys.push([5,10,11,12]),h=a[Symbol.iterator](),y.label=6;case 6:if(u=(f=h.next()).done)return[3,9];return d=f.value,[4,o.getDirectoryHandle(d,{create:e.create})];case 7:o=y.sent(),y.label=8;case 8:return u=!0,[3,6];case 9:return[3,12];case 10:return p=y.sent(),l=!0,c=p,[3,12];case 11:try{u||null==h.return||h.return()}finally{if(l)throw c}return[7];case 12:if(!e.isFile)return[3,14];return[4,o.getFileHandle(s,{create:e.create})];case 13:return m=y.sent(),[3,16];case 14:return[4,o.getDirectoryHandle(s,{create:e.create})];case 15:m=y.sent(),y.label=16;case 16:return[2,m];case 17:if("NotFoundError"===(_=y.sent()).name)return[2,null];throw _;case 18:return[2]}})})).apply(this,arguments)}function e5(t){return e9.apply(this,arguments)}function e9(){return(e9=(0,ey._)(function(t){var e,r,n,s,a,o,u,l,c,h,f,d;return(0,eB._)(this,function(p){switch(p.label){case 0:if(r=(e=e4(t)).parent,n=e.name,null!=r)return[3,15];return[4,navigator.storage.getDirectory()];case 1:s=p.sent(),a=!1,o=!1,p.label=2;case 2:p.trys.push([2,8,9,14]),l=(0,e_._)(s.keys()),p.label=3;case 3:return[4,l.next()];case 4:if(!(a=!(c=p.sent()).done))return[3,7];return h=c.value,[4,s.removeEntry(h,{recursive:!0})];case 5:p.sent(),p.label=6;case 6:return a=!1,[3,3];case 7:return[3,14];case 8:return f=p.sent(),o=!0,u=f,[3,14];case 9:if(p.trys.push([9,,12,13]),!(a&&null!=l.return))return[3,11];return[4,l.return()];case 10:p.sent(),p.label=11;case 11:return[3,13];case 12:if(o)throw u;return[7];case 13:return[7];case 14:return[2];case 15:return[4,e6(r,{create:!1,isFile:!1})];case 16:if(!(null!=(d=p.sent())))return[3,18];return[4,d.removeEntry(n,{recursive:!0})];case 17:p.sent(),p.label=18;case 18:return[2]}})})).apply(this,arguments)}function e7(t,e){return"".concat(t,"/").concat(e).replace("//","/")}function rt(t){return new re(t)}var re=/*#__PURE__*/function(){function t(e){(0,eg._)(this,t),eq(this,v),eq(this,b),eq(this,w),eQ(this,v,e);var r=e4(e),n=r.parent,s=r.name;eQ(this,b,s),eQ(this,w,n)}return(0,ev._)(t,[{key:"kind",get:function(){return"dir"}},{key:"name",get:function(){return eK(this,b)}},{key:"path",get:function(){return eK(this,v)}},{key:"parent",get:function(){return null==eK(this,w)?null:rt(eK(this,w))}},{key:"create",value:function(){var t=this;return(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,e6(eK(t,v),{create:!0,isFile:!1})];case 1:return[2,(e.sent(),rt(eK(t,v)))]}})})()}},{key:"exists",value:function(){var t=this;return(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,e6(eK(t,v),{create:!1,isFile:!1})];case 1:return[2,e.sent() instanceof FileSystemDirectoryHandle]}})})()}},{key:"remove",value:function(){var t=this;return(0,ey._)(function(){var e,r,n,s,a,o,u;return(0,eB._)(this,function(l){switch(l.label){case 0:e=!0,r=!1,n=void 0,l.label=1;case 1:return l.trys.push([1,9,10,11]),[4,t.children()];case 2:s=l.sent()[Symbol.iterator](),l.label=3;case 3:if(e=(a=s.next()).done)return[3,8];o=a.value,l.label=4;case 4:return l.trys.push([4,6,,7]),[4,o.remove()];case 5:return l.sent(),[3,7];case 6:return console.warn(l.sent()),[3,7];case 7:return e=!0,[3,3];case 8:return[3,11];case 9:return u=l.sent(),r=!0,n=u,[3,11];case 10:try{e||null==s.return||s.return()}finally{if(r)throw n}return[7];case 11:return l.trys.push([11,13,,14]),[4,e5(eK(t,v))];case 12:return l.sent(),[3,14];case 13:return console.warn(l.sent()),[3,14];case 14:return[2]}})})()}},{key:"children",value:function(){var t=this;return(0,ey._)(function(){var e,r,n,s,a,o,u,l,c;return(0,eB._)(this,function(h){switch(h.label){case 0:return[4,e6(eK(t,v),{create:!1,isFile:!1})];case 1:if(null==(e=h.sent()))return[2,[]];r=[],n=!1,s=!1,h.label=2;case 2:h.trys.push([2,7,8,13]),o=(0,e_._)(e.values()),h.label=3;case 3:return[4,o.next()];case 4:if(!(n=!(u=h.sent()).done))return[3,6];l=u.value,r.push(("file"===l.kind?ri:rt)(e7(eK(t,v),l.name))),h.label=5;case 5:return n=!1,[3,3];case 6:return[3,13];case 7:return c=h.sent(),s=!0,a=c,[3,13];case 8:if(h.trys.push([8,,11,12]),!(n&&null!=o.return))return[3,10];return[4,o.return()];case 9:h.sent(),h.label=10;case 10:return[3,12];case 11:if(s)throw a;return[7];case 12:return[7];case 13:return[2,r]}})})()}},{key:"copyTo",value:function(t){var e=this;return(0,ey._)(function(){var r,n;return(0,eB._)(this,function(s){switch(s.label){case 0:return[4,e.exists()];case 1:if(!s.sent())throw Error("dir ".concat(e.path," not exists"));return[4,t.exists()];case 2:return[4,(r=s.sent()?rt(e7(t.path,e.name)):t).create()];case 3:return s.sent(),n=Promise.all,[4,e.children()];case 4:return[4,n.apply(Promise,[s.sent().map(function(t){return t.copyTo(r)})])];case 5:return[2,(s.sent(),r)]}})})()}},{key:"moveTo",value:function(t){var e=this;return(0,ey._)(function(){var r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,e.copyTo(t)];case 1:return r=n.sent(),[4,e.remove()];case 2:return[2,(n.sent(),r)]}})})()}}]),t}();v=/* @__PURE__ */new WeakMap,b=/* @__PURE__ */new WeakMap,w=/* @__PURE__ */new WeakMap;var rr=/* @__PURE__ */new Map;function ri(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rw";if("rw"===e){var r,n=null!==(r=rr.get(t))&&void 0!==r?r:new ru(t,e);return rr.set(t,n),n}return new ru(t,e)}function rn(t,e){return rs.apply(this,arguments)}function rs(){return(rs=(0,ey._)(function(t,e){var r,n,s,a,o,u,l,c=arguments;return(0,eB._)(this,function(h){switch(h.label){case 0:if(r=c.length>2&&void 0!==c[2]?c[2]:{overwrite:!0},!(e instanceof ru))return[3,3];return n=[t],[4,e.stream()];case 1:return[4,rn.apply(void 0,n.concat([h.sent(),r]))];case 2:return h.sent(),[2];case 3:return[4,(t instanceof ru?t:ri(t,"rw")).createWriter()];case 4:s=h.sent(),h.label=5;case 5:if(h.trys.push([5,16,17,19]),!r.overwrite)return[3,7];return[4,s.truncate(0)];case 6:h.sent(),h.label=7;case 7:if(!(e instanceof ReadableStream))return[3,13];a=e.getReader(),h.label=8;case 8:return[4,a.read()];case 9:if(u=(o=h.sent()).done,l=o.value,u)return[3,12];return[4,s.write(l)];case 10:h.sent(),h.label=11;case 11:return[3,8];case 12:return[3,15];case 13:return[4,s.write(e)];case 14:h.sent(),h.label=15;case 15:return[3,19];case 16:throw h.sent();case 17:return[4,s.close()];case 18:return h.sent(),[7];case 19:return[2]}})})).apply(this,arguments)}var ra=0,ro=/*#__PURE__*/function(){function t(e,r){var n,s=this;(0,eg._)(this,t),eq(this,S),eq(this,x),eq(this,E),eq(this,U),eq(this,T),eq(this,A,0),eq(this,I,(n=null,function(){var t;return eQ(s,A,eK(s,A)+1),null!=n?n:n=new Promise((t=(0,ey._)(function(t,e){var r;return(0,eB._)(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,function(t,e,r){return e1.apply(this,arguments)}(eK(s,T),eK(s,S),eK(s,U))];case 1:return t([r=a.sent(),/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:if(eQ(s,A,eK(s,A)-1),eK(s,A)>0)return[3,2];return n=null,[4,r.close()];case 1:t.sent(),t.label=2;case 2:return[2]}})})]),[3,3];case 2:return e(a.sent()),[3,3];case 3:return[2]}})}),function(e,r){return t.apply(this,arguments)}))})),eq(this,k,!1),eQ(this,T,++ra),eQ(this,S,e),eQ(this,U,{r:"read-only",rw:"readwrite","rw-unsafe":"readwrite-unsafe"}[r]);var a=e4(e),o=a.parent,u=a.name;eQ(this,E,u),eQ(this,x,o)}return(0,ev._)(t,[{key:"kind",get:function(){return"file"}},{key:"path",get:function(){return eK(this,S)}},{key:"name",get:function(){return eK(this,E)}},{key:"parent",get:function(){return null==eK(this,x)?null:rt(eK(this,x))}},{key:"createWriter",value:function(){var t=this;return(0,ey._)(function(){var e,r,n,s,a,o;return(0,eB._)(this,function(u){switch(u.label){case 0:if("read-only"===eK(t,U))throw Error("file is read-only");if(eK(t,k))throw Error("Other writer have not been closed");return eQ(t,k,!0),e=new TextEncoder,[4,eK(t,I).call(t)];case 1:return n=(r=(0,eA._).apply(void 0,[u.sent(),2]))[0],s=r[1],[4,n.getSize()];case 2:var l,c;return a=u.sent(),o=!1,[2,{write:(l=(0,ey._)(function(t){var r,s,u,l,c=arguments;return(0,eB._)(this,function(h){switch(h.label){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:{},o)throw Error("Writer is closed");return u="string"==typeof t?e.encode(t):t,a=(l=null!==(s=r.at)&&void 0!==s?s:a)+u.byteLength,[4,n.write(u,{at:l})];case 1:return[2,h.sent()]}})}),function(t){return l.apply(this,arguments)}),truncate:(c=(0,ey._)(function(t){return(0,eB._)(this,function(e){switch(e.label){case 0:if(o)throw Error("Writer is closed");return[4,n.truncate(t)];case 1:return e.sent(),a>t&&(a=t),[2]}})}),function(t){return c.apply(this,arguments)}),flush:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:if(o)throw Error("Writer is closed");return[4,n.flush()];case 1:return t.sent(),[2]}})}),close:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:if(o)throw Error("Writer is closed");return o=!0,eQ(t,k,!1),[4,s()];case 1:return e.sent(),[2]}})})}]}})})()}},{key:"createReader",value:function(){var t=this;return(0,ey._)(function(){var e,r,n,s,a;return(0,eB._)(this,function(o){switch(o.label){case 0:return[4,eK(t,I).call(t)];case 1:var u;return r=(e=(0,eA._).apply(void 0,[o.sent(),2]))[0],n=e[1],s=!1,a=0,[2,{read:(u=(0,ey._)(function(t){var e,n,o,u,l=arguments;return(0,eB._)(this,function(c){switch(c.label){case 0:if(e=l.length>1&&void 0!==l[1]?l[1]:{},s)throw Error("Reader is closed");return o=null!==(n=e.at)&&void 0!==n?n:a,[4,r.read(o,t)];case 1:return u=c.sent(),[2,(a=o+u.byteLength,u)]}})}),function(t){return u.apply(this,arguments)}),getSize:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:if(s)throw Error("Reader is closed");return[4,r.getSize()];case 1:return[2,t.sent()]}})}),close:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:if(s)return[3,2];return s=!0,[4,n()];case 1:t.sent(),t.label=2;case 2:return[2]}})})}]}})})()}},{key:"text",value:function(){var t=this;return(0,ey._)(function(){var e,r;return(0,eB._)(this,function(n){switch(n.label){case 0:return r=(e=new TextDecoder).decode,[4,t.arrayBuffer()];case 1:return[2,r.apply(e,[n.sent()])]}})})()}},{key:"arrayBuffer",value:function(){var t=this;return(0,ey._)(function(){var e,r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,e6(eK(t,S),{create:!1,isFile:!0})];case 1:if(null!=(e=n.sent()))return[3,2];return r=new ArrayBuffer(0),[3,4];case 2:return[4,e.getFile()];case 3:r=n.sent().arrayBuffer(),n.label=4;case 4:return[2,r]}})})()}},{key:"stream",value:function(){var t=this;return(0,ey._)(function(){var e;return(0,eB._)(this,function(r){switch(r.label){case 0:return[4,t.getOriginFile()];case 1:return[2,null==(e=r.sent())?new ReadableStream({pull:function(t){t.close()}}):e.stream()]}})})()}},{key:"getOriginFile",value:function(){var t=this;return(0,ey._)(function(){var e;return(0,eB._)(this,function(r){switch(r.label){case 0:return[4,e6(eK(t,S),{create:!1,isFile:!0})];case 1:return[2,null==(e=r.sent())?void 0:e.getFile()]}})})()}},{key:"getSize",value:function(){var t=this;return(0,ey._)(function(){var e,r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,e6(eK(t,S),{create:!1,isFile:!0})];case 1:if(null!=(e=n.sent()))return[3,2];return r=0,[3,4];case 2:return[4,e.getFile()];case 3:r=n.sent().size,n.label=4;case 4:return[2,r]}})})()}},{key:"exists",value:function(){var t=this;return(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,e6(eK(t,S),{create:!1,isFile:!0})];case 1:return[2,e.sent() instanceof FileSystemFileHandle]}})})()}},{key:"remove",value:function(){var t=this;return(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:if(eK(t,A))throw Error("exists unclosed reader/writer");return[4,e5(eK(t,S))];case 1:return e.sent(),[2]}})})()}},{key:"copyTo",value:function(e){var r=this;return(0,ey._)(function(){var n;return(0,eB._)(this,function(s){switch(s.label){case 0:return[4,r.exists()];case 1:if(!s.sent())throw Error("file ".concat(r.path," not exists"));if(!(e instanceof t))return[3,5];if(ri(e.path)!==r)return[3,2];return n=r,[3,4];case 2:return[4,rn(e.path,r)];case 3:s.sent(),n=ri(e.path),s.label=4;case 4:return[2,n];case 5:if(!(e instanceof re))return[3,7];return[4,r.copyTo(ri(e7(e.path,r.name)))];case 6:return[2,s.sent()];case 7:throw Error("Illegal target type")}})})()}},{key:"moveTo",value:function(t){var e=this;return(0,ey._)(function(){var r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,e.copyTo(t)];case 1:return r=n.sent(),[4,e.remove()];case 2:return[2,(n.sent(),r)]}})})()}}]),t}();S=/* @__PURE__ */new WeakMap,x=/* @__PURE__ */new WeakMap,E=/* @__PURE__ */new WeakMap,U=/* @__PURE__ */new WeakMap,T=/* @__PURE__ */new WeakMap,A=/* @__PURE__ */new WeakMap,I=/* @__PURE__ */new WeakMap,k=/* @__PURE__ */new WeakMap;var ru=ro,rl="/.opfs-tools-temp-dir";function rc(t){return rh.apply(this,arguments)}function rh(){return(rh=(0,ey._)(function(t){var e;return(0,eB._)(this,function(r){switch(r.label){case 0:if(r.trys.push([0,9,,10]),"file"!==t.kind)return[3,6];return[4,t.exists()];case 1:if(!r.sent())return[2,!0];return[4,t.createWriter()];case 2:return[4,(e=r.sent()).truncate(0)];case 3:return r.sent(),[4,e.close()];case 4:return r.sent(),[4,t.remove()];case 5:return r.sent(),[3,8];case 6:return[4,t.remove()];case 7:r.sent(),r.label=8;case 8:return[2,!0];case 9:return[2,(console.warn(r.sent()),!1)];case 10:return[2]}})})).apply(this,arguments)}var rf=[],rd=!1;function rp(){return(rp=(0,ey._)(function(){var t,e,r,n,s,a,o,u,l,c,h;return(0,eB._)(this,function(f){switch(f.label){case 0:if(null==globalThis.localStorage)return[2];t="OPFS_TOOLS_EXPIRES_TMP_FILES",rd||(rd=!0,globalThis.addEventListener("unload",function(){var e;0!==rf.length&&localStorage.setItem(t,"".concat(null!==(e=localStorage.getItem(t))&&void 0!==e?e:"",",").concat(rf.join(",")))})),r=null!==(e=localStorage.getItem(t))&&void 0!==e?e:"",n=!0,s=!1,a=void 0,f.label=1;case 1:f.trys.push([1,7,8,9]),o=r.split(",")[Symbol.iterator](),f.label=2;case 2:if(n=(u=o.next()).done)return[3,6];if(!(c=0!==(l=u.value).length))return[3,4];return[4,rc(ri("".concat(rl,"/").concat(l)))];case 3:c=f.sent(),f.label=4;case 4:c&&(r=r.replace(l,"")),f.label=5;case 5:return n=!0,[3,2];case 6:return[3,9];case 7:return h=f.sent(),s=!0,a=h,[3,9];case 8:try{n||null==o.return||o.return()}finally{if(s)throw a}return[7];case 9:return localStorage.setItem(t,r.replace(/,{2,}/g,",")),[2]}})})).apply(this,arguments)}function rm(){var t="".concat(Math.random().toString().slice(2),"-").concat(Date.now());return rf.push(t),ri("".concat(rl,"/").concat(t))}(0,ey._)(function(){var t,e;return(0,eB._)(this,function(e){switch(e.label){case 0:if(!(!0!==globalThis.__opfs_tools_tmpfile_init__))return[3,3];if(globalThis.__opfs_tools_tmpfile_init__=!0,null==globalThis.FileSystemDirectoryHandle||null==globalThis.FileSystemFileHandle||(null==(t=globalThis.navigator)?void 0:t.storage.getDirectory)==null)return[3,2];return setInterval(/*#__PURE__*/(0,ey._)(function(){var t,e,r,n,s,a,o,u;return(0,eB._)(this,function(l){switch(l.label){case 0:t=!0,e=!1,r=void 0,l.label=1;case 1:return l.trys.push([1,8,9,10]),[4,rt(rl).children()];case 2:n=l.sent()[Symbol.iterator](),l.label=3;case 3:if(t=(s=n.next()).done)return[3,7];if(a=s.value,!(null==(o=/^\d+-(\d+)$/.exec(a.name))||Date.now()-Number(o[1])>2592e5))return[3,5];return[4,rc(a)];case 4:l.sent(),l.label=5;case 5:l.label=6;case 6:return t=!0,[3,3];case 7:return[3,10];case 8:return u=l.sent(),e=!0,r=u,[3,10];case 9:try{t||null==n.return||n.return()}finally{if(e)throw r}return[7];case 10:return[2]}})}),6e4),[4,function(){return rp.apply(this,arguments)}()];case 1:e.sent(),e.label=2;case 2:e.label=3;case 3:return[2]}})})();var r_=1,ry=rm(),rg=null,rv=["debug","info","warn","error"].reduce(function(t,e,r){return Object.assign(t,(0,eb._)({},e,function(){for(var t,n,s=arguments.length,a=Array(s),o=0;o<s;o++)a[o]=arguments[o];r_<=r&&((n=console)[e].apply(n,(0,eI._)(a)),null==rg||rg.write("[".concat(e,"][").concat((t=/* @__PURE__ */new Date,"".concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds(),".").concat(t.getMilliseconds())),"] ").concat(a.map(function(t){return t instanceof Error?String(t):"object"==typeof t?JSON.stringify(t,function(t,e){return e instanceof Error?String(e):e}):String(t)}).join(" "),"\n")))}))},{}),rb=/* @__PURE__ */new Map,rw=(0,eU._)((0,eE._)({setLogLevel:function(t){var e;r_=null!==(e=rb.get(t))&&void 0!==e?e:1}},rv),{create:function(t){return Object.fromEntries(Object.entries(rv).map(function(e){var r=(0,eA._)(e,2),n=r[0],s=r[1];return[n,function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return s.apply(void 0,[t].concat((0,eI._)(r)))}]}))},dump:function(){return(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:return[4,rx];case 1:return t.sent(),[4,null==rg?void 0:rg.flush()];case 2:return t.sent(),[4,ry.text()];case 3:return[2,t.sent()]}})})()}});function rS(){return(rS=(0,ey._)(function(){var t;return(0,eB._)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,ry.createWriter()];case 1:return rg=e.sent(),rw.info(navigator.userAgent),rw.info("date: "+/* @__PURE__ */new Date().toLocaleDateString()),[3,3];case 2:if(!((t=e.sent())instanceof Error))throw t;if(t.message.includes("createSyncAccessHandle is not a function"))console.warn(t);else throw t;return[3,3];case 3:return[2]}})})).apply(this,arguments)}rb.set(rw.debug,0),rb.set(rw.info,1),rb.set(rw.warn,2),rb.set(rw.error,3);var rx=null==globalThis.navigator?null:function(){return rS.apply(this,arguments)}(),rE=/* @__PURE__ */new Map,rU=1,rT=null;null!=globalThis.Worker&&(n=new Blob(["(".concat((function(){var t;self.onmessage=function(e){"start"===e.data.event&&(self.clearInterval(t),t=self.setInterval(function(){self.postMessage({})},16.6)),"stop"===e.data.event&&self.clearInterval(t)}}).toString(),")()")]),(rT=new Worker(URL.createObjectURL(n))).onmessage=function(){rU+=1;var t=!0,e=!1,r=void 0,n=!0,s=!1,a=void 0;try{for(var o,u=rE[Symbol.iterator]();!(n=(o=u.next()).done);n=!0){var l=(0,eA._)(o.value,2),c=l[0],h=l[1];if(rU%c==0)try{for(var f,d=h[Symbol.iterator]();!(t=(f=d.next()).done);t=!0)(0,f.value)()}catch(t){e=!0,r=t}finally{try{t||null==d.return||d.return()}finally{if(e)throw r}}}}catch(t){s=!0,a=t}finally{try{n||null==u.return||u.return()}finally{if(s)throw a}}});var rA=function(t,e){var r,n=Math.round(e/16.6),s=null!==(r=rE.get(n))&&void 0!==r?r:/* @__PURE__ */new Set;return s.add(t),rE.set(n,s),1===rE.size&&1===s.size&&(null==rT||rT.postMessage({event:"start"})),function(){s.delete(t),0===s.size&&rE.delete(n),0===rE.size&&(rU=0,null==rT||rT.postMessage({event:"stop"}))}},rI=/*#__PURE__*/function(){function t(e,r,n){var s;(0,eg._)(this,t),this.length_=e,this.scaleFactor_=(e-1)/r,this.interpolate=this.cubic,"point"===n.method?this.interpolate=this.point:"linear"===n.method?this.interpolate=this.linear:"sinc"===n.method&&(this.interpolate=this.sinc),this.tangentFactor_=1-Math.max(0,Math.min(1,n.tension||0)),this.sincFilterSize_=n.sincFilterSize||1,this.kernel_=(s=n.sincWindow||rk,function(t){return(0===t?1:Math.sin(Math.PI*t)/(Math.PI*t))*s(t)})}return(0,ev._)(t,[{key:"point",value:function(t,e){return this.getClippedInput_(Math.round(this.scaleFactor_*t),e)}},{key:"linear",value:function(t,e){var r=Math.floor(t=this.scaleFactor_*t);return(1-(t-=r))*this.getClippedInput_(r,e)+t*this.getClippedInput_(r+1,e)}},{key:"cubic",value:function(t,e){var r=Math.floor(t=this.scaleFactor_*t),n=[this.getTangent_(r,e),this.getTangent_(r+1,e)],s=[this.getClippedInput_(r,e),this.getClippedInput_(r+1,e)],a=(t-=r)*t,o=t*a;return(2*o-3*a+1)*s[0]+(o-2*a+t)*n[0]+(-2*o+3*a)*s[1]+(o-a)*n[1]}},{key:"sinc",value:function(t,e){for(var r=Math.floor(t=this.scaleFactor_*t),n=r-this.sincFilterSize_+1,s=r+this.sincFilterSize_,a=0,o=n;o<=s;o++)a+=this.kernel_(t-o)*this.getClippedInput_(o,e);return a}},{key:"getTangent_",value:function(t,e){return this.tangentFactor_*(this.getClippedInput_(t+1,e)-this.getClippedInput_(t-1,e))/2}},{key:"getClippedInput_",value:function(t,e){return 0<=t&&t<this.length_?e[t]:0}}]),t}();function rk(t){return Math.exp(-t/2*t/2)}var rC=/*#__PURE__*/function(){function t(e,r,n){(0,eg._)(this,t);var s=2*Math.PI*n/r,a=0;this.filters=[];for(var o=0;o<=e;o++)o-e/2==0?this.filters[o]=s:(this.filters[o]=Math.sin(s*(o-e/2))/(o-e/2),this.filters[o]*=.54-.46*Math.cos(2*Math.PI*o/e)),a+=this.filters[o];for(var u=0;u<=e;u++)this.filters[u]/=a;this.z=this.initZ_()}return(0,ev._)(t,[{key:"filter",value:function(t){this.z.buf[this.z.pointer]=t;for(var e=0,r=0,n=this.z.buf.length;r<n;r++)e+=this.filters[r]*this.z.buf[(this.z.pointer+r)%this.z.buf.length];return this.z.pointer=(this.z.pointer+1)%this.z.buf.length,e}},{key:"reset",value:function(){this.z=this.initZ_()}},{key:"initZ_",value:function(){for(var t=[],e=0;e<this.filters.length-1;e++)t.push(0);return{buf:t,pointer:0}}}]),t}(),rB=/*#__PURE__*/function(){function t(e,r,n){(0,eg._)(this,t);for(var s=[],a=0;a<e;a++)s.push(this.getCoeffs_({Fs:r,Fc:n,Q:.5/Math.sin(Math.PI/(2*e)*(a+.5))}));this.stages=[];for(var o=0;o<s.length;o++)this.stages[o]={b0:s[o].b[0],b1:s[o].b[1],b2:s[o].b[2],a1:s[o].a[0],a2:s[o].a[1],k:s[o].k,z:[0,0]}}return(0,ev._)(t,[{key:"filter",value:function(t){for(var e=t,r=0,n=this.stages.length;r<n;r++)e=this.runStage_(r,e);return e}},{key:"getCoeffs_",value:function(t){var e={};e.z=[0,0],e.a=[],e.b=[];var r=this.preCalc_(t,e);return e.k=1,e.b.push((1-r.cw)/(2*r.a0)),e.b.push(2*e.b[0]),e.b.push(e.b[0]),e}},{key:"preCalc_",value:function(t,e){var r={},n=2*Math.PI*t.Fc/t.Fs;return r.alpha=Math.sin(n)/(2*t.Q),r.cw=Math.cos(n),r.a0=1+r.alpha,e.a0=r.a0,e.a.push(-2*r.cw/r.a0),e.k=1,e.a.push((1-r.alpha)/r.a0),r}},{key:"runStage_",value:function(t,e){var r=e*this.stages[t].k-this.stages[t].a1*this.stages[t].z[0]-this.stages[t].a2*this.stages[t].z[1],n=this.stages[t].b0*r+this.stages[t].b1*this.stages[t].z[0]+this.stages[t].b2*this.stages[t].z[1];return this.stages[t].z[1]=this.stages[t].z[0],this.stages[t].z[0]=r,n}},{key:"reset",value:function(){for(var t=0;t<this.stages.length;t++)this.stages[t].z=[0,0]}}]),t}(),rP={point:!1,linear:!1,cubic:!0,sinc:!0},rR={IIR:16,FIR:71},rF={IIR:rB,FIR:rC};function rD(t,e,r){for(var n=0,s=e.length;n<s;n++)e[n]=r.interpolate(n,t)}function rz(t){var e=new Float32Array(t.map(function(t){return t.length}).reduce(function(t,e){return t+e})),r=0,n=!0,s=!1,a=void 0;try{for(var o,u=t[Symbol.iterator]();!(n=(o=u.next()).done);n=!0){var l=o.value;e.set(l,r),r+=l.length}}catch(t){s=!0,a=t}finally{try{n||null==u.return||u.return()}finally{if(s)throw a}}return e}function rL(t){for(var e=[],r=0;r<t.length;r+=1)for(var n=0;n<t[r].length;n+=1)null==e[n]&&(e[n]=[]),e[n].push(t[r][n]);return e.map(rz)}function rO(t){if("f32-planar"===t.format){for(var e=[],r=0;r<t.numberOfChannels;r+=1){var n=new ArrayBuffer(t.allocationSize({planeIndex:r}));t.copyTo(n,{planeIndex:r}),e.push(new Float32Array(n))}return e}if("s16"===t.format){var s=new ArrayBuffer(t.allocationSize({planeIndex:0}));return t.copyTo(s,{planeIndex:0}),function(t,e){for(var r=t.length/e,n=Array.from({length:e},function(){return new Float32Array(r)}),s=0;s<r;s++)for(var a=0;a<e;a++){var o=t[s*e+a];n[a][s]=o/32768}return n}(new Int16Array(s),t.numberOfChannels)}throw Error("Unsupported audio data format")}function rM(t){return Array(t.numberOfChannels).fill(0).map(function(e,r){return t.getChannelData(r)})}function rN(t,e){var r=new Float32Array(rz(rO(t))).map(function(t){return t*e}),n=new AudioData({sampleRate:t.sampleRate,numberOfChannels:t.numberOfChannels,timestamp:t.timestamp,format:t.format,numberOfFrames:t.numberOfFrames,data:r});return t.close(),n}function rj(t,e){return rG.apply(this,arguments)}function rG(){return(rG=(0,ey._)(function(t,e){var r,n,s,a,o,u,l;return(0,eB._)(this,function(c){switch(c.label){case 0:return[4,Promise.all([(n=new ImageDecoder({type:e,data:t})).completed,n.tracks.ready])];case 1:c.sent(),a=null!==(s=null==(r=n.tracks.selectedTrack)?void 0:r.frameCount)&&void 0!==s?s:1,o=[],u=0,c.label=2;case 2:if(!(u<a))return[3,5];return l=o.push,[4,n.decode({frameIndex:u})];case 3:l.apply(o,[c.sent().image]),c.label=4;case 4:return u+=1,[3,2];case 5:return[2,o]}})})).apply(this,arguments)}function rY(t){for(var e=(u=Math).max.apply(u,(0,eI._)(t.map(function(t){var e,r;return null!==(r=null==(e=t[0])?void 0:e.length)&&void 0!==r?r:0}))),r=new Float32Array(2*e),n=0;n<e;n++){for(var s=0,a=0,o=0;o<t.length;o++){var u,l,c,h,f,d=null!==(h=null==(l=t[o][0])?void 0:l[n])&&void 0!==h?h:0,p=null!==(f=null==(c=t[o][1])?void 0:c[n])&&void 0!==f?f:d;s+=d,a+=p}r[n]=s,r[n+e]=a}return r}function rW(t,e,r){return rV.apply(this,arguments)}function rV(){return(rV=(0,ey._)(function(t,e,r){var n,s,a,o,u,l,c;return(0,eB._)(this,function(h){switch(h.label){case 0:if(s=t.length,a=Array(r.chanCount).fill(0).map(function(){return new Float32Array(0)}),0===s||0===(o=(n=Math).max.apply(n,(0,eI._)(t.map(function(t){return t.length})))))return[2,a];if(null==globalThis.OfflineAudioContext)return[2,t.map(function(t){return new Float32Array(function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=(r-e)/e+1,a=new Float64Array(t.length*s);n.method=n.method||"cubic";var o=new rI(t.length,a.length,{method:n.method,tension:n.tension||0,sincFilterSize:n.sincFilterSize||6,sincWindow:n.sincWindow||void 0});if(void 0===n.LPF&&(n.LPF=rP[n.method]),n.LPF){n.LPFType=n.LPFType||"IIR";var u=rF[n.LPFType];r>e?function(t,e,r,n){for(var s=0,a=e.length;s<a;s++)e[s]=n.filter(r.interpolate(s,t));n.reset();for(var o=e.length-1;o>=0;o--)e[o]=n.filter(e[o])}(t,a,o,new u(n.LPFOrder||rR[n.LPFType],r,e/2)):function(t,e,r,n){for(var s=0,a=t.length;s<a;s++)t[s]=n.filter(t[s]);n.reset();for(var o=t.length-1;o>=0;o--)t[o]=n.filter(t[o]);rD(t,e,r)}(t,a,o,new u(n.LPFOrder||rR[n.LPFType],e,r/2))}else rD(t,a,o);return a}(t,e,r.rate,{method:"sinc",LPF:!1}))})];return l=(u=new globalThis.OfflineAudioContext(r.chanCount,o*r.rate/e,r.rate)).createBufferSource(),c=u.createBuffer(s,o,e),t.forEach(function(t,e){return c.copyToChannel(t,e)}),l.buffer=c,l.connect(u.destination),l.start(),[4,u.startRendering()];case 1:return[2,rM.apply(void 0,[h.sent()])]}})})).apply(this,arguments)}function rH(t){return new Promise(function(e){var r=rA(function(){r(),e()},t)})}function rX(t,e,r){for(var n=r-e,s=new Float32Array(n),a=0;a<n;)s[a]=t[(e+a)%t.length],a+=1;return s}function rZ(t,e){var r=!1;function n(){return(n=(0,ey._)(function(){var n,s,a;return(0,eB._)(this,function(o){switch(o.label){case 0:n=t.getReader(),o.label=1;case 1:if(r)return[3,5];return[4,n.read()];case 2:if(a=(s=o.sent()).value,s.done)return e.onDone(),[2];return[4,e.onChunk(a)];case 3:o.sent(),o.label=4;case 4:return[3,1];case 5:return n.releaseLock(),[4,t.cancel()];case 6:return o.sent(),[2]}})})).apply(this,arguments)}return(function(){return n.apply(this,arguments)})().catch(rw.error),function(){r=!0}}var rK=("undefined"==typeof globalThis?"undefined":(0,ek._)(globalThis))<"u"?globalThis:("undefined"==typeof window?"undefined":(0,ek._)(window))<"u"?window:(void 0===eR?"undefined":(0,ek._)(eR))<"u"?eR:("undefined"==typeof self?"undefined":(0,ek._)(self))<"u"?self:{};function rq(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rQ={};(s=/* @__PURE__ */new Date,a=4,o={setLogLevel:function(t){t==this.debug?a=1:t==this.info?a=2:t==this.warn?a=3:(this.error,a=4)},debug:function(t,e){void 0===console.debug&&(console.debug=console.log),1>=a&&console.debug("["+o.getDurationString(/* @__PURE__ */new Date-s,1e3)+"]","["+t+"]",e)},log:function(t,e){this.debug(t.msg)},info:function(t,e){2>=a&&console.info("["+o.getDurationString(/* @__PURE__ */new Date-s,1e3)+"]","["+t+"]",e)},warn:function(t,e){3>=a&&console.warn("["+o.getDurationString(/* @__PURE__ */new Date-s,1e3)+"]","["+t+"]",e)},error:function(t,e){4>=a&&console.error("["+o.getDurationString(/* @__PURE__ */new Date-s,1e3)+"]","["+t+"]",e)}}).getDurationString=function(t,e){function r(t,e){for(var r=(""+t).split(".");r[0].length<e;)r[0]="0"+r[0];return r.join(".")}t<0?(n=!0,t=-t):n=!1;var n,s=t/(e||1),a=Math.floor(s/3600),o=Math.floor((s-=3600*a)/60),u=1e3*(s-=60*o);return u-=1e3*(s=Math.floor(s)),u=Math.floor(u),(n?"-":"")+a+":"+r(o,2)+":"+r(s,2)+"."+r(u,3)},o.printRanges=function(t){var e=t.length;if(!(e>0))return"(empty)";for(var r="",n=0;n<e;n++)n>0&&(r+=","),r+="["+o.getDurationString(t.start(n))+","+o.getDurationString(t.end(n))+"]";return r},rQ.Log=o,(u=function(t){if(t instanceof ArrayBuffer)this.buffer=t,this.dataview=new DataView(t);else throw"Needs an array buffer";this.position=0}).prototype.getPosition=function(){return this.position},u.prototype.getEndPosition=function(){return this.buffer.byteLength},u.prototype.getLength=function(){return this.buffer.byteLength},u.prototype.seek=function(t){var e=Math.max(0,Math.min(this.buffer.byteLength,t));return this.position=isNaN(e)||!isFinite(e)?0:e,!0},u.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},u.prototype.readAnyInt=function(t,e){var r=0;if(this.position+t<=this.buffer.byteLength){switch(t){case 1:r=e?this.dataview.getInt8(this.position):this.dataview.getUint8(this.position);break;case 2:r=e?this.dataview.getInt16(this.position):this.dataview.getUint16(this.position);break;case 3:if(e)throw"No method for reading signed 24 bits values";r=this.dataview.getUint8(this.position)<<16|this.dataview.getUint8(this.position+1)<<8|this.dataview.getUint8(this.position+2);break;case 4:r=e?this.dataview.getInt32(this.position):this.dataview.getUint32(this.position);break;case 8:if(e)throw"No method for reading signed 64 bits values";r=this.dataview.getUint32(this.position)<<32|this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+t}return this.position+=t,r}throw"Not enough bytes in buffer"},u.prototype.readUint8=function(){return this.readAnyInt(1,!1)},u.prototype.readUint16=function(){return this.readAnyInt(2,!1)},u.prototype.readUint24=function(){return this.readAnyInt(3,!1)},u.prototype.readUint32=function(){return this.readAnyInt(4,!1)},u.prototype.readUint64=function(){return this.readAnyInt(8,!1)},u.prototype.readString=function(t){if(this.position+t<=this.buffer.byteLength){for(var e="",r=0;r<t;r++)e+=String.fromCharCode(this.readUint8());return e}throw"Not enough bytes in buffer"},u.prototype.readCString=function(){for(var t=[];;){var e=this.readUint8();if(0!==e)t.push(e);else break}return String.fromCharCode.apply(null,t)},u.prototype.readInt8=function(){return this.readAnyInt(1,!0)},u.prototype.readInt16=function(){return this.readAnyInt(2,!0)},u.prototype.readInt32=function(){return this.readAnyInt(4,!0)},u.prototype.readInt64=function(){return this.readAnyInt(8,!1)},u.prototype.readUint8Array=function(t){for(var e=new Uint8Array(t),r=0;r<t;r++)e[r]=this.readUint8();return e},u.prototype.readInt16Array=function(t){for(var e=new Int16Array(t),r=0;r<t;r++)e[r]=this.readInt16();return e},u.prototype.readUint16Array=function(t){for(var e=new Int16Array(t),r=0;r<t;r++)e[r]=this.readUint16();return e},u.prototype.readUint32Array=function(t){for(var e=new Uint32Array(t),r=0;r<t;r++)e[r]=this.readUint32();return e},u.prototype.readInt32Array=function(t){for(var e=new Int32Array(t),r=0;r<t;r++)e[r]=this.readInt32();return e},rQ.MP4BoxStream=u,(l=function(t,e,r){this._byteOffset=e||0,t instanceof ArrayBuffer?this.buffer=t:"object"==typeof t?(this.dataView=t,e&&(this._byteOffset+=e)):this.buffer=new ArrayBuffer(t||0),this.position=0,this.endianness=null!=r?r:l.LITTLE_ENDIAN}).prototype={},l.prototype.getPosition=function(){return this.position},l.prototype._realloc=function(t){if(this._dynamicSize){var e=this._byteOffset+this.position+t,r=this._buffer.byteLength;if(e<=r){e>this._byteLength&&(this._byteLength=e);return}for(r<1&&(r=1);e>r;)r*=2;var n=new ArrayBuffer(r),s=new Uint8Array(this._buffer);new Uint8Array(n,0,s.length).set(s),this.buffer=n,this._byteLength=e}},l.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var t=new ArrayBuffer(this._byteLength),e=new Uint8Array(t),r=new Uint8Array(this._buffer,0,e.length);e.set(r),this.buffer=t}},l.BIG_ENDIAN=!1,l.LITTLE_ENDIAN=!0,l.prototype._byteLength=0,Object.defineProperty(l.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(l.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(t){this._buffer=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(l.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(t){this._byteOffset=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(l.prototype,"dataView",{get:function(){return this._dataView},set:function(t){this._byteOffset=t.byteOffset,this._buffer=t.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+t.byteLength}}),l.prototype.seek=function(t){var e=Math.max(0,Math.min(this.byteLength,t));this.position=isNaN(e)||!isFinite(e)?0:e},l.prototype.isEof=function(){return this.position>=this._byteLength},l.prototype.mapUint8Array=function(t){this._realloc(1*t);var e=new Uint8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=1*t,e},l.prototype.readInt32Array=function(t,e){var r=new Int32Array(t=null!=t?t:this.byteLength-this.position/4);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,t*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null!=e?e:this.endianness),this.position+=r.byteLength,r},l.prototype.readInt16Array=function(t,e){var r=new Int16Array(t=null!=t?t:this.byteLength-this.position/2);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,t*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null!=e?e:this.endianness),this.position+=r.byteLength,r},l.prototype.readInt8Array=function(t){var e=new Int8Array(t=null!=t?t:this.byteLength-this.position);return l.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e},l.prototype.readUint32Array=function(t,e){var r=new Uint32Array(t=null!=t?t:this.byteLength-this.position/4);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,t*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null!=e?e:this.endianness),this.position+=r.byteLength,r},l.prototype.readUint16Array=function(t,e){var r=new Uint16Array(t=null!=t?t:this.byteLength-this.position/2);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,t*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null!=e?e:this.endianness),this.position+=r.byteLength,r},l.prototype.readUint8Array=function(t){var e=new Uint8Array(t=null!=t?t:this.byteLength-this.position);return l.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e},l.prototype.readFloat64Array=function(t,e){var r=new Float64Array(t=null!=t?t:this.byteLength-this.position/8);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,t*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null!=e?e:this.endianness),this.position+=r.byteLength,r},l.prototype.readFloat32Array=function(t,e){var r=new Float32Array(t=null!=t?t:this.byteLength-this.position/4);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,t*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null!=e?e:this.endianness),this.position+=r.byteLength,r},l.prototype.readInt32=function(t){var e=this._dataView.getInt32(this.position,null!=t?t:this.endianness);return this.position+=4,e},l.prototype.readInt16=function(t){var e=this._dataView.getInt16(this.position,null!=t?t:this.endianness);return this.position+=2,e},l.prototype.readInt8=function(){var t=this._dataView.getInt8(this.position);return this.position+=1,t},l.prototype.readUint32=function(t){var e=this._dataView.getUint32(this.position,null!=t?t:this.endianness);return this.position+=4,e},l.prototype.readUint16=function(t){var e=this._dataView.getUint16(this.position,null!=t?t:this.endianness);return this.position+=2,e},l.prototype.readUint8=function(){var t=this._dataView.getUint8(this.position);return this.position+=1,t},l.prototype.readFloat32=function(t){var e=this._dataView.getFloat32(this.position,null!=t?t:this.endianness);return this.position+=4,e},l.prototype.readFloat64=function(t){var e=this._dataView.getFloat64(this.position,null!=t?t:this.endianness);return this.position+=8,e},l.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,l.memcpy=function(t,e,r,n,s){var a=new Uint8Array(t,e,s),o=new Uint8Array(r,n,s);a.set(o)},l.arrayToNative=function(t,e){return e==this.endianness?t:this.flipArrayEndianness(t)},l.nativeToEndian=function(t,e){return this.endianness==e?t:this.flipArrayEndianness(t)},l.flipArrayEndianness=function(t){for(var e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=0;r<t.byteLength;r+=t.BYTES_PER_ELEMENT)for(var n=r+t.BYTES_PER_ELEMENT-1,s=r;n>s;n--,s++){var a=e[s];e[s]=e[n],e[n]=a}return t},l.prototype.failurePosition=0,String.fromCharCodeUint8=function(t){for(var e=[],r=0;r<t.length;r++)e[r]=t[r];return String.fromCharCode.apply(null,e)},l.prototype.readString=function(t,e){return null==e||"ASCII"==e?String.fromCharCodeUint8.apply(null,[this.mapUint8Array(null!=t?t:this.byteLength-this.position)]):new TextDecoder(e).decode(this.mapUint8Array(t))},l.prototype.readCString=function(t){var e=this.byteLength-this.position,r=new Uint8Array(this._buffer,this._byteOffset+this.position),n=e;null!=t&&(n=Math.min(t,e));for(var s=0;s<n&&0!==r[s];s++);var a=String.fromCharCodeUint8.apply(null,[this.mapUint8Array(s)]);return null!=t?this.position+=n-s:s!=e&&(this.position+=1),a},l.prototype.readInt64=function(){return 4294967296*this.readInt32()+this.readUint32()},l.prototype.readUint64=function(){return 4294967296*this.readUint32()+this.readUint32()},l.prototype.readInt64=function(){return 4294967296*this.readUint32()+this.readUint32()},l.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()},rQ.DataStream=l,l.prototype.save=function(t){var e=new Blob([this.buffer]);if(window.URL&&URL.createObjectURL){var r=window.URL.createObjectURL(e),n=document.createElement("a");document.body.appendChild(n),n.setAttribute("href",r),n.setAttribute("download",t),n.setAttribute("target","_self"),n.click(),window.URL.revokeObjectURL(r)}else throw"DataStream.save: Can't create object URL."},l.prototype._dynamicSize=!0,Object.defineProperty(l.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(t){t||this._trimAlloc(),this._dynamicSize=t}}),l.prototype.shift=function(t){var e=new ArrayBuffer(this._byteLength-t),r=new Uint8Array(e),n=new Uint8Array(this._buffer,t,r.length);r.set(n),this.buffer=e,this.position-=t},l.prototype.writeInt32Array=function(t,e){if(this._realloc(4*t.length),t instanceof Int32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt32Array(t.length,e);else for(var r=0;r<t.length;r++)this.writeInt32(t[r],e)},l.prototype.writeInt16Array=function(t,e){if(this._realloc(2*t.length),t instanceof Int16Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt16Array(t.length,e);else for(var r=0;r<t.length;r++)this.writeInt16(t[r],e)},l.prototype.writeInt8Array=function(t){if(this._realloc(1*t.length),t instanceof Int8Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt8Array(t.length);else for(var e=0;e<t.length;e++)this.writeInt8(t[e])},l.prototype.writeUint32Array=function(t,e){if(this._realloc(4*t.length),t instanceof Uint32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint32Array(t.length,e);else for(var r=0;r<t.length;r++)this.writeUint32(t[r],e)},l.prototype.writeUint16Array=function(t,e){if(this._realloc(2*t.length),t instanceof Uint16Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint16Array(t.length,e);else for(var r=0;r<t.length;r++)this.writeUint16(t[r],e)},l.prototype.writeUint8Array=function(t){if(this._realloc(1*t.length),t instanceof Uint8Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint8Array(t.length);else for(var e=0;e<t.length;e++)this.writeUint8(t[e])},l.prototype.writeFloat64Array=function(t,e){if(this._realloc(8*t.length),t instanceof Float64Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapFloat64Array(t.length,e);else for(var r=0;r<t.length;r++)this.writeFloat64(t[r],e)},l.prototype.writeFloat32Array=function(t,e){if(this._realloc(4*t.length),t instanceof Float32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapFloat32Array(t.length,e);else for(var r=0;r<t.length;r++)this.writeFloat32(t[r],e)},l.prototype.writeInt32=function(t,e){this._realloc(4),this._dataView.setInt32(this.position,t,null!=e?e:this.endianness),this.position+=4},l.prototype.writeInt16=function(t,e){this._realloc(2),this._dataView.setInt16(this.position,t,null!=e?e:this.endianness),this.position+=2},l.prototype.writeInt8=function(t){this._realloc(1),this._dataView.setInt8(this.position,t),this.position+=1},l.prototype.writeUint32=function(t,e){this._realloc(4),this._dataView.setUint32(this.position,t,null!=e?e:this.endianness),this.position+=4},l.prototype.writeUint16=function(t,e){this._realloc(2),this._dataView.setUint16(this.position,t,null!=e?e:this.endianness),this.position+=2},l.prototype.writeUint8=function(t){this._realloc(1),this._dataView.setUint8(this.position,t),this.position+=1},l.prototype.writeFloat32=function(t,e){this._realloc(4),this._dataView.setFloat32(this.position,t,null!=e?e:this.endianness),this.position+=4},l.prototype.writeFloat64=function(t,e){this._realloc(8),this._dataView.setFloat64(this.position,t,null!=e?e:this.endianness),this.position+=8},l.prototype.writeUCS2String=function(t,e,r){null==r&&(r=t.length);for(var n=0;n<t.length&&n<r;n++)this.writeUint16(t.charCodeAt(n),e);for(;n<r;n++)this.writeUint16(0)},l.prototype.writeString=function(t,e,r){var n=0;if(null==e||"ASCII"==e){if(null!=r){var s=Math.min(t.length,r);for(n=0;n<s;n++)this.writeUint8(t.charCodeAt(n));for(;n<r;n++)this.writeUint8(0)}else for(n=0;n<t.length;n++)this.writeUint8(t.charCodeAt(n))}else this.writeUint8Array(new TextEncoder(e).encode(t.substring(0,r)))},l.prototype.writeCString=function(t,e){var r=0;if(null!=e){var n=Math.min(t.length,e);for(r=0;r<n;r++)this.writeUint8(t.charCodeAt(r));for(;r<e;r++)this.writeUint8(0)}else{for(r=0;r<t.length;r++)this.writeUint8(t.charCodeAt(r));this.writeUint8(0)}},l.prototype.writeStruct=function(t,e){for(var r=0;r<t.length;r+=2){var n=t[r+1];this.writeType(n,e[t[r]],e)}},l.prototype.writeType=function(t,e,r){if("function"==typeof t)return t(this,e);if("object"==typeof t&&!(t instanceof Array))return t.set(this,e,r);var n,s=null,a="ASCII",o=this.position;switch("string"==typeof t&&/:/.test(t)&&(t=(n=t.split(":"))[0],s=parseInt(n[1])),"string"==typeof t&&/,/.test(t)&&(t=(n=t.split(","))[0],a=parseInt(n[1])),t){case"uint8":this.writeUint8(e);break;case"int8":this.writeInt8(e);break;case"uint16":this.writeUint16(e,this.endianness);break;case"int16":this.writeInt16(e,this.endianness);break;case"uint32":this.writeUint32(e,this.endianness);break;case"int32":this.writeInt32(e,this.endianness);break;case"float32":this.writeFloat32(e,this.endianness);break;case"float64":this.writeFloat64(e,this.endianness);break;case"uint16be":this.writeUint16(e,l.BIG_ENDIAN);break;case"int16be":this.writeInt16(e,l.BIG_ENDIAN);break;case"uint32be":this.writeUint32(e,l.BIG_ENDIAN);break;case"int32be":this.writeInt32(e,l.BIG_ENDIAN);break;case"float32be":this.writeFloat32(e,l.BIG_ENDIAN);break;case"float64be":this.writeFloat64(e,l.BIG_ENDIAN);break;case"uint16le":this.writeUint16(e,l.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(e,l.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(e,l.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(e,l.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(e,l.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(e,l.LITTLE_ENDIAN);break;case"cstring":this.writeCString(e,s);break;case"string":this.writeString(e,a,s);break;case"u16string":this.writeUCS2String(e,this.endianness,s);break;case"u16stringle":this.writeUCS2String(e,l.LITTLE_ENDIAN,s);break;case"u16stringbe":this.writeUCS2String(e,l.BIG_ENDIAN,s);break;default:if(3==t.length){for(var u=t[1],c=0;c<e.length;c++)this.writeType(u,e[c]);break}this.writeStruct(t,e)}null!=s&&(this.position=o,this._realloc(s),this.position=o+s)},l.prototype.writeUint64=function(t){var e=Math.floor(t/4294967296);this.writeUint32(e),this.writeUint32(4294967295&t)},l.prototype.writeUint24=function(t){this.writeUint8((16711680&t)>>16),this.writeUint8((65280&t)>>8),this.writeUint8(255&t)},l.prototype.adjustUint32=function(t,e){var r=this.position;this.seek(t),this.writeUint32(e),this.seek(r)},l.prototype.mapInt32Array=function(t,e){this._realloc(4*t);var r=new Int32Array(this._buffer,this.byteOffset+this.position,t);return l.arrayToNative(r,null!=e?e:this.endianness),this.position+=4*t,r},l.prototype.mapInt16Array=function(t,e){this._realloc(2*t);var r=new Int16Array(this._buffer,this.byteOffset+this.position,t);return l.arrayToNative(r,null!=e?e:this.endianness),this.position+=2*t,r},l.prototype.mapInt8Array=function(t){this._realloc(1*t);var e=new Int8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=1*t,e},l.prototype.mapUint32Array=function(t,e){this._realloc(4*t);var r=new Uint32Array(this._buffer,this.byteOffset+this.position,t);return l.arrayToNative(r,null!=e?e:this.endianness),this.position+=4*t,r},l.prototype.mapUint16Array=function(t,e){this._realloc(2*t);var r=new Uint16Array(this._buffer,this.byteOffset+this.position,t);return l.arrayToNative(r,null!=e?e:this.endianness),this.position+=2*t,r},l.prototype.mapFloat64Array=function(t,e){this._realloc(8*t);var r=new Float64Array(this._buffer,this.byteOffset+this.position,t);return l.arrayToNative(r,null!=e?e:this.endianness),this.position+=8*t,r},l.prototype.mapFloat32Array=function(t,e){this._realloc(4*t);var r=new Float32Array(this._buffer,this.byteOffset+this.position,t);return l.arrayToNative(r,null!=e?e:this.endianness),this.position+=4*t,r},(c=function(t){this.buffers=[],this.bufferIndex=-1,t&&(this.insertBuffer(t),this.bufferIndex=0)}).prototype=new l(new ArrayBuffer,0,l.BIG_ENDIAN),c.prototype.initialized=function(){var t;return this.bufferIndex>-1||(this.buffers.length>0?0===(t=this.buffers[0]).fileStart?(this.buffer=t,this.bufferIndex=0,o.debug("MultiBufferStream","Stream ready for parsing"),!0):(o.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1):(o.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1))},ArrayBuffer.concat=function(t,e){o.debug("ArrayBuffer","Trying to create a new buffer of size: "+(t.byteLength+e.byteLength));var r=new Uint8Array(t.byteLength+e.byteLength);return r.set(new Uint8Array(t),0),r.set(new Uint8Array(e),t.byteLength),r.buffer},c.prototype.reduceBuffer=function(t,e,r){var n;return(n=new Uint8Array(r)).set(new Uint8Array(t,e,r)),n.buffer.fileStart=t.fileStart+e,n.buffer.usedBytes=0,n.buffer},c.prototype.insertBuffer=function(t){for(var e=!0,r=0;r<this.buffers.length;r++){var n=this.buffers[r];if(t.fileStart<=n.fileStart){if(t.fileStart===n.fileStart){if(t.byteLength>n.byteLength){this.buffers.splice(r,1),r--;continue}o.warn("MultiBufferStream","Buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+") already appended, ignoring")}else t.fileStart+t.byteLength<=n.fileStart||(t=this.reduceBuffer(t,0,n.fileStart-t.fileStart)),o.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.splice(r,0,t),0===r&&(this.buffer=t);e=!1;break}if(t.fileStart<n.fileStart+n.byteLength){var s=n.fileStart+n.byteLength-t.fileStart,a=t.byteLength-s;if(a>0)t=this.reduceBuffer(t,s,a);else{e=!1;break}}}e&&(o.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.push(t),0===r&&(this.buffer=t))},c.prototype.logBufferLevel=function(t){var e,r,n,s,a,u=[],l="";for(n=0,s=0,e=0;e<this.buffers.length;e++)r=this.buffers[e],0===e?(u.push(a={}),a.start=r.fileStart,a.end=r.fileStart+r.byteLength,l+="["+a.start+"-"):a.end===r.fileStart?a.end=r.fileStart+r.byteLength:((a={}).start=r.fileStart,l+=u[u.length-1].end-1+"], ["+a.start+"-",a.end=r.fileStart+r.byteLength,u.push(a)),n+=r.usedBytes,s+=r.byteLength;u.length>0&&(l+=a.end-1+"]"),(t?o.info:o.debug)("MultiBufferStream",0===this.buffers.length?"No more buffer in memory":""+this.buffers.length+" stored buffer(s) ("+n+"/"+s+" bytes), continuous ranges: "+l)},c.prototype.cleanBuffers=function(){var t,e;for(t=0;t<this.buffers.length;t++)(e=this.buffers[t]).usedBytes===e.byteLength&&(o.debug("MultiBufferStream","Removing buffer #"+t),this.buffers.splice(t,1),t--)},c.prototype.mergeNextBuffer=function(){if(!(this.bufferIndex+1<this.buffers.length)||(t=this.buffers[this.bufferIndex+1]).fileStart!==this.buffer.fileStart+this.buffer.byteLength)return!1;var t,e=this.buffer.byteLength,r=this.buffer.usedBytes,n=this.buffer.fileStart;return this.buffers[this.bufferIndex]=ArrayBuffer.concat(this.buffer,t),this.buffer=this.buffers[this.bufferIndex],this.buffers.splice(this.bufferIndex+1,1),this.buffer.usedBytes=r,this.buffer.fileStart=n,o.debug("ISOFile","Concatenating buffer for box parsing (length: "+e+"->"+this.buffer.byteLength+")"),!0},c.prototype.findPosition=function(t,e,r){var n,s=null,a=-1;for(n=!0===t?0:this.bufferIndex;n<this.buffers.length&&(s=this.buffers[n]).fileStart<=e;)a=n,r&&(s.fileStart+s.byteLength<=e?s.usedBytes=s.byteLength:s.usedBytes=e-s.fileStart,this.logBufferLevel()),n++;return -1!==a&&(s=this.buffers[a]).fileStart+s.byteLength>=e?(o.debug("MultiBufferStream","Found position in existing buffer #"+a),a):-1},c.prototype.findEndContiguousBuf=function(t){var e,r,n,s=void 0!==t?t:this.bufferIndex;if(r=this.buffers[s],this.buffers.length>s+1)for(e=s+1;e<this.buffers.length&&(n=this.buffers[e]).fileStart===r.fileStart+r.byteLength;e++)r=n;return r.fileStart+r.byteLength},c.prototype.getEndFilePositionAfter=function(t){var e=this.findPosition(!0,t,!1);return -1!==e?this.findEndContiguousBuf(e):t},c.prototype.addUsedBytes=function(t){this.buffer.usedBytes+=t,this.logBufferLevel()},c.prototype.setAllUsedBytes=function(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()},c.prototype.seek=function(t,e,r){var n;return -1!==(n=this.findPosition(e,t,r))?(this.buffer=this.buffers[n],this.bufferIndex=n,this.position=t-this.buffer.fileStart,o.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),!0):(o.debug("MultiBufferStream","Position "+t+" not found in buffered data"),!1)},c.prototype.getPosition=function(){if(-1===this.bufferIndex||null===this.buffers[this.bufferIndex])throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.position},c.prototype.getLength=function(){return this.byteLength},c.prototype.getEndPosition=function(){if(-1===this.bufferIndex||null===this.buffers[this.bufferIndex])throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.byteLength},rQ.MultiBufferStream=c,h=function(){var t=[];t[3]="ES_Descriptor",t[4]="DecoderConfigDescriptor",t[5]="DecoderSpecificInfo",t[6]="SLConfigDescriptor",this.getDescriptorName=function(e){return t[e]};var e=this,r={};return this.parseOneDescriptor=function(e){var n,s,a,u=0;for(n=e.readUint8(),a=e.readUint8();128&a;)u=(127&a)<<7,a=e.readUint8();return u+=127&a,o.debug("MPEG4DescriptorParser","Found "+(t[n]||"Descriptor "+n)+", size "+u+" at position "+e.getPosition()),(s=t[n]?new r[t[n]](u):new r.Descriptor(u)).parse(e),s},r.Descriptor=function(t,e){this.tag=t,this.size=e,this.descs=[]},r.Descriptor.prototype.parse=function(t){this.data=t.readUint8Array(this.size)},r.Descriptor.prototype.findDescriptor=function(t){for(var e=0;e<this.descs.length;e++)if(this.descs[e].tag==t)return this.descs[e];return null},r.Descriptor.prototype.parseRemainingDescriptors=function(t){for(var r=t.position;t.position<r+this.size;){var n=e.parseOneDescriptor(t);this.descs.push(n)}},r.ES_Descriptor=function(t){r.Descriptor.call(this,3,t)},r.ES_Descriptor.prototype=new r.Descriptor,r.ES_Descriptor.prototype.parse=function(t){if(this.ES_ID=t.readUint16(),this.flags=t.readUint8(),this.size-=3,128&this.flags?(this.dependsOn_ES_ID=t.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,64&this.flags){var e=t.readUint8();this.URL=t.readString(e),this.size-=e+1}else this.URL="";32&this.flags?(this.OCR_ES_ID=t.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(t)},r.ES_Descriptor.prototype.getOTI=function(t){var e=this.findDescriptor(4);return e?e.oti:0},r.ES_Descriptor.prototype.getAudioConfig=function(t){var e=this.findDescriptor(4);if(!e)return null;var r=e.findDescriptor(5);if(!r||!r.data)return null;var n=(248&r.data[0])>>3;return 31===n&&r.data.length>=2&&(n=32+((7&r.data[0])<<3)+((224&r.data[1])>>5)),n},r.DecoderConfigDescriptor=function(t){r.Descriptor.call(this,4,t)},r.DecoderConfigDescriptor.prototype=new r.Descriptor,r.DecoderConfigDescriptor.prototype.parse=function(t){this.oti=t.readUint8(),this.streamType=t.readUint8(),this.bufferSize=t.readUint24(),this.maxBitrate=t.readUint32(),this.avgBitrate=t.readUint32(),this.size-=13,this.parseRemainingDescriptors(t)},r.DecoderSpecificInfo=function(t){r.Descriptor.call(this,5,t)},r.DecoderSpecificInfo.prototype=new r.Descriptor,r.SLConfigDescriptor=function(t){r.Descriptor.call(this,6,t)},r.SLConfigDescriptor.prototype=new r.Descriptor,this},rQ.MPEG4DescriptorParser=h,(f={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"],["grpl"],["j2kH"],["etyp",["tyco"]]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){f.FullBox.prototype=new f.Box,f.ContainerBox.prototype=new f.Box,f.SampleEntry.prototype=new f.Box,f.TrackGroupTypeBox.prototype=new f.FullBox,f.BASIC_BOXES.forEach(function(t){f.createBoxCtor(t)}),f.FULL_BOXES.forEach(function(t){f.createFullBoxCtor(t)}),f.CONTAINER_BOXES.forEach(function(t){f.createContainerBoxCtor(t[0],null,t[1])})},Box:function(t,e,r){this.type=t,this.size=e,this.uuid=r},FullBox:function(t,e,r){f.Box.call(this,t,e,r),this.flags=0,this.version=0},ContainerBox:function(t,e,r){f.Box.call(this,t,e,r),this.boxes=[]},SampleEntry:function(t,e,r,n){f.ContainerBox.call(this,t,e),this.hdr_size=r,this.start=n},SampleGroupEntry:function(t){this.grouping_type=t},TrackGroupTypeBox:function(t,e){f.FullBox.call(this,t,e)},createBoxCtor:function(t,e){f.boxCodes.push(t),f[t+"Box"]=function(e){f.Box.call(this,t,e)},f[t+"Box"].prototype=new f.Box,e&&(f[t+"Box"].prototype.parse=e)},createFullBoxCtor:function(t,e){f[t+"Box"]=function(e){f.FullBox.call(this,t,e)},f[t+"Box"].prototype=new f.FullBox,f[t+"Box"].prototype.parse=function(t){this.parseFullHeader(t),e&&e.call(this,t)}},addSubBoxArrays:function(t){if(t){this.subBoxNames=t;for(var e=t.length,r=0;r<e;r++)this[t[r]+"s"]=[]}},createContainerBoxCtor:function(t,e,r){f[t+"Box"]=function(e){f.ContainerBox.call(this,t,e),f.addSubBoxArrays.call(this,r)},f[t+"Box"].prototype=new f.ContainerBox,e&&(f[t+"Box"].prototype.parse=e)},createMediaSampleEntryCtor:function(t,e,r){f.sampleEntryCodes[t]=[],f[t+"SampleEntry"]=function(t,e){f.SampleEntry.call(this,t,e),f.addSubBoxArrays.call(this,r)},f[t+"SampleEntry"].prototype=new f.SampleEntry,e&&(f[t+"SampleEntry"].prototype.parse=e)},createSampleEntryCtor:function(t,e,r,n){f.sampleEntryCodes[t].push(e),f[e+"SampleEntry"]=function(r){f[t+"SampleEntry"].call(this,e,r),f.addSubBoxArrays.call(this,n)},f[e+"SampleEntry"].prototype=new f[t+"SampleEntry"],r&&(f[e+"SampleEntry"].prototype.parse=r)},createEncryptedSampleEntryCtor:function(t,e,r){f.createSampleEntryCtor.call(this,t,e,r,["sinf"])},createSampleGroupCtor:function(t,e){f[t+"SampleGroupEntry"]=function(e){f.SampleGroupEntry.call(this,t,e)},f[t+"SampleGroupEntry"].prototype=new f.SampleGroupEntry,e&&(f[t+"SampleGroupEntry"].prototype.parse=e)},createTrackGroupCtor:function(t,e){f[t+"TrackGroupTypeBox"]=function(e){f.TrackGroupTypeBox.call(this,t,e)},f[t+"TrackGroupTypeBox"].prototype=new f.TrackGroupTypeBox,e&&(f[t+"TrackGroupTypeBox"].prototype.parse=e)},createUUIDBox:function(t,e,r,n){f.UUIDs.push(t),f.UUIDBoxes[t]=function(n){e?f.FullBox.call(this,"uuid",n,t):r?f.ContainerBox.call(this,"uuid",n,t):f.Box.call(this,"uuid",n,t)},f.UUIDBoxes[t].prototype=e?new f.FullBox:r?new f.ContainerBox:new f.Box,n&&(e?f.UUIDBoxes[t].prototype.parse=function(t){this.parseFullHeader(t),n&&n.call(this,t)}:f.UUIDBoxes[t].prototype.parse=n)}}).initialize(),f.TKHD_FLAG_ENABLED=1,f.TKHD_FLAG_IN_MOVIE=2,f.TKHD_FLAG_IN_PREVIEW=4,f.TFHD_FLAG_BASE_DATA_OFFSET=1,f.TFHD_FLAG_SAMPLE_DESC=2,f.TFHD_FLAG_SAMPLE_DUR=8,f.TFHD_FLAG_SAMPLE_SIZE=16,f.TFHD_FLAG_SAMPLE_FLAGS=32,f.TFHD_FLAG_DUR_EMPTY=65536,f.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072,f.TRUN_FLAGS_DATA_OFFSET=1,f.TRUN_FLAGS_FIRST_FLAG=4,f.TRUN_FLAGS_DURATION=256,f.TRUN_FLAGS_SIZE=512,f.TRUN_FLAGS_FLAGS=1024,f.TRUN_FLAGS_CTS_OFFSET=2048,f.Box.prototype.add=function(t){return this.addBox(new f[t+"Box"])},f.Box.prototype.addBox=function(t){return this.boxes.push(t),this[t.type+"s"]?this[t.type+"s"].push(t):this[t.type]=t,t},f.Box.prototype.set=function(t,e){return this[t]=e,this},f.Box.prototype.addEntry=function(t,e){var r=e||"entries";return this[r]||(this[r]=[]),this[r].push(t),this},rQ.BoxParser=f,f.parseUUID=function(t){return f.parseHex16(t)},f.parseHex16=function(t){for(var e="",r=0;r<16;r++){var n=t.readUint8().toString(16);e+=1===n.length?"0"+n:n}return e},f.parseOneBox=function(t,e,r){var n,s,a,u=t.getPosition(),l=0;if(t.getEndPosition()-u<8)return o.debug("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:f.ERR_NOT_ENOUGH_DATA};if(r&&r<8)return o.debug("BoxParser","Not enough bytes left in the parent box to parse a new box"),{code:f.ERR_NOT_ENOUGH_DATA};var c=t.readUint32(),h=t.readString(4),d=h;if(o.debug("BoxParser","Found box of type '"+h+"' and size "+c+" at position "+u),l=8,"uuid"==h){if(t.getEndPosition()-t.getPosition()<16||r-l<16)return t.seek(u),o.debug("BoxParser","Not enough bytes left in the parent box to parse a UUID box"),{code:f.ERR_NOT_ENOUGH_DATA};a=f.parseUUID(t),l+=16,d=a}if(1==c){if(t.getEndPosition()-t.getPosition()<8||r&&r-l<8)return t.seek(u),o.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+h+'" box'),{code:f.ERR_NOT_ENOUGH_DATA};c=t.readUint64(),l+=8}else if(0===c){if(r)c=r;else if("mdat"!==h)return o.error("BoxParser","Unlimited box size not supported for type: '"+h+"'"),n=new f.Box(h,c),{code:f.OK,box:n,size:n.size}}return 0!==c&&c<l?(o.error("BoxParser","Box of type "+h+" has an invalid size "+c+" (too small to be a box)"),{code:f.ERR_NOT_ENOUGH_DATA,type:h,size:c,hdr_size:l,start:u}):0!==c&&r&&c>r?(o.error("BoxParser","Box of type '"+h+"' has a size "+c+" greater than its container size "+r),{code:f.ERR_NOT_ENOUGH_DATA,type:h,size:c,hdr_size:l,start:u}):0!==c&&u+c>t.getEndPosition()?(t.seek(u),o.info("BoxParser","Not enough data in stream to parse the entire '"+h+"' box"),{code:f.ERR_NOT_ENOUGH_DATA,type:h,size:c,hdr_size:l,start:u}):e?{code:f.OK,type:h,size:c,hdr_size:l,start:u}:(f[h+"Box"]?n=new f[h+"Box"](c):"uuid"!==h?(o.warn("BoxParser","Unknown box type: '"+h+"'"),(n=new f.Box(h,c)).has_unparsed_data=!0):f.UUIDBoxes[a]?n=new f.UUIDBoxes[a](c):(o.warn("BoxParser","Unknown uuid type: '"+a+"'"),(n=new f.Box(h,c)).uuid=a,n.has_unparsed_data=!0),n.hdr_size=l,n.start=u,n.write===f.Box.prototype.write&&"mdat"!==n.type&&(o.info("BoxParser","'"+d+"' box writing not yet implemented, keeping unparsed data in memory for later write"),n.parseDataAndRewind(t)),n.parse(t),(s=t.getPosition()-(n.start+n.size))<0?(o.warn("BoxParser","Parsing of box '"+d+"' did not read the entire indicated box data size (missing "+-s+" bytes), seeking forward"),t.seek(n.start+n.size)):s>0&&(o.error("BoxParser","Parsing of box '"+d+"' read "+s+" more bytes than the indicated box data size, seeking backwards"),0!==n.size&&t.seek(n.start+n.size)),{code:f.OK,box:n,size:n.size})},f.Box.prototype.parse=function(t){"mdat"!=this.type?this.data=t.readUint8Array(this.size-this.hdr_size):0===this.size?t.seek(t.getEndPosition()):t.seek(this.start+this.size)},f.Box.prototype.parseDataAndRewind=function(t){this.data=t.readUint8Array(this.size-this.hdr_size),t.position-=this.size-this.hdr_size},f.FullBox.prototype.parseDataAndRewind=function(t){this.parseFullHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,t.position-=this.size-this.hdr_size},f.FullBox.prototype.parseFullHeader=function(t){this.version=t.readUint8(),this.flags=t.readUint24(),this.hdr_size+=4},f.FullBox.prototype.parse=function(t){this.parseFullHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)},f.ContainerBox.prototype.parse=function(t){for(var e,r;t.getPosition()<this.start+this.size;)if((e=f.parseOneBox(t,!1,this.size-(t.getPosition()-this.start))).code!==f.OK)return;else if(r=e.box,this.boxes.push(r),this.subBoxNames&&-1!=this.subBoxNames.indexOf(r.type))this[this.subBoxNames[this.subBoxNames.indexOf(r.type)]+"s"].push(r);else{var n="uuid"!==r.type?r.type:r.uuid;this[n]?o.warn("Box of type "+n+" already stored in field of this type"):this[n]=r}},f.Box.prototype.parseLanguage=function(t){this.language=t.readUint16();var e=[];e[0]=this.language>>10&31,e[1]=this.language>>5&31,e[2]=31&this.language,this.languageString=String.fromCharCode(e[0]+96,e[1]+96,e[2]+96)},f.SAMPLE_ENTRY_TYPE_VISUAL="Visual",f.SAMPLE_ENTRY_TYPE_AUDIO="Audio",f.SAMPLE_ENTRY_TYPE_HINT="Hint",f.SAMPLE_ENTRY_TYPE_METADATA="Metadata",f.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",f.SAMPLE_ENTRY_TYPE_SYSTEM="System",f.SAMPLE_ENTRY_TYPE_TEXT="Text",f.SampleEntry.prototype.parseHeader=function(t){t.readUint8Array(6),this.data_reference_index=t.readUint16(),this.hdr_size+=8},f.SampleEntry.prototype.parse=function(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)},f.SampleEntry.prototype.parseDataAndRewind=function(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,t.position-=this.size-this.hdr_size},f.SampleEntry.prototype.parseFooter=function(t){f.ContainerBox.prototype.parse.call(this,t)},f.createMediaSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_HINT),f.createMediaSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_METADATA),f.createMediaSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_SUBTITLE),f.createMediaSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_SYSTEM),f.createMediaSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_TEXT),f.createMediaSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,function(t){var e;this.parseHeader(t),t.readUint16(),t.readUint16(),t.readUint32Array(3),this.width=t.readUint16(),this.height=t.readUint16(),this.horizresolution=t.readUint32(),this.vertresolution=t.readUint32(),t.readUint32(),this.frame_count=t.readUint16(),e=Math.min(31,t.readUint8()),this.compressorname=t.readString(e),e<31&&t.readString(31-e),this.depth=t.readUint16(),t.readUint16(),this.parseFooter(t)}),f.createMediaSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,function(t){this.parseHeader(t),t.readUint32Array(2),this.channel_count=t.readUint16(),this.samplesize=t.readUint16(),t.readUint16(),t.readUint16(),this.samplerate=t.readUint32()/65536,this.parseFooter(t)}),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"dav1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"hvt1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"lhe1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"dvh1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"dvhe"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"vp08"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"vp09"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"avs3"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"j2ki"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"mjp2"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"mjpg"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"uncv"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"ac-4"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"Opus"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"mha1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"mha2"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"mhm1"),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"mhm2"),f.createEncryptedSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),f.createEncryptedSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),f.createEncryptedSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),f.createEncryptedSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),f.createEncryptedSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_TEXT,"enct"),f.createEncryptedSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_METADATA,"encm"),f.createBoxCtor("a1lx",function(t){var e=((1&(1&t.readUint8()))+1)*16;this.layer_size=[];for(var r=0;r<3;r++)16==e?this.layer_size[r]=t.readUint16():this.layer_size[r]=t.readUint32()}),f.createBoxCtor("a1op",function(t){this.op_index=t.readUint8()}),f.createFullBoxCtor("auxC",function(t){this.aux_type=t.readCString();var e=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=t.readUint8Array(e)}),f.createBoxCtor("av1C",function(t){var e=t.readUint8();if(this.version=127&e,1!==this.version){o.error("av1C version "+this.version+" not supported");return}if(e=t.readUint8(),this.seq_profile=e>>5&7,this.seq_level_idx_0=31&e,e=t.readUint8(),this.seq_tier_0=e>>7&1,this.high_bitdepth=e>>6&1,this.twelve_bit=e>>5&1,this.monochrome=e>>4&1,this.chroma_subsampling_x=e>>3&1,this.chroma_subsampling_y=e>>2&1,this.chroma_sample_position=3&e,e=t.readUint8(),this.reserved_1=e>>5&7,0!==this.reserved_1){o.error("av1C reserved_1 parsing problem");return}if(this.initial_presentation_delay_present=e>>4&1,1===this.initial_presentation_delay_present)this.initial_presentation_delay_minus_one=15&e;else if(this.reserved_2=15&e,0!==this.reserved_2){o.error("av1C reserved_2 parsing problem");return}var r=this.size-this.hdr_size-4;this.configOBUs=t.readUint8Array(r)}),f.createBoxCtor("avcC",function(t){var e,r;for(this.configurationVersion=t.readUint8(),this.AVCProfileIndication=t.readUint8(),this.profile_compatibility=t.readUint8(),this.AVCLevelIndication=t.readUint8(),this.lengthSizeMinusOne=3&t.readUint8(),this.nb_SPS_nalus=31&t.readUint8(),r=this.size-this.hdr_size-6,this.SPS=[],e=0;e<this.nb_SPS_nalus;e++)this.SPS[e]={},this.SPS[e].length=t.readUint16(),this.SPS[e].nalu=t.readUint8Array(this.SPS[e].length),r-=2+this.SPS[e].length;for(this.nb_PPS_nalus=t.readUint8(),r--,this.PPS=[],e=0;e<this.nb_PPS_nalus;e++)this.PPS[e]={},this.PPS[e].length=t.readUint16(),this.PPS[e].nalu=t.readUint8Array(this.PPS[e].length),r-=2+this.PPS[e].length;r>0&&(this.ext=t.readUint8Array(r))}),f.createBoxCtor("btrt",function(t){this.bufferSizeDB=t.readUint32(),this.maxBitrate=t.readUint32(),this.avgBitrate=t.readUint32()}),f.createFullBoxCtor("ccst",function(t){var e=t.readUint8();this.all_ref_pics_intra=(128&e)==128,this.intra_pred_used=(64&e)==64,this.max_ref_per_pic=(63&e)>>2,t.readUint24()}),f.createBoxCtor("cdef",function(t){var e;for(this.channel_count=t.readUint16(),this.channel_indexes=[],this.channel_types=[],this.channel_associations=[],e=0;e<this.channel_count;e++)this.channel_indexes.push(t.readUint16()),this.channel_types.push(t.readUint16()),this.channel_associations.push(t.readUint16())}),f.createBoxCtor("clap",function(t){this.cleanApertureWidthN=t.readUint32(),this.cleanApertureWidthD=t.readUint32(),this.cleanApertureHeightN=t.readUint32(),this.cleanApertureHeightD=t.readUint32(),this.horizOffN=t.readUint32(),this.horizOffD=t.readUint32(),this.vertOffN=t.readUint32(),this.vertOffD=t.readUint32()}),f.createBoxCtor("clli",function(t){this.max_content_light_level=t.readUint16(),this.max_pic_average_light_level=t.readUint16()}),f.createFullBoxCtor("cmex",function(t){1&this.flags&&(this.pos_x=t.readInt32()),2&this.flags&&(this.pos_y=t.readInt32()),4&this.flags&&(this.pos_z=t.readInt32()),8&this.flags&&(0==this.version?16&this.flags?(this.quat_x=t.readInt32(),this.quat_y=t.readInt32(),this.quat_z=t.readInt32()):(this.quat_x=t.readInt16(),this.quat_y=t.readInt16(),this.quat_z=t.readInt16()):this.version),32&this.flags&&(this.id=t.readUint32())}),f.createFullBoxCtor("cmin",function(t){this.focal_length_x=t.readInt32(),this.principal_point_x=t.readInt32(),this.principal_point_y=t.readInt32(),1&this.flags&&(this.focal_length_y=t.readInt32(),this.skew_factor=t.readInt32())}),f.createBoxCtor("cmpd",function(t){for(this.component_count=t.readUint16(),this.component_types=[],this.component_type_urls=[],i=0;i<this.component_count;i++){var e=t.readUint16();this.component_types.push(e),e>=32768&&this.component_type_urls.push(t.readCString())}}),f.createFullBoxCtor("co64",function(t){var e,r;if(e=t.readUint32(),this.chunk_offsets=[],0===this.version)for(r=0;r<e;r++)this.chunk_offsets.push(t.readUint64())}),f.createFullBoxCtor("CoLL",function(t){this.maxCLL=t.readUint16(),this.maxFALL=t.readUint16()}),f.createBoxCtor("colr",function(t){if(this.colour_type=t.readString(4),"nclx"===this.colour_type){this.colour_primaries=t.readUint16(),this.transfer_characteristics=t.readUint16(),this.matrix_coefficients=t.readUint16();var e=t.readUint8();this.full_range_flag=e>>7}else"rICC"===this.colour_type?this.ICC_profile=t.readUint8Array(this.size-4):"prof"===this.colour_type&&(this.ICC_profile=t.readUint8Array(this.size-4))}),f.createFullBoxCtor("cprt",function(t){this.parseLanguage(t),this.notice=t.readCString()}),f.createFullBoxCtor("cslg",function(t){0===this.version&&(this.compositionToDTSShift=t.readInt32(),this.leastDecodeToDisplayDelta=t.readInt32(),this.greatestDecodeToDisplayDelta=t.readInt32(),this.compositionStartTime=t.readInt32(),this.compositionEndTime=t.readInt32())}),f.createFullBoxCtor("ctts",function(t){var e,r;if(e=t.readUint32(),this.sample_counts=[],this.sample_offsets=[],0===this.version)for(r=0;r<e;r++){this.sample_counts.push(t.readUint32());var n=t.readInt32();n<0&&o.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(n)}else if(1==this.version)for(r=0;r<e;r++)this.sample_counts.push(t.readUint32()),this.sample_offsets.push(t.readInt32())}),f.createBoxCtor("dac3",function(t){var e=t.readUint8(),r=t.readUint8(),n=t.readUint8();this.fscod=e>>6,this.bsid=e>>1&31,this.bsmod=(1&e)<<2|r>>6&3,this.acmod=r>>3&7,this.lfeon=r>>2&1,this.bit_rate_code=3&r|n>>5&7}),f.createBoxCtor("dec3",function(t){var e=t.readUint16();this.data_rate=e>>3,this.num_ind_sub=7&e,this.ind_subs=[];for(var r=0;r<this.num_ind_sub+1;r++){var n={};this.ind_subs.push(n);var s=t.readUint8(),a=t.readUint8(),o=t.readUint8();n.fscod=s>>6,n.bsid=s>>1&31,n.bsmod=(1&s)<<4|a>>4&15,n.acmod=a>>1&7,n.lfeon=1&a,n.num_dep_sub=o>>1&15,n.num_dep_sub>0&&(n.chan_loc=(1&o)<<8|t.readUint8())}}),f.createFullBoxCtor("dfLa",function(t){var e=[],r=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];for(this.parseFullHeader(t);;){var n=t.readUint8(),s=Math.min(127&n,r.length-1);if(s?t.readUint8Array(t.readUint24()):(t.readUint8Array(13),this.samplerate=t.readUint32()>>12,t.readUint8Array(20)),e.push(r[s]),128&n)break}this.numMetadataBlocks=e.length+" ("+e.join(", ")+")"}),f.createBoxCtor("dimm",function(t){this.bytessent=t.readUint64()}),f.createBoxCtor("dmax",function(t){this.time=t.readUint32()}),f.createBoxCtor("dmed",function(t){this.bytessent=t.readUint64()}),f.createBoxCtor("dOps",function(t){if(this.Version=t.readUint8(),this.OutputChannelCount=t.readUint8(),this.PreSkip=t.readUint16(),this.InputSampleRate=t.readUint32(),this.OutputGain=t.readInt16(),this.ChannelMappingFamily=t.readUint8(),0!==this.ChannelMappingFamily){this.StreamCount=t.readUint8(),this.CoupledCount=t.readUint8(),this.ChannelMapping=[];for(var e=0;e<this.OutputChannelCount;e++)this.ChannelMapping[e]=t.readUint8()}}),f.createFullBoxCtor("dref",function(t){var e,r;this.entries=[];for(var n=t.readUint32(),s=0;s<n;s++)if((e=f.parseOneBox(t,!1,this.size-(t.getPosition()-this.start))).code!==f.OK)return;else r=e.box,this.entries.push(r)}),f.createBoxCtor("drep",function(t){this.bytessent=t.readUint64()}),f.createFullBoxCtor("elng",function(t){this.extended_language=t.readString(this.size-this.hdr_size)}),f.createFullBoxCtor("elst",function(t){this.entries=[];for(var e=t.readUint32(),r=0;r<e;r++){var n={};this.entries.push(n),1===this.version?(n.segment_duration=t.readUint64(),n.media_time=t.readInt64()):(n.segment_duration=t.readUint32(),n.media_time=t.readInt32()),n.media_rate_integer=t.readInt16(),n.media_rate_fraction=t.readInt16()}}),f.createFullBoxCtor("emsg",function(t){1==this.version?(this.timescale=t.readUint32(),this.presentation_time=t.readUint64(),this.event_duration=t.readUint32(),this.id=t.readUint32(),this.scheme_id_uri=t.readCString(),this.value=t.readCString()):(this.scheme_id_uri=t.readCString(),this.value=t.readCString(),this.timescale=t.readUint32(),this.presentation_time_delta=t.readUint32(),this.event_duration=t.readUint32(),this.id=t.readUint32());var e=this.size-this.hdr_size-(16+(this.scheme_id_uri.length+1)+(this.value.length+1));1==this.version&&(e-=4),this.message_data=t.readUint8Array(e)}),f.createEntityToGroupCtor=function(t,e){f[t+"Box"]=function(e){f.FullBox.call(this,t,e)},f[t+"Box"].prototype=new f.FullBox,f[t+"Box"].prototype.parse=function(t){if(this.parseFullHeader(t),e)e.call(this,t);else for(this.group_id=t.readUint32(),this.num_entities_in_group=t.readUint32(),this.entity_ids=[],i=0;i<this.num_entities_in_group;i++){var r=t.readUint32();this.entity_ids.push(r)}}},f.createEntityToGroupCtor("aebr"),f.createEntityToGroupCtor("afbr"),f.createEntityToGroupCtor("albc"),f.createEntityToGroupCtor("altr"),f.createEntityToGroupCtor("brst"),f.createEntityToGroupCtor("dobr"),f.createEntityToGroupCtor("eqiv"),f.createEntityToGroupCtor("favc"),f.createEntityToGroupCtor("fobr"),f.createEntityToGroupCtor("iaug"),f.createEntityToGroupCtor("pano"),f.createEntityToGroupCtor("slid"),f.createEntityToGroupCtor("ster"),f.createEntityToGroupCtor("tsyn"),f.createEntityToGroupCtor("wbbr"),f.createEntityToGroupCtor("prgr"),f.createFullBoxCtor("esds",function(t){var e=t.readUint8Array(this.size-this.hdr_size);if(this.data=e,(void 0===h?"undefined":(0,ek._)(h))<"u"){var r=new h;this.esd=r.parseOneDescriptor(new l(e.buffer,0,l.BIG_ENDIAN))}}),f.createBoxCtor("fiel",function(t){this.fieldCount=t.readUint8(),this.fieldOrdering=t.readUint8()}),f.createBoxCtor("frma",function(t){this.data_format=t.readString(4)}),f.createBoxCtor("ftyp",function(t){var e=this.size-this.hdr_size;this.major_brand=t.readString(4),this.minor_version=t.readUint32(),e-=8,this.compatible_brands=[];for(var r=0;e>=4;)this.compatible_brands[r]=t.readString(4),e-=4,r++}),f.createFullBoxCtor("hdlr",function(t){0===this.version&&(t.readUint32(),this.handler=t.readString(4),t.readUint32Array(3),this.name=t.readString(this.size-this.hdr_size-20),"\0"===this.name[this.name.length-1]&&(this.name=this.name.slice(0,-1)))}),f.createBoxCtor("hvcC",function(t){this.configurationVersion=t.readUint8(),s=t.readUint8(),this.general_profile_space=s>>6,this.general_tier_flag=(32&s)>>5,this.general_profile_idc=31&s,this.general_profile_compatibility=t.readUint32(),this.general_constraint_indicator=t.readUint8Array(6),this.general_level_idc=t.readUint8(),this.min_spatial_segmentation_idc=4095&t.readUint16(),this.parallelismType=3&t.readUint8(),this.chroma_format_idc=3&t.readUint8(),this.bit_depth_luma_minus8=7&t.readUint8(),this.bit_depth_chroma_minus8=7&t.readUint8(),this.avgFrameRate=t.readUint16(),s=t.readUint8(),this.constantFrameRate=s>>6,this.numTemporalLayers=(13&s)>>3,this.temporalIdNested=(4&s)>>2,this.lengthSizeMinusOne=3&s,this.nalu_arrays=[];var e,r,n,s,a=t.readUint8();for(e=0;e<a;e++){var o=[];this.nalu_arrays.push(o),s=t.readUint8(),o.completeness=(128&s)>>7,o.nalu_type=63&s;var u=t.readUint16();for(r=0;r<u;r++){var l={};o.push(l),n=t.readUint16(),l.data=t.readUint8Array(n)}}}),f.createFullBoxCtor("iinf",function(t){var e;0===this.version?this.entry_count=t.readUint16():this.entry_count=t.readUint32(),this.item_infos=[];for(var r=0;r<this.entry_count;r++)if((e=f.parseOneBox(t,!1,this.size-(t.getPosition()-this.start))).code!==f.OK)return;else"infe"!==e.box.type&&o.error("BoxParser","Expected 'infe' box, got "+e.box.type),this.item_infos[r]=e.box}),f.createFullBoxCtor("iloc",function(t){e=t.readUint8(),this.offset_size=e>>4&15,this.length_size=15&e,e=t.readUint8(),this.base_offset_size=e>>4&15,1===this.version||2===this.version?this.index_size=15&e:this.index_size=0,this.items=[];var e,r=0;if(this.version<2)r=t.readUint16();else if(2===this.version)r=t.readUint32();else throw"version of iloc box not supported";for(var n=0;n<r;n++){var s={};if(this.items.push(s),this.version<2)s.item_ID=t.readUint16();else if(2===this.version)s.item_ID=t.readUint16();else throw"version of iloc box not supported";switch(1===this.version||2===this.version?s.construction_method=15&t.readUint16():s.construction_method=0,s.data_reference_index=t.readUint16(),this.base_offset_size){case 0:s.base_offset=0;break;case 4:s.base_offset=t.readUint32();break;case 8:s.base_offset=t.readUint64();break;default:throw"Error reading base offset size"}var a=t.readUint16();s.extents=[];for(var o=0;o<a;o++){var u={};if(s.extents.push(u),1===this.version||2===this.version)switch(this.index_size){case 0:u.extent_index=0;break;case 4:u.extent_index=t.readUint32();break;case 8:u.extent_index=t.readUint64();break;default:throw"Error reading extent index"}switch(this.offset_size){case 0:u.extent_offset=0;break;case 4:u.extent_offset=t.readUint32();break;case 8:u.extent_offset=t.readUint64();break;default:throw"Error reading extent index"}switch(this.length_size){case 0:u.extent_length=0;break;case 4:u.extent_length=t.readUint32();break;case 8:u.extent_length=t.readUint64();break;default:throw"Error reading extent index"}}}}),f.createBoxCtor("imir",function(t){var e=t.readUint8();this.reserved=e>>7,this.axis=1&e}),f.createFullBoxCtor("infe",function(t){if((0===this.version||1===this.version)&&(this.item_ID=t.readUint16(),this.item_protection_index=t.readUint16(),this.item_name=t.readCString(),this.content_type=t.readCString(),this.content_encoding=t.readCString()),1===this.version){this.extension_type=t.readString(4),o.warn("BoxParser","Cannot parse extension type"),t.seek(this.start+this.size);return}this.version>=2&&(2===this.version?this.item_ID=t.readUint16():3===this.version&&(this.item_ID=t.readUint32()),this.item_protection_index=t.readUint16(),this.item_type=t.readString(4),this.item_name=t.readCString(),"mime"===this.item_type?(this.content_type=t.readCString(),this.content_encoding=t.readCString()):"uri "===this.item_type&&(this.item_uri_type=t.readCString()))}),f.createFullBoxCtor("ipma",function(t){var e,r;for(entry_count=t.readUint32(),this.associations=[],e=0;e<entry_count;e++){var n={};this.associations.push(n),this.version<1?n.id=t.readUint16():n.id=t.readUint32();var s=t.readUint8();for(n.props=[],r=0;r<s;r++){var a=t.readUint8(),o={};n.props.push(o),o.essential=(128&a)>>7==1,1&this.flags?o.property_index=(127&a)<<8|t.readUint8():o.property_index=127&a}}}),f.createFullBoxCtor("iref",function(t){var e,r;for(this.references=[];t.getPosition()<this.start+this.size;)if((e=f.parseOneBox(t,!0,this.size-(t.getPosition()-this.start))).code!==f.OK)return;else(r=0===this.version?new f.SingleItemTypeReferenceBox(e.type,e.size,e.hdr_size,e.start):new f.SingleItemTypeReferenceBoxLarge(e.type,e.size,e.hdr_size,e.start)).write===f.Box.prototype.write&&"mdat"!==r.type&&(o.warn("BoxParser",r.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(t)),r.parse(t),this.references.push(r)}),f.createBoxCtor("irot",function(t){this.angle=3&t.readUint8()}),f.createFullBoxCtor("ispe",function(t){this.image_width=t.readUint32(),this.image_height=t.readUint32()}),f.createFullBoxCtor("kind",function(t){this.schemeURI=t.readCString(),this.value=t.readCString()}),f.createFullBoxCtor("leva",function(t){var e=t.readUint8();this.levels=[];for(var r=0;r<e;r++){var n={};this.levels[r]=n,n.track_ID=t.readUint32();var s=t.readUint8();switch(n.padding_flag=s>>7,n.assignment_type=127&s,n.assignment_type){case 0:n.grouping_type=t.readString(4);break;case 1:n.grouping_type=t.readString(4),n.grouping_type_parameter=t.readUint32();break;case 2:case 3:break;case 4:n.sub_track_id=t.readUint32();break;default:o.warn("BoxParser","Unknown leva assignement type")}}}),f.createBoxCtor("lsel",function(t){this.layer_id=t.readUint16()}),f.createBoxCtor("maxr",function(t){this.period=t.readUint32(),this.bytes=t.readUint32()}),f.createBoxCtor("mdcv",function(t){this.display_primaries=[],this.display_primaries[0]={},this.display_primaries[0].x=t.readUint16(),this.display_primaries[0].y=t.readUint16(),this.display_primaries[1]={},this.display_primaries[1].x=t.readUint16(),this.display_primaries[1].y=t.readUint16(),this.display_primaries[2]={},this.display_primaries[2].x=t.readUint16(),this.display_primaries[2].y=t.readUint16(),this.white_point={},this.white_point.x=t.readUint16(),this.white_point.y=t.readUint16(),this.max_display_mastering_luminance=t.readUint32(),this.min_display_mastering_luminance=t.readUint32()}),f.createFullBoxCtor("mdhd",function(t){1==this.version?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.timescale=t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.timescale=t.readUint32(),this.duration=t.readUint32()),this.parseLanguage(t),t.readUint16()}),f.createFullBoxCtor("mehd",function(t){1&this.flags&&(o.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),1==this.version?this.fragment_duration=t.readUint64():this.fragment_duration=t.readUint32()}),f.createFullBoxCtor("meta",function(t){this.boxes=[],f.ContainerBox.prototype.parse.call(this,t)}),f.createFullBoxCtor("mfhd",function(t){this.sequence_number=t.readUint32()}),f.createFullBoxCtor("mfro",function(t){this._size=t.readUint32()}),f.createFullBoxCtor("mvhd",function(t){1==this.version?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.timescale=t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.timescale=t.readUint32(),this.duration=t.readUint32()),this.rate=t.readUint32(),this.volume=t.readUint16()>>8,t.readUint16(),t.readUint32Array(2),this.matrix=t.readUint32Array(9),t.readUint32Array(6),this.next_track_id=t.readUint32()}),f.createBoxCtor("npck",function(t){this.packetssent=t.readUint32()}),f.createBoxCtor("nump",function(t){this.packetssent=t.readUint64()}),f.createFullBoxCtor("padb",function(t){var e=t.readUint32();this.padbits=[];for(var r=0;r<Math.floor((e+1)/2);r++)this.padbits=t.readUint8()}),f.createBoxCtor("pasp",function(t){this.hSpacing=t.readUint32(),this.vSpacing=t.readUint32()}),f.createBoxCtor("payl",function(t){this.text=t.readString(this.size-this.hdr_size)}),f.createBoxCtor("payt",function(t){this.payloadID=t.readUint32();var e=t.readUint8();this.rtpmap_string=t.readString(e)}),f.createFullBoxCtor("pdin",function(t){var e=(this.size-this.hdr_size)/8;this.rate=[],this.initial_delay=[];for(var r=0;r<e;r++)this.rate[r]=t.readUint32(),this.initial_delay[r]=t.readUint32()}),f.createFullBoxCtor("pitm",function(t){0===this.version?this.item_id=t.readUint16():this.item_id=t.readUint32()}),f.createFullBoxCtor("pixi",function(t){var e;for(this.num_channels=t.readUint8(),this.bits_per_channels=[],e=0;e<this.num_channels;e++)this.bits_per_channels[e]=t.readUint8()}),f.createBoxCtor("pmax",function(t){this.bytes=t.readUint32()}),f.createFullBoxCtor("prdi",function(t){if(this.step_count=t.readUint16(),this.item_count=[],2&this.flags)for(var e=0;e<this.step_count;e++)this.item_count[e]=t.readUint16()}),f.createFullBoxCtor("prft",function(t){this.ref_track_id=t.readUint32(),this.ntp_timestamp=t.readUint64(),0===this.version?this.media_time=t.readUint32():this.media_time=t.readUint64()}),f.createFullBoxCtor("pssh",function(t){if(this.system_id=f.parseHex16(t),this.version>0){var e=t.readUint32();this.kid=[];for(var r=0;r<e;r++)this.kid[r]=f.parseHex16(t)}var n=t.readUint32();n>0&&(this.data=t.readUint8Array(n))}),f.createFullBoxCtor("clef",function(t){this.width=t.readUint32(),this.height=t.readUint32()}),f.createFullBoxCtor("enof",function(t){this.width=t.readUint32(),this.height=t.readUint32()}),f.createFullBoxCtor("prof",function(t){this.width=t.readUint32(),this.height=t.readUint32()}),f.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),f.createBoxCtor("rtp ",function(t){this.descriptionformat=t.readString(4),this.sdptext=t.readString(this.size-this.hdr_size-4)}),f.createFullBoxCtor("saio",function(t){1&this.flags&&(this.aux_info_type=t.readUint32(),this.aux_info_type_parameter=t.readUint32());var e=t.readUint32();this.offset=[];for(var r=0;r<e;r++)0===this.version?this.offset[r]=t.readUint32():this.offset[r]=t.readUint64()}),f.createFullBoxCtor("saiz",function(t){1&this.flags&&(this.aux_info_type=t.readUint32(),this.aux_info_type_parameter=t.readUint32()),this.default_sample_info_size=t.readUint8();var e=t.readUint32();if(this.sample_info_size=[],0===this.default_sample_info_size)for(var r=0;r<e;r++)this.sample_info_size[r]=t.readUint8()}),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_METADATA,"mett",function(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_METADATA,"metx",function(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.namespace=t.readCString(),this.schema_location=t.readCString(),this.parseFooter(t)}),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_SUBTITLE,"sbtt",function(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_SUBTITLE,"stpp",function(t){this.parseHeader(t),this.namespace=t.readCString(),this.schema_location=t.readCString(),this.auxiliary_mime_types=t.readCString(),this.parseFooter(t)}),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_SUBTITLE,"stxt",function(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_SUBTITLE,"tx3g",function(t){this.parseHeader(t),this.displayFlags=t.readUint32(),this.horizontal_justification=t.readInt8(),this.vertical_justification=t.readInt8(),this.bg_color_rgba=t.readUint8Array(4),this.box_record=t.readInt16Array(4),this.style_record=t.readUint8Array(12),this.parseFooter(t)}),f.createSampleEntryCtor(f.SAMPLE_ENTRY_TYPE_METADATA,"wvtt",function(t){this.parseHeader(t),this.parseFooter(t)}),f.createSampleGroupCtor("alst",function(t){var e,r=t.readUint16();for(this.first_output_sample=t.readUint16(),this.sample_offset=[],e=0;e<r;e++)this.sample_offset[e]=t.readUint32();var n=this.description_length-4-4*r;for(this.num_output_samples=[],this.num_total_samples=[],e=0;e<n/4;e++)this.num_output_samples[e]=t.readUint16(),this.num_total_samples[e]=t.readUint16()}),f.createSampleGroupCtor("avll",function(t){this.layerNumber=t.readUint8(),this.accurateStatisticsFlag=t.readUint8(),this.avgBitRate=t.readUint16(),this.avgFrameRate=t.readUint16()}),f.createSampleGroupCtor("avss",function(t){this.subSequenceIdentifier=t.readUint16(),this.layerNumber=t.readUint8();var e=t.readUint8();this.durationFlag=e>>7,this.avgRateFlag=e>>6&1,this.durationFlag&&(this.duration=t.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=t.readUint8(),this.avgBitRate=t.readUint16(),this.avgFrameRate=t.readUint16()),this.dependency=[];for(var r=t.readUint8(),n=0;n<r;n++){var s={};this.dependency.push(s),s.subSeqDirectionFlag=t.readUint8(),s.layerNumber=t.readUint8(),s.subSequenceIdentifier=t.readUint16()}}),f.createSampleGroupCtor("dtrt",function(t){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),f.createSampleGroupCtor("mvif",function(t){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),f.createSampleGroupCtor("prol",function(t){this.roll_distance=t.readInt16()}),f.createSampleGroupCtor("rap ",function(t){var e=t.readUint8();this.num_leading_samples_known=e>>7,this.num_leading_samples=127&e}),f.createSampleGroupCtor("rash",function(t){if(this.operation_point_count=t.readUint16(),this.description_length!==2+(1===this.operation_point_count?2:6*this.operation_point_count)+9)o.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=t.readUint8Array(this.description_length-2);else{if(1===this.operation_point_count)this.target_rate_share=t.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(var e=0;e<this.operation_point_count;e++)this.available_bitrate[e]=t.readUint32(),this.target_rate_share[e]=t.readUint16()}this.maximum_bitrate=t.readUint32(),this.minimum_bitrate=t.readUint32(),this.discard_priority=t.readUint8()}}),f.createSampleGroupCtor("roll",function(t){this.roll_distance=t.readInt16()}),f.SampleGroupEntry.prototype.parse=function(t){o.warn("BoxParser","Unknown Sample Group type: "+this.grouping_type),this.data=t.readUint8Array(this.description_length)},f.createSampleGroupCtor("scif",function(t){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),f.createSampleGroupCtor("scnm",function(t){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),f.createSampleGroupCtor("seig",function(t){this.reserved=t.readUint8();var e=t.readUint8();this.crypt_byte_block=e>>4,this.skip_byte_block=15&e,this.isProtected=t.readUint8(),this.Per_Sample_IV_Size=t.readUint8(),this.KID=f.parseHex16(t),this.constant_IV_size=0,this.constant_IV=0,1===this.isProtected&&0===this.Per_Sample_IV_Size&&(this.constant_IV_size=t.readUint8(),this.constant_IV=t.readUint8Array(this.constant_IV_size))}),f.createSampleGroupCtor("stsa",function(t){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),f.createSampleGroupCtor("sync",function(t){var e=t.readUint8();this.NAL_unit_type=63&e}),f.createSampleGroupCtor("tele",function(t){var e=t.readUint8();this.level_independently_decodable=e>>7}),f.createSampleGroupCtor("tsas",function(t){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),f.createSampleGroupCtor("tscl",function(t){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),f.createSampleGroupCtor("vipr",function(t){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}),f.createFullBoxCtor("sbgp",function(t){this.grouping_type=t.readString(4),1===this.version?this.grouping_type_parameter=t.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var e=t.readUint32(),r=0;r<e;r++){var n={};this.entries.push(n),n.sample_count=t.readInt32(),n.group_description_index=t.readInt32()}}),f.createFullBoxCtor("schm",function(t){this.scheme_type=t.readString(4),this.scheme_version=t.readUint32(),1&this.flags&&(this.scheme_uri=t.readString(this.size-this.hdr_size-8))}),f.createBoxCtor("sdp ",function(t){this.sdptext=t.readString(this.size-this.hdr_size)}),f.createFullBoxCtor("sdtp",function(t){var e,r=this.size-this.hdr_size;this.is_leading=[],this.sample_depends_on=[],this.sample_is_depended_on=[],this.sample_has_redundancy=[];for(var n=0;n<r;n++)e=t.readUint8(),this.is_leading[n]=e>>6,this.sample_depends_on[n]=e>>4&3,this.sample_is_depended_on[n]=e>>2&3,this.sample_has_redundancy[n]=3&e}),f.createFullBoxCtor("senc"),f.createFullBoxCtor("sgpd",function(t){this.grouping_type=t.readString(4),o.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),1===this.version?this.default_length=t.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=t.readUint32()),this.entries=[];for(var e,r=t.readUint32(),n=0;n<r;n++)e=f[this.grouping_type+"SampleGroupEntry"]?new f[this.grouping_type+"SampleGroupEntry"](this.grouping_type):new f.SampleGroupEntry(this.grouping_type),this.entries.push(e),1===this.version&&0===this.default_length?e.description_length=t.readUint32():e.description_length=this.default_length,e.write===f.SampleGroupEntry.prototype.write&&(o.info("BoxParser","SampleGroup for type "+this.grouping_type+" writing not yet implemented, keeping unparsed data in memory for later write"),e.data=t.readUint8Array(e.description_length),t.position-=e.description_length),e.parse(t)}),f.createFullBoxCtor("sidx",function(t){this.reference_ID=t.readUint32(),this.timescale=t.readUint32(),0===this.version?(this.earliest_presentation_time=t.readUint32(),this.first_offset=t.readUint32()):(this.earliest_presentation_time=t.readUint64(),this.first_offset=t.readUint64()),t.readUint16(),this.references=[];for(var e=t.readUint16(),r=0;r<e;r++){var n={};this.references.push(n);var s=t.readUint32();n.reference_type=s>>31&1,n.referenced_size=2147483647&s,n.subsegment_duration=t.readUint32(),s=t.readUint32(),n.starts_with_SAP=s>>31&1,n.SAP_type=s>>28&7,n.SAP_delta_time=268435455&s}}),f.SingleItemTypeReferenceBox=function(t,e,r,n){f.Box.call(this,t,e),this.hdr_size=r,this.start=n},f.SingleItemTypeReferenceBox.prototype=new f.Box,f.SingleItemTypeReferenceBox.prototype.parse=function(t){this.from_item_ID=t.readUint16();var e=t.readUint16();this.references=[];for(var r=0;r<e;r++)this.references[r]={},this.references[r].to_item_ID=t.readUint16()},f.SingleItemTypeReferenceBoxLarge=function(t,e,r,n){f.Box.call(this,t,e),this.hdr_size=r,this.start=n},f.SingleItemTypeReferenceBoxLarge.prototype=new f.Box,f.SingleItemTypeReferenceBoxLarge.prototype.parse=function(t){this.from_item_ID=t.readUint32();var e=t.readUint16();this.references=[];for(var r=0;r<e;r++)this.references[r]={},this.references[r].to_item_ID=t.readUint32()},f.createFullBoxCtor("SmDm",function(t){this.primaryRChromaticity_x=t.readUint16(),this.primaryRChromaticity_y=t.readUint16(),this.primaryGChromaticity_x=t.readUint16(),this.primaryGChromaticity_y=t.readUint16(),this.primaryBChromaticity_x=t.readUint16(),this.primaryBChromaticity_y=t.readUint16(),this.whitePointChromaticity_x=t.readUint16(),this.whitePointChromaticity_y=t.readUint16(),this.luminanceMax=t.readUint32(),this.luminanceMin=t.readUint32()}),f.createFullBoxCtor("smhd",function(t){this.balance=t.readUint16(),t.readUint16()}),f.createFullBoxCtor("ssix",function(t){this.subsegments=[];for(var e=t.readUint32(),r=0;r<e;r++){var n={};this.subsegments.push(n),n.ranges=[];for(var s=t.readUint32(),a=0;a<s;a++){var o={};n.ranges.push(o),o.level=t.readUint8(),o.range_size=t.readUint24()}}}),f.createFullBoxCtor("stco",function(t){var e;if(e=t.readUint32(),this.chunk_offsets=[],0===this.version)for(var r=0;r<e;r++)this.chunk_offsets.push(t.readUint32())}),f.createFullBoxCtor("stdp",function(t){var e=(this.size-this.hdr_size)/2;this.priority=[];for(var r=0;r<e;r++)this.priority[r]=t.readUint16()}),f.createFullBoxCtor("sthd"),f.createFullBoxCtor("stri",function(t){this.switch_group=t.readUint16(),this.alternate_group=t.readUint16(),this.sub_track_id=t.readUint32();var e=(this.size-this.hdr_size-8)/4;this.attribute_list=[];for(var r=0;r<e;r++)this.attribute_list[r]=t.readUint32()}),f.createFullBoxCtor("stsc",function(t){var e,r;if(e=t.readUint32(),this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],0===this.version)for(r=0;r<e;r++)this.first_chunk.push(t.readUint32()),this.samples_per_chunk.push(t.readUint32()),this.sample_description_index.push(t.readUint32())}),f.createFullBoxCtor("stsd",function(t){var e,r,n,s;for(this.entries=[],n=t.readUint32(),e=1;e<=n;e++)if((r=f.parseOneBox(t,!0,this.size-(t.getPosition()-this.start))).code!==f.OK)return;else f[r.type+"SampleEntry"]?((s=new f[r.type+"SampleEntry"](r.size)).hdr_size=r.hdr_size,s.start=r.start):(o.warn("BoxParser","Unknown sample entry type: "+r.type),s=new f.SampleEntry(r.type,r.size,r.hdr_size,r.start)),s.write===f.SampleEntry.prototype.write&&(o.info("BoxParser","SampleEntry "+s.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),s.parseDataAndRewind(t)),s.parse(t),this.entries.push(s)}),f.createFullBoxCtor("stsg",function(t){this.grouping_type=t.readUint32();var e=t.readUint16();this.group_description_index=[];for(var r=0;r<e;r++)this.group_description_index[r]=t.readUint32()}),f.createFullBoxCtor("stsh",function(t){var e,r;if(e=t.readUint32(),this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],0===this.version)for(r=0;r<e;r++)this.shadowed_sample_numbers.push(t.readUint32()),this.sync_sample_numbers.push(t.readUint32())}),f.createFullBoxCtor("stss",function(t){var e,r;if(r=t.readUint32(),0===this.version)for(this.sample_numbers=[],e=0;e<r;e++)this.sample_numbers.push(t.readUint32())}),f.createFullBoxCtor("stsz",function(t){var e;if(this.sample_sizes=[],0===this.version)for(this.sample_size=t.readUint32(),this.sample_count=t.readUint32(),e=0;e<this.sample_count;e++)0===this.sample_size?this.sample_sizes.push(t.readUint32()):this.sample_sizes[e]=this.sample_size}),f.createFullBoxCtor("stts",function(t){var e,r,n;if(e=t.readUint32(),this.sample_counts=[],this.sample_deltas=[],0===this.version)for(r=0;r<e;r++)this.sample_counts.push(t.readUint32()),(n=t.readInt32())<0&&(o.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),n=1),this.sample_deltas.push(n)}),f.createFullBoxCtor("stvi",function(t){var e,r,n=t.readUint32();this.single_view_allowed=3&n,this.stereo_scheme=t.readUint32();var s=t.readUint32();for(this.stereo_indication_type=t.readString(s),this.boxes=[];t.getPosition()<this.start+this.size;)if((e=f.parseOneBox(t,!1,this.size-(t.getPosition()-this.start))).code!==f.OK)return;else r=e.box,this.boxes.push(r),this[r.type]=r}),f.createBoxCtor("styp",function(t){f.ftypBox.prototype.parse.call(this,t)}),f.createFullBoxCtor("stz2",function(t){var e,r;if(this.sample_sizes=[],0===this.version){if(this.reserved=t.readUint24(),this.field_size=t.readUint8(),r=t.readUint32(),4===this.field_size)for(e=0;e<r;e+=2){var n=t.readUint8();this.sample_sizes[e]=n>>4&15,this.sample_sizes[e+1]=15&n}else if(8===this.field_size)for(e=0;e<r;e++)this.sample_sizes[e]=t.readUint8();else if(16===this.field_size)for(e=0;e<r;e++)this.sample_sizes[e]=t.readUint16();else o.error("BoxParser","Error in length field in stz2 box")}}),f.createFullBoxCtor("subs",function(t){var e,r,n,s;for(n=t.readUint32(),this.entries=[],e=0;e<n;e++){var a={};if(this.entries[e]=a,a.sample_delta=t.readUint32(),a.subsamples=[],(s=t.readUint16())>0)for(r=0;r<s;r++){var o={};a.subsamples.push(o),1==this.version?o.size=t.readUint32():o.size=t.readUint16(),o.priority=t.readUint8(),o.discardable=t.readUint8(),o.codec_specific_parameters=t.readUint32()}}}),f.createFullBoxCtor("tenc",function(t){if(t.readUint8(),0===this.version)t.readUint8();else{var e=t.readUint8();this.default_crypt_byte_block=e>>4&15,this.default_skip_byte_block=15&e}this.default_isProtected=t.readUint8(),this.default_Per_Sample_IV_Size=t.readUint8(),this.default_KID=f.parseHex16(t),1===this.default_isProtected&&0===this.default_Per_Sample_IV_Size&&(this.default_constant_IV_size=t.readUint8(),this.default_constant_IV=t.readUint8Array(this.default_constant_IV_size))}),f.createFullBoxCtor("tfdt",function(t){1==this.version?this.baseMediaDecodeTime=t.readUint64():this.baseMediaDecodeTime=t.readUint32()}),f.createFullBoxCtor("tfhd",function(t){var e=0;this.track_id=t.readUint32(),this.size-this.hdr_size>e&&this.flags&f.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=t.readUint64(),e+=8):this.base_data_offset=0,this.size-this.hdr_size>e&&this.flags&f.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=t.readUint32(),e+=4):this.default_sample_description_index=0,this.size-this.hdr_size>e&&this.flags&f.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=t.readUint32(),e+=4):this.default_sample_duration=0,this.size-this.hdr_size>e&&this.flags&f.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=t.readUint32(),e+=4):this.default_sample_size=0,this.size-this.hdr_size>e&&this.flags&f.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=t.readUint32(),e+=4):this.default_sample_flags=0}),f.createFullBoxCtor("tfra",function(t){this.track_ID=t.readUint32(),t.readUint24();var e=t.readUint8();this.length_size_of_traf_num=e>>4&3,this.length_size_of_trun_num=e>>2&3,this.length_size_of_sample_num=3&e,this.entries=[];for(var r=t.readUint32(),n=0;n<r;n++)1===this.version?(this.time=t.readUint64(),this.moof_offset=t.readUint64()):(this.time=t.readUint32(),this.moof_offset=t.readUint32()),this.traf_number=t["readUint"+8*(this.length_size_of_traf_num+1)](),this.trun_number=t["readUint"+8*(this.length_size_of_trun_num+1)](),this.sample_number=t["readUint"+8*(this.length_size_of_sample_num+1)]()}),f.createFullBoxCtor("tkhd",function(t){1==this.version?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.track_id=t.readUint32(),t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.track_id=t.readUint32(),t.readUint32(),this.duration=t.readUint32()),t.readUint32Array(2),this.layer=t.readInt16(),this.alternate_group=t.readInt16(),this.volume=t.readInt16()>>8,t.readUint16(),this.matrix=t.readInt32Array(9),this.width=t.readUint32(),this.height=t.readUint32()}),f.createBoxCtor("tmax",function(t){this.time=t.readUint32()}),f.createBoxCtor("tmin",function(t){this.time=t.readUint32()}),f.createBoxCtor("totl",function(t){this.bytessent=t.readUint32()}),f.createBoxCtor("tpay",function(t){this.bytessent=t.readUint32()}),f.createBoxCtor("tpyl",function(t){this.bytessent=t.readUint64()}),f.TrackGroupTypeBox.prototype.parse=function(t){this.parseFullHeader(t),this.track_group_id=t.readUint32()},f.createTrackGroupCtor("msrc"),f.TrackReferenceTypeBox=function(t,e,r,n){f.Box.call(this,t,e),this.hdr_size=r,this.start=n},f.TrackReferenceTypeBox.prototype=new f.Box,f.TrackReferenceTypeBox.prototype.parse=function(t){this.track_ids=t.readUint32Array((this.size-this.hdr_size)/4)},f.trefBox.prototype.parse=function(t){for(var e,r;t.getPosition()<this.start+this.size;)if((e=f.parseOneBox(t,!0,this.size-(t.getPosition()-this.start))).code!==f.OK)return;else(r=new f.TrackReferenceTypeBox(e.type,e.size,e.hdr_size,e.start)).write===f.Box.prototype.write&&"mdat"!==r.type&&(o.info("BoxParser","TrackReference "+r.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(t)),r.parse(t),this.boxes.push(r)},f.createFullBoxCtor("trep",function(t){for(this.track_ID=t.readUint32(),this.boxes=[];t.getPosition()<this.start+this.size;)if((ret=f.parseOneBox(t,!1,this.size-(t.getPosition()-this.start))).code!==f.OK)return;else box=ret.box,this.boxes.push(box)}),f.createFullBoxCtor("trex",function(t){this.track_id=t.readUint32(),this.default_sample_description_index=t.readUint32(),this.default_sample_duration=t.readUint32(),this.default_sample_size=t.readUint32(),this.default_sample_flags=t.readUint32()}),f.createBoxCtor("trpy",function(t){this.bytessent=t.readUint64()}),f.createFullBoxCtor("trun",function(t){var e=0;if(this.sample_count=t.readUint32(),e+=4,this.size-this.hdr_size>e&&this.flags&f.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=t.readInt32(),e+=4):this.data_offset=0,this.size-this.hdr_size>e&&this.flags&f.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=t.readUint32(),e+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>e)for(var r=0;r<this.sample_count;r++)this.flags&f.TRUN_FLAGS_DURATION&&(this.sample_duration[r]=t.readUint32()),this.flags&f.TRUN_FLAGS_SIZE&&(this.sample_size[r]=t.readUint32()),this.flags&f.TRUN_FLAGS_FLAGS&&(this.sample_flags[r]=t.readUint32()),this.flags&f.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?this.sample_composition_time_offset[r]=t.readUint32():this.sample_composition_time_offset[r]=t.readInt32())}),f.createFullBoxCtor("tsel",function(t){this.switch_group=t.readUint32();var e=(this.size-this.hdr_size-4)/4;this.attribute_list=[];for(var r=0;r<e;r++)this.attribute_list[r]=t.readUint32()}),f.createFullBoxCtor("txtC",function(t){this.config=t.readCString()}),f.createBoxCtor("tyco",function(t){var e=(this.size-this.hdr_size)/4;this.compatible_brands=[];for(var r=0;r<e;r++)this.compatible_brands[r]=t.readString(4)}),f.createFullBoxCtor("udes",function(t){this.lang=t.readCString(),this.name=t.readCString(),this.description=t.readCString(),this.tags=t.readCString()}),f.createFullBoxCtor("uncC",function(t){for(this.profile=t.readUint32(),this.component_count=t.readUint16(),this.component_index=[],this.component_bit_depth_minus_one=[],this.component_format=[],this.component_align_size=[],e=0;e<this.component_count;e++)this.component_index.push(t.readUint16()),this.component_bit_depth_minus_one.push(t.readUint8()),this.component_format.push(t.readUint8()),this.component_align_size.push(t.readUint8());this.sampling_type=t.readUint8(),this.interleave_type=t.readUint8(),this.block_size=t.readUint8();var e,r=t.readUint8();this.component_little_endian=r>>7&1,this.block_pad_lsb=r>>6&1,this.block_little_endian=r>>5&1,this.block_reversed=r>>4&1,this.pad_unknown=r>>3&1,this.pixel_size=t.readUint8(),this.row_align_size=t.readUint32(),this.tile_align_size=t.readUint32(),this.num_tile_cols_minus_one=t.readUint32(),this.num_tile_rows_minus_one=t.readUint32()}),f.createFullBoxCtor("url ",function(t){1!==this.flags&&(this.location=t.readCString())}),f.createFullBoxCtor("urn ",function(t){this.name=t.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=t.readCString())}),f.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,function(t){this.LiveServerManifest=t.readString(this.size-this.hdr_size).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}),f.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,function(t){this.system_id=f.parseHex16(t);var e=t.readUint32();e>0&&(this.data=t.readUint8Array(e))}),f.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),f.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,function(t){this.default_AlgorithmID=t.readUint24(),this.default_IV_size=t.readUint8(),this.default_KID=f.parseHex16(t)}),f.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,function(t){this.fragment_count=t.readUint8(),this.entries=[];for(var e=0;e<this.fragment_count;e++){var r={},n=0,s=0;1===this.version?(n=t.readUint64(),s=t.readUint64()):(n=t.readUint32(),s=t.readUint32()),r.absolute_time=n,r.absolute_duration=s,this.entries.push(r)}}),f.createUUIDBox("6d1d9b0542d544e680e2141daff757b2",!0,!1,function(t){1===this.version?(this.absolute_time=t.readUint64(),this.duration=t.readUint64()):(this.absolute_time=t.readUint32(),this.duration=t.readUint32())}),f.createFullBoxCtor("vmhd",function(t){this.graphicsmode=t.readUint16(),this.opcolor=t.readUint16Array(3)}),f.createFullBoxCtor("vpcC",function(t){var e;1===this.version?(this.profile=t.readUint8(),this.level=t.readUint8(),e=t.readUint8(),this.bitDepth=e>>4,this.chromaSubsampling=e>>1&7,this.videoFullRangeFlag=1&e,this.colourPrimaries=t.readUint8(),this.transferCharacteristics=t.readUint8(),this.matrixCoefficients=t.readUint8()):(this.profile=t.readUint8(),this.level=t.readUint8(),e=t.readUint8(),this.bitDepth=e>>4&15,this.colorSpace=15&e,e=t.readUint8(),this.chromaSubsampling=e>>4&15,this.transferFunction=e>>1&7,this.videoFullRangeFlag=1&e),this.codecIntializationDataSize=t.readUint16(),this.codecIntializationData=t.readUint8Array(this.codecIntializationDataSize)}),f.createBoxCtor("vttC",function(t){this.text=t.readString(this.size-this.hdr_size)}),f.createFullBoxCtor("vvcC",function(t){var e,r,n={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(t){this.held_bits=t.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(t){this.held_bits=t.readUint16(),this.num_held_bits=16},extract_bits:function(t){var e=this.held_bits>>this.num_held_bits-t&(1<<t)-1;return this.num_held_bits-=t,e}};if(n.stream_read_1_bytes(t),n.extract_bits(5),this.lengthSizeMinusOne=n.extract_bits(2),this.ptl_present_flag=n.extract_bits(1),this.ptl_present_flag){if(n.stream_read_2_bytes(t),this.ols_idx=n.extract_bits(9),this.num_sublayers=n.extract_bits(3),this.constant_frame_rate=n.extract_bits(2),this.chroma_format_idc=n.extract_bits(2),n.stream_read_1_bytes(t),this.bit_depth_minus8=n.extract_bits(3),n.extract_bits(5),n.stream_read_2_bytes(t),n.extract_bits(2),this.num_bytes_constraint_info=n.extract_bits(6),this.general_profile_idc=n.extract_bits(7),this.general_tier_flag=n.extract_bits(1),this.general_level_idc=t.readUint8(),n.stream_read_1_bytes(t),this.ptl_frame_only_constraint_flag=n.extract_bits(1),this.ptl_multilayer_enabled_flag=n.extract_bits(1),this.general_constraint_info=new Uint8Array(this.num_bytes_constraint_info),this.num_bytes_constraint_info){for(e=0;e<this.num_bytes_constraint_info-1;e++){var s=n.extract_bits(6);n.stream_read_1_bytes(t);var a=n.extract_bits(2);this.general_constraint_info[e]=s<<2|a}this.general_constraint_info[this.num_bytes_constraint_info-1]=n.extract_bits(6)}else n.extract_bits(6);if(this.num_sublayers>1){for(n.stream_read_1_bytes(t),this.ptl_sublayer_present_mask=0,r=this.num_sublayers-2;r>=0;--r){var o=n.extract_bits(1);this.ptl_sublayer_present_mask|=o<<r}for(r=this.num_sublayers;r<=8&&this.num_sublayers>1;++r)n.extract_bits(1);for(this.sublayer_level_idc=[],r=this.num_sublayers-2;r>=0;--r)this.ptl_sublayer_present_mask&1<<r&&(this.sublayer_level_idc[r]=t.readUint8())}if(this.ptl_num_sub_profiles=t.readUint8(),this.general_sub_profile_idc=[],this.ptl_num_sub_profiles)for(e=0;e<this.ptl_num_sub_profiles;e++)this.general_sub_profile_idc.push(t.readUint32());this.max_picture_width=t.readUint16(),this.max_picture_height=t.readUint16(),this.avg_frame_rate=t.readUint16()}this.nalu_arrays=[];var u=t.readUint8();for(e=0;e<u;e++){var l=[];this.nalu_arrays.push(l),n.stream_read_1_bytes(t),l.completeness=n.extract_bits(1),n.extract_bits(2),l.nalu_type=n.extract_bits(5);var c=1;for(13!=l.nalu_type&&12!=l.nalu_type&&(c=t.readUint16()),r=0;r<c;r++){var h=t.readUint16();l.push({data:t.readUint8Array(h),length:h})}}}),f.createFullBoxCtor("vvnC",function(t){var e=strm.readUint8();this.lengthSizeMinusOne=3&e}),f.SampleEntry.prototype.isVideo=function(){return!1},f.SampleEntry.prototype.isAudio=function(){return!1},f.SampleEntry.prototype.isSubtitle=function(){return!1},f.SampleEntry.prototype.isMetadata=function(){return!1},f.SampleEntry.prototype.isHint=function(){return!1},f.SampleEntry.prototype.getCodec=function(){return this.type.replace(".","")},f.SampleEntry.prototype.getWidth=function(){return""},f.SampleEntry.prototype.getHeight=function(){return""},f.SampleEntry.prototype.getChannelCount=function(){return""},f.SampleEntry.prototype.getSampleRate=function(){return""},f.SampleEntry.prototype.getSampleSize=function(){return""},f.VisualSampleEntry.prototype.isVideo=function(){return!0},f.VisualSampleEntry.prototype.getWidth=function(){return this.width},f.VisualSampleEntry.prototype.getHeight=function(){return this.height},f.AudioSampleEntry.prototype.isAudio=function(){return!0},f.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count},f.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate},f.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize},f.SubtitleSampleEntry.prototype.isSubtitle=function(){return!0},f.MetadataSampleEntry.prototype.isMetadata=function(){return!0},f.decimalToHex=function(t,e){var r=Number(t).toString(16);for(e=(void 0===e?"undefined":(0,ek._)(e))>"u"||null===e?e=2:e;r.length<e;)r="0"+r;return r},f.avc1SampleEntry.prototype.getCodec=f.avc2SampleEntry.prototype.getCodec=f.avc3SampleEntry.prototype.getCodec=f.avc4SampleEntry.prototype.getCodec=function(){var t=f.SampleEntry.prototype.getCodec.call(this);return this.avcC?t+"."+f.decimalToHex(this.avcC.AVCProfileIndication)+f.decimalToHex(this.avcC.profile_compatibility)+f.decimalToHex(this.avcC.AVCLevelIndication):t},f.hev1SampleEntry.prototype.getCodec=f.hvc1SampleEntry.prototype.getCodec=function(){var t,e=f.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){switch(e+=".",this.hvcC.general_profile_space){case 0:e+="";break;case 1:e+="A";break;case 2:e+="B";break;case 3:e+="C"}e+=this.hvcC.general_profile_idc+".";var r=this.hvcC.general_profile_compatibility,n=0;for(t=0;t<32&&(n|=1&r,31!=t);t++)n<<=1,r>>=1;e+=f.decimalToHex(n,0)+".",0===this.hvcC.general_tier_flag?e+="L":e+="H",e+=this.hvcC.general_level_idc;var s=!1,a="";for(t=5;t>=0;t--)(this.hvcC.general_constraint_indicator[t]||s)&&(a="."+f.decimalToHex(this.hvcC.general_constraint_indicator[t],0)+a,s=!0);e+=a}return e},f.vvc1SampleEntry.prototype.getCodec=f.vvi1SampleEntry.prototype.getCodec=function(){var t,e=f.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){e+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?e+=".H":e+=".L",e+=this.vvcC.general_level_idc;var r="";if(this.vvcC.general_constraint_info){var n,s,a=[];for(s=0|this.vvcC.ptl_frame_only_constraint<<7|this.vvcC.ptl_multilayer_enabled<<6,t=0;t<this.vvcC.general_constraint_info.length;++t)s|=this.vvcC.general_constraint_info[t]>>2&63,a.push(s),s&&(n=t),s=this.vvcC.general_constraint_info[t]>>2&3;if(void 0===n)r=".CA";else{r=".C";var o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",u=0,l=0;for(t=0;t<=n;++t)for(u=u<<8|a[t],l+=8;l>=5;)r+=o[u>>l-5&31],l-=5,u&=(1<<l)-1;l&&(u<<=5-l,r+=o[31&u])}}e+=r}return e},f.mp4aSampleEntry.prototype.getCodec=function(){var t=f.SampleEntry.prototype.getCodec.call(this);if(!this.esds||!this.esds.esd)return t;var e=this.esds.esd.getOTI(),r=this.esds.esd.getAudioConfig();return t+"."+f.decimalToHex(e)+(r?"."+r:"")},f.stxtSampleEntry.prototype.getCodec=function(){var t=f.SampleEntry.prototype.getCodec.call(this);return this.mime_format?t+"."+this.mime_format:t},f.vp08SampleEntry.prototype.getCodec=f.vp09SampleEntry.prototype.getCodec=function(){var t=f.SampleEntry.prototype.getCodec.call(this),e=this.vpcC.level;0==e&&(e="00");var r=this.vpcC.bitDepth;return 8==r&&(r="08"),t+".0"+this.vpcC.profile+"."+e+"."+r},f.av01SampleEntry.prototype.getCodec=function(){var t,e=f.SampleEntry.prototype.getCodec.call(this),r=this.av1C.seq_level_idx_0;return r<10&&(r="0"+r),2===this.av1C.seq_profile&&1===this.av1C.high_bitdepth?t=1===this.av1C.twelve_bit?"12":"10":this.av1C.seq_profile<=2&&(t=1===this.av1C.high_bitdepth?"10":"08"),e+"."+this.av1C.seq_profile+"."+r+(this.av1C.seq_tier_0?"H":"M")+"."+t},f.Box.prototype.writeHeader=function(t,e){this.size+=8,this.size>4294967296&&(this.size+=8),"uuid"===this.type&&(this.size+=16),o.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+t.getPosition()+(e||"")),this.size>4294967296?t.writeUint32(1):(this.sizePosition=t.getPosition(),t.writeUint32(this.size)),t.writeString(this.type,null,4),"uuid"===this.type&&t.writeUint8Array(this.uuid),this.size>4294967296&&t.writeUint64(this.size)},f.FullBox.prototype.writeHeader=function(t){this.size+=4,f.Box.prototype.writeHeader.call(this,t," v="+this.version+" f="+this.flags),t.writeUint8(this.version),t.writeUint24(this.flags)},f.Box.prototype.write=function(t){"mdat"===this.type?this.data&&(this.size=this.data.length,this.writeHeader(t),t.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(t),this.data&&t.writeUint8Array(this.data))},f.ContainerBox.prototype.write=function(t){this.size=0,this.writeHeader(t);for(var e=0;e<this.boxes.length;e++)this.boxes[e]&&(this.boxes[e].write(t),this.size+=this.boxes[e].size);o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)},f.TrackReferenceTypeBox.prototype.write=function(t){this.size=4*this.track_ids.length,this.writeHeader(t),t.writeUint32Array(this.track_ids)},f.avcCBox.prototype.write=function(t){var e;for(this.size=7,e=0;e<this.SPS.length;e++)this.size+=2+this.SPS[e].length;for(e=0;e<this.PPS.length;e++)this.size+=2+this.PPS[e].length;for(this.ext&&(this.size+=this.ext.length),this.writeHeader(t),t.writeUint8(this.configurationVersion),t.writeUint8(this.AVCProfileIndication),t.writeUint8(this.profile_compatibility),t.writeUint8(this.AVCLevelIndication),t.writeUint8(this.lengthSizeMinusOne+252),t.writeUint8(this.SPS.length+224),e=0;e<this.SPS.length;e++)t.writeUint16(this.SPS[e].length),t.writeUint8Array(this.SPS[e].nalu);for(t.writeUint8(this.PPS.length),e=0;e<this.PPS.length;e++)t.writeUint16(this.PPS[e].length),t.writeUint8Array(this.PPS[e].nalu);this.ext&&t.writeUint8Array(this.ext)},f.co64Box.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+8*this.chunk_offsets.length,this.writeHeader(t),t.writeUint32(this.chunk_offsets.length),e=0;e<this.chunk_offsets.length;e++)t.writeUint64(this.chunk_offsets[e])},f.cslgBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=20,this.writeHeader(t),t.writeInt32(this.compositionToDTSShift),t.writeInt32(this.leastDecodeToDisplayDelta),t.writeInt32(this.greatestDecodeToDisplayDelta),t.writeInt32(this.compositionStartTime),t.writeInt32(this.compositionEndTime)},f.cttsBox.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(t),t.writeUint32(this.sample_counts.length),e=0;e<this.sample_counts.length;e++)t.writeUint32(this.sample_counts[e]),1===this.version?t.writeInt32(this.sample_offsets[e]):t.writeUint32(this.sample_offsets[e])},f.drefBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.entries.length);for(var e=0;e<this.entries.length;e++)this.entries[e].write(t),this.size+=this.entries[e].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)},f.elngBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=this.extended_language.length,this.writeHeader(t),t.writeString(this.extended_language)},f.elstBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4+12*this.entries.length,this.writeHeader(t),t.writeUint32(this.entries.length);for(var e=0;e<this.entries.length;e++){var r=this.entries[e];t.writeUint32(r.segment_duration),t.writeInt32(r.media_time),t.writeInt16(r.media_rate_integer),t.writeInt16(r.media_rate_fraction)}},f.emsgBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=16+this.message_data.length+(this.scheme_id_uri.length+1)+(this.value.length+1),this.writeHeader(t),t.writeCString(this.scheme_id_uri),t.writeCString(this.value),t.writeUint32(this.timescale),t.writeUint32(this.presentation_time_delta),t.writeUint32(this.event_duration),t.writeUint32(this.id),t.writeUint8Array(this.message_data)},f.ftypBox.prototype.write=function(t){this.size=8+4*this.compatible_brands.length,this.writeHeader(t),t.writeString(this.major_brand,null,4),t.writeUint32(this.minor_version);for(var e=0;e<this.compatible_brands.length;e++)t.writeString(this.compatible_brands[e],null,4)},f.hdlrBox.prototype.write=function(t){this.size=20+this.name.length+1,this.version=0,this.flags=0,this.writeHeader(t),t.writeUint32(0),t.writeString(this.handler,null,4),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeCString(this.name)},f.hvcCBox.prototype.write=function(t){var e,r;for(this.size=23,e=0;e<this.nalu_arrays.length;e++)for(this.size+=3,r=0;r<this.nalu_arrays[e].length;r++)this.size+=2+this.nalu_arrays[e][r].data.length;for(this.writeHeader(t),t.writeUint8(this.configurationVersion),t.writeUint8(this.general_profile_space<<6+this.general_tier_flag<<5+this.general_profile_idc),t.writeUint32(this.general_profile_compatibility),t.writeUint8Array(this.general_constraint_indicator),t.writeUint8(this.general_level_idc),t.writeUint16(this.min_spatial_segmentation_idc+251658240),t.writeUint8(this.parallelismType+252),t.writeUint8(this.chroma_format_idc+252),t.writeUint8(this.bit_depth_luma_minus8+248),t.writeUint8(this.bit_depth_chroma_minus8+248),t.writeUint16(this.avgFrameRate),t.writeUint8((this.constantFrameRate<<6)+(this.numTemporalLayers<<3)+(this.temporalIdNested<<2)+this.lengthSizeMinusOne),t.writeUint8(this.nalu_arrays.length),e=0;e<this.nalu_arrays.length;e++)for(t.writeUint8((this.nalu_arrays[e].completeness<<7)+this.nalu_arrays[e].nalu_type),t.writeUint16(this.nalu_arrays[e].length),r=0;r<this.nalu_arrays[e].length;r++)t.writeUint16(this.nalu_arrays[e][r].data.length),t.writeUint8Array(this.nalu_arrays[e][r].data)},f.kindBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=this.schemeURI.length+1+(this.value.length+1),this.writeHeader(t),t.writeCString(this.schemeURI),t.writeCString(this.value)},f.mdhdBox.prototype.write=function(t){this.size=20,this.flags=0,this.version=0,this.writeHeader(t),t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.timescale),t.writeUint32(this.duration),t.writeUint16(this.language),t.writeUint16(0)},f.mehdBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.fragment_duration)},f.mfhdBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.sequence_number)},f.mvhdBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=96,this.writeHeader(t),t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.timescale),t.writeUint32(this.duration),t.writeUint32(this.rate),t.writeUint16(this.volume<<8),t.writeUint16(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32Array(this.matrix),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(this.next_track_id)},f.SampleEntry.prototype.writeHeader=function(t){this.size=8,f.Box.prototype.writeHeader.call(this,t),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint16(this.data_reference_index)},f.SampleEntry.prototype.writeFooter=function(t){for(var e=0;e<this.boxes.length;e++)this.boxes[e].write(t),this.size+=this.boxes[e].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)},f.SampleEntry.prototype.write=function(t){this.writeHeader(t),t.writeUint8Array(this.data),this.size+=this.data.length,o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)},f.VisualSampleEntry.prototype.write=function(t){this.writeHeader(t),this.size+=70,t.writeUint16(0),t.writeUint16(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint16(this.width),t.writeUint16(this.height),t.writeUint32(this.horizresolution),t.writeUint32(this.vertresolution),t.writeUint32(0),t.writeUint16(this.frame_count),t.writeUint8(Math.min(31,this.compressorname.length)),t.writeString(this.compressorname,null,31),t.writeUint16(this.depth),t.writeInt16(-1),this.writeFooter(t)},f.AudioSampleEntry.prototype.write=function(t){this.writeHeader(t),this.size+=20,t.writeUint32(0),t.writeUint32(0),t.writeUint16(this.channel_count),t.writeUint16(this.samplesize),t.writeUint16(0),t.writeUint16(0),t.writeUint32(this.samplerate<<16),this.writeFooter(t)},f.stppSampleEntry.prototype.write=function(t){this.writeHeader(t),this.size+=this.namespace.length+1+this.schema_location.length+1+this.auxiliary_mime_types.length+1,t.writeCString(this.namespace),t.writeCString(this.schema_location),t.writeCString(this.auxiliary_mime_types),this.writeFooter(t)},f.SampleGroupEntry.prototype.write=function(t){t.writeUint8Array(this.data)},f.sbgpBox.prototype.write=function(t){this.version=1,this.flags=0,this.size=12+8*this.entries.length,this.writeHeader(t),t.writeString(this.grouping_type,null,4),t.writeUint32(this.grouping_type_parameter),t.writeUint32(this.entries.length);for(var e=0;e<this.entries.length;e++){var r=this.entries[e];t.writeInt32(r.sample_count),t.writeInt32(r.group_description_index)}},f.sgpdBox.prototype.write=function(t){var e,r;for(this.flags=0,this.size=12,e=0;e<this.entries.length;e++)r=this.entries[e],1===this.version&&(0===this.default_length&&(this.size+=4),this.size+=r.data.length);for(this.writeHeader(t),t.writeString(this.grouping_type,null,4),1===this.version&&t.writeUint32(this.default_length),this.version>=2&&t.writeUint32(this.default_sample_description_index),t.writeUint32(this.entries.length),e=0;e<this.entries.length;e++)r=this.entries[e],1===this.version&&0===this.default_length&&t.writeUint32(r.description_length),r.write(t)},f.sidxBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=20+12*this.references.length,this.writeHeader(t),t.writeUint32(this.reference_ID),t.writeUint32(this.timescale),t.writeUint32(this.earliest_presentation_time),t.writeUint32(this.first_offset),t.writeUint16(0),t.writeUint16(this.references.length);for(var e=0;e<this.references.length;e++){var r=this.references[e];t.writeUint32(r.reference_type<<31|r.referenced_size),t.writeUint32(r.subsegment_duration),t.writeUint32(r.starts_with_SAP<<31|r.SAP_type<<28|r.SAP_delta_time)}},f.smhdBox.prototype.write=function(t){this.version=0,this.flags=1,this.size=4,this.writeHeader(t),t.writeUint16(this.balance),t.writeUint16(0)},f.stcoBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4+4*this.chunk_offsets.length,this.writeHeader(t),t.writeUint32(this.chunk_offsets.length),t.writeUint32Array(this.chunk_offsets)},f.stscBox.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+12*this.first_chunk.length,this.writeHeader(t),t.writeUint32(this.first_chunk.length),e=0;e<this.first_chunk.length;e++)t.writeUint32(this.first_chunk[e]),t.writeUint32(this.samples_per_chunk[e]),t.writeUint32(this.sample_description_index[e])},f.stsdBox.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=0,this.writeHeader(t),t.writeUint32(this.entries.length),this.size+=4,e=0;e<this.entries.length;e++)this.entries[e].write(t),this.size+=this.entries[e].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)},f.stshBox.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+8*this.shadowed_sample_numbers.length,this.writeHeader(t),t.writeUint32(this.shadowed_sample_numbers.length),e=0;e<this.shadowed_sample_numbers.length;e++)t.writeUint32(this.shadowed_sample_numbers[e]),t.writeUint32(this.sync_sample_numbers[e])},f.stssBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4+4*this.sample_numbers.length,this.writeHeader(t),t.writeUint32(this.sample_numbers.length),t.writeUint32Array(this.sample_numbers)},f.stszBox.prototype.write=function(t){var e,r=!0;if(this.version=0,this.flags=0,this.sample_sizes.length>0)for(e=0;e+1<this.sample_sizes.length;)if(this.sample_sizes[e+1]!==this.sample_sizes[0]){r=!1;break}else e++;else r=!1;this.size=8,r||(this.size+=4*this.sample_sizes.length),this.writeHeader(t),r?t.writeUint32(this.sample_sizes[0]):t.writeUint32(0),t.writeUint32(this.sample_sizes.length),r||t.writeUint32Array(this.sample_sizes)},f.sttsBox.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(t),t.writeUint32(this.sample_counts.length),e=0;e<this.sample_counts.length;e++)t.writeUint32(this.sample_counts[e]),t.writeUint32(this.sample_deltas[e])},f.tfdtBox.prototype.write=function(t){this.version=this.baseMediaDecodeTime>4294967295?1:0,this.flags=0,this.size=4,1===this.version&&(this.size+=4),this.writeHeader(t),1===this.version?t.writeUint64(this.baseMediaDecodeTime):t.writeUint32(this.baseMediaDecodeTime)},f.tfhdBox.prototype.write=function(t){this.version=0,this.size=4,this.flags&f.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&f.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&f.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&f.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&f.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(t),t.writeUint32(this.track_id),this.flags&f.TFHD_FLAG_BASE_DATA_OFFSET&&t.writeUint64(this.base_data_offset),this.flags&f.TFHD_FLAG_SAMPLE_DESC&&t.writeUint32(this.default_sample_description_index),this.flags&f.TFHD_FLAG_SAMPLE_DUR&&t.writeUint32(this.default_sample_duration),this.flags&f.TFHD_FLAG_SAMPLE_SIZE&&t.writeUint32(this.default_sample_size),this.flags&f.TFHD_FLAG_SAMPLE_FLAGS&&t.writeUint32(this.default_sample_flags)},f.tkhdBox.prototype.write=function(t){this.version=0,this.size=80,this.writeHeader(t),t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.track_id),t.writeUint32(0),t.writeUint32(this.duration),t.writeUint32(0),t.writeUint32(0),t.writeInt16(this.layer),t.writeInt16(this.alternate_group),t.writeInt16(this.volume<<8),t.writeUint16(0),t.writeInt32Array(this.matrix),t.writeUint32(this.width),t.writeUint32(this.height)},f.trexBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=20,this.writeHeader(t),t.writeUint32(this.track_id),t.writeUint32(this.default_sample_description_index),t.writeUint32(this.default_sample_duration),t.writeUint32(this.default_sample_size),t.writeUint32(this.default_sample_flags)},f.trunBox.prototype.write=function(t){this.version=0,this.size=4,this.flags&f.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&f.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&f.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&f.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&f.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&f.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(t),t.writeUint32(this.sample_count),this.flags&f.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=t.getPosition(),t.writeInt32(this.data_offset)),this.flags&f.TRUN_FLAGS_FIRST_FLAG&&t.writeUint32(this.first_sample_flags);for(var e=0;e<this.sample_count;e++)this.flags&f.TRUN_FLAGS_DURATION&&t.writeUint32(this.sample_duration[e]),this.flags&f.TRUN_FLAGS_SIZE&&t.writeUint32(this.sample_size[e]),this.flags&f.TRUN_FLAGS_FLAGS&&t.writeUint32(this.sample_flags[e]),this.flags&f.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?t.writeUint32(this.sample_composition_time_offset[e]):t.writeInt32(this.sample_composition_time_offset[e]))},f["url Box"].prototype.write=function(t){this.version=0,this.location?(this.flags=0,this.size=this.location.length+1):(this.flags=1,this.size=0),this.writeHeader(t),this.location&&t.writeCString(this.location)},f["urn Box"].prototype.write=function(t){this.version=0,this.flags=0,this.size=this.name.length+1+(this.location?this.location.length+1:0),this.writeHeader(t),t.writeCString(this.name),this.location&&t.writeCString(this.location)},f.vmhdBox.prototype.write=function(t){this.version=0,this.flags=1,this.size=8,this.writeHeader(t),t.writeUint16(this.graphicsmode),t.writeUint16Array(this.opcolor)},f.cttsBox.prototype.unpack=function(t){var e,r,n;for(n=0,e=0;e<this.sample_counts.length;e++)for(r=0;r<this.sample_counts[e];r++)t[n].pts=t[n].dts+this.sample_offsets[e],n++},f.sttsBox.prototype.unpack=function(t){var e,r,n;for(n=0,e=0;e<this.sample_counts.length;e++)for(r=0;r<this.sample_counts[e];r++)0===n?t[n].dts=0:t[n].dts=t[n-1].dts+this.sample_deltas[e],n++},f.stcoBox.prototype.unpack=function(t){var e;for(e=0;e<this.chunk_offsets.length;e++)t[e].offset=this.chunk_offsets[e]},f.stscBox.prototype.unpack=function(t){var e,r,n,s,a;for(s=0,a=0,e=0;e<this.first_chunk.length;e++)for(r=0;r<(e+1<this.first_chunk.length?this.first_chunk[e+1]:1/0);r++)for(a++,n=0;n<this.samples_per_chunk[e];n++){if(!t[s])return;t[s].description_index=this.sample_description_index[e],t[s].chunk_index=a,s++}},f.stszBox.prototype.unpack=function(t){var e;for(e=0;e<this.sample_sizes.length;e++)t[e].size=this.sample_sizes[e]},f.DIFF_BOXES_PROP_NAMES=["boxes","entries","references","subsamples","items","item_infos","extents","associations","subsegments","ranges","seekLists","seekPoints","esd","levels"],f.DIFF_PRIMITIVE_ARRAY_PROP_NAMES=["compatible_brands","matrix","opcolor","sample_counts","sample_counts","sample_deltas","first_chunk","samples_per_chunk","sample_sizes","chunk_offsets","sample_offsets","sample_description_index","sample_duration"],f.boxEqualFields=function(t,e){var r;if(t&&!e)return!1;for(r in t)if(!(f.DIFF_BOXES_PROP_NAMES.indexOf(r)>-1)){if(t[r]instanceof f.Box||e[r]instanceof f.Box||(0,ek._)(t[r])>"u"||(0,ek._)(e[r])>"u"||"function"==typeof t[r]||"function"==typeof e[r]||t.subBoxNames&&t.subBoxNames.indexOf(r.slice(0,4))>-1||e.subBoxNames&&e.subBoxNames.indexOf(r.slice(0,4))>-1||"data"===r||"start"===r||"size"===r||"creation_time"===r||"modification_time"===r||f.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(r)>-1)continue;if(t[r]!==e[r])return!1}return!0},f.boxEqual=function(t,e){if(!f.boxEqualFields(t,e))return!1;for(var r=0;r<f.DIFF_BOXES_PROP_NAMES.length;r++){var n=f.DIFF_BOXES_PROP_NAMES[r];if(t[n]&&e[n]&&!f.boxEqual(t[n],e[n]))return!1}return!0},(d=function(){}).prototype.parseSample=function(t){var e,r={};r.resources=[];var n=new u(t.data.buffer);if(t.subsamples&&0!==t.subsamples.length){if(r.documentString=n.readString(t.subsamples[0].size),t.subsamples.length>1)for(e=1;e<t.subsamples.length;e++)r.resources[e]=n.readUint8Array(t.subsamples[e].size)}else r.documentString=n.readString(t.data.length);return("undefined"==typeof DOMParser?"undefined":(0,ek._)(DOMParser))<"u"&&(r.document=new DOMParser().parseFromString(r.documentString,"application/xml")),r},(p=function(){}).prototype.parseSample=function(t){return new u(t.data.buffer).readString(t.data.length)},p.prototype.parseConfig=function(t){var e=new u(t.buffer);return e.readUint32(),e.readCString()},rQ.XMLSubtitlein4Parser=d,rQ.Textin4Parser=p,(m=function(t){this.stream=t||new c,this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=!1,this.moovStartFound=!1,this.onMoovStart=null,this.moovStartSent=!1,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.sampleListBuilt=!1,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationInitialized=!1,this.sampleProcessingStarted=!1,this.nextMoofNumber=0,this.itemListBuilt=!1,this.onSidx=null,this.sidxSent=!1}).prototype.setSegmentOptions=function(t,e,r){var n=this.getTrackById(t);if(n){var s={};this.fragmentedTracks.push(s),s.id=t,s.user=e,s.trak=n,n.nextSample=0,s.segmentStream=null,s.nb_samples=1e3,s.rapAlignement=!0,r&&(r.nbSamples&&(s.nb_samples=r.nbSamples),r.rapAlignement&&(s.rapAlignement=r.rapAlignement))}},m.prototype.unsetSegmentOptions=function(t){for(var e=-1,r=0;r<this.fragmentedTracks.length;r++)this.fragmentedTracks[r].id==t&&(e=r);e>-1&&this.fragmentedTracks.splice(e,1)},m.prototype.setExtractionOptions=function(t,e,r){var n=this.getTrackById(t);if(n){var s={};this.extractedTracks.push(s),s.id=t,s.user=e,s.trak=n,n.nextSample=0,s.nb_samples=1e3,s.samples=[],r&&r.nbSamples&&(s.nb_samples=r.nbSamples)}},m.prototype.unsetExtractionOptions=function(t){for(var e=-1,r=0;r<this.extractedTracks.length;r++)this.extractedTracks[r].id==t&&(e=r);e>-1&&this.extractedTracks.splice(e,1)},m.prototype.parse=function(){var t,e,r;if(!(this.restoreParsePosition&&!this.restoreParsePosition()))for(;;)if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}else if(this.saveParsePosition&&this.saveParsePosition(),(e=f.parseOneBox(this.stream,!1)).code===f.ERR_NOT_ENOUGH_DATA){if(!this.processIncompleteBox)return;if(this.processIncompleteBox(e))continue;return}else{switch(t="uuid"!==(r=e.box).type?r.type:r.uuid,this.boxes.push(r),t){case"mdat":this.mdats.push(r);break;case"moof":this.moofs.push(r);break;case"moov":this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0);default:void 0!==this[t]&&o.warn("ISOFile","Duplicate Box of type: "+t+", overriding previous occurrence"),this[t]=r}this.updateUsedBytes&&this.updateUsedBytes(r,e)}},m.prototype.checkBuffer=function(t){if(null==t)throw"Buffer must be defined and non empty";if(void 0===t.fileStart)throw"Buffer must have a fileStart property";return 0===t.byteLength?(o.warn("ISOFile","Ignoring empty buffer (fileStart: "+t.fileStart+")"),this.stream.logBufferLevel(),!1):(o.info("ISOFile","Processing buffer (fileStart: "+t.fileStart+")"),t.usedBytes=0,this.stream.insertBuffer(t),this.stream.logBufferLevel(),!!this.stream.initialized()||(o.warn("ISOFile","Not ready to start parsing"),!1))},m.prototype.appendBuffer=function(t,e){var r;if(this.checkBuffer(t))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(e),this.nextSeekPosition?(r=this.nextSeekPosition,this.nextSeekPosition=void 0):r=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(r=this.stream.getEndFilePositionAfter(r))):r=this.nextParsePosition?this.nextParsePosition:0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(o.info("ISOFile","Done processing buffer (fileStart: "+t.fileStart+") - next buffer to fetch should have a fileStart position of "+r),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),o.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),r},m.prototype.getInfo=function(){var t,e,r,n,s,a,o={},u=/* @__PURE__ */new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(o.hasMoov=!0,o.duration=this.moov.mvhd.duration,o.timescale=this.moov.mvhd.timescale,o.isFragmented=null!=this.moov.mvex,o.isFragmented&&this.moov.mvex.mehd&&(o.fragment_duration=this.moov.mvex.mehd.fragment_duration),o.isProgressive=this.isProgressive,o.hasIOD=null!=this.moov.iods,o.brands=[],o.brands.push(this.ftyp.major_brand),o.brands=o.brands.concat(this.ftyp.compatible_brands),o.created=new Date(u+1e3*this.moov.mvhd.creation_time),o.modified=new Date(u+1e3*this.moov.mvhd.modification_time),o.tracks=[],o.audioTracks=[],o.videoTracks=[],o.subtitleTracks=[],o.metadataTracks=[],o.hintTracks=[],o.otherTracks=[],t=0;t<this.moov.traks.length;t++){if(a=(r=this.moov.traks[t]).mdia.minf.stbl.stsd.entries[0],n={},o.tracks.push(n),n.id=r.tkhd.track_id,n.name=r.mdia.hdlr.name,n.references=[],r.tref)for(e=0;e<r.tref.boxes.length;e++)s={},n.references.push(s),s.type=r.tref.boxes[e].type,s.track_ids=r.tref.boxes[e].track_ids;r.edts&&(n.edits=r.edts.elst.entries),n.created=new Date(u+1e3*r.tkhd.creation_time),n.modified=new Date(u+1e3*r.tkhd.modification_time),n.movie_duration=r.tkhd.duration,n.movie_timescale=o.timescale,n.layer=r.tkhd.layer,n.alternate_group=r.tkhd.alternate_group,n.volume=r.tkhd.volume,n.matrix=r.tkhd.matrix,n.track_width=r.tkhd.width/65536,n.track_height=r.tkhd.height/65536,n.timescale=r.mdia.mdhd.timescale,n.cts_shift=r.mdia.minf.stbl.cslg,n.duration=r.mdia.mdhd.duration,n.samples_duration=r.samples_duration,n.codec=a.getCodec(),n.kind=r.udta&&r.udta.kinds.length?r.udta.kinds[0]:{schemeURI:"",value:""},n.language=r.mdia.elng?r.mdia.elng.extended_language:r.mdia.mdhd.languageString,n.nb_samples=r.samples.length,n.size=r.samples_size,n.bitrate=8*n.size*n.timescale/n.samples_duration,a.isAudio()?(n.type="audio",o.audioTracks.push(n),n.audio={},n.audio.sample_rate=a.getSampleRate(),n.audio.channel_count=a.getChannelCount(),n.audio.sample_size=a.getSampleSize()):a.isVideo()?(n.type="video",o.videoTracks.push(n),n.video={},n.video.width=a.getWidth(),n.video.height=a.getHeight()):a.isSubtitle()?(n.type="subtitles",o.subtitleTracks.push(n)):a.isHint()?(n.type="metadata",o.hintTracks.push(n)):a.isMetadata()?(n.type="metadata",o.metadataTracks.push(n)):(n.type="metadata",o.otherTracks.push(n))}else o.hasMoov=!1;if(o.mime="",o.hasMoov&&o.tracks){for(o.videoTracks&&o.videoTracks.length>0?o.mime+='video/mp4; codecs="':o.audioTracks&&o.audioTracks.length>0?o.mime+='audio/mp4; codecs="':o.mime+='application/mp4; codecs="',t=0;t<o.tracks.length;t++)0!==t&&(o.mime+=","),o.mime+=o.tracks[t].codec;o.mime+='"; profiles="',o.mime+=this.ftyp.compatible_brands.join(),o.mime+='"'}return o},m.prototype.setNextSeekPositionFromSample=function(t){t&&(this.nextSeekPosition?this.nextSeekPosition=Math.min(t.offset+t.alreadyRead,this.nextSeekPosition):this.nextSeekPosition=t.offset+t.alreadyRead)},m.prototype.processSamples=function(t){var e,r;if(this.sampleProcessingStarted){if(this.isFragmentationInitialized&&null!==this.onSegment)for(e=0;e<this.fragmentedTracks.length;e++){var n=this.fragmentedTracks[e];for(r=n.trak;r.nextSample<r.samples.length&&this.sampleProcessingStarted;){o.debug("ISOFile","Creating media fragment on track #"+n.id+" for sample "+r.nextSample);var s=this.createFragment(n.id,r.nextSample,n.segmentStream);if(s)n.segmentStream=s,r.nextSample++;else break;if((r.nextSample%n.nb_samples==0||t||r.nextSample>=r.samples.length)&&(o.info("ISOFile","Sending fragmented data on track #"+n.id+" for samples ["+Math.max(0,r.nextSample-n.nb_samples)+","+(r.nextSample-1)+"]"),o.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(n.id,n.user,n.segmentStream.buffer,r.nextSample,t||r.nextSample>=r.samples.length),n.segmentStream=null,n!==this.fragmentedTracks[e]))break}}if(null!==this.onSamples)for(e=0;e<this.extractedTracks.length;e++){var a=this.extractedTracks[e];for(r=a.trak;r.nextSample<r.samples.length&&this.sampleProcessingStarted;){o.debug("ISOFile","Exporting on track #"+a.id+" sample #"+r.nextSample);var u=this.getSample(r,r.nextSample);if(u)r.nextSample++,a.samples.push(u);else{this.setNextSeekPositionFromSample(r.samples[r.nextSample]);break}if((r.nextSample%a.nb_samples==0||r.nextSample>=r.samples.length)&&(o.debug("ISOFile","Sending samples on track #"+a.id+" for sample "+r.nextSample),this.onSamples&&this.onSamples(a.id,a.user,a.samples),a.samples=[],a!==this.extractedTracks[e]))break}}}},m.prototype.getBox=function(t){var e=this.getBoxes(t,!0);return e.length?e[0]:null},m.prototype.getBoxes=function(t,e){var r=[];return m._sweep.call(this,t,r,e),r},m._sweep=function(t,e,r){for(var n in this.type&&this.type==t&&e.push(this),this.boxes){if(e.length&&r)return;m._sweep.call(this.boxes[n],t,e,r)}},m.prototype.getTrackSamplesInfo=function(t){var e=this.getTrackById(t);if(e)return e.samples},m.prototype.getTrackSample=function(t,e){var r=this.getTrackById(t);return this.getSample(r,e)},m.prototype.releaseUsedSamples=function(t,e){var r=0,n=this.getTrackById(t);n.lastValidSample||(n.lastValidSample=0);for(var s=n.lastValidSample;s<e;s++)r+=this.releaseSample(n,s);o.info("ISOFile","Track #"+t+" released samples up to "+e+" (released size: "+r+", remaining: "+this.samplesDataSize+")"),n.lastValidSample=e},m.prototype.start=function(){this.sampleProcessingStarted=!0,this.processSamples(!1)},m.prototype.stop=function(){this.sampleProcessingStarted=!1},m.prototype.flush=function(){o.info("ISOFile","Flushing remaining samples"),this.updateSampleLists(),this.processSamples(!0),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0)},m.prototype.seekTrack=function(t,e,r){var n,s,a,u=1/0,l=0,c=0;if(0===r.samples.length)return o.info("ISOFile","No sample in track, cannot seek! Using time "+o.getDurationString(0,1)+" and offset: 0"),{offset:0,time:0};for(n=0;n<r.samples.length;n++){if(s=r.samples[n],0===n)c=0,a=s.timescale;else if(s.cts>t*s.timescale){c=n-1;break}e&&s.is_sync&&(l=n)}for(e&&(c=l),t=r.samples[c].cts,r.nextSample=c;r.samples[c].alreadyRead===r.samples[c].size&&r.samples[c+1];)c++;return u=r.samples[c].offset+r.samples[c].alreadyRead,o.info("ISOFile","Seeking to "+(e?"RAP":"")+" sample #"+r.nextSample+" on track "+r.tkhd.track_id+", time "+o.getDurationString(t,a)+" and offset: "+u),{offset:u,time:t/a}},m.prototype.getTrackDuration=function(t){var e;return t.samples?((e=t.samples[t.samples.length-1]).cts+e.duration)/e.timescale:1/0},m.prototype.seek=function(t,e){var r,n,s,a=this.moov,u={offset:1/0,time:1/0};if(this.moov){for(s=0;s<a.traks.length;s++)r=a.traks[s],!(t>this.getTrackDuration(r))&&((n=this.seekTrack(t,e,r)).offset<u.offset&&(u.offset=n.offset),n.time<u.time&&(u.time=n.time));return o.info("ISOFile","Seeking at time "+o.getDurationString(u.time,1)+" needs a buffer with a fileStart position of "+u.offset),u.offset===1/0?u={offset:this.nextParsePosition,time:0}:u.offset=this.stream.getEndFilePositionAfter(u.offset),o.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+u.offset),u}throw"Cannot seek: moov not received!"},m.prototype.equal=function(t){for(var e=0;e<this.boxes.length&&e<t.boxes.length;){var r=this.boxes[e],n=t.boxes[e];if(!f.boxEqual(r,n))return!1;e++}return!0},rQ.ISOFile=m,m.prototype.lastBoxStartPosition=0,m.prototype.parsingMdat=null,m.prototype.nextParsePosition=0,m.prototype.discardMdatData=!1,m.prototype.processIncompleteBox=function(t){var e;return"mdat"===t.type?(e=new f[t.type+"Box"](t.size),this.parsingMdat=e,this.boxes.push(e),this.mdats.push(e),e.start=t.start,e.hdr_size=t.hdr_size,this.stream.addUsedBytes(e.hdr_size),this.lastBoxStartPosition=e.start+e.size,this.stream.seek(e.start+e.size,!1,this.discardMdatData)?(this.parsingMdat=null,!0):(this.moovStartFound?this.nextParsePosition=this.stream.findEndContiguousBuf():this.nextParsePosition=e.start+e.size,!1)):("moov"===t.type&&(this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0)),this.stream.mergeNextBuffer&&this.stream.mergeNextBuffer()?(this.nextParsePosition=this.stream.getEndPosition(),!0):(t.type?this.moovStartFound?this.nextParsePosition=this.stream.getEndPosition():this.nextParsePosition=this.stream.getPosition()+t.size:this.nextParsePosition=this.stream.getEndPosition(),!1))},m.prototype.hasIncompleteMdat=function(){return null!==this.parsingMdat},m.prototype.processIncompleteMdat=function(){var t;return t=this.parsingMdat,this.stream.seek(t.start+t.size,!1,this.discardMdatData)?(o.debug("ISOFile","Found 'mdat' end in buffered data"),this.parsingMdat=null,!0):(this.nextParsePosition=this.stream.findEndContiguousBuf(),!1)},m.prototype.restoreParsePosition=function(){return this.stream.seek(this.lastBoxStartPosition,!0,this.discardMdatData)},m.prototype.saveParsePosition=function(){this.lastBoxStartPosition=this.stream.getPosition()},m.prototype.updateUsedBytes=function(t,e){this.stream.addUsedBytes&&("mdat"===t.type?(this.stream.addUsedBytes(t.hdr_size),this.discardMdatData&&this.stream.addUsedBytes(t.size-t.hdr_size)):this.stream.addUsedBytes(t.size))},m.prototype.add=f.Box.prototype.add,m.prototype.addBox=f.Box.prototype.addBox,m.prototype.init=function(t){var e=t||{};this.add("ftyp").set("major_brand",e.brands&&e.brands[0]||"iso4").set("minor_version",0).set("compatible_brands",e.brands||["iso4"]);var r=this.add("moov");return r.add("mvhd").set("timescale",e.timescale||600).set("rate",e.rate||65536).set("creation_time",0).set("modification_time",0).set("duration",e.duration||0).set("volume",e.width?0:256).set("matrix",[65536,0,0,0,65536,0,0,0,1073741824]).set("next_track_id",1),r.add("mvex"),this},m.prototype.addTrack=function(t){this.moov||this.init(t);var e=t||{};e.width=e.width||320,e.height=e.height||320,e.id=e.id||this.moov.mvhd.next_track_id,e.type=e.type||"avc1";var r=this.moov.add("trak");this.moov.mvhd.next_track_id=e.id+1,r.add("tkhd").set("flags",f.TKHD_FLAG_ENABLED|f.TKHD_FLAG_IN_MOVIE|f.TKHD_FLAG_IN_PREVIEW).set("creation_time",0).set("modification_time",0).set("track_id",e.id).set("duration",e.duration||0).set("layer",e.layer||0).set("alternate_group",0).set("volume",1).set("matrix",[0,0,0,0,0,0,0,0,0]).set("width",e.width<<16).set("height",e.height<<16);var n=r.add("mdia");n.add("mdhd").set("creation_time",0).set("modification_time",0).set("timescale",e.timescale||1).set("duration",e.media_duration||0).set("language",e.language||"und"),n.add("hdlr").set("handler",e.hdlr||"vide").set("name",e.name||"Track created with MP4Box.js"),n.add("elng").set("extended_language",e.language||"fr-FR");var s=n.add("minf");if(void 0!==f[e.type+"SampleEntry"]){var a=new f[e.type+"SampleEntry"];a.data_reference_index=1;var o="";for(var l in f.sampleEntryCodes)for(var c=f.sampleEntryCodes[l],h=0;h<c.length;h++)if(c.indexOf(e.type)>-1){o=l;break}switch(o){case"Visual":if(s.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),a.set("width",e.width).set("height",e.height).set("horizresolution",4718592).set("vertresolution",4718592).set("frame_count",1).set("compressorname",e.type+" Compressor").set("depth",24),e.avcDecoderConfigRecord){var d=new f.avcCBox;d.parse(new u(e.avcDecoderConfigRecord)),a.addBox(d)}else if(e.hevcDecoderConfigRecord){var p=new f.hvcCBox;p.parse(new u(e.hevcDecoderConfigRecord)),a.addBox(p)}break;case"Audio":s.add("smhd").set("balance",e.balance||0),a.set("channel_count",e.channel_count||2).set("samplesize",e.samplesize||16).set("samplerate",e.samplerate||65536);break;case"Hint":s.add("hmhd");break;case"Subtitle":s.add("sthd"),"stpp"===e.type&&a.set("namespace",e.namespace||"nonamespace").set("schema_location",e.schema_location||"").set("auxiliary_mime_types",e.auxiliary_mime_types||"");break;default:s.add("nmhd")}e.description&&a.addBox(e.description),e.description_boxes&&e.description_boxes.forEach(function(t){a.addBox(t)}),s.add("dinf").add("dref").addEntry(new f["url Box"]().set("flags",1));var m=s.add("stbl");return m.add("stsd").addEntry(a),m.add("stts").set("sample_counts",[]).set("sample_deltas",[]),m.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),m.add("stco").set("chunk_offsets",[]),m.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",e.id).set("default_sample_description_index",e.default_sample_description_index||1).set("default_sample_duration",e.default_sample_duration||0).set("default_sample_size",e.default_sample_size||0).set("default_sample_flags",e.default_sample_flags||0),this.buildTrakSampleLists(r),e.id}},f.Box.prototype.computeSize=function(t){var e=t||new l;e.endianness=l.BIG_ENDIAN,this.write(e)},m.prototype.addSample=function(t,e,r){var n=r||{},s={},a=this.getTrackById(t);if(null!==a){s.number=a.samples.length,s.track_id=a.tkhd.track_id,s.timescale=a.mdia.mdhd.timescale,s.description_index=n.sample_description_index?n.sample_description_index-1:0,s.description=a.mdia.minf.stbl.stsd.entries[s.description_index],s.data=e,s.size=e.byteLength,s.alreadyRead=s.size,s.duration=n.duration||1,s.cts=n.cts||0,s.dts=n.dts||0,s.is_sync=n.is_sync||!1,s.is_leading=n.is_leading||0,s.depends_on=n.depends_on||0,s.is_depended_on=n.is_depended_on||0,s.has_redundancy=n.has_redundancy||0,s.degradation_priority=n.degradation_priority||0,s.offset=0,s.subsamples=n.subsamples,a.samples.push(s),a.samples_size+=s.size,a.samples_duration+=s.duration,void 0===a.first_dts&&(a.first_dts=n.dts),this.processSamples();var o=this.createSingleSampleMoof(s);return this.addBox(o),o.computeSize(),o.trafs[0].truns[0].data_offset=o.size+8,this.add("mdat").data=new Uint8Array(e),s}},m.prototype.createSingleSampleMoof=function(t){var e=0;e=t.is_sync?33554432:65536;var r=new f.moofBox;r.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var n=r.add("traf"),s=this.getTrackById(t.track_id);return n.add("tfhd").set("track_id",t.track_id).set("flags",f.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),n.add("tfdt").set("baseMediaDecodeTime",t.dts-(s.first_dts||0)),n.add("trun").set("flags",f.TRUN_FLAGS_DATA_OFFSET|f.TRUN_FLAGS_DURATION|f.TRUN_FLAGS_SIZE|f.TRUN_FLAGS_FLAGS|f.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[t.duration]).set("sample_size",[t.size]).set("sample_flags",[e]).set("sample_composition_time_offset",[t.cts-t.dts]),r},m.prototype.lastMoofIndex=0,m.prototype.samplesDataSize=0,m.prototype.resetTables=function(){var t,e,r,n,s,a;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,t=0;t<this.moov.traks.length;t++){(e=this.moov.traks[t]).tkhd.duration=0,e.mdia.mdhd.duration=0,(e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64).chunk_offsets=[],(r=e.mdia.minf.stbl.stsc).first_chunk=[],r.samples_per_chunk=[],r.sample_description_index=[],(e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2).sample_sizes=[],(n=e.mdia.minf.stbl.stts).sample_counts=[],n.sample_deltas=[],(s=e.mdia.minf.stbl.ctts)&&(s.sample_counts=[],s.sample_offsets=[]),a=e.mdia.minf.stbl.stss;var o=e.mdia.minf.stbl.boxes.indexOf(a);-1!=o&&(e.mdia.minf.stbl.boxes[o]=null)}},m.initSampleGroups=function(t,e,r,n,s){var a,o,u,l;function c(t,e,r){this.grouping_type=t,this.grouping_type_parameter=e,this.sbgp=r,this.last_sample_in_run=-1,this.entry_index=-1}for(e&&(e.sample_groups_info=[]),t.sample_groups_info||(t.sample_groups_info=[]),o=0;o<r.length;o++){for(l=r[o].grouping_type+"/"+r[o].grouping_type_parameter,u=new c(r[o].grouping_type,r[o].grouping_type_parameter,r[o]),e&&(e.sample_groups_info[l]=u),t.sample_groups_info[l]||(t.sample_groups_info[l]=u),a=0;a<n.length;a++)n[a].grouping_type===r[o].grouping_type&&(u.description=n[a],u.description.used=!0);if(s)for(a=0;a<s.length;a++)s[a].grouping_type===r[o].grouping_type&&(u.fragment_description=s[a],u.fragment_description.used=!0,u.is_fragment=!0)}if(e){if(s)for(o=0;o<s.length;o++)!s[o].used&&s[o].version>=2&&(l=s[o].grouping_type+"/0",(u=new c(s[o].grouping_type,0)).is_fragment=!0,e.sample_groups_info[l]||(e.sample_groups_info[l]=u))}else for(o=0;o<n.length;o++)!n[o].used&&n[o].version>=2&&(l=n[o].grouping_type+"/0",u=new c(n[o].grouping_type,0),t.sample_groups_info[l]||(t.sample_groups_info[l]=u))},m.setSampleGroupProperties=function(t,e,r,n){var s,a,o;for(s in e.sample_groups=[],n)e.sample_groups[s]={},e.sample_groups[s].grouping_type=n[s].grouping_type,e.sample_groups[s].grouping_type_parameter=n[s].grouping_type_parameter,r>=n[s].last_sample_in_run&&(n[s].last_sample_in_run<0&&(n[s].last_sample_in_run=0),n[s].entry_index++,n[s].entry_index<=n[s].sbgp.entries.length-1&&(n[s].last_sample_in_run+=n[s].sbgp.entries[n[s].entry_index].sample_count)),n[s].entry_index<=n[s].sbgp.entries.length-1?e.sample_groups[s].group_description_index=n[s].sbgp.entries[n[s].entry_index].group_description_index:e.sample_groups[s].group_description_index=-1,0!==e.sample_groups[s].group_description_index&&(o=n[s].fragment_description?n[s].fragment_description:n[s].description,e.sample_groups[s].group_description_index>0?(a=e.sample_groups[s].group_description_index>65535?(e.sample_groups[s].group_description_index>>16)-1:e.sample_groups[s].group_description_index-1,o&&a>=0&&(e.sample_groups[s].description=o.entries[a])):o&&o.version>=2&&o.default_group_description_index>0&&(e.sample_groups[s].description=o.entries[o.default_group_description_index-1]))},m.process_sdtp=function(t,e,r){e&&(t?(e.is_leading=t.is_leading[r],e.depends_on=t.sample_depends_on[r],e.is_depended_on=t.sample_is_depended_on[r],e.has_redundancy=t.sample_has_redundancy[r]):(e.is_leading=0,e.depends_on=0,e.is_depended_on=0,e.has_redundancy=0))},m.prototype.buildSampleLists=function(){var t,e;for(t=0;t<this.moov.traks.length;t++)e=this.moov.traks[t],this.buildTrakSampleLists(e)},m.prototype.buildTrakSampleLists=function(t){var e,r,n,s,a,o,u,l,c,h,f,d,p,_,y,g,v,b,w,S,x,E,U,T;if(t.samples=[],t.samples_duration=0,t.samples_size=0,r=t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64,n=t.mdia.minf.stbl.stsc,s=t.mdia.minf.stbl.stsz||t.mdia.minf.stbl.stz2,a=t.mdia.minf.stbl.stts,o=t.mdia.minf.stbl.ctts,u=t.mdia.minf.stbl.stss,l=t.mdia.minf.stbl.stsd,c=t.mdia.minf.stbl.subs,d=t.mdia.minf.stbl.stdp,h=t.mdia.minf.stbl.sbgps,f=t.mdia.minf.stbl.sgpds,b=-1,w=-1,S=-1,x=-1,E=0,U=0,T=0,m.initSampleGroups(t,null,h,f),!((void 0===s?"undefined":(0,ek._)(s))>"u")){for(e=0;e<s.sample_sizes.length;e++){var A={};A.number=e,A.track_id=t.tkhd.track_id,A.timescale=t.mdia.mdhd.timescale,A.alreadyRead=0,t.samples[e]=A,A.size=s.sample_sizes[e],t.samples_size+=A.size,0===e?(_=1,p=0,A.chunk_index=_,A.chunk_run_index=p,v=n.samples_per_chunk[p],g=0,y=p+1<n.first_chunk.length?n.first_chunk[p+1]-1:1/0):e<v?(A.chunk_index=_,A.chunk_run_index=p):(_++,A.chunk_index=_,g=0,_<=y||(y=++p+1<n.first_chunk.length?n.first_chunk[p+1]-1:1/0),A.chunk_run_index=p,v+=n.samples_per_chunk[p]),A.description_index=n.sample_description_index[A.chunk_run_index]-1,A.description=l.entries[A.description_index],A.offset=r.chunk_offsets[A.chunk_index-1]+g,g+=A.size,e>b&&(w++,b<0&&(b=0),b+=a.sample_counts[w]),e>0?(t.samples[e-1].duration=a.sample_deltas[w],t.samples_duration+=t.samples[e-1].duration,A.dts=t.samples[e-1].dts+t.samples[e-1].duration):A.dts=0,o?(e>=S&&(x++,S<0&&(S=0),S+=o.sample_counts[x]),A.cts=t.samples[e].dts+o.sample_offsets[x]):A.cts=A.dts,u?(e==u.sample_numbers[E]-1?(A.is_sync=!0,E++):(A.is_sync=!1,A.degradation_priority=0),c&&c.entries[U].sample_delta+T==e+1&&(A.subsamples=c.entries[U].subsamples,T+=c.entries[U].sample_delta,U++)):A.is_sync=!0,m.process_sdtp(t.mdia.minf.stbl.sdtp,A,A.number),d?A.degradation_priority=d.priority[e]:A.degradation_priority=0,c&&c.entries[U].sample_delta+T==e&&(A.subsamples=c.entries[U].subsamples,T+=c.entries[U].sample_delta),(h.length>0||f.length>0)&&m.setSampleGroupProperties(t,A,e,t.sample_groups_info)}e>0&&(t.samples[e-1].duration=Math.max(t.mdia.mdhd.duration-t.samples[e-1].dts,0),t.samples_duration+=t.samples[e-1].duration)}},m.prototype.updateSampleLists=function(){var t,e,r,n,s,a,o,u,l,c,h,d,p,_;if(void 0!==this.moov){for(;this.lastMoofIndex<this.moofs.length;)if(l=this.moofs[this.lastMoofIndex],this.lastMoofIndex++,"moof"==l.type)for(t=0;t<l.trafs.length;t++){for(c=l.trafs[t],h=this.getTrackById(c.tfhd.track_id),d=this.getTrexById(c.tfhd.track_id),n=c.tfhd.flags&f.TFHD_FLAG_SAMPLE_DESC?c.tfhd.default_sample_description_index:d?d.default_sample_description_index:1,s=c.tfhd.flags&f.TFHD_FLAG_SAMPLE_DUR?c.tfhd.default_sample_duration:d?d.default_sample_duration:0,a=c.tfhd.flags&f.TFHD_FLAG_SAMPLE_SIZE?c.tfhd.default_sample_size:d?d.default_sample_size:0,o=c.tfhd.flags&f.TFHD_FLAG_SAMPLE_FLAGS?c.tfhd.default_sample_flags:d?d.default_sample_flags:0,c.sample_number=0,c.sbgps.length>0&&m.initSampleGroups(h,c,c.sbgps,h.mdia.minf.stbl.sgpds,c.sgpds),e=0;e<c.truns.length;e++){var y=c.truns[e];for(r=0;r<y.sample_count;r++){(p={}).moof_number=this.lastMoofIndex,p.number_in_traf=c.sample_number,c.sample_number++,p.number=h.samples.length,c.first_sample_index=h.samples.length,h.samples.push(p),p.track_id=h.tkhd.track_id,p.timescale=h.mdia.mdhd.timescale,p.description_index=n-1,p.description=h.mdia.minf.stbl.stsd.entries[p.description_index],p.size=a,y.flags&f.TRUN_FLAGS_SIZE&&(p.size=y.sample_size[r]),h.samples_size+=p.size,p.duration=s,y.flags&f.TRUN_FLAGS_DURATION&&(p.duration=y.sample_duration[r]),h.samples_duration+=p.duration,h.first_traf_merged||r>0?p.dts=h.samples[h.samples.length-2].dts+h.samples[h.samples.length-2].duration:(c.tfdt?p.dts=c.tfdt.baseMediaDecodeTime:p.dts=0,h.first_traf_merged=!0),p.cts=p.dts,y.flags&f.TRUN_FLAGS_CTS_OFFSET&&(p.cts=p.dts+y.sample_composition_time_offset[r]),_=o,y.flags&f.TRUN_FLAGS_FLAGS?_=y.sample_flags[r]:0===r&&y.flags&f.TRUN_FLAGS_FIRST_FLAG&&(_=y.first_sample_flags),p.is_sync=!(_>>16&1),p.is_leading=_>>26&3,p.depends_on=_>>24&3,p.is_depended_on=_>>22&3,p.has_redundancy=_>>20&3,p.degradation_priority=65535&_;var g=!!(c.tfhd.flags&f.TFHD_FLAG_BASE_DATA_OFFSET),v=!!(c.tfhd.flags&f.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),b=!!(y.flags&f.TRUN_FLAGS_DATA_OFFSET),w=0;w=g?c.tfhd.base_data_offset:v||0===e?l.start:u,0===e&&0===r?b?p.offset=w+y.data_offset:p.offset=w:p.offset=u,u=p.offset+p.size,(c.sbgps.length>0||c.sgpds.length>0||h.mdia.minf.stbl.sbgps.length>0||h.mdia.minf.stbl.sgpds.length>0)&&m.setSampleGroupProperties(h,p,p.number_in_traf,c.sample_groups_info)}}if(c.subs){h.has_fragment_subsamples=!0;var S=c.first_sample_index;for(e=0;e<c.subs.entries.length;e++)S+=c.subs.entries[e].sample_delta,(p=h.samples[S-1]).subsamples=c.subs.entries[e].subsamples}}}},m.prototype.getSample=function(t,e){var r,n=t.samples[e];if(!this.moov)return null;if(n.data){if(n.alreadyRead==n.size)return n}else n.data=new Uint8Array(n.size),n.alreadyRead=0,this.samplesDataSize+=n.size,o.debug("ISOFile","Allocating sample #"+e+" on track #"+t.tkhd.track_id+" of size "+n.size+" (total: "+this.samplesDataSize+")");for(;;){var s=this.stream.findPosition(!0,n.offset+n.alreadyRead,!1);if(!(s>-1))return null;var a=(r=this.stream.buffers[s]).byteLength-(n.offset+n.alreadyRead-r.fileStart);if(n.size-n.alreadyRead<=a)return o.debug("ISOFile","Getting sample #"+e+" data (alreadyRead: "+n.alreadyRead+" offset: "+(n.offset+n.alreadyRead-r.fileStart)+" read size: "+(n.size-n.alreadyRead)+" full size: "+n.size+")"),l.memcpy(n.data.buffer,n.alreadyRead,r,n.offset+n.alreadyRead-r.fileStart,n.size-n.alreadyRead),r.usedBytes+=n.size-n.alreadyRead,this.stream.logBufferLevel(),n.alreadyRead=n.size,n;if(0===a)return null;o.debug("ISOFile","Getting sample #"+e+" partial data (alreadyRead: "+n.alreadyRead+" offset: "+(n.offset+n.alreadyRead-r.fileStart)+" read size: "+a+" full size: "+n.size+")"),l.memcpy(n.data.buffer,n.alreadyRead,r,n.offset+n.alreadyRead-r.fileStart,a),n.alreadyRead+=a,r.usedBytes+=a,this.stream.logBufferLevel()}},m.prototype.releaseSample=function(t,e){var r=t.samples[e];return r.data?(this.samplesDataSize-=r.size,r.data=null,r.alreadyRead=0,r.size):0},m.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},m.prototype.getCodecs=function(){var t,e="";for(t=0;t<this.moov.traks.length;t++){var r=this.moov.traks[t];t>0&&(e+=","),e+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return e},m.prototype.getTrexById=function(t){var e;if(!this.moov||!this.moov.mvex)return null;for(e=0;e<this.moov.mvex.trexs.length;e++){var r=this.moov.mvex.trexs[e];if(r.track_id==t)return r}return null},m.prototype.getTrackById=function(t){if(void 0===this.moov)return null;for(var e=0;e<this.moov.traks.length;e++){var r=this.moov.traks[e];if(r.tkhd.track_id==t)return r}return null},m.prototype.items=[],m.prototype.itemsDataSize=0,m.prototype.flattenItemInfo=function(){var t,e,r,n=this.items,s=this.meta;if(null!=s&&void 0!==s.hdlr&&void 0!==s.iinf){for(t=0;t<s.iinf.item_infos.length;t++)(r={}).id=s.iinf.item_infos[t].item_ID,n[r.id]=r,r.ref_to=[],r.name=s.iinf.item_infos[t].item_name,s.iinf.item_infos[t].protection_index>0&&(r.protection=s.ipro.protections[s.iinf.item_infos[t].protection_index-1]),s.iinf.item_infos[t].item_type?r.type=s.iinf.item_infos[t].item_type:r.type="mime",r.content_type=s.iinf.item_infos[t].content_type,r.content_encoding=s.iinf.item_infos[t].content_encoding;if(s.iloc)for(t=0;t<s.iloc.items.length;t++){var a=s.iloc.items[t];switch(r=n[a.item_ID],0!==a.data_reference_index&&(o.warn("Item storage with reference to other files: not supported"),r.source=s.dinf.boxes[a.data_reference_index-1]),a.construction_method){case 0:break;case 1:case 2:o.warn("Item storage with construction_method : not supported")}for(r.extents=[],r.size=0,e=0;e<a.extents.length;e++)r.extents[e]={},r.extents[e].offset=a.extents[e].extent_offset+a.base_offset,r.extents[e].length=a.extents[e].extent_length,r.extents[e].alreadyRead=0,r.size+=r.extents[e].length}if(s.pitm&&(n[s.pitm.item_id].primary=!0),s.iref)for(t=0;t<s.iref.references.length;t++){var u=s.iref.references[t];for(e=0;e<u.references.length;e++)n[u.from_item_ID].ref_to.push({type:u.type,id:u.references[e]})}if(s.iprp)for(var l=0;l<s.iprp.ipmas.length;l++){var c=s.iprp.ipmas[l];for(t=0;t<c.associations.length;t++){var h=c.associations[t];for(void 0===(r=n[h.id]).properties&&(r.properties={},r.properties.boxes=[]),e=0;e<h.props.length;e++){var f=h.props[e];if(f.property_index>0&&f.property_index-1<s.iprp.ipco.boxes.length){var d=s.iprp.ipco.boxes[f.property_index-1];r.properties[d.type]=d,r.properties.boxes.push(d)}}}}}},m.prototype.getItem=function(t){var e,r;if(!this.meta)return null;if(!(r=this.items[t]).data&&r.size)r.data=new Uint8Array(r.size),r.alreadyRead=0,this.itemsDataSize+=r.size,o.debug("ISOFile","Allocating item #"+t+" of size "+r.size+" (total: "+this.itemsDataSize+")");else if(r.alreadyRead===r.size)return r;for(var n=0;n<r.extents.length;n++){var s=r.extents[n];if(s.alreadyRead!==s.length){var a=this.stream.findPosition(!0,s.offset+s.alreadyRead,!1);if(!(a>-1))return null;var u=(e=this.stream.buffers[a]).byteLength-(s.offset+s.alreadyRead-e.fileStart);if(!(s.length-s.alreadyRead<=u))return o.debug("ISOFile","Getting item #"+t+" extent #"+n+" partial data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-e.fileStart)+" read size: "+u+" full extent size: "+s.length+" full item size: "+r.size+")"),l.memcpy(r.data.buffer,r.alreadyRead,e,s.offset+s.alreadyRead-e.fileStart,u),s.alreadyRead+=u,r.alreadyRead+=u,e.usedBytes+=u,this.stream.logBufferLevel(),null;o.debug("ISOFile","Getting item #"+t+" extent #"+n+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-e.fileStart)+" read size: "+(s.length-s.alreadyRead)+" full extent size: "+s.length+" full item size: "+r.size+")"),l.memcpy(r.data.buffer,r.alreadyRead,e,s.offset+s.alreadyRead-e.fileStart,s.length-s.alreadyRead),e.usedBytes+=s.length-s.alreadyRead,this.stream.logBufferLevel(),r.alreadyRead+=s.length-s.alreadyRead,s.alreadyRead=s.length}}return r.alreadyRead===r.size?r:null},m.prototype.releaseItem=function(t){var e=this.items[t];if(!e.data)return 0;this.itemsDataSize-=e.size,e.data=null,e.alreadyRead=0;for(var r=0;r<e.extents.length;r++)e.extents[r].alreadyRead=0;return e.size},m.prototype.processItems=function(t){for(var e in this.items){var r=this.items[e];this.getItem(r.id),t&&!r.sent&&(t(r),r.sent=!0,r.data=null)}},m.prototype.hasItem=function(t){for(var e in this.items){var r=this.items[e];if(r.name===t)return r.id}return -1},m.prototype.getMetaHandler=function(){return this.meta?this.meta.hdlr.handler:null},m.prototype.getPrimaryItem=function(){return this.meta&&this.meta.pitm?this.getItem(this.meta.pitm.item_id):null},m.prototype.itemToFragmentedTrackFile=function(t){var e=t||{},r=null;if(null==(r=e.itemId?this.getItem(e.itemId):this.getPrimaryItem()))return null;var n=new m;n.discardMdatData=!1;var s={type:r.type,description_boxes:r.properties.boxes};r.properties.ispe&&(s.width=r.properties.ispe.image_width,s.height=r.properties.ispe.image_height);var a=n.addTrack(s);return a?(n.addSample(a,r.data),n):null},m.prototype.write=function(t){for(var e=0;e<this.boxes.length;e++)this.boxes[e].write(t)},m.prototype.createFragment=function(t,e,r){var n=this.getTrackById(t),s=this.getSample(n,e);if(null==s)return this.setNextSeekPositionFromSample(n.samples[e]),null;var a=r||new l;a.endianness=l.BIG_ENDIAN;var u=this.createSingleSampleMoof(s);u.write(a),u.trafs[0].truns[0].data_offset=u.size+8,o.debug("MP4Box","Adjusting data_offset with new value "+u.trafs[0].truns[0].data_offset),a.adjustUint32(u.trafs[0].truns[0].data_offset_position,u.trafs[0].truns[0].data_offset);var c=new f.mdatBox;return c.data=s.data,c.write(a),a},m.writeInitializationSegment=function(t,e,r,n){o.debug("ISOFile","Generating initialization segment");var s,a=new l;a.endianness=l.BIG_ENDIAN,t.write(a);var u=e.add("mvex");for(r&&u.add("mehd").set("fragment_duration",r),s=0;s<e.traks.length;s++)u.add("trex").set("track_id",e.traks[s].tkhd.track_id).set("default_sample_description_index",1).set("default_sample_duration",n).set("default_sample_size",0).set("default_sample_flags",65536);return e.write(a),a.buffer},m.prototype.save=function(t){var e=new l;e.endianness=l.BIG_ENDIAN,this.write(e),e.save(t)},m.prototype.getBuffer=function(){var t=new l;return t.endianness=l.BIG_ENDIAN,this.write(t),t.buffer},m.prototype.initializeSegmentation=function(){var t,e,r,n;for(null===this.onSegment&&o.warn("MP4Box","No segmentation callback set!"),this.isFragmentationInitialized||(this.isFragmentationInitialized=!0,this.nextMoofNumber=0,this.resetTables()),e=[],t=0;t<this.fragmentedTracks.length;t++){var s=new f.moovBox;s.mvhd=this.moov.mvhd,s.boxes.push(s.mvhd),r=this.getTrackById(this.fragmentedTracks[t].id),s.boxes.push(r),s.traks.push(r),(n={}).id=r.tkhd.track_id,n.user=this.fragmentedTracks[t].user,n.buffer=m.writeInitializationSegment(this.ftyp,s,this.moov.mvex&&this.moov.mvex.mehd?this.moov.mvex.mehd.fragment_duration:void 0,this.moov.traks[t].samples.length>0?this.moov.traks[t].samples[0].duration:0),e.push(n)}return e},f.Box.prototype.printHeader=function(t){this.size+=8,this.size>4294967296&&(this.size+=8),"uuid"===this.type&&(this.size+=16),t.log(t.indent+"size:"+this.size),t.log(t.indent+"type:"+this.type)},f.FullBox.prototype.printHeader=function(t){this.size+=4,f.Box.prototype.printHeader.call(this,t),t.log(t.indent+"version:"+this.version),t.log(t.indent+"flags:"+this.flags)},f.Box.prototype.print=function(t){this.printHeader(t)},f.ContainerBox.prototype.print=function(t){this.printHeader(t);for(var e=0;e<this.boxes.length;e++)if(this.boxes[e]){var r=t.indent;t.indent+=" ",this.boxes[e].print(t),t.indent=r}},m.prototype.print=function(t){t.indent="";for(var e=0;e<this.boxes.length;e++)this.boxes[e]&&this.boxes[e].print(t)},f.mvhdBox.prototype.print=function(t){f.FullBox.prototype.printHeader.call(this,t),t.log(t.indent+"creation_time: "+this.creation_time),t.log(t.indent+"modification_time: "+this.modification_time),t.log(t.indent+"timescale: "+this.timescale),t.log(t.indent+"duration: "+this.duration),t.log(t.indent+"rate: "+this.rate),t.log(t.indent+"volume: "+(this.volume>>8)),t.log(t.indent+"matrix: "+this.matrix.join(", ")),t.log(t.indent+"next_track_id: "+this.next_track_id)},f.tkhdBox.prototype.print=function(t){f.FullBox.prototype.printHeader.call(this,t),t.log(t.indent+"creation_time: "+this.creation_time),t.log(t.indent+"modification_time: "+this.modification_time),t.log(t.indent+"track_id: "+this.track_id),t.log(t.indent+"duration: "+this.duration),t.log(t.indent+"volume: "+(this.volume>>8)),t.log(t.indent+"matrix: "+this.matrix.join(", ")),t.log(t.indent+"layer: "+this.layer),t.log(t.indent+"alternate_group: "+this.alternate_group),t.log(t.indent+"width: "+this.width),t.log(t.indent+"height: "+this.height)},(_={}).createFile=function(t,e){var r=new m(e);return r.discardMdatData=!(void 0===t||t),r},rQ.createFile=_.createFile;var rJ=/* @__PURE__ */rq(rQ),r$={sampleRate:48e3,channelCount:2,codec:"mp4a.40.2"};function r0(t,e){var r=e.videoTracks[0],n={};if(null!=r){var s=function(t){var e=!0,r=!1,n=void 0;try{for(var s,a=t.mdia.minf.stbl.stsd.entries[Symbol.iterator]();!(e=(s=a.next()).done);e=!0){var o,u,l=s.value,c=null!==(u=null!==(o=l.avcC)&&void 0!==o?o:l.hvcC)&&void 0!==u?u:l.vpcC;if(null!=c){var h=new rJ.DataStream(void 0,0,rJ.DataStream.BIG_ENDIAN);return c.write(h),new Uint8Array(h.buffer.slice(8))}}}catch(t){r=!0,n=t}finally{try{e||null==a.return||a.return()}finally{if(r)throw n}}throw Error("avcC, hvcC or VPX not found")}(t.getTrackById(r.id)).buffer,a=r.codec.startsWith("avc1")?{descKey:"avcDecoderConfigRecord",type:"avc1"}:r.codec.startsWith("hvc1")?{descKey:"hevcDecoderConfigRecord",type:"hvc1"}:{descKey:"",type:""},o=a.descKey,u=a.type;""!==o&&(n.videoTrackConf=(0,eb._)({timescale:r.timescale,duration:r.duration,width:r.video.width,height:r.video.height,brands:e.brands,type:u},o,s)),n.videoDecoderConf={codec:r.codec,codedHeight:r.video.height,codedWidth:r.video.width,description:s}}var l=e.audioTracks[0];if(null!=l){var c=r1(t);n.audioTrackConf={timescale:l.timescale,samplerate:l.audio.sample_rate,channel_count:l.audio.channel_count,hdlr:"soun",type:l.codec.startsWith("mp4a")?"mp4a":l.codec,description:r1(t)},n.audioDecoderConf=(0,eE._)({codec:l.codec.startsWith("mp4a")?r$.codec:l.codec,numberOfChannels:l.audio.channel_count,sampleRate:l.audio.sample_rate},null==c?{}:function(t){var e,r=null==(e=t.esd.descs[0])?void 0:e.descs[0];if(null==r)return{};var n=(0,eA._)(r.data,2),s=n[0],a=n[1];return{sampleRate:[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][((7&s)<<1)+(a>>7)],numberOfChannels:(127&a)>>3}}(c))}return n}function r1(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"mp4a",n=null==(e=t.moov)?void 0:e.traks.map(function(t){return t.mdia.minf.stbl.stsd.entries}).flat().find(function(t){return t.type===r});return null==n?void 0:n.esds}var r2=function t(){(0,eg._)(this,t),eL(this,"readable"),eL(this,"writable"),eN(this,C,0);var e,r=rJ.createFile(),n=!1,s=this;this.readable=new ReadableStream({start:function(t){r.onReady=function(e){var n,s,a=null==(n=e.videoTracks[0])?void 0:n.id;null!=a&&r.setExtractionOptions(a,"video",{nbSamples:100});var o=null==(s=e.audioTracks[0])?void 0:s.id;null!=o&&r.setExtractionOptions(o,"audio",{nbSamples:100}),t.enqueue({chunkType:"ready",data:{info:e,file:r}}),r.start()};var e={};r.onSamples=function(n,s,a){var o;t.enqueue({chunkType:"samples",data:{id:n,type:s,samples:a.map(function(t){return(0,eE._)({},t)})}}),e[n]=(null!==(o=e[n])&&void 0!==o?o:0)+a.length,r.releaseUsedSamples(n,e[n])},r.onFlush=function(){t.close()}},cancel:function(){r.stop(),n=!0}},{highWaterMark:50}),this.writable=new WritableStream({write:(e=(0,ey._)(function(t){var e;return(0,eB._)(this,function(a){return n?s.writable.abort():((e=t.buffer).fileStart=eM(s,C),ej(s,C,eM(s,C)+e.byteLength),r.appendBuffer(e)),[2]})}),function(t){return e.apply(this,arguments)}),close:function(){var t;r.flush(),r.stop(),null==(t=r.onFlush)||t.call(r)}})};C=new WeakMap;var r3=0;function r4(t){return"file"===t.kind&&t.createReader instanceof Function}var r6=/*#__PURE__*/function(){function t(e){var r,n,s,a=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0};if((0,eg._)(this,t),eN(this,B,rw.create("MP4Clip id:".concat(r3++,","))),eL(this,"ready"),eN(this,P,!1),eN(this,R,{duration:0,width:0,height:0,audioSampleRate:0,audioChanCount:0}),eN(this,F),eN(this,D,1),eN(this,z,[]),eN(this,L,[]),eN(this,O,null),eN(this,M,null),eN(this,N,{video:null,audio:null}),eN(this,j,{audio:!0}),eL(this,"tickInterceptor",(r=(0,ey._)(function(t,e){return(0,eB._)(this,function(t){return[2,e]})}),function(t,e){return r.apply(this,arguments)})),eN(this,G,new AbortController),!(e instanceof ReadableStream)&&!r4(e)&&!Array.isArray(e.videoSamples))throw Error("Illegal argument");ej(this,j,(0,eE._)({},o)),ej(this,D,"object"==typeof o.audio&&"volume"in o.audio?o.audio.volume:1);var u=this,l=(n=(0,ey._)(function(t){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,rn(eM(u,F),t)];case 1:return e.sent(),[4,eM(u,F).stream()];case 2:return[2,e.sent()]}})}),function(t){return n.apply(this,arguments)}),c=this;ej(this,F,r4(e)?e:"localFile"in e?e.localFile:rm()),this.ready=(e instanceof ReadableStream?l(e).then(function(t){return r9(t,eM(a,j))}):r4(e)?e.stream().then(function(t){return r9(t,eM(a,j))}):Promise.resolve(e)).then((s=(0,ey._)(function(t){var e,r,n,s,a,o,u;return(0,eB._)(this,function(l){switch(l.label){case 0:return e=t.videoSamples,r=t.audioSamples,n=t.decoderConf,ej(c,z,e),ej(c,L,r),ej(c,N,n),u=[{video:null==n.video?null:(0,eU._)((0,eE._)({},n.video),{hardwareAcceleration:eM(c,j).__unsafe_hardwareAcceleration__}),audio:n.audio}],[4,eM(c,F).createReader()];case 1:return a=(s=r5.apply(void 0,u.concat([l.sent(),e,r,!1!==eM(c,j).audio?eM(c,D):null]))).videoFrameFinder,o=s.audioFrameFinder,[2,(ej(c,O,a),ej(c,M,o),ej(c,R,function(t,e,r){var n,s,a={duration:0,width:0,height:0,audioSampleRate:0,audioChanCount:0};null!=t.video&&e.length>0&&(a.width=null!==(n=t.video.codedWidth)&&void 0!==n?n:0,a.height=null!==(s=t.video.codedHeight)&&void 0!==s?s:0),null!=t.audio&&r.length>0&&(a.audioSampleRate=r$.sampleRate,a.audioChanCount=r$.channelCount);var o=0,u=0;if(e.length>0)for(var l=e.length-1;l>=0;l--){var c=e[l];if(!c.deleted){o=c.cts+c.duration;break}}if(r.length>0){var h=r.at(-1);u=h.cts+h.duration}return a.duration=Math.max(o,u),a}(n,e,r)),eM(c,B).info("MP4Clip meta:",eM(c,R)),(0,eE._)({},eM(c,R)))]}})}),function(t){return s.apply(this,arguments)}))}return(0,ev._)(t,[{key:"meta",get:function(){return(0,eE._)({},eM(this,R))}},{key:"tick",value:function(t){var e=this;return(0,ey._)(function(){var r,n,s,a,o,u,l;return(0,eB._)(this,function(c){switch(c.label){case 0:if(!(t>=eM(e,R).duration))return[3,2];return[4,e.tickInterceptor(t,{audio:[],state:"done"})];case 1:return[2,c.sent()];case 2:return[4,Promise.all([null!==(s=null==(r=eM(e,M))?void 0:r.find(t))&&void 0!==s?s:[],null==(n=eM(e,O))?void 0:n.find(t)])];case 3:if(o=(a=(0,eA._).apply(void 0,[c.sent(),2]))[0],null!=(u=a[1]))return[3,5];return[4,e.tickInterceptor(t,{audio:o,state:"success"})];case 4:return l=c.sent(),[3,7];case 5:return[4,e.tickInterceptor(t,{video:u,audio:o,state:"success"})];case 6:l=c.sent(),c.label=7;case 7:return[2,l]}})})()}},{key:"thumbnails",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=arguments.length>1?arguments[1]:void 0,r=this;return(0,ey._)(function(){var n,s,a,o;return(0,eB._)(this,function(u){switch(u.label){case 0:return eM(r,G).abort(),ej(r,G,new AbortController),n=eM(r,G).signal,[4,r.ready];case 1:var l,c,h,f,d,p;if(u.sent(),s="generate thumbnails aborted",n.aborted)throw Error(s);return c=Math.round(t/(a=eM(r,R)).width*a.height),h={quality:.1,type:"image/png"},p=(d=new OffscreenCanvas(t,c)).getContext("2d"),f=(0,ey._)(function(e){return(0,eB._)(this,function(r){switch(r.label){case 0:return p.drawImage(e,0,0,t,c),e.close(),[4,d.convertToBlob(h)];case 1:return[2,r.sent()]}})}),o=function(t){return f.apply(this,arguments)},[2,new Promise((l=(0,ey._)(function(t,a){var u,l,c,h,f,d,p,m,_,y,g,v;function b(){return w.apply(this,arguments)}function w(){return(w=(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:var r;if(n.aborted)return[3,2];return[4,Promise.all(u.map((r=(0,ey._)(function(t){var e;return(0,eB._)(this,function(r){switch(r.label){case 0:return e={ts:t.ts},[4,t.img];case 1:return[2,(e.img=r.sent(),e)]}})}),function(t){return r.apply(this,arguments)})))];case 1:t.apply(void 0,[e.sent()]),e.label=2;case 2:return[2]}})})).apply(this,arguments)}function S(t){u.push({ts:t.timestamp,img:o(t)})}return(0,eB._)(this,function(t){switch(t.label){case 0:if(u=[],null==(l=eM(r,N).video)||0===eM(r,z).length)return b(),[2];if(n.addEventListener("abort",function(){a(Error(s))}),f=void 0===(h=(c=null!=e?e:{}).start)?0:h,p=void 0===(d=c.end)?eM(r,R).duration:d,!(m=c.step))return[3,6];return _=f,g=it.bind,[4,eM(r,F).createReader()];case 1:y=new(g.apply(it,[void 0,t.sent(),eM(r,z),(0,eU._)((0,eE._)({},l),{hardwareAcceleration:eM(r,j).__unsafe_hardwareAcceleration__})])),t.label=2;case 2:if(!(_<=p&&!n.aborted))return[3,5];return[4,y.find(_)];case 3:(v=t.sent())&&S(v),_+=m,t.label=4;case 4:return[3,2];case 5:return y.destroy(),b(),[3,8];case 6:return[4,function(t,e,r,n,s,a){return io.apply(this,arguments)}(eM(r,z),eM(r,F),l,n,{start:f,end:p},function(t,e){S(t),e&&b()})];case 7:t.sent(),t.label=8;case 8:return[2]}})}),function(t,e){return l.apply(this,arguments)}))]}})})()}},{key:"split",value:function(e){var r=this;return(0,ey._)(function(){var n,s,a,o,u,l,c,h;return(0,eB._)(this,function(f){switch(f.label){case 0:return[4,r.ready];case 1:if(f.sent(),e<=0||e>=eM(r,R).duration)throw Error('"time" out of bounds');return s=(n=(0,eA._)(function(t,e){if(0===t.length)return[];for(var r=0,n=0,s=-1,a=0;a<t.length;a++){var o=t[a];if(-1===s&&e<o.cts&&(s=a-1),o.is_idr){if(-1===s)r=a;else{n=a;break}}}var u=t[s];if(null==u)throw Error("Not found video sample by time");for(var l=t.slice(0,0===n?t.length:n).map(function(t){return(0,eE._)({},t)}),c=r;c<l.length;c++){var h=l[c];e<h.cts&&(h.deleted=!0,h.cts=-1)}var f=t.slice(u.is_idr?n:r).map(function(t){return(0,eU._)((0,eE._)({},t),{cts:t.cts-e})}),d=!0,p=!1,m=void 0;try{for(var _,y=f[Symbol.iterator]();!(d=(_=y.next()).done);d=!0){var g=_.value;if(g.cts>=0)break;g.deleted=!0,g.cts=-1}}catch(t){p=!0,m=t}finally{try{d||null==y.return||y.return()}finally{if(p)throw m}}return[l,f]}(eM(r,z),e),2))[0],a=n[1],u=(o=(0,eA._)(function(t,e){if(0===t.length)return[];for(var r=-1,n=0;n<t.length;n++)if(!(e>t[n].cts)){r=n;break}if(-1===r)throw Error("Not found audio sample by time");return[t.slice(0,r),t.slice(r).map(function(t){return(0,eU._)((0,eE._)({},t),{cts:t.cts-e})})]}(eM(r,L),e),2))[0],l=o[1],c=new t({localFile:eM(r,F),videoSamples:null!=s?s:[],audioSamples:null!=u?u:[],decoderConf:eM(r,N)},eM(r,j)),h=new t({localFile:eM(r,F),videoSamples:null!=a?a:[],audioSamples:null!=l?l:[],decoderConf:eM(r,N)},eM(r,j)),[4,Promise.all([c.ready,h.ready])];case 2:return[2,(f.sent(),[c,h])]}})})()}},{key:"clone",value:function(){var e=this;return(0,ey._)(function(){var r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,e.ready];case 1:return n.sent(),[4,(r=new t({localFile:eM(e,F),videoSamples:(0,eI._)(eM(e,z)),audioSamples:(0,eI._)(eM(e,L)),decoderConf:eM(e,N)},eM(e,j))).ready];case 2:return[2,(n.sent(),r.tickInterceptor=e.tickInterceptor,r)]}})})()}},{key:"splitTrack",value:function(){var e=this;return(0,ey._)(function(){var r,n,s;return(0,eB._)(this,function(a){switch(a.label){case 0:return[4,e.ready];case 1:if(a.sent(),r=[],!(eM(e,z).length>0))return[3,3];return[4,(n=new t({localFile:eM(e,F),videoSamples:(0,eI._)(eM(e,z)),audioSamples:[],decoderConf:{video:eM(e,N).video,audio:null}},eM(e,j))).ready];case 2:a.sent(),n.tickInterceptor=e.tickInterceptor,r.push(n),a.label=3;case 3:if(!(eM(e,L).length>0))return[3,5];return[4,(s=new t({localFile:eM(e,F),videoSamples:[],audioSamples:(0,eI._)(eM(e,L)),decoderConf:{audio:eM(e,N).audio,video:null}},eM(e,j))).ready];case 4:a.sent(),s.tickInterceptor=e.tickInterceptor,r.push(s),a.label=5;case 5:return[2,r]}})})()}},{key:"destroy",value:function(){var t,e;eM(this,P)||(eM(this,B).info("MP4Clip destroy"),ej(this,P,!0),null==(t=eM(this,O))||t.destroy(),null==(e=eM(this,M))||e.destroy())}}]),t}();B=new WeakMap,P=new WeakMap,R=new WeakMap,F=new WeakMap,D=new WeakMap,z=new WeakMap,L=new WeakMap,O=new WeakMap,M=new WeakMap,N=new WeakMap,j=new WeakMap,G=new WeakMap;var r8=r6;function r5(t,e,r,n,s){return{audioFrameFinder:null==s||null==t.audio||0===n.length?null:new ie(e,n,t.audio,{volume:s,targetSampleRate:r$.sampleRate}),videoFrameFinder:null==t.video||0===r.length?null:new it(e,r,t.video)}}function r9(t){return r7.apply(this,arguments)}function r7(){return(r7=(0,ey._)(function(t){var e,r,n,s,a,o=arguments;function u(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;return(0,eU._)((0,eE._)({},t),{is_idr:"video"===r&&t.is_sync&&function(t){for(var e=new DataView(t.buffer),r=0;r<t.byteLength-4;){if((31&e.getUint8(r+4))==5)return!0;r+=e.getUint32(r)+4}return!1}(t.data),cts:(t.cts-e)/t.timescale*1e6,dts:(t.dts-e)/t.timescale*1e6,duration:t.duration/t.timescale*1e6,timescale:1e6,data:"video"===r?null:t.data})}return(0,eB._)(this,function(l){var c;return e=o.length>1&&void 0!==o[1]?o[1]:{},n={video:null,audio:null},s=[],a=[],[2,new Promise((c=(0,ey._)(function(o,l){var c,h,f;return(0,eB._)(this,function(d){var p;return c=-1,h=-1,f=rZ(t.pipeThrough(new r2),{onChunk:(p=(0,ey._)(function(t){var o,d,p,m,_,y,g,v,b,w,S,x,E,U,T,A,I;return(0,eB._)(this,function(k){if(o=t.chunkType,d=t.data,"ready"===o)r=d.info,m=(p=r0(d.file,d.info)).videoDecoderConf,_=p.audioDecoderConf,n.video=null!=m?m:null,n.audio=null!=_?_:null,null==m&&null==_&&(f(),l(Error("MP4Clip must contain at least one video or audio track"))),rw.info("mp4BoxFile moov ready",(0,eU._)((0,eE._)({},d.info),{tracks:null,videoTracks:null,audioTracks:null}),n);else if("samples"===o){if("video"===d.type){-1===c&&(c=d.samples[0].dts),y=!0,g=!1,v=void 0;try{for(b=d.samples[Symbol.iterator]();!(y=(w=b.next()).done);y=!0)S=w.value,s.push(u(S,c,"video"))}catch(t){g=!0,v=t}finally{try{y||null==b.return||b.return()}finally{if(g)throw v}}}else if("audio"===d.type&&e.audio){-1===h&&(h=d.samples[0].dts),x=!0,E=!1,U=void 0;try{for(T=d.samples[Symbol.iterator]();!(x=(A=T.next()).done);x=!0)I=A.value,a.push(u(I,h,"audio"))}catch(t){E=!0,U=t}finally{try{x||null==T.return||T.return()}finally{if(E)throw U}}}}return[2]})}),function(t){return p.apply(this,arguments)}),onDone:function(){var t,e=null!==(t=s.at(-1))&&void 0!==t?t:a.at(-1);if(null==r){l(Error("MP4Clip stream is done, but not emit ready"));return}if(null==e){l(Error("MP4Clip stream not contain any sample"));return}var u=s[0];null!=u&&u.cts<2e5&&(u.duration+=u.cts,u.cts=0),rw.info("mp4 stream parsed"),o({videoSamples:s,audioSamples:a,decoderConf:n})}}),[2]})}),function(t,e){return c.apply(this,arguments)}))]})})).apply(this,arguments)}var it=function t(e,r,n){var s,a,o,u=this;(0,eg._)(this,t),eN(this,Y,null),eN(this,W,0),eN(this,V,{abort:!1,st:performance.now()});var l=this;eL(this,"find",(s=(0,ey._)(function(t){return(0,eB._)(this,function(e){switch(e.label){case 0:return(null==eM(l,Y)||t<=eM(l,W)||t-eM(l,W)>3e6)&&eM(l,te).call(l,t),eM(l,V).abort=!0,ej(l,W,t),ej(l,V,{abort:!1,st:performance.now()}),[4,eM(l,J).call(l,t,eM(l,Y),eM(l,V))];case 1:return[2,e.sent()]}})}),function(t){return s.apply(this,arguments)})),eN(this,H,0),eN(this,X,!1),eN(this,Z,0),eN(this,K,[]),eN(this,q,0),eN(this,Q,0);var c=this;eN(this,J,(a=(0,ey._)(function(t,e,r){var n,s,a,o,u;return(0,eB._)(this,function(l){switch(l.label){case 0:if(null==e||"closed"===e.state||r.abort)return[2,null];if(!(eM(c,K).length>0))return[3,6];if(!(t<(n=eM(c,K)[0]).timestamp))return[3,1];return a=null,[3,5];case 1:if(eM(c,K).shift(),!(t>n.timestamp+(null!==(s=n.duration)&&void 0!==s?s:0)))return[3,3];return n.close(),[4,eM(c,J).call(c,t,e,r)];case 2:return o=l.sent(),[3,4];case 3:eM(c,K).length<10&&eM(c,tt).call(c,e).catch(function(e){throw eM(c,te).call(c,t),e}),o=n,l.label=4;case 4:a=o,l.label=5;case 5:return[2,a];case 6:if(!(eM(c,$)||eM(c,q)<eM(c,Q)&&e.decodeQueueSize>0))return[3,8];if(performance.now()-r.st>3e3)throw Error("MP4Clip.tick video timeout, ".concat(JSON.stringify(eM(c,tr).call(c))));return[4,rH(15)];case 7:return l.sent(),[3,12];case 8:if(eM(c,Z)>=c.samples.length)return[2,null];l.label=9;case 9:return l.trys.push([9,11,,12]),[4,eM(c,tt).call(c,e)];case 10:return l.sent(),[3,12];case 11:throw u=l.sent(),eM(c,te).call(c,t),u;case 12:return[4,eM(c,J).call(c,t,e,r)];case 13:return[2,l.sent()]}})}),function(t,e,r){return a.apply(this,arguments)})),eN(this,$,!1);var h=this;eN(this,tt,(o=(0,ey._)(function(t){var e,r,n,s,a,o,u,l;return(0,eB._)(this,function(c){switch(c.label){case 0:if(eM(h,$))return[2];for(ej(h,$,!0),n=eM(h,Z)+1,s=!1;n<h.samples.length&&(a=h.samples[n],s||a.deleted||(s=!0),!a.is_idr);n++);if(!s)return[3,3];if(!((null==(e=(o=h.samples.slice(eM(h,Z),n))[0])?void 0:e.is_idr)!==!0))return[3,1];return rw.warn("First sample not idr frame"),[3,3];case 1:return[4,ir(o,h.localFileReader)];case 2:if(u=c.sent(),"closed"===t.state)return[2];ej(h,H,null!==(l=null==(r=u[0])?void 0:r.duration)&&void 0!==l?l:0),is(t,u,{onDecodingError:function(t){if(eM(h,X))throw t;ej(h,X,!0),rw.warn("Downgrade to software decode"),eM(h,te).call(h)}}),ej(h,Q,eM(h,Q)+u.length),c.label=3;case 3:return ej(h,Z,n),ej(h,$,!1),[2]}})}),function(t){return o.apply(this,arguments)})),eN(this,te,function(t){var e,r;if(ej(u,$,!1),eM(u,K).forEach(function(t){return t.close()}),ej(u,K,[]),null==t||0===t)ej(u,Z,0);else for(var n=0,s=0;s<u.samples.length;s++){var a=u.samples[s];if(a.is_idr&&(n=s),!(a.cts<t)){ej(u,Z,n);break}}ej(u,Q,0),ej(u,q,0),(null==(e=eM(u,Y))?void 0:e.state)!=="closed"&&(null==(r=eM(u,Y))||r.close()),ej(u,Y,new VideoDecoder({output:function(t){if(ej(u,q,eM(u,q)+1),-1===t.timestamp){t.close();return}var e=t;null==t.duration&&(e=new VideoFrame(t,{duration:eM(u,H)}),t.close()),eM(u,K).push(e)},error:function(t){rw.error("MP4Clip VideoDecoder err: ".concat(t.message))}})),eM(u,Y).configure((0,eE._)({},u.conf,eM(u,X)?{hardwareAcceleration:"prefer-software"}:{}))}),eN(this,tr,function(){var t,e;return{time:eM(u,W),decState:null==(t=eM(u,Y))?void 0:t.state,decQSize:null==(e=eM(u,Y))?void 0:e.decodeQueueSize,decCusorIdx:eM(u,Z),sampleLen:u.samples.length,inputCnt:eM(u,Q),outputCnt:eM(u,q),cacheFrameLen:eM(u,K).length,softDeocde:eM(u,X)}}),eL(this,"destroy",function(){var t,e;(null==(t=eM(u,Y))?void 0:t.state)!=="closed"&&(null==(e=eM(u,Y))||e.close()),ej(u,Y,null),eM(u,V).abort=!0,eM(u,K).forEach(function(t){return t.close()}),ej(u,K,[]),u.localFileReader.close()}),this.localFileReader=e,this.samples=r,this.conf=n};Y=new WeakMap,W=new WeakMap,V=new WeakMap,H=new WeakMap,X=new WeakMap,Z=new WeakMap,K=new WeakMap,q=new WeakMap,Q=new WeakMap,J=new WeakMap,$=new WeakMap,tt=new WeakMap,te=new WeakMap,tr=new WeakMap;var ie=function t(e,r,n,s){var a,o,u=this;(0,eg._)(this,t),eN(this,ti,1),eN(this,tn),eN(this,ts,null),eN(this,ta,{abort:!1,st:performance.now()});var l=this;eL(this,"find",(a=(0,ey._)(function(t){var e,r;return(0,eB._)(this,function(n){switch(n.label){case 0:if(null==eM(l,ts)||t<=eM(l,to)||t-eM(l,to)>1e5){for(eM(l,tf).call(l),ej(l,to,t),e=0;e<l.samples.length;e++)if(!(l.samples[e].cts<t)){ej(l,tu,e);break}return[2,[]]}return eM(l,ta).abort=!0,r=t-eM(l,to),ej(l,to,t),ej(l,ta,{abort:!1,st:performance.now()}),[4,eM(l,tc).call(l,r,eM(l,ts),eM(l,ta))];case 1:return[2,n.sent()]}})}),function(t){return a.apply(this,arguments)})),eN(this,to,0),eN(this,tu,0),eN(this,tl,{frameCnt:0,data:[]});var c=this;eN(this,tc,(o=(0,ey._)(function(t){var e,r,n,s,a=arguments;return(0,eB._)(this,function(o){switch(o.label){case 0:if(e=a.length>1&&void 0!==a[1]?a[1]:null,r=a.length>2?a[2]:void 0,null==e||r.abort||"closed"===e.state||0===(n=Math.ceil(t*(eM(c,tn)/1e6))))return[2,[]];if((s=eM(c,tl).frameCnt-n)>0)return[2,(s<r$.sampleRate/10&&eM(c,th).call(c,e),function(t,e){for(var r=[new Float32Array(e),new Float32Array(e)],n=0,s=0;s<t.data.length;){var a=(0,eA._)(t.data[s],2),o=a[0],u=a[1];if(n+o.length>e){var l=e-n;r[0].set(o.subarray(0,l),n),r[1].set(u.subarray(0,l),n),t.data[s][0]=o.subarray(l,o.length),t.data[s][1]=u.subarray(l,u.length);break}r[0].set(o,n),r[1].set(u,n),n+=o.length,s++}return t.data=t.data.slice(s),t.frameCnt-=e,r}(eM(c,tl),n))];if(!(e.decodeQueueSize>10))return[3,2];if(performance.now()-r.st>3e3)throw r.abort=!0,Error("MP4Clip.tick audio timeout, ".concat(JSON.stringify(eM(c,td).call(c))));return[4,rH(15)];case 1:return o.sent(),[3,3];case 2:if(eM(c,tu)>=c.samples.length-1)return[2,[]];eM(c,th).call(c,e),o.label=3;case 3:return[2,eM(c,tc).call(c,t,e,r)]}})}),function(t){return o.apply(this,arguments)})),eN(this,th,function(t){if(!(t.decodeQueueSize>100)){for(var e=[],r=eM(u,tu);r<u.samples.length;){var n=u.samples[r];if(r+=1,!n.deleted&&(e.push(n),e.length>=10))break}ej(u,tu,r),t.decode(e.map(function(t){return new EncodedAudioChunk({type:"key",timestamp:t.cts,duration:t.duration,data:t.data})}))}}),eN(this,tf,function(){var t,e,r,n,s,a,o,l;ej(u,to,0),ej(u,tu,0),ej(u,tl,{frameCnt:0,data:[]}),null==(t=eM(u,ts))||t.close(),ej(u,ts,(e=u.conf,r={resampleRate:r$.sampleRate,volume:eM(u,ti)},n=function(t){eM(u,tl).data.push(t),eM(u,tl).frameCnt+=t[0].length},a=function(t){var e=[],r=0;function n(){var s=e[r];null!=s&&(t(s),r+=1,n())}var s=0;return function(t){var r=s;s+=1,t().then(function(t){e[r]=t,n()}).catch(function(t){e[r]=t,n()})}}(s=function(t){if(0!==t.length){var e=!0,s=!1,a=void 0;if(1!==r.volume)try{for(var o,u=t[Symbol.iterator]();!(e=(o=u.next()).done);e=!0)for(var l=o.value,c=0;c<l.length;c++)l[c]*=r.volume}catch(t){s=!0,a=t}finally{try{e||null==u.return||u.return()}finally{if(s)throw a}}1===t.length&&(t=[t[0],t[0]]),n(t)}}),o=r.resampleRate!==e.sampleRate,(l=new AudioDecoder({output:function(t){var e=rO(t);o?a(function(){return rW(e,t.sampleRate,{rate:r.resampleRate,chanCount:t.numberOfChannels})}):s(e),t.close()},error:function(t){rw.error("MP4Clip AudioDecoder err: ".concat(t.message))}})).configure(e),{decode:function(t){var e=!0,r=!1,n=void 0;try{for(var s,a=t[Symbol.iterator]();!(e=(s=a.next()).done);e=!0){var o=s.value;l.decode(o)}}catch(t){r=!0,n=t}finally{try{e||null==a.return||a.return()}finally{if(r)throw n}}},close:function(){"closed"!==l.state&&l.close()},get state(){return l.state},get decodeQueueSize(){return l.decodeQueueSize}}))}),eN(this,td,function(){var t,e;return{time:eM(u,to),decState:null==(t=eM(u,ts))?void 0:t.state,decQSize:null==(e=eM(u,ts))?void 0:e.decodeQueueSize,decCusorIdx:eM(u,tu),sampleLen:u.samples.length,pcmLen:eM(u,tl).frameCnt}}),eL(this,"destroy",function(){ej(u,ts,null),eM(u,ta).abort=!0,ej(u,tl,{frameCnt:0,data:[]}),u.localFileReader.close()}),this.localFileReader=e,this.samples=r,this.conf=n,ej(this,ti,s.volume),ej(this,tn,s.targetSampleRate)};function ir(t,e){return ii.apply(this,arguments)}function ii(){return(ii=(0,ey._)(function(t,e){var r,n,s,a,o;return(0,eB._)(this,function(u){switch(u.label){case 0:if(r=t[0],null==(n=t.at(-1)))return[2,[]];if(!((s=n.offset+n.size-r.offset)<3e7))return[3,2];return o=Uint8Array.bind,[4,e.read(s,{at:r.offset})];case 1:return a=new(o.apply(Uint8Array,[void 0,u.sent()])),[2,t.map(function(t){var e=t.offset-r.offset,n=a.subarray(e,e+t.size);return t.is_idr&&(n=ia(n)),new EncodedVideoChunk({type:t.is_sync?"key":"delta",timestamp:t.cts,duration:t.duration,data:n})})];case 2:var l;return[4,Promise.all(t.map((l=(0,ey._)(function(t){var r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,e.read(t.size,{at:t.offset})];case 1:return r=n.sent(),[2,(t.is_idr&&(r=ia(new Uint8Array(r))),new EncodedVideoChunk({type:t.is_sync?"key":"delta",timestamp:t.cts,duration:t.duration,data:r}))]}})}),function(t){return l.apply(this,arguments)})))];case 3:return[2,u.sent()]}})})).apply(this,arguments)}function is(t,e,r){var n=0;if("configured"===t.state){for(;n<e.length;n++)t.decode(e[n]);t.flush().catch(function(t){if(!(t instanceof Error))throw t;if(t.message.includes("Decoding error")&&null!=r.onDecodingError){r.onDecodingError(t);return}if(!t.message.includes("Aborted due to close"))throw t})}}function ia(t){var e=new DataView(t.buffer);return(31&e.getUint8(4))==6?t.subarray(e.getUint32(0)+4):t}function io(){return(io=(0,ey._)(function(t,e,r,n,s,a){var o,u,l,c;return(0,eB._)(this,function(h){switch(h.label){case 0:return[4,e.createReader()];case 1:return o=h.sent(),u=0,l=new VideoDecoder({output:function(t){var e=(u+=1)===c.length;a(t,e),e&&o.close()},error:rw.error}),n.addEventListener("abort",function(){o.close(),l.close()}),[4,ir(t.filter(function(t){return!t.deleted&&t.is_sync&&t.cts>=s.start&&t.cts<=s.end}),o)];case 2:return 0===(c=h.sent()).length||n.aborted||(l.configure(r),is(l,c,{})),[2]}})})).apply(this,arguments)}ti=new WeakMap,tn=new WeakMap,ts=new WeakMap,ta=new WeakMap,to=new WeakMap,tu=new WeakMap,tl=new WeakMap,tc=new WeakMap,th=new WeakMap,tf=new WeakMap,td=new WeakMap;var iu=/*#__PURE__*/function(){function t(e){var r=this;(0,eg._)(this,t),eN(this,ty),eL(this,"ready"),eN(this,tp,{duration:0,width:0,height:0}),eN(this,tm,null),eN(this,t_,[]);var n=function(t){return ej(r,tm,t),eM(r,tp).width=t.width,eM(r,tp).height=t.height,eM(r,tp).duration=1/0,(0,eE._)({},eM(r,tp))};if(e instanceof ReadableStream)this.ready=new Response(e).blob().then(function(t){return createImageBitmap(t)}).then(n);else if(e instanceof ImageBitmap)this.ready=Promise.resolve(n(e));else if(Array.isArray(e)&&e.every(function(t){return t instanceof VideoFrame})){ej(this,t_,e);var s=eM(this,t_)[0];if(null==s)throw Error("The frame count must be greater than 0");ej(this,tp,{width:s.displayWidth,height:s.displayHeight,duration:eM(this,t_).reduce(function(t,e){var r;return t+(null!==(r=e.duration)&&void 0!==r?r:0)},0)}),this.ready=Promise.resolve((0,eU._)((0,eE._)({},eM(this,tp)),{duration:1/0}))}else if("type"in e)this.ready=eG(this,ty,tg).call(this,e.stream,e.type).then(function(){return{width:eM(r,tp).width,height:eM(r,tp).height,duration:1/0}});else throw Error("Illegal arguments")}return(0,ev._)(t,[{key:"meta",get:function(){return(0,eE._)({},eM(this,tp))}},{key:"tick",value:function(t){var e=this;return(0,ey._)(function(){var r,n,s;return(0,eB._)(this,function(a){switch(a.label){case 0:if(!(null!=eM(e,tm)))return[3,2];return r={},[4,createImageBitmap(eM(e,tm))];case 1:return[2,(r.video=a.sent(),r.state="success",r)];case 2:return n=t%eM(e,tp).duration,[2,{video:(null!==(s=eM(e,t_).find(function(t){var e;return n>=t.timestamp&&n<=t.timestamp+(null!==(e=t.duration)&&void 0!==e?e:0)}))&&void 0!==s?s:eM(e,t_)[0]).clone(),state:"success"}]}})})()}},{key:"split",value:function(e){var r=this;return(0,ey._)(function(){var n,s,a,o,u,l,c;return(0,eB._)(this,function(h){switch(h.label){case 0:return[4,r.ready];case 1:if(h.sent(),null==eM(r,tm))return[3,4];return n=t.bind,[4,createImageBitmap(eM(r,tm))];case 2:return s=[new(n.apply(t,[void 0,h.sent()]))],a=t.bind,[4,createImageBitmap(eM(r,tm))];case 3:return[2,s.concat([new(a.apply(t,[void 0,h.sent()]))])];case 4:for(u=0,o=-1;u<eM(r,t_).length;u++)if(!(e>eM(r,t_)[u].timestamp)){o=u;break}if(-1===o)throw Error("Not found frame by time");return l=eM(r,t_).slice(0,o).map(function(t){return new VideoFrame(t)}),c=eM(r,t_).slice(o).map(function(t){return new VideoFrame(t,{timestamp:t.timestamp-e})}),[2,[new t(l),new t(c)]]}})})()}},{key:"clone",value:function(){var e=this;return(0,ey._)(function(){var r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,e.ready];case 1:if(n.sent(),null!=eM(e,tm))return[3,2];return r=eM(e,t_).map(function(t){return t.clone()}),[3,4];case 2:return[4,createImageBitmap(eM(e,tm))];case 3:r=n.sent(),n.label=4;case 4:return[2,new t(r)]}})})()}},{key:"destroy",value:function(){var t;rw.info("ImgClip destroy"),null==(t=eM(this,tm))||t.close(),eM(this,t_).forEach(function(t){return t.close()})}}]),t}();tp=new WeakMap,tm=new WeakMap,t_=new WeakMap,ty=new WeakSet,y=(0,ey._)(function(t,e){var r,n;return(0,eB._)(this,function(s){switch(s.label){case 0:return r=[this,t_],[4,rj(t,e)];case 1:if(ej.apply(void 0,r.concat([s.sent()])),null==(n=eM(this,t_)[0]))throw Error("No frame available in gif");return ej(this,tp,{duration:eM(this,t_).reduce(function(t,e){var r;return t+(null!==(r=e.duration)&&void 0!==r?r:0)},0),width:n.codedWidth,height:n.codedHeight}),rw.info("ImgClip ready:",eM(this,tp)),[2]}})}),tg=function(t,e){return y.apply(this,arguments)};var il=iu,ic=/*#__PURE__*/function(){function t(e){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,eg._)(this,t),eN(this,tx),eL(this,"ready"),eN(this,tv,{duration:0,width:0,height:0}),eN(this,tb,new Float32Array),eN(this,tw,new Float32Array),eN(this,tS),eN(this,tU,0),eN(this,tT,0),ej(this,tS,(0,eE._)({loop:!1,volume:1},n)),this.ready=eG(this,tx,tE).call(this,e).then(function(){return{width:0,height:0,duration:n.loop?1/0:eM(r,tv).duration}})}return(0,ev._)(t,[{key:"meta",get:function(){return(0,eU._)((0,eE._)({},eM(this,tv)),{sampleRate:r$.sampleRate,chanCount:2})}},{key:"getPCMData",value:function(){return[eM(this,tb),eM(this,tw)]}},{key:"tick",value:function(t){var e=this;return(0,ey._)(function(){var r,n,s,a;return(0,eB._)(this,function(o){return!eM(e,tS).loop&&t>=eM(e,tv).duration?[2,{audio:[],state:"done"}]:(r=t-eM(e,tU),t<eM(e,tU)||r>3e6)?[2,(ej(e,tU,t),ej(e,tT,Math.ceil(eM(e,tU)/1e6*r$.sampleRate)),{audio:[new Float32Array(0),new Float32Array(0)],state:"success"})]:(ej(e,tU,t),n=Math.ceil(r/1e6*r$.sampleRate),s=eM(e,tT)+n,a=eM(e,tS).loop?[rX(eM(e,tb),eM(e,tT),s),rX(eM(e,tw),eM(e,tT),s)]:[eM(e,tb).slice(eM(e,tT),s),eM(e,tw).slice(eM(e,tT),s)],[2,(ej(e,tT,s),{audio:a,state:"success"})])})})()}},{key:"split",value:function(e){var r=this;return(0,ey._)(function(){var n;return(0,eB._)(this,function(s){switch(s.label){case 0:return[4,r.ready];case 1:return s.sent(),n=Math.ceil(e/1e6*r$.sampleRate),[2,[new t(r.getPCMData().map(function(t){return t.slice(0,n)}),eM(r,tS)),new t(r.getPCMData().map(function(t){return t.slice(n)}),eM(r,tS))]]}})})()}},{key:"clone",value:function(){var e=this;return(0,ey._)(function(){var r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,e.ready];case 1:return n.sent(),[4,(r=new t(e.getPCMData(),eM(e,tS))).ready];case 2:return[2,(n.sent(),r)]}})})()}},{key:"destroy",value:function(){ej(this,tb,new Float32Array(0)),ej(this,tw,new Float32Array(0)),rw.info("---- audioclip destroy ----")}}]),t}();tv=new WeakMap,tb=new WeakMap,tw=new WeakMap,tS=new WeakMap,tx=new WeakSet,g=(0,ey._)(function(t){var e,r,n,s,a,o,u,l,c,h,f,d;return(0,eB._)(this,function(p){switch(p.label){case 0:if(null==ic.ctx&&(ic.ctx=new AudioContext({sampleRate:r$.sampleRate})),e=performance.now(),!(t instanceof ReadableStream))return[3,2];return[4,function(t,e){return im.apply(this,arguments)}(t,ic.ctx)];case 1:return n=p.sent(),[3,3];case 2:n=t,p.label=3;case 3:if(r=n,rw.info("Audio clip decoded complete:",performance.now()-e),s=eM(this,tS).volume,a=!0,o=!1,u=void 0,1!==s)try{for(l=r[Symbol.iterator]();!(a=(c=l.next()).done);a=!0)for(f=0,h=c.value;f<h.length;f+=1)h[f]*=s}catch(t){o=!0,u=t}finally{try{a||null==l.return||l.return()}finally{if(o)throw u}}return eM(this,tv).duration=r[0].length/r$.sampleRate*1e6,ej(this,tb,r[0]),ej(this,tw,null!==(d=r[1])&&void 0!==d?d:eM(this,tb)),rw.info("Audio clip convert to AudioData, time:",performance.now()-e),[2]}})}),tE=function(t){return g.apply(this,arguments)},tU=new WeakMap,tT=new WeakMap,eL(ic,"ctx",null);var ih=ic;function id(t,e){return ip.apply(this,arguments)}function ip(){return(ip=(0,ey._)(function(t,e){var r,n,s,a,o,u,l,c;return(0,eB._)(this,function(h){switch(h.label){case 0:r=[],n=!0,s=!1,a=void 0,h.label=1;case 1:h.trys.push([1,6,7,8]),o=t[Symbol.iterator](),h.label=2;case 2:if(n=(u=o.next()).done)return[3,5];return[4,(l=u.value).ready];case 3:h.sent(),r.push(l.getPCMData()),h.label=4;case 4:return n=!0,[3,2];case 5:return[3,8];case 6:return c=h.sent(),s=!0,a=c,[3,8];case 7:try{n||null==o.return||o.return()}finally{if(s)throw a}return[7];case 8:return[2,new ih(rL(r),e)]}})})).apply(this,arguments)}function im(){return(im=(0,ey._)(function(t,e){var r;return(0,eB._)(this,function(n){switch(n.label){case 0:return[4,new Response(t).arrayBuffer()];case 1:return r=n.sent(),[4,e.decodeAudioData(r)];case 2:return[2,rM.apply(void 0,[n.sent()])]}})})).apply(this,arguments)}var i_=/*#__PURE__*/function(){function t(e){(0,eg._)(this,t),eL(this,"ready"),eN(this,tA,{duration:0,width:0,height:0}),eN(this,tI,function(){}),eL(this,"audioTrack"),eN(this,tk,null),eN(this,tC),ej(this,tC,e);var r,n=e.getVideoTracks()[0];if(null!=n){var s,a,o=n.getSettings(),u=o.width,l=o.height;n.contentHint="motion",eM(this,tA).width=null!=u?u:0,eM(this,tA).height=null!=l?l:0,ej(this,tk,new OffscreenCanvas(null!=u?u:0,null!=l?l:0)),ej(this,tI,(s=eM(this,tk).getContext("2d"),rZ(new MediaStreamTrackProcessor({track:n}).readable,{onChunk:(a=(0,ey._)(function(t){return(0,eB._)(this,function(e){return s.drawImage(t,0,0),t.close(),[2]})}),function(t){return a.apply(this,arguments)}),onDone:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(t){return[2]})})})))}this.audioTrack=null!==(r=e.getAudioTracks()[0])&&void 0!==r?r:null,eM(this,tA).duration=1/0,this.ready=Promise.resolve(this.meta)}return(0,ev._)(t,[{key:"meta",get:function(){return(0,eE._)({},eM(this,tA))}},{key:"tick",value:function(){var t=this;return(0,ey._)(function(){var e,r;return(0,eB._)(this,function(n){switch(n.label){case 0:if(e={},null!=eM(t,tk))return[3,1];return r=null,[3,3];case 1:return[4,createImageBitmap(eM(t,tk))];case 2:r=n.sent(),n.label=3;case 3:return[2,(e.video=r,e.audio=[],e.state="success",e)]}})})()}},{key:"split",value:function(){var t=this;return(0,ey._)(function(){var e;return(0,eB._)(this,function(r){switch(r.label){case 0:return[4,t.clone()];case 1:return e=[r.sent()],[4,t.clone()];case 2:return[2,e.concat([r.sent()])]}})})()}},{key:"clone",value:function(){var e=this;return(0,ey._)(function(){return(0,eB._)(this,function(r){return[2,new t(eM(e,tC).clone())]})})()}},{key:"destroy",value:function(){eM(this,tC).getTracks().forEach(function(t){return t.stop()}),eM(this,tI).call(this)}}]),t}();tA=new WeakMap,tI=new WeakMap,tk=new WeakMap,tC=new WeakMap,eL(i_,"ctx",null);var iy=i_,ig=/*#__PURE__*/function(){function t(e,r){if((0,eg._)(this,t),eN(this,tM),eL(this,"ready"),eN(this,tB,[]),eN(this,tP,{width:0,height:0,duration:0}),eN(this,tR,{color:"#FFF",textBgColor:null,type:"srt",fontSize:30,letterSpacing:null,bottomOffset:30,fontFamily:"Noto Sans SC",strokeStyle:"#000",lineWidth:null,lineCap:null,lineJoin:null,textShadow:{offsetX:2,offsetY:2,blur:4,color:"#000"},videoWidth:1280,videoHeight:720}),eN(this,tF),eN(this,tD),eN(this,tz,null),eN(this,tL,0),eN(this,tO,0),ej(this,tB,Array.isArray(e)?e:e.split(/\r|\n/).map(function(t){return t.trim()}).filter(function(t){return t.length>0}).map(function(t){return{lineStr:t,match:t.match(/(\d{2}:\d{2}:\d{2},\d{3}) --> (\d{2}:\d{2}:\d{2},\d{3})/)}}).filter(function(t,e,r){var n,s=t.lineStr;return!(/^\d+$/.test(s)&&(null==(n=r[e+1])?void 0:n.match)!=null)}).reduce(function(t,e){var r=e.lineStr,n=e.match;if(null==n){var s=t.at(-1);if(null==s)return t;s.text+=0===s.text.length?r:"\n".concat(r)}else t.push({start:ib(n[1]),end:ib(n[2]),text:""});return t},[]).map(function(t){return{start:1e6*t.start,end:1e6*t.end,text:t.text}})),0===eM(this,tB).length)throw Error("No subtitles content");ej(this,tR,Object.assign(eM(this,tR),r)),ej(this,tO,null==r.textBgColor?0:(null!==(s=r.fontSize)&&void 0!==s?s:50)*.2);var n,s,a,o=eM(this,tR),u=o.fontSize,l=o.fontFamily,c=o.videoWidth,h=o.videoHeight,f=o.letterSpacing;ej(this,tL,u+2*eM(this,tO)),ej(this,tF,new OffscreenCanvas(c,h)),ej(this,tD,eM(this,tF).getContext("2d")),eM(this,tD).font="".concat(u,"px ").concat(l),eM(this,tD).textAlign="center",eM(this,tD).textBaseline="top",eM(this,tD).letterSpacing=null!=f?f:"0px",ej(this,tP,{width:c,height:h,duration:null!==(a=null==(n=eM(this,tB).at(-1))?void 0:n.end)&&void 0!==a?a:0}),this.ready=Promise.resolve(this.meta)}return(0,ev._)(t,[{key:"meta",get:function(){return(0,eE._)({},eM(this,tP))}},{key:"tick",value:function(t){var e=this;return(0,ey._)(function(){var r,n,s,a,o,u,l,c;return(0,eB._)(this,function(h){if(null!=eM(e,tz)&&t>=eM(e,tz).timestamp&&t<=eM(e,tz).timestamp+(null!==(s=eM(e,tz).duration)&&void 0!==s?s:0))return[2,{video:eM(e,tz).clone(),state:"success"}];for(a=0;a<eM(e,tB).length&&!(t<=eM(e,tB)[a].end);a+=1);return t>(u=null!==(o=eM(e,tB)[a])&&void 0!==o?o:eM(e,tB).at(-1)).end?[2,{state:"done"}]:t<u.start?(eM(e,tD).clearRect(0,0,eM(e,tF).width,eM(e,tF).height),l=new VideoFrame(eM(e,tF),{timestamp:t,duration:u.start-t}),[2,(null==(r=eM(e,tz))||r.close(),ej(e,tz,l),{video:l.clone(),state:"success"})]):(eG(e,tM,tN).call(e,u.text),c=new VideoFrame(eM(e,tF),{timestamp:t,duration:u.end-t}),[2,(null==(n=eM(e,tz))||n.close(),ej(e,tz,c),{video:c.clone(),state:"success"})])})})()}},{key:"split",value:function(e){var r=this;return(0,ey._)(function(){var n,s,a,o,u,l;return(0,eB._)(this,function(c){switch(c.label){case 0:return[4,r.ready];case 1:for(c.sent(),n=-1,s=0;s<eM(r,tB).length;s++)if(!(e>eM(r,tB)[s].start)){n=s;break}if(-1===n)throw Error("Not found subtitle by time");return o=(a=eM(r,tB).slice(0,n).map(function(t){return(0,eE._)({},t)})).at(-1),u=null,null!=o&&o.end>e&&(u={start:0,end:o.end-e,text:o.text},o.end=e),l=eM(r,tB).slice(n).map(function(t){return(0,eU._)((0,eE._)({},t),{start:t.start-e,end:t.end-e})}),[2,(null!=u&&l.unshift(u),[new t(a,eM(r,tR)),new t(l,eM(r,tR))])]}})})()}},{key:"clone",value:function(){var e=this;return(0,ey._)(function(){return(0,eB._)(this,function(r){return[2,new t(eM(e,tB).slice(0),eM(e,tR))]})})()}},{key:"destroy",value:function(){var t;null==(t=eM(this,tz))||t.close()}}]),t}();tB=new WeakMap,tP=new WeakMap,tR=new WeakMap,tF=new WeakMap,tD=new WeakMap,tz=new WeakMap,tL=new WeakMap,tO=new WeakMap,tM=new WeakSet,tN=function(t){var e=t.split("\n").reverse().map(function(t){return t.trim()}),r=eM(this,tF),n=r.width,s=r.height,a=eM(this,tR),o=a.color,u=a.fontSize,l=a.textBgColor,c=a.textShadow,h=a.strokeStyle,f=a.lineWidth,d=a.lineCap,p=a.lineJoin,m=a.bottomOffset,_=eM(this,tD);_.clearRect(0,0,n,s),_.globalAlpha=.6;var y=m,g=!0,v=!1,b=void 0;try{for(var w,S=e[Symbol.iterator]();!(g=(w=S.next()).done);g=!0){var x=w.value,E=_.measureText(x),U=n/2;null!=l&&(_.shadowOffsetX=0,_.shadowOffsetY=0,_.shadowBlur=0,_.fillStyle=l,_.globalAlpha=.5,_.fillRect(U-E.actualBoundingBoxLeft-eM(this,tO),s-y-eM(this,tL),E.width+2*eM(this,tO),eM(this,tL))),_.shadowColor=c.color,_.shadowOffsetX=c.offsetX,_.shadowOffsetY=c.offsetY,_.shadowBlur=c.blur,_.globalAlpha=1,null!=h&&(_.lineWidth=null!=f?f:u/6,null!=d&&(_.lineCap=d),null!=p&&(_.lineJoin=p),_.strokeStyle=h,_.strokeText(x,U,s-y-eM(this,tL)+eM(this,tO))),_.fillStyle=o,_.fillText(x,U,s-y-eM(this,tL)+eM(this,tO)),y+=eM(this,tL)+.2*u}}catch(t){v=!0,b=t}finally{try{g||null==S.return||S.return()}finally{if(v)throw b}}};var iv=ig;function ib(t){var e=t.match(/(\d{2}):(\d{2}):(\d{2}),(\d{3})/);if(null==e)throw Error("time format error: ".concat(t));return 3600*Number(e[1])+60*Number(e[2])+Number(e[3])+Number(e[4])/1e3}var iw=/*#__PURE__*/function(){function t(){var e=this,r=this;(0,eg._)(this,t),eN(this,tj,/* @__PURE__ */new Map),eL(this,"on",function(t,r){var n,s=null!==(n=eM(e,tj).get(t))&&void 0!==n?n:/* @__PURE__ */new Set;return s.add(r),eM(e,tj).has(t)||eM(e,tj).set(t,s),function(){s.delete(r),0===s.size&&eM(e,tj).delete(t)}}),eL(this,"once",function(t,r){var n=e.on(t,function(){for(var t=arguments.length,e=Array(t),s=0;s<t;s++)e[s]=arguments[s];n(),r.apply(void 0,(0,eI._)(e))});return n}),eL(this,"emit",function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),s=1;s<e;s++)n[s-1]=arguments[s];var a=eM(r,tj).get(t);null!=a&&a.forEach(function(t){return t.apply(void 0,(0,eI._)(n))})})}return(0,ev._)(t,[{key:"destroy",value:function(){eM(this,tj).clear()}}],[{key:"forwardEvent",value:function(t,e,r){var n=r.map(function(r){var n=(0,eA._)(Array.isArray(r)?r:[r,r],2),s=n[0],a=n[1];return t.on(s,function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];e.emit.apply(e,[a].concat((0,eI._)(r)))})});return function(){n.forEach(function(t){return t()})}}}]),t}();tj=new WeakMap;var iS=function(t,e){var r=new Uint8Array(8);new DataView(r.buffer).setUint32(0,e);for(var n=0;n<4;n++)r[4+n]=t.charCodeAt(n);return r},ix=function(){var t=new TextEncoder,e=t.encode("mdta"),r=t.encode("mp4 handler"),n=32+r.byteLength+1,s=new Uint8Array(n),a=new DataView(s.buffer);return s.set(iS("hdlr",n),0),a.setUint32(8,0),s.set(e,16),s.set(r,32),s},iE=function(t){var e=new TextEncoder,r=e.encode("mdta"),n=t.map(function(t){var n=e.encode(t),s=8+n.byteLength,a=new Uint8Array(s);return new DataView(a.buffer).setUint32(0,s),a.set(r,4),a.set(n,4+r.byteLength),a}),s=16+n.reduce(function(t,e){return t+e.byteLength},0),a=new Uint8Array(s),o=new DataView(a.buffer);a.set(iS("keys",s),0),o.setUint32(8,0),o.setUint32(12,t.length);var u=16,l=!0,c=!1,h=void 0;try{for(var f,d=n[Symbol.iterator]();!(l=(f=d.next()).done);l=!0){var p=f.value;a.set(p,u),u+=p.byteLength}}catch(t){c=!0,h=t}finally{try{l||null==d.return||d.return()}finally{if(c)throw h}}return a},iU=function(t){var e=new TextEncoder,r=e.encode("data"),n=Object.entries(t).map(function(t,n){var s=(0,eA._)(t,2),a=(s[0],s[1]),o=e.encode(a),u=24+o.byteLength,l=new Uint8Array(u),c=new DataView(l.buffer);return c.setUint32(0,u),c.setUint32(4,n+1),c.setUint32(8,16+o.byteLength),l.set(r,12),c.setUint32(16,1),l.set(o,24),l}),s=8+n.reduce(function(t,e){return t+e.byteLength},0),a=new Uint8Array(s);a.set(iS("ilst",s),0);var o=8,u=!0,l=!1,c=void 0;try{for(var h,f=n[Symbol.iterator]();!(u=(h=f.next()).done);u=!0){var d=h.value;a.set(d,o),o+=d.byteLength}}catch(t){l=!0,c=t}finally{try{u||null==f.return||f.return()}finally{if(l)throw c}}return a},iT=function(t){var e=ix(),r=iE(Object.keys(t)),n=iU(t),s=new Uint8Array(e.length+r.length+n.length);return s.set(e,0),s.set(r,e.length),s.set(n,e.length+r.length),s};function iA(t){rw.info("recodemux opts:",t);var e=rJ.createFile(),r=new iw,n=function(t,e){var r=t.add("udta").add("meta");r.data=iT(e),r.size=r.data.byteLength},s=!1,a=function(){null==e.moov||s||(s=!0,null!=t.metaDataTags&&n(e.moov,t.metaDataTags),null!=t.duration&&(e.moov.mvhd.duration=t.duration))};r.once("VideoReady",a),r.once("AudioReady",a);var o=null!=t.video?function(t,e,r){var n={timescale:1e6,width:t.width,height:t.height,brands:["isom","iso2","avc1","mp42","mp41"],avcDecoderConfigRecord:null,name:"Track created with WebAV"},s=-1,a=!1;r.once("AudioReady",function(){a=!0});var o={encoder0:[],encoder1:[]},u=function(t,a,u){var l;if(-1===s&&null!=u){var c,h=null==(l=u.decoderConfig)?void 0:l.description;(c=new Uint8Array(h))[2].toString(2).slice(-2).includes("1")&&(c[2]=0),n.avcDecoderConfigRecord=h,s=e.addTrack(n),r.emit("VideoReady"),rw.info("VideoEncoder, video track ready, trackId:",s)}o[t].push(iC(a))},l="encoder1",c=0;function h(){if(a){var t="encoder1"===l?"encoder0":"encoder1",r=o[l],n=o[t];if(0!==r.length||0!==n.length){var u=r[0];if(null!=u&&u.cts-c<1e4){var f=function(t){for(var r=-1,n=0;n<t.length;n++){var a=t[n];if(n>0&&a.is_sync)break;e.addSample(s,a.data,a),r=a.cts+a.duration}return t.splice(0,n),r}(r);f>c&&(c=f)}var d=n[0];null!=d&&d.cts-c<1e4&&(l=t,h())}}}var f=rA(h,15),d=iI(t,function(t,e){return u("encoder0",t,e)}),p=iI(t,function(t,e){return u("encoder1",t,e)}),m=0;return{get encodeQueueSize(){return d.encodeQueueSize+p.encodeQueueSize},encode:function(t,e){e.keyFrame&&(m+=1),(m%2==0?d:p).encode(t,e)},flush:/*#__PURE__*/(0,ey._)(function(){var t,e,r,n;return(0,eB._)(this,function(s){switch(s.label){case 0:if(t=Promise.all,"configured"!==d.state)return[3,2];return[4,d.flush()];case 1:return e=s.sent(),[3,3];case 2:e=null,s.label=3;case 3:if(r=[e],"configured"!==p.state)return[3,5];return[4,p.flush()];case 4:return n=s.sent(),[3,6];case 5:n=null,s.label=6;case 6:return[4,t.apply(Promise,[r.concat([n])])];case 7:return s.sent(),f(),h(),[2]}})}),close:function(){"configured"===d.state&&d.close(),"configured"===p.state&&p.close()}}}(t.video,e,r):null,u=null!=t.audio?function(t,e,r){var n={timescale:1e6,samplerate:t.sampleRate,channel_count:t.channelCount,hdlr:"soun",type:"aac"===t.codec?"mp4a":"Opus",name:"Track created with WebAV"},s=-1,a=[],o=!1;r.once("VideoReady",function(){o=!0,a.forEach(function(t){var r=iC(t);e.addSample(s,r.data,r)}),a=[]});var u=new AudioEncoder({error:rw.error,output:function(t,u){var l;if(-1===s){var c,h,f,d=null==(l=u.decoderConfig)?void 0:l.description;s=e.addTrack((0,eU._)((0,eE._)({},n),{description:null==d?void 0:(h=new Uint8Array([0,0,0,0,3,23+(c=d.byteLength),0,2,0,4,18+c,64,21,0,0,0,0,0,0,0,0,0,0,0,5,c].concat((0,eI._)(new Uint8Array(d instanceof ArrayBuffer?d:d.buffer)),[6,1,2])),(f=new rJ.BoxParser.esdsBox(h.byteLength)).hdr_size=0,f.parse(new rJ.DataStream(h,0,rJ.DataStream.BIG_ENDIAN)),f)})),r.emit("AudioReady"),rw.info("AudioEncoder, audio track ready, trackId:",s)}if(o){var p=iC(t);e.addSample(s,p.data,p)}else a.push(t)}});return u.configure({codec:"aac"===t.codec?r$.codec:"opus",sampleRate:t.sampleRate,numberOfChannels:t.channelCount,bitrate:128e3}),u}(t.audio,e,r):null;return null==t.video&&r.emit("VideoReady"),null==t.audio&&r.emit("AudioReady"),{encodeVideo:function(t,e){null==o||o.encode(t,e),t.close()},encodeAudio:function(t){null!=u&&(u.encode(t),t.close())},getEncodeQueueSize:function(){var t,e;return null!==(e=null!==(t=null==o?void 0:o.encodeQueueSize)&&void 0!==t?t:null==u?void 0:u.encodeQueueSize)&&void 0!==e?e:0},flush:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:return[4,Promise.all([null==o?void 0:o.flush(),(null==u?void 0:u.state)==="configured"?u.flush():null])];case 1:return t.sent(),[2]}})}),close:function(){r.destroy(),null==o||o.close(),(null==u?void 0:u.state)==="configured"&&u.close()},mp4file:e}}function iI(t,e){var r=new VideoEncoder({error:rw.error,output:e});return r.configure({codec:t.codec,framerate:t.expectFPS,hardwareAcceleration:t.__unsafe_hardwareAcceleration__,bitrate:t.bitrate,width:t.width,height:t.height,alpha:"discard",avc:{format:"avc"}}),r}function ik(t,e,r){var n=0,s=0,a=t.boxes,o=!1,u=function(){if(!o){if(null==a.find(function(t){return"moof"===t.type}))return null;o=!0}if(s>=a.length)return null;var e=new rJ.DataStream;e.endianness=rJ.DataStream.BIG_ENDIAN;var r=s;try{for(;r<a.length;)a[r].write(e),delete a[r],r+=1}catch(t){var n,u,l=a[r];throw t instanceof Error&&null!=l?Error("".concat(t.message," | deltaBuf( boxType: ").concat(l.type,", boxSize: ").concat(l.size,", boxDataLen: ").concat(null!==(u=null==(n=l.data)?void 0:n.length)&&void 0!==u?u:-1,")")):t}return function(t){if(null!=t.moov){for(var e=0;e<t.moov.traks.length;e++)t.moov.traks[e].samples=[];t.mdats=[],t.moofs=[]}}(t),s=a.length,new Uint8Array(e.buffer)},l=!1,c=!1,h=null;return{stream:new ReadableStream({start:function(r){n=self.setInterval(function(){var t=u();null==t||c||r.enqueue(t)},e),h=function(e){if(clearInterval(n),t.flush(),null!=e){r.error(e);return}var s=u();null==s||c||r.enqueue(s),c||r.close()},l&&h()},cancel:function(){c=!0,clearInterval(n),null==r||r()}}),stop:function(t){l||(l=!0,null==h||h(t))}}}function iC(t){var e,r=new ArrayBuffer(t.byteLength);t.copyTo(r);var n=t.timestamp;return{duration:null!==(e=t.duration)&&void 0!==e?e:0,dts:n,cts:n,is_sync:"key"===t.type,data:r}}function iB(t){return iP.apply(this,arguments)}function iP(){return(iP=(0,ey._)(function(t){var e,r,n;return(0,eB._)(this,function(s){switch(s.label){case 0:return r=function(t){var e=0,r=t.boxes,n=[],s=0;function a(){return o.apply(this,arguments)}function o(){return(o=(0,ey._)(function(){var a;return(0,eB._)(this,function(o){switch(o.label){case 0:if(a=m(r,e),e=r.length,n.forEach(function(e){var r=e.track,n=e.id,a=r.samples.at(-1);null!=a&&(s=Math.max(s,a.cts+a.duration)),t.releaseUsedSamples(n,r.samples.length),r.samples=[]}),t.mdats=[],t.moofs=[],!(null!=a))return[3,2];return[4,null==f?void 0:f.write(a)];case 1:o.sent(),o.label=2;case 2:return[2]}})})).apply(this,arguments)}var u=[];function l(){if(u.length>0)return!0;var s=r.findIndex(function(t){return"moov"===t.type});if(-1===s)return!1;if(u=r.slice(0,s+1),e=s+1,0===n.length)for(var a=1;;a+=1){var o=t.getTrackById(a);if(null==o)break;n.push({track:o,id:a})}return!0}var c=0,h=rm(),f=null,d=(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:return[4,h.createWriter()];case 1:return f=t.sent(),c=self.setInterval(function(){l()&&a()},100),[2]}})})(),p=!1;return/*#__PURE__*/(0,ey._)(function(){var e,r,n;return(0,eB._)(this,function(o){switch(o.label){case 0:if(p)throw Error("File exported");return p=!0,[4,d];case 1:if(o.sent(),clearInterval(c),!l()||null==f)return[2,null];return t.flush(),[4,a()];case 2:return o.sent(),[4,null==f?void 0:f.close()];case 3:if(o.sent(),null==(e=u.find(function(t){return"moov"===t.type})))return[2,null];return e.mvhd.duration=s,r=rm(),n=m(u,0),[4,rn(r,n)];case 4:return o.sent(),[4,rn(r,h,{overwrite:!1})];case 5:return o.sent(),[4,r.stream()];case 6:return[2,o.sent()]}})});function m(t,e){if(e>=t.length)return null;var r=new rJ.DataStream;r.endianness=rJ.DataStream.BIG_ENDIAN;for(var n=e;n<t.length;n++)null!==t[n]&&(t[n].write(r),delete t[n]);return new Uint8Array(r.buffer)}}(e=rJ.createFile()),[4,function(t,e){return iR.apply(this,arguments)}(t,e)];case 1:return s.sent(),[4,r()];case 2:if(null==(n=s.sent()))throw Error("Can not generate file from streams");return[2,n]}})})).apply(this,arguments)}function iR(){return(iR=(0,ey._)(function(t,e){var r,n,s,a,o,u,l,c,h,f,d,p,m,_,y;return(0,eB._)(this,function(g){switch(g.label){case 0:r=0,n=0,s=0,a=0,o=0,u=0,l=null,c=null,h=!0,f=!1,d=void 0,g.label=1;case 1:g.trys.push([1,6,7,8]),p=function(){var t;return(0,eB._)(this,function(h){switch(h.label){case 0:var f;return t=_.value,[4,new Promise((f=(0,ey._)(function(h){return(0,eB._)(this,function(f){var d;return rZ(t.pipeThrough(new r2),{onDone:h,onChunk:(d=(0,ey._)(function(t){var h,f,d,p,m,_,y,g,v,b,w;return(0,eB._)(this,function(S){if(h=t.chunkType,f=t.data,"ready"===h)p=(d=r0(f.file,f.info)).videoTrackConf,m=d.audioTrackConf,0===r&&null!=p&&(r=e.addTrack(p)),0===a&&null!=m&&(a=e.addTrack(m));else if("samples"===h){if(_=f.type,y=f.samples,g="video"===_?r:a,v="video"===_?n:o,b="video"===_?s:u,y.forEach(function(t){e.addSample(g,t.data,{duration:t.duration,dts:t.dts+v,cts:t.cts+b,is_sync:t.is_sync})}),null==(w=y.at(-1)))return[2];"video"===_?l=w:"audio"===_&&(c=w)}return[2]})}),function(t){return d.apply(this,arguments)})}),[2]})}),function(t){return f.apply(this,arguments)}))];case 1:return h.sent(),null!=l&&(n+=l.dts,s+=l.cts),null!=c&&(o+=c.dts,u+=c.cts),[2]}})},m=t[Symbol.iterator](),g.label=2;case 2:if(h=(_=m.next()).done)return[3,5];return[5,(0,eP._)(p())];case 3:g.sent(),g.label=4;case 4:return h=!0,[3,2];case 5:return[3,8];case 6:return y=g.sent(),f=!0,d=y,[3,8];case 7:try{h||null==m.return||m.return()}finally{if(f)throw d}return[7];case 8:return[2]}})})).apply(this,arguments)}function iF(t){return iD.apply(this,arguments)}function iD(){return(iD=(0,ey._)(function(t){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,iB([t])];case 1:return[2,e.sent()]}})})).apply(this,arguments)}function iz(t,e){rw.info("mixinMP4AndAudio, opts:",{volume:e.volume,loop:e.loop});var r,n=rJ.createFile(),s=ik(n,500),a=s.stream,o=s.stop,u=null,l=null,c=[],h=0,f=0,d=0,p=!0,m=48e3;function _(t){var r=c.map(function(r){return e.loop?rX(r,d,d+t):r.slice(d,d+t)}),n=!0,s=!1,a=void 0;if(d+=t,1!==e.volume)try{for(var o,u=r[Symbol.iterator]();!(n=(o=u.next()).done);n=!0)for(var l=o.value,h=0;h<l.length;h++)l[h]*=e.volume}catch(t){s=!0,a=t}finally{try{n||null==u.return||u.return()}finally{if(s)throw a}}return r}function y(){return(y=(0,ey._)(function(t){var e,r,n;return(0,eB._)(this,function(s){return e=t[0],0!==(n=rY([_(Math.floor(((r=t[t.length-1]).cts+r.duration-e.cts)/r.timescale*m))])).length&&(null==l||l.encode(n,e.cts/e.timescale*1e6)),[2]})})).apply(this,arguments)}function g(){return(g=(0,ey._)(function(t){var e,r,n;return(0,eB._)(this,function(s){switch(s.label){case 0:if(null==u)return[2];return[4,u.decode(t)];case 1:return r=_((e=rL(s.sent().map(rO)))[0].length),n=t[0],null==l||l.encode(rY([e,r]),n.cts/n.timescale*1e6),[2]}})})).apply(this,arguments)}return rZ(t.pipeThrough(new r2),{onDone:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:return[4,null==l?void 0:l.stop()];case 1:return t.sent(),null==u||u.close(),o(),[2]}})}),onChunk:(r=(0,ey._)(function(t){var r,s,a,o,d,_,v,b,w,S,x,E,U;return(0,eB._)(this,function(T){switch(T.label){case 0:if(r=t.chunkType,s=t.data,"ready"!==r)return[3,3];return o=(a=r0(s.file,s.info)).videoTrackConf,d=a.audioTrackConf,_=a.audioDecoderConf,0===h&&null!=o&&(h=n.addTrack(o)),v=null!=d?d:{timescale:1e6,samplerate:m,channel_count:r$.channelCount,hdlr:"soun",name:"SoundHandler",type:"mp4a"},0===f&&(f=n.addTrack(v),m=null!==(b=null==d?void 0:d.samplerate)&&void 0!==b?b:m,p=null!=d),S=(w=new AudioContext({sampleRate:m})).decodeAudioData,[4,new Response(e.stream).arrayBuffer()];case 1:return[4,S.apply(w,[T.sent()])];case 2:var A,I,k,C;return c=rM.apply(void 0,[T.sent()]),null!=_&&(A=_,I=[],(k=new AudioDecoder({output:function(t){I.push(t)},error:rw.error})).configure(A),u={decode:(C=(0,ey._)(function(t){var e;return(0,eB._)(this,function(r){switch(r.label){case 0:return t.forEach(function(t){k.decode(new EncodedAudioChunk({type:t.is_sync?"key":"delta",timestamp:1e6*t.cts/t.timescale,duration:1e6*t.duration/t.timescale,data:t.data}))}),[4,k.flush()];case 1:return r.sent(),e=I,[2,(I=[],e)]}})}),function(t){return C.apply(this,arguments)}),close:function(){k.close()}}),l=function(t,e){var r,n=new AudioEncoder({output:function(t){e(iC(t))},error:rw.error});n.configure({codec:t.codec,sampleRate:t.sampleRate,numberOfChannels:t.numberOfChannels});var s=null;function a(e,r){return new AudioData({timestamp:r,numberOfChannels:t.numberOfChannels,numberOfFrames:e.length/t.numberOfChannels,sampleRate:t.sampleRate,format:"f32-planar",data:e})}return{encode:(r=(0,ey._)(function(t,e){return(0,eB._)(this,function(r){return null!=s&&n.encode(a(s.data,s.ts)),s={data:t,ts:e},[2]})}),function(t,e){return r.apply(this,arguments)}),stop:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(e){switch(e.label){case 0:return null!=s&&(function(t,e,r){for(var n=t.length-1,s=Math.min(r/2,n),a=0;a<s;a++)for(var o=1;o<=e;o++)t[Math.floor(n/o)-a]*=a/s}(s.data,t.numberOfChannels,t.sampleRate),n.encode(a(s.data,s.ts)),s=null),[4,n.flush()];case 1:return e.sent(),n.close(),[2]}})})}}(null!=_?_:{codec:"mp4a"===v.type?r$.codec:v.type,numberOfChannels:v.channel_count,sampleRate:v.samplerate},function(t){return n.addSample(f,t.data,t)}),[3,9];case 3:if("samples"!==r)return[3,9];if(x=s.id,E=s.type,U=s.samples,"video"!==E)return[3,6];if(U.forEach(function(t){return n.addSample(x,t.data,t)}),p)return[3,5];return[4,function(t){return y.apply(this,arguments)}(U)];case 4:T.sent(),T.label=5;case 5:return[2];case 6:if("audio"!==E)return[3,8];return[4,function(t){return g.apply(this,arguments)}(U)];case 7:T.sent(),T.label=8;case 8:T.label=9;case 9:return[2]}})}),function(t){return r.apply(this,arguments)})}),a}var iL=/* @__PURE__ */function(){function t(){this.listeners={}}var e=t.prototype;return e.on=function(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)},e.off=function(t,e){if(!this.listeners[t])return!1;var r=this.listeners[t].indexOf(e);return this.listeners[t]=this.listeners[t].slice(0),this.listeners[t].splice(r,1),r>-1},e.trigger=function(t){var e=this.listeners[t];if(e){if(2==arguments.length)for(var r=e.length,n=0;n<r;++n)e[n].call(this,arguments[1]);else for(var s=Array.prototype.slice.call(arguments,1),a=e.length,o=0;o<a;++o)e[o].apply(this,s)}},e.dispose=function(){this.listeners={}},e.pipe=function(t){this.on("data",function(e){t.push(e)})},t}();function iO(){return(iO=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(null,arguments)}("undefined"==typeof window?"undefined":(0,ek._)(window))<"u"?tG=window:(void 0===rK?"undefined":(0,ek._)(rK))<"u"?tG=rK:("undefined"==typeof self?"undefined":(0,ek._)(self))<"u"?tG=self:tG={};var iM=/* @__PURE__ */rq(tG),iN=/*#__PURE__*/function(t){(0,ex._)(r,t);var e=(0,eC._)(r);function r(){var t;return(0,eg._)(this,r),(t=e.call(this)).buffer="",(0,eT._)(t)}return(0,ev._)(r,[{key:"push",value:function(t){var e;for(this.buffer+=t,e=this.buffer.indexOf("\n");e>-1;e=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)}}]),r}(iL),ij=function(t){var e=/([0-9.]*)?@?([0-9.]*)?/.exec(t||""),r={};return e[1]&&(r.length=parseInt(e[1],10)),e[2]&&(r.offset=parseInt(e[2],10)),r},iG=function(t){var e={};if(!t)return e;for(var r,n=t.split(RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))')),s=n.length;s--;)""!==n[s]&&((r=/([^=]*)=(.*)/.exec(n[s]).slice(1))[0]=r[0].replace(/^\s+|\s+$/g,""),r[1]=r[1].replace(/^\s+|\s+$/g,""),r[1]=r[1].replace(/^['"](.*)['"]$/g,"$1"),e[r[0]]=r[1]);return e},iY=/*#__PURE__*/function(t){(0,ex._)(r,t);var e=(0,eC._)(r);function r(){var t;return(0,eg._)(this,r),(t=e.call(this)).customParsers=[],t.tagMappers=[],(0,eT._)(t)}return(0,ev._)(r,[{key:"push",value:function(t){var e,r,n=this;if(0!==(t=t.trim()).length){if("#"!==t[0]){this.trigger("data",{type:"uri",uri:t});return}this.tagMappers.reduce(function(e,r){var n=r(t);return n===t?e:e.concat([n])},[t]).forEach(function(t){for(var s=0;s<n.customParsers.length;s++)if(n.customParsers[s].call(n,t))return;if(0!==t.indexOf("#EXT")){n.trigger("data",{type:"comment",text:t.slice(1)});return}if(t=t.replace("\r",""),e=/^#EXTM3U/.exec(t)){n.trigger("data",{type:"tag",tagType:"m3u"});return}if(e=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(t)){r={type:"tag",tagType:"inf"},e[1]&&(r.duration=parseFloat(e[1])),e[2]&&(r.title=e[2]),n.trigger("data",r);return}if(e=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(t)){r={type:"tag",tagType:"targetduration"},e[1]&&(r.duration=parseInt(e[1],10)),n.trigger("data",r);return}if(e=/^#EXT-X-VERSION:([0-9.]*)?/.exec(t)){r={type:"tag",tagType:"version"},e[1]&&(r.version=parseInt(e[1],10)),n.trigger("data",r);return}if(e=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(t)){r={type:"tag",tagType:"media-sequence"},e[1]&&(r.number=parseInt(e[1],10)),n.trigger("data",r);return}if(e=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(t)){r={type:"tag",tagType:"discontinuity-sequence"},e[1]&&(r.number=parseInt(e[1],10)),n.trigger("data",r);return}if(e=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(t)){r={type:"tag",tagType:"playlist-type"},e[1]&&(r.playlistType=e[1]),n.trigger("data",r);return}if(e=/^#EXT-X-BYTERANGE:(.*)?$/.exec(t)){r=iO(ij(e[1]),{type:"tag",tagType:"byterange"}),n.trigger("data",r);return}if(e=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(t)){r={type:"tag",tagType:"allow-cache"},e[1]&&(r.allowed=!/NO/.test(e[1])),n.trigger("data",r);return}if(e=/^#EXT-X-MAP:(.*)$/.exec(t)){if(r={type:"tag",tagType:"map"},e[1]){var a=iG(e[1]);a.URI&&(r.uri=a.URI),a.BYTERANGE&&(r.byterange=ij(a.BYTERANGE))}n.trigger("data",r);return}if(e=/^#EXT-X-STREAM-INF:(.*)$/.exec(t)){if(r={type:"tag",tagType:"stream-inf"},e[1]){if(r.attributes=iG(e[1]),r.attributes.RESOLUTION){var o=r.attributes.RESOLUTION.split("x"),u={};o[0]&&(u.width=parseInt(o[0],10)),o[1]&&(u.height=parseInt(o[1],10)),r.attributes.RESOLUTION=u}r.attributes.BANDWIDTH&&(r.attributes.BANDWIDTH=parseInt(r.attributes.BANDWIDTH,10)),r.attributes["FRAME-RATE"]&&(r.attributes["FRAME-RATE"]=parseFloat(r.attributes["FRAME-RATE"])),r.attributes["PROGRAM-ID"]&&(r.attributes["PROGRAM-ID"]=parseInt(r.attributes["PROGRAM-ID"],10))}n.trigger("data",r);return}if(e=/^#EXT-X-MEDIA:(.*)$/.exec(t)){r={type:"tag",tagType:"media"},e[1]&&(r.attributes=iG(e[1])),n.trigger("data",r);return}if(e=/^#EXT-X-ENDLIST/.exec(t)){n.trigger("data",{type:"tag",tagType:"endlist"});return}if(e=/^#EXT-X-DISCONTINUITY/.exec(t)){n.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(e=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(t)){r={type:"tag",tagType:"program-date-time"},e[1]&&(r.dateTimeString=e[1],r.dateTimeObject=new Date(e[1])),n.trigger("data",r);return}if(e=/^#EXT-X-KEY:(.*)$/.exec(t)){r={type:"tag",tagType:"key"},e[1]&&(r.attributes=iG(e[1]),r.attributes.IV&&("0x"===r.attributes.IV.substring(0,2).toLowerCase()&&(r.attributes.IV=r.attributes.IV.substring(2)),r.attributes.IV=r.attributes.IV.match(/.{8}/g),r.attributes.IV[0]=parseInt(r.attributes.IV[0],16),r.attributes.IV[1]=parseInt(r.attributes.IV[1],16),r.attributes.IV[2]=parseInt(r.attributes.IV[2],16),r.attributes.IV[3]=parseInt(r.attributes.IV[3],16),r.attributes.IV=new Uint32Array(r.attributes.IV))),n.trigger("data",r);return}if(e=/^#EXT-X-START:(.*)$/.exec(t)){r={type:"tag",tagType:"start"},e[1]&&(r.attributes=iG(e[1]),r.attributes["TIME-OFFSET"]=parseFloat(r.attributes["TIME-OFFSET"]),r.attributes.PRECISE=/YES/.test(r.attributes.PRECISE)),n.trigger("data",r);return}if(e=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(t)){r={type:"tag",tagType:"cue-out-cont"},e[1]?r.data=e[1]:r.data="",n.trigger("data",r);return}if(e=/^#EXT-X-CUE-OUT:(.*)?$/.exec(t)){r={type:"tag",tagType:"cue-out"},e[1]?r.data=e[1]:r.data="",n.trigger("data",r);return}if(e=/^#EXT-X-CUE-IN:(.*)?$/.exec(t)){r={type:"tag",tagType:"cue-in"},e[1]?r.data=e[1]:r.data="",n.trigger("data",r);return}if((e=/^#EXT-X-SKIP:(.*)$/.exec(t))&&e[1]){(r={type:"tag",tagType:"skip"}).attributes=iG(e[1]),r.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(r.attributes["SKIPPED-SEGMENTS"]=parseInt(r.attributes["SKIPPED-SEGMENTS"],10)),r.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(r.attributes["RECENTLY-REMOVED-DATERANGES"]=r.attributes["RECENTLY-REMOVED-DATERANGES"].split(" ")),n.trigger("data",r);return}if((e=/^#EXT-X-PART:(.*)$/.exec(t))&&e[1]){(r={type:"tag",tagType:"part"}).attributes=iG(e[1]),["DURATION"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=parseFloat(r.attributes[t]))}),["INDEPENDENT","GAP"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=/YES/.test(r.attributes[t]))}),r.attributes.hasOwnProperty("BYTERANGE")&&(r.attributes.byterange=ij(r.attributes.BYTERANGE)),n.trigger("data",r);return}if((e=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(t))&&e[1]){(r={type:"tag",tagType:"server-control"}).attributes=iG(e[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=parseFloat(r.attributes[t]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=/YES/.test(r.attributes[t]))}),n.trigger("data",r);return}if((e=/^#EXT-X-PART-INF:(.*)$/.exec(t))&&e[1]){(r={type:"tag",tagType:"part-inf"}).attributes=iG(e[1]),["PART-TARGET"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=parseFloat(r.attributes[t]))}),n.trigger("data",r);return}if((e=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(t))&&e[1]){(r={type:"tag",tagType:"preload-hint"}).attributes=iG(e[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(t){if(r.attributes.hasOwnProperty(t)){r.attributes[t]=parseInt(r.attributes[t],10);var e="BYTERANGE-LENGTH"===t?"length":"offset";r.attributes.byterange=r.attributes.byterange||{},r.attributes.byterange[e]=r.attributes[t],delete r.attributes[t]}}),n.trigger("data",r);return}if((e=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(t))&&e[1]){(r={type:"tag",tagType:"rendition-report"}).attributes=iG(e[1]),["LAST-MSN","LAST-PART"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=parseInt(r.attributes[t],10))}),n.trigger("data",r);return}if((e=/^#EXT-X-DATERANGE:(.*)$/.exec(t))&&e[1]){(r={type:"tag",tagType:"daterange"}).attributes=iG(e[1]),["ID","CLASS"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=String(r.attributes[t]))}),["START-DATE","END-DATE"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=new Date(r.attributes[t]))}),["DURATION","PLANNED-DURATION"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=parseFloat(r.attributes[t]))}),["END-ON-NEXT"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=/YES/i.test(r.attributes[t]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(t){r.attributes.hasOwnProperty(t)&&(r.attributes[t]=r.attributes[t].toString(16))});var l=/^X-([A-Z]+-)+[A-Z]+$/;for(var c in r.attributes)if(l.test(c)){var h=/[0-9A-Fa-f]{6}/g.test(r.attributes[c]),f=/^\d+(\.\d+)?$/.test(r.attributes[c]);r.attributes[c]=h?r.attributes[c].toString(16):f?parseFloat(r.attributes[c]):String(r.attributes[c])}n.trigger("data",r);return}if(e=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(t)){n.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(e=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(t)){(r={type:"tag",tagType:"content-steering"}).attributes=iG(e[1]),n.trigger("data",r);return}n.trigger("data",{type:"tag",data:t.slice(4)})})}}},{key:"addParser",value:function(t){var e=this,r=t.expression,n=t.customType,s=t.dataParser,a=t.segment;"function"!=typeof s&&(s=function(t){return t}),this.customParsers.push(function(t){if(r.exec(t))return e.trigger("data",{type:"custom",data:s(t),customType:n,segment:a}),!0})}},{key:"addTagMapper",value:function(t){var e=t.expression,r=t.map;this.tagMappers.push(function(t){return e.test(t)?r(t):t})}}]),r}(iL),iW=function(t){var e={};return Object.keys(t).forEach(function(r){e[r.toLowerCase().replace(/-(\w)/g,function(t){return t[1].toUpperCase()})]=t[r]}),e},iV=function(t){var e=t.serverControl,r=t.targetDuration,n=t.partTargetDuration;if(e){var s="#EXT-X-SERVER-CONTROL",a="holdBack",o="partHoldBack",u=r&&3*r,l=n&&2*n;r&&!e.hasOwnProperty(a)&&(e[a]=u,this.trigger("info",{message:"".concat(s," defaulting HOLD-BACK to targetDuration * 3 (").concat(u,").")})),u&&e[a]<u&&(this.trigger("warn",{message:"".concat(s," clamping HOLD-BACK (").concat(e[a],") to targetDuration * 3 (").concat(u,")")}),e[a]=u),n&&!e.hasOwnProperty(o)&&(e[o]=3*n,this.trigger("info",{message:"".concat(s," defaulting PART-HOLD-BACK to partTargetDuration * 3 (").concat(e[o],").")})),n&&e[o]<l&&(this.trigger("warn",{message:"".concat(s," clamping PART-HOLD-BACK (").concat(e[o],") to partTargetDuration * 2 (").concat(l,").")}),e[o]=l)}},iH=/*#__PURE__*/function(t){(0,ex._)(r,t);var e=(0,eC._)(r);function r(){(0,eg._)(this,r),(t=e.call(this)).lineStream=new iN,t.parseStream=new iY,t.lineStream.pipe(t.parseStream),t.lastProgramDateTime=null;var t,n,s,a=(0,em._)(t),o=[],u={},l=!1,c=function(){},h={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},f=0;t.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],segments:[]};var d=0,p=0,m={};return t.on("end",function(){!u.uri&&(u.parts||u.preloadHints)&&(!u.map&&n&&(u.map=n),!u.key&&s&&(u.key=s),u.timeline||"number"!=typeof f||(u.timeline=f),t.manifest.preloadSegment=u)}),t.parseStream.on("data",function(t){var e,r;({tag:function(){(({version:function(){t.version&&(this.manifest.version=t.version)},"allow-cache":function(){this.manifest.allowCache=t.allowed,"allowed"in t||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange:function(){var e={};"length"in t&&(u.byterange=e,e.length=t.length,"offset"in t||(t.offset=d)),"offset"in t&&(u.byterange=e,e.offset=t.offset),d=e.offset+e.length},endlist:function(){this.manifest.endList=!0},inf:function(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),t.title&&(u.title=t.title),t.duration>0&&(u.duration=t.duration),0===t.duration&&(u.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=o},key:function(){if(!t.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if("NONE"===t.attributes.METHOD){s=null;return}if(!t.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if("com.apple.streamingkeydelivery"===t.attributes.KEYFORMAT){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:t.attributes};return}if("com.microsoft.playready"===t.attributes.KEYFORMAT){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:t.attributes.URI};return}if("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"===t.attributes.KEYFORMAT){if(-1===["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(t.attributes.METHOD)){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if("SAMPLE-AES-CENC"===t.attributes.METHOD&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),"data:text/plain;base64,"!==t.attributes.URI.substring(0,23)){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(t.attributes.KEYID&&"0x"===t.attributes.KEYID.substring(0,2))){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:t.attributes.KEYFORMAT,keyId:t.attributes.KEYID.substring(2)},pssh:function(t){for(var e=iM.atob?iM.atob(t):eF.from(t,"base64").toString("binary"),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}(t.attributes.URI.split(",")[1])};return}t.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),s={method:t.attributes.METHOD||"AES-128",uri:t.attributes.URI},"u">(0,ek._)(t.attributes.IV)&&(s.iv=t.attributes.IV)},"media-sequence":function(){if(!isFinite(t.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+t.number});return}this.manifest.mediaSequence=t.number},"discontinuity-sequence":function(){if(!isFinite(t.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+t.number});return}this.manifest.discontinuitySequence=t.number,f=t.number},"playlist-type":function(){if(!/VOD|EVENT/.test(t.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+t.playlist});return}this.manifest.playlistType=t.playlistType},map:function(){n={},t.uri&&(n.uri=t.uri),t.byterange&&(n.byterange=t.byterange),s&&(n.key=s)},"stream-inf":function(){if(this.manifest.playlists=o,this.manifest.mediaGroups=this.manifest.mediaGroups||h,!t.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}u.attributes||(u.attributes={}),iO(u.attributes,t.attributes)},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||h,!(t.attributes&&t.attributes.TYPE&&t.attributes["GROUP-ID"]&&t.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}var n=this.manifest.mediaGroups[t.attributes.TYPE];n[t.attributes["GROUP-ID"]]=n[t.attributes["GROUP-ID"]]||{},e=n[t.attributes["GROUP-ID"]],(r={default:/yes/i.test(t.attributes.DEFAULT)}).default?r.autoselect=!0:r.autoselect=/yes/i.test(t.attributes.AUTOSELECT),t.attributes.LANGUAGE&&(r.language=t.attributes.LANGUAGE),t.attributes.URI&&(r.uri=t.attributes.URI),t.attributes["INSTREAM-ID"]&&(r.instreamId=t.attributes["INSTREAM-ID"]),t.attributes.CHARACTERISTICS&&(r.characteristics=t.attributes.CHARACTERISTICS),t.attributes.FORCED&&(r.forced=/yes/i.test(t.attributes.FORCED)),e[t.attributes.NAME]=r},discontinuity:function(){f+=1,u.discontinuity=!0,this.manifest.discontinuityStarts.push(o.length)},"program-date-time":function(){(0,ek._)(this.manifest.dateTimeString)>"u"&&(this.manifest.dateTimeString=t.dateTimeString,this.manifest.dateTimeObject=t.dateTimeObject),u.dateTimeString=t.dateTimeString,u.dateTimeObject=t.dateTimeObject;var e=this.lastProgramDateTime;this.lastProgramDateTime=new Date(t.dateTimeString).getTime(),null===e&&this.manifest.segments.reduceRight(function(t,e){return e.programDateTime=t-1e3*e.duration,e.programDateTime},this.lastProgramDateTime)},targetduration:function(){if(!isFinite(t.duration)||t.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+t.duration});return}this.manifest.targetDuration=t.duration,iV.call(this,this.manifest)},start:function(){if(!t.attributes||isNaN(t.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:t.attributes["TIME-OFFSET"],precise:t.attributes.PRECISE}},"cue-out":function(){u.cueOut=t.data},"cue-out-cont":function(){u.cueOutCont=t.data},"cue-in":function(){u.cueIn=t.data},skip:function(){this.manifest.skip=iW(t.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",t.attributes,["SKIPPED-SEGMENTS"])},part:function(){var e=this;l=!0;var r=this.manifest.segments.length,n=iW(t.attributes);u.parts=u.parts||[],u.parts.push(n),n.byterange&&(n.byterange.hasOwnProperty("offset")||(n.byterange.offset=p),p=n.byterange.offset+n.byterange.length);var s=u.parts.length-1;this.warnOnMissingAttributes_("#EXT-X-PART #".concat(s," for segment #").concat(r),t.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach(function(t,r){t.hasOwnProperty("lastPart")||e.trigger("warn",{message:"#EXT-X-RENDITION-REPORT #".concat(r," lacks required attribute(s): LAST-PART")})})},"server-control":function(){var e=this.manifest.serverControl=iW(t.attributes);e.hasOwnProperty("canBlockReload")||(e.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),iV.call(this,this.manifest),e.canSkipDateranges&&!e.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint":function(){var e=this.manifest.segments.length,r=iW(t.attributes),n=r.type&&"PART"===r.type;u.preloadHints=u.preloadHints||[],u.preloadHints.push(r),r.byterange&&(r.byterange.hasOwnProperty("offset")||(r.byterange.offset=n?p:0,n&&(p=r.byterange.offset+r.byterange.length)));var s=u.preloadHints.length-1;if(this.warnOnMissingAttributes_("#EXT-X-PRELOAD-HINT #".concat(s," for segment #").concat(e),t.attributes,["TYPE","URI"]),r.type)for(var a=0;a<u.preloadHints.length-1;a++){var o=u.preloadHints[a];o.type&&o.type===r.type&&this.trigger("warn",{message:"#EXT-X-PRELOAD-HINT #".concat(s," for segment #").concat(e," has the same TYPE ").concat(r.type," as preload hint #").concat(a)})}},"rendition-report":function(){var e=iW(t.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(e);var r=this.manifest.renditionReports.length-1,n=["LAST-MSN","URI"];l&&n.push("LAST-PART"),this.warnOnMissingAttributes_("#EXT-X-RENDITION-REPORT #".concat(r),t.attributes,n)},"part-inf":function(){this.manifest.partInf=iW(t.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",t.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),iV.call(this,this.manifest)},daterange:function(){this.manifest.dateRanges.push(iW(t.attributes));var e=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_("#EXT-X-DATERANGE #".concat(e),t.attributes,["ID","START-DATE"]);var r=this.manifest.dateRanges[e];r.endDate&&r.startDate&&new Date(r.endDate)<new Date(r.startDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"}),r.duration&&r.duration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"}),r.plannedDuration&&r.plannedDuration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});var n=!!r.endOnNext;if(n&&!r.class&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"}),n&&(r.duration||r.endDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"}),r.duration&&r.endDate){var s=r.startDate.getTime()+1e3*r.duration;this.manifest.dateRanges[e].endDate=new Date(s)}if(m[r.id]){for(var a in m[r.id])if(r[a]&&JSON.stringify(m[r.id][a])!==JSON.stringify(r[a])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}var o=this.manifest.dateRanges.findIndex(function(t){return t.id===r.id});this.manifest.dateRanges[o]=iO(this.manifest.dateRanges[o],r),m[r.id]=iO(m[r.id],r),this.manifest.dateRanges.pop()}else m[r.id]=r},"independent-segments":function(){this.manifest.independentSegments=!0},"content-steering":function(){this.manifest.contentSteering=iW(t.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",t.attributes,["SERVER-URI"])}})[t.tagType]||c).call(a)},uri:function(){u.uri=t.uri,o.push(u),!this.manifest.targetDuration||"duration"in u||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),u.duration=this.manifest.targetDuration),s&&(u.key=s),u.timeline=f,n&&(u.map=n),p=0,null!==this.lastProgramDateTime&&(u.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=1e3*u.duration),u={}},comment:function(){},custom:function(){t.segment?(u.custom=u.custom||{},u.custom[t.customType]=t.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[t.customType]=t.data)}})[t.type].call(a)}),(0,eT._)(t)}return(0,ev._)(r,[{key:"warnOnMissingAttributes_",value:function(t,e,r){var n=[];r.forEach(function(t){e.hasOwnProperty(t)||n.push(t)}),n.length&&this.trigger("warn",{message:"".concat(t," lacks required attribute(s): ").concat(n.join(", "))})}},{key:"push",value:function(t){this.lineStream.push(t)}},{key:"end",value:function(){this.lineStream.push("\n"),this.manifest.dateRanges.length&&null===this.lastProgramDateTime&&this.trigger("warn",{message:"A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"}),this.lastProgramDateTime=null,this.trigger("end")}},{key:"addParser",value:function(t){this.parseStream.addParser(t)}},{key:"addTagMapper",value:function(t){this.parseStream.addTagMapper(t)}}]),r}(iL);function iX(t){return iZ.apply(this,arguments)}function iZ(){return(iZ=(0,ey._)(function(t){var e,r,n,s,a,o,u=arguments;function l(){return(l=(0,ey._)(function(t,r,n){var s,u,l,c,h,f,d;function p(){return(p=(0,ey._)(function(t){return(0,eB._)(this,function(e){switch(e.label){case 0:return[4,fetch(t)];case 1:return[2,e.sent().arrayBuffer()]}})})).apply(this,arguments)}return(0,eB._)(this,function(m){s=function(e){var s=0,a=0,o=[];function u(){return(u=(0,ey._)(function(t){return(0,eB._)(this,function(e){return o.push(t),l(),[2]})})).apply(this,arguments)}function l(){return c.apply(this,arguments)}function c(){return(c=(0,ey._)(function(){var u,c;return(0,eB._)(this,function(h){switch(h.label){case 0:if(!(s<e&&o.length))return[3,5];u=o.shift(),s++,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,null==u?void 0:u()];case 2:return h.sent(),a++,n.emit("progress",Math.round(a/t.length*100)/100),l(),[3,4];case 3:return c=h.sent(),o=[],r.error(c),n.destroy(),rw.error(c),[3,4];case 4:s--,h.label=5;case 5:return[2]}})})).apply(this,arguments)}return function(t){return u.apply(this,arguments)}}(e),u=!0,l=!1,c=void 0;try{for(h=function(){var t=(0,eA._)(d.value,2)[1],e=new URL(t.uri,a).href;s(function(){return o[e]=function(t){return p.apply(this,arguments)}(e)})},f=t.entries()[Symbol.iterator]();!(u=(d=f.next()).done);u=!0)h()}catch(t){l=!0,c=t}finally{try{u||null==f.return||f.return()}finally{if(l)throw c}}return[2]})})).apply(this,arguments)}function c(){return(c=(0,ey._)(function(t){var e;return(0,eB._)(this,function(r){switch(r.label){case 0:return[4,o[t]];case 1:return e=r.sent(),[2,(delete o[t],e)]}})})).apply(this,arguments)}return(0,eB._)(this,function(h){switch(h.label){case 0:return e=u.length>1&&void 0!==u[1]?u[1]:10,n=(r=new iH).push,[4,fetch(t)];case 1:return[4,h.sent().text()];case 2:return n.apply(r,[h.sent()]),r.end(),s=r.manifest.segments.reduce(function(t,e){var r;return t[e.map.uri]=null!==(r=t[e.map.uri])&&void 0!==r?r:[],t[e.map.uri].push(e),t},{}),a=new URL(t,location.href),o={},[2,{load:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r={},n=0,o=0,u=!0,h=!1,f=void 0;try{for(var d,p=Object.entries(s)[Symbol.iterator]();!(u=(d=p.next()).done);u=!0){for(var m=(0,eA._)(d.value,2),_=m[0],y=m[1],g=0,v=[],b=-1,w=-1,S=0;S<y.length;S++){var x=y[S];if(g+=x.duration,-1===b&&g>t/1e6&&(b=S,n=(g-x.duration)*1e6),b>-1&&-1===w&&g>=e/1e6){w=S+1,o=1e6*g;break}}e>=1e6*g&&(w=y.length,o=1e6*g),w>b&&(v=v.concat(y.slice(b,w))),v.length>0&&(r[_]={actualStartTime:n,actualEndTime:o,segments:v})}}catch(t){h=!0,f=t}finally{try{u||null==p.return||p.return()}finally{if(h)throw f}}return 0===Object.keys(r).length?null:Object.entries(r).map(function(t){var e,r,n=(0,eA._)(t,2),s=n[0],o=n[1],u=o.actualStartTime,h=o.actualEndTime,f=o.segments,d=0,p=new iw;return{actualStartTime:u,actualEndTime:h,on:p.on,stream:new ReadableStream({start:(e=(0,ey._)(function(t){var e,r;return(0,eB._)(this,function(n){switch(n.label){case 0:return function(t,e,r){l.apply(this,arguments)}(f,t,p),e=t.enqueue,r=Uint8Array.bind,[4,fetch(new URL(s,a).href)];case 1:return[4,n.sent().arrayBuffer()];case 2:return e.apply(t,[new(r.apply(Uint8Array,[void 0,n.sent()]))]),[2]}})}),function(t){return e.apply(this,arguments)}),pull:(r=(0,ey._)(function(t){var e,r,n;return(0,eB._)(this,function(s){switch(s.label){case 0:return e=new URL(f[d].uri,a).href,r=t.enqueue,n=Uint8Array.bind,[4,function(t){return c.apply(this,arguments)}(e)];case 1:return r.apply(t,[new(n.apply(Uint8Array,[void 0,s.sent()]))]),(d+=1)>=f.length&&(t.close(),p.destroy()),[2]}})}),function(t){return r.apply(this,arguments)})})}})}}]}})})).apply(this,arguments)}var iK=[-1,1,-1,-1,1,-1,1,-1,1,1,-1,1],iq=[0,1,0,0,1,0,1,0,1,1,0,1];function iQ(t,e,r){var n=t.createShader(e);if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var s=t.getShaderInfoLog(n);throw t.deleteShader(n),Error(null!=s?s:"An error occurred compiling the shaders")}return n}var iJ=function(t){var e,r=null,n=null,s=t.keyColor,a=null;return e=(0,ey._)(function(e){var o,u,l;return(0,eB._)(this,function(c){var h,f,d,p,m;return((null==r||null==n||null==a)&&(null==s&&((h=new OffscreenCanvas(1,1).getContext("2d")).drawImage(e,0,0),f=h.getImageData(0,0,1,1),s=[(d=(0,eA._)(f.data,3))[0],d[1],d[2]]),r=(o=function(t){var e="document"in globalThis?globalThis.document.createElement("canvas"):new OffscreenCanvas(t.width,t.height);e.width=t.width,e.height=t.height;var r=e.getContext("webgl2",{premultipliedAlpha:!1,alpha:!0});if(null==r)throw Error("Cant create gl context");var n=function(t,e,r){var n,s=iQ(t,t.VERTEX_SHADER,e),a=iQ(t,t.FRAGMENT_SHADER,r),o=t.createProgram();if(t.attachShader(o,s),t.attachShader(o,a),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw Error(null!==(n=t.getProgramInfoLog(o))&&void 0!==n?n:"Unable to initialize the shader program");return o}(r,"#version 300 es\n layout (location = 0) in vec4 a_position;\n layout (location = 1) in vec2 a_texCoord;\n out vec2 v_texCoord;\n void main () {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n }\n","#version 300 es\nprecision mediump float;\nout vec4 FragColor;\nin vec2 v_texCoord;\n\nuniform sampler2D frameTexture;\nuniform vec3 keyColor;\n\n// 色度的相似度计算\nuniform float similarity;\n// 透明度的平滑度计算\nuniform float smoothness;\n// 降低绿幕饱和度,提高抠图准确度\nuniform float spill;\n\nvec2 RGBtoUV(vec3 rgb) {\n return vec2(\n rgb.r * -0.169 + rgb.g * -0.331 + rgb.b * 0.5 + 0.5,\n rgb.r * 0.5 + rgb.g * -0.419 + rgb.b * -0.081 + 0.5\n );\n}\n\nvoid main() {\n // 获取当前像素的rgba值\n vec4 rgba = texture(frameTexture, v_texCoord);\n // 计算当前像素与绿幕像素的色度差值\n vec2 chromaVec = RGBtoUV(rgba.rgb) - RGBtoUV(keyColor);\n // 计算当前像素与绿幕像素的色度距离(向量长度), 越相像则色度距离越小\n float chromaDist = sqrt(dot(chromaVec, chromaVec));\n // 设置了一个相似度阈值,baseMask为负,则表明是绿幕,为正则表明不是绿幕\n float baseMask = chromaDist - similarity;\n // 如果baseMask为负数,fullMask等于0;baseMask为正数,越大,则透明度越低\n float fullMask = pow(clamp(baseMask / smoothness, 0., 1.), 1.5);\n rgba.a = fullMask; // 设置透明度\n // 如果baseMask为负数,spillVal等于0;baseMask为整数,越小,饱和度越低\n float spillVal = pow(clamp(baseMask / spill, 0., 1.), 1.5);\n float desat = clamp(rgba.r * 0.2126 + rgba.g * 0.7152 + rgba.b * 0.0722, 0., 1.); // 计算当前像素的灰度值\n rgba.rgb = mix(vec3(desat, desat, desat), rgba.rgb, spillVal);\n FragColor = rgba;\n}\n");r.useProgram(n),r.uniform3fv(r.getUniformLocation(n,"keyColor"),t.keyColor.map(function(t){return t/255})),r.uniform1f(r.getUniformLocation(n,"similarity"),t.similarity),r.uniform1f(r.getUniformLocation(n,"smoothness"),t.smoothness),r.uniform1f(r.getUniformLocation(n,"spill"),t.spill);var s=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,s),r.bufferData(r.ARRAY_BUFFER,new Float32Array(iK),r.STATIC_DRAW);var a=r.getAttribLocation(n,"a_position");r.vertexAttribPointer(a,2,r.FLOAT,!1,2*Float32Array.BYTES_PER_ELEMENT,0),r.enableVertexAttribArray(a);var o=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,new Float32Array(iq),r.STATIC_DRAW);var u=r.getAttribLocation(n,"a_texCoord");return r.vertexAttribPointer(u,2,r.FLOAT,!1,2*Float32Array.BYTES_PER_ELEMENT,0),r.enableVertexAttribArray(u),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1),{cvs:e,gl:r}}((0,eE._)((0,eU._)((0,eE._)({},e instanceof VideoFrame?{width:e.codedWidth,height:e.codedHeight}:{width:e.width,height:e.height}),{keyColor:s}),t))).cvs,a=function(t){var e=t.createTexture();if(null==e)throw Error("Create WebGL texture error");t.bindTexture(t.TEXTURE_2D,e);var r=t.RGBA,n=t.RGBA,s=t.UNSIGNED_BYTE,a=new Uint8Array([0,0,255,255]);return t.texImage2D(t.TEXTURE_2D,0,r,1,1,0,n,s,a),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}(n=o.gl)),p=n,m=a,p.bindTexture(p.TEXTURE_2D,m),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,e),p.drawArrays(p.TRIANGLES,0,6),null!=globalThis.VideoFrame&&e instanceof globalThis.VideoFrame)?(l=new VideoFrame(r,{alpha:"keep",timestamp:e.timestamp,duration:null!==(u=e.duration)&&void 0!==u?u:void 0}),[2,(e.close(),l)]):[2,createImageBitmap(r,{imageOrientation:e instanceof ImageBitmap?"flipY":"none"})]})}),function(t){return e.apply(this,arguments)}},i$=/*#__PURE__*/function(){function t(e,r,n,s,a){(0,eg._)(this,t),eN(this,tK),eN(this,tY,new iw),eL(this,"on",eM(this,tY).on),eN(this,tW,0),eN(this,tV,0),eN(this,tH,0),eN(this,tX,0),eN(this,tZ,0),eL(this,"master",null),eL(this,"fixedAspectRatio",!1),this.x=null!=e?e:0,this.y=null!=r?r:0,this.w=null!=n?n:0,this.h=null!=s?s:0,this.master=null!=a?a:null}return(0,ev._)(t,[{key:"x",get:function(){return eM(this,tW)},set:function(t){eG(this,tK,tq).call(this,"x",t)}},{key:"y",get:function(){return eM(this,tV)},set:function(t){eG(this,tK,tq).call(this,"y",t)}},{key:"w",get:function(){return eM(this,tH)},set:function(t){eG(this,tK,tq).call(this,"w",t)}},{key:"h",get:function(){return eM(this,tX)},set:function(t){eG(this,tK,tq).call(this,"h",t)}},{key:"angle",get:function(){return eM(this,tZ)},set:function(t){eG(this,tK,tq).call(this,"angle",t)}},{key:"center",get:function(){var t=this.x,e=this.y;return{x:t+this.w/2,y:e+this.h/2}}},{key:"ctrls",get:function(){var e=this.w,r=this.h,n=t.CTRL_SIZE,s=n/2,a=e/2,o=r/2,u=1.5*n,l=u/2;return(0,eU._)((0,eE._)({},this.fixedAspectRatio?{}:{t:new t(-s,-o-s,n,n,this),b:new t(-s,o-s,n,n,this),l:new t(-a-s,-s,n,n,this),r:new t(a-s,-s,n,n,this)}),{lt:new t(-a-s,-o-s,n,n,this),lb:new t(-a-s,o-s,n,n,this),rt:new t(a-s,-o-s,n,n,this),rb:new t(a-s,o-s,n,n,this),rotate:new t(-l,-o-2*n-l,u,u,this)})}},{key:"clone",value:function(){var e=new t(this.x,this.y,this.w,this.h,this.master);return e.angle=this.angle,e.fixedAspectRatio=this.fixedAspectRatio,e}},{key:"checkHit",value:function(t,e){var r,n,s=this.angle,a=this.center,o=this.x,u=this.y,l=this.w,c=this.h,h=this.master,f=null!==(r=null==h?void 0:h.center)&&void 0!==r?r:a,d=null!==(n=null==h?void 0:h.angle)&&void 0!==n?n:s;null==h&&(o-=f.x,u-=f.y);var p=t-f.x,m=e-f.y,_=p,y=m;return 0!==d&&(_=p*Math.cos(d)+m*Math.sin(d),y=m*Math.cos(d)-p*Math.sin(d)),!(_<o||_>o+l||y<u||y>u+c)}}]),t}();tY=new WeakMap,tW=new WeakMap,tV=new WeakMap,tH=new WeakMap,tX=new WeakMap,tZ=new WeakMap,tK=new WeakSet,tq=function(t,e){var r=this[t]!==e;switch(t){case"x":ej(this,tW,e);break;case"y":ej(this,tV,e);break;case"w":ej(this,tH,e);break;case"h":ej(this,tX,e);break;case"angle":ej(this,tZ,e)}r&&eM(this,tY).emit("propsChange",(0,eb._)({},t,e))},eL(i$,"CTRL_SIZE",16),eL(i$,"CTRL_KEYS",["t","b","l","r","lt","lb","rt","rb","rotate"]);var i0=i$,i1=/*#__PURE__*/function(){function t(){var e=this;(0,eg._)(this,t),eL(this,"rect",new i0),eL(this,"time",{offset:0,duration:0}),eL(this,"visible",!0),eN(this,tQ,new iw),eL(this,"on",eM(this,tQ).on),eN(this,tJ,0),eL(this,"opacity",1),eL(this,"flip",null),eN(this,t$,null),eN(this,t0,null),eL(this,"ready",Promise.resolve()),this.rect.on("propsChange",function(t){eM(e,tQ).emit("propsChange",{rect:t})})}return(0,ev._)(t,[{key:"zIndex",get:function(){return eM(this,tJ)},set:function(t){var e=eM(this,tJ)!==t;ej(this,tJ,t),e&&eM(this,tQ).emit("propsChange",{zIndex:t})}},{key:"_render",value:function(t){var e=this.rect,r=e.center,n=e.angle;t.setTransform("horizontal"===this.flip?-1:1,0,0,"vertical"===this.flip?-1:1,r.x,r.y),t.rotate((null==this.flip?1:-1)*n),t.globalAlpha=this.opacity}},{key:"setAnimation",value:function(t,e){var r,n;ej(this,t$,Object.entries(t).map(function(t){var e,r=(0,eA._)(t,2),n=r[0],s=r[1],a=null!==(e=({from:0,to:100})[n])&&void 0!==e?e:Number(n.slice(0,-1));if(isNaN(a)||a>100||a<0)throw Error("keyFrame must between 0~100");return[a/100,s]})),ej(this,t0,Object.assign({},eM(this,t0),{duration:1e6*e.duration,delay:(null!==(r=e.delay)&&void 0!==r?r:0)*1e6,iterCount:null!==(n=e.iterCount)&&void 0!==n?n:1/0}))}},{key:"animate",value:function(t){if(null!=eM(this,t$)&&null!=eM(this,t0)&&!(t<eM(this,t0).delay)){var e=function(t,e,r){if(t/r.duration>=r.iterCount)return{};var n=t%r.duration,s=t===r.duration?1:n/r.duration,a=e.findIndex(function(t){return t[0]>=s});if(-1===a)return{};var o=e[a-1],u=e[a],l=u[1];if(null==o)return l;var c=o[1],h={},f=(s-o[0])/(u[0]-o[0]);for(var d in l)null!=c[d]&&(h[d]=(l[d]-c[d])*f+c[d]);return h}(t,eM(this,t$),eM(this,t0));for(var r in e)switch(r){case"opacity":this.opacity=e[r];break;case"x":case"y":case"w":case"h":case"angle":this.rect[r]=e[r]}}}},{key:"copyStateTo",value:function(t){ej(t,t$,eM(this,t$)),ej(t,t0,eM(this,t0)),t.visible=this.visible,t.zIndex=this.zIndex,t.opacity=this.opacity,t.flip=this.flip,t.rect=this.rect.clone(),t.time=(0,eE._)({},this.time)}},{key:"destroy",value:function(){eM(this,tQ).destroy()}}]),t}();tQ=new WeakMap,tJ=new WeakMap,t$=new WeakMap,t0=new WeakMap;var i2=/*#__PURE__*/function(t){(0,ex._)(r,t);var e=(0,eC._)(r);function r(t){var n;return(0,eg._)(this,r),n=e.call(this),eN((0,em._)(n),t1),eN((0,em._)(n),t2,null),eN((0,em._)(n),t3,!1),ej((0,em._)(n),t1,t),n.ready=t.ready.then(function(t){var e=t.width,r=t.height,s=t.duration;n.rect.w=0===n.rect.w?e:n.rect.w,n.rect.h=0===n.rect.h?r:n.rect.h,n.time.duration=0===n.time.duration?s:n.time.duration}),n}return(0,ev._)(r,[{key:"offscreenRender",value:function(t,e){var n=this,s=this;return(0,ey._)(function(){var a,o,u,l,c,h,f,d;return(0,eB._)(this,function(p){switch(p.label){case 0:return s.animate(e),(0,ew._)((0,eS._)(r.prototype),"_render",n).call(s,t),u=(o=s.rect).w,l=o.h,[4,eM(s,t1).tick(e)];case 1:if(h=(c=p.sent()).video,f=c.audio,"done"===c.state)return[2,{audio:null!=f?f:[],done:!0}];return[2,(null!=(d=null!=h?h:eM(s,t2))&&t.drawImage(d,-u/2,-l/2,u,l),null!=h&&(null==(a=eM(s,t2))||a.close(),ej(s,t2,h)),{audio:null!=f?f:[],done:!1})]}})})()}},{key:"clone",value:function(){var t=this;return(0,ey._)(function(){var e,n;return(0,eB._)(this,function(s){switch(s.label){case 0:return n=r.bind,[4,eM(t,t1).clone()];case 1:return[4,(e=new(n.apply(r,[void 0,s.sent()]))).ready];case 2:return[2,(s.sent(),t.copyStateTo(e),e)]}})})()}},{key:"destroy",value:function(){var t;eM(this,t3)||(ej(this,t3,!0),rw.info("OffscreenSprite destroy"),(0,ew._)((0,eS._)(r.prototype),"destroy",this).call(this),null==(t=eM(this,t2))||t.close(),ej(this,t2,null),eM(this,t1).destroy())}}]),r}(i1);t1=new WeakMap,t2=new WeakMap,t3=new WeakMap;var i3=i2,i4=/*#__PURE__*/function(t){(0,ex._)(r,t);var e=(0,eC._)(r);function r(t){var n;return(0,eg._)(this,r),n=e.call(this),eN((0,em._)(n),t9),eN((0,em._)(n),t4),eN((0,em._)(n),t6,null),eN((0,em._)(n),t8,[]),eN((0,em._)(n),t5,!1),eN((0,em._)(n),et,-1),eN((0,em._)(n),ee,!1),ej((0,em._)(n),t4,t),n.ready=t.ready.then(function(t){var e=t.width,r=t.height,s=t.duration;n.rect.w=0===n.rect.w?e:n.rect.w,n.rect.h=0===n.rect.h?r:n.rect.h,n.time.duration=0===n.time.duration?s:n.time.duration}),n}return(0,ev._)(r,[{key:"getClip",value:function(){return eM(this,t4)}},{key:"preFrame",value:function(t){eG(this,t9,t7).call(this,t)}},{key:"render",value:function(t,e){this.animate(e),(0,ew._)((0,eS._)(r.prototype),"_render",this).call(this,t);var n=this.rect,s=n.w,a=n.h;eM(this,et)!==e&&eG(this,t9,t7).call(this,e),ej(this,et,e);var o=eM(this,t8);ej(this,t8,[]);var u=eM(this,t6);return null!=u&&t.drawImage(u,-s/2,-a/2,s,a),{audio:o}}},{key:"destroy",value:function(){var t;eM(this,ee)||(ej(this,ee,!0),rw.info("VisibleSprite destroy"),(0,ew._)((0,eS._)(r.prototype),"destroy",this).call(this),null==(t=eM(this,t6))||t.close(),ej(this,t6,null),eM(this,t4).destroy())}}]),r}(i1);t4=new WeakMap,t6=new WeakMap,t8=new WeakMap,t5=new WeakMap,t9=new WeakSet,t7=function(t){var e=this;eM(this,t5)||(ej(this,t5,!0),eM(this,t4).tick(t).then(function(t){var r,n=t.video,s=t.audio;null!=n&&(null==(r=eM(e,t6))||r.close(),ej(e,t6,null!=n?n:null)),ej(e,t8,null!=s?s:[])}).finally(function(){ej(e,t5,!1)}))},et=new WeakMap,ee=new WeakMap;var i6=0;function i8(t){return i5.apply(this,arguments)}function i5(){return(i5=(0,ey._)(function(t){return(0,eB._)(this,function(e){switch(e.label){case 0:if(!(t()>50))return[3,3];return[4,rH(15)];case 1:return e.sent(),[4,i8(t)];case 2:e.sent(),e.label=3;case 3:return[2]}})})).apply(this,arguments)}var i9=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,eg._)(this,t),eN(this,eh),eN(this,er,rw.create("id:".concat(i6++,","))),eN(this,ei,!1),eN(this,en,[]),eN(this,es),eN(this,ea),eN(this,eo,null),eN(this,eu),eN(this,el),eN(this,ec,new iw),eL(this,"on",eM(this,ec).on);var r=e.width,n=void 0===r?0:r,s=e.height,a=void 0===s?0:s;ej(this,es,new OffscreenCanvas(n,a));var o=eM(this,es).getContext("2d",{alpha:!1});if(null==o)throw Error("Can not create 2d offscreen context");ej(this,ea,o),ej(this,eu,Object.assign({bgColor:"#000",width:0,height:0,videoCodec:"avc1.42E032",audio:!0,bitrate:5e6,metaDataTags:null},e)),ej(this,el,n*a>0)}return(0,ev._)(t,[{key:"addSprite",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this;return(0,ey._)(function(){var n,s;return(0,eB._)(this,function(a){switch(a.label){case 0:return eM(r,er).info("Combinator add sprite",t),[4,t.clone()];case 1:return n=a.sent(),eM(r,er).info("Combinator add sprite ready",t),eM(r,en).push(Object.assign(n,{main:null!==(s=e.main)&&void 0!==s&&s,expired:!1})),eM(r,en).sort(function(t,e){return t.zIndex-e.zIndex}),[2]}})})()}},{key:"output",value:function(){var t,e=this;if(0===eM(this,en).length)throw Error("No sprite added");var r=eM(this,en).find(function(t){return t.main}),n=null!=r?r.time.offset+r.time.duration:(t=Math).max.apply(t,(0,eI._)(eM(this,en).map(function(t){return t.time.offset+t.time.duration})));if(n===1/0)throw Error("Unable to determine the end time, please specify a main sprite, or limit the duration of ImgClip, AudioCli");-1===n&&eM(this,er).warn("Unable to determine the end time, process value don't update"),eM(this,er).info("start combinate video, maxTime:".concat(n));var s=eG(this,eh,ef).call(this,n),a=performance.now(),o=this,u=eG(this,eh,ed).call(this,s,n,{onProgress:function(t){eM(e,er).debug("OutputProgress:",t),eM(e,ec).emit("OutputProgress",t)},onEnded:/*#__PURE__*/(0,ey._)(function(){return(0,eB._)(this,function(t){switch(t.label){case 0:return[4,s.flush()];case 1:return t.sent(),eM(o,er).info("===== output ended =====, cost:",performance.now()-a),eM(o,ec).emit("OutputProgress",1),o.destroy(),[2]}})}),onError:function(t){eM(e,ec).emit("error",t),h(t),e.destroy()}});ej(this,eo,function(){u(),s.close(),h()});var l=ik(s.mp4file,500,this.destroy),c=l.stream,h=l.stop;return c}},{key:"destroy",value:function(){var t;eM(this,ei)||(ej(this,ei,!0),null==(t=eM(this,eo))||t.call(this),eM(this,ec).destroy())}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{videoCodec:"avc1.42E032"};return(0,ey._)(function(){var e,r,n;return(0,eB._)(this,function(s){switch(s.label){case 0:if(!(n=null!=self.OffscreenCanvas&&null!=self.VideoEncoder&&null!=self.VideoDecoder&&null!=self.VideoFrame&&null!=self.AudioEncoder&&null!=self.AudioDecoder&&null!=self.AudioData))return[3,2];return[4,self.VideoEncoder.isConfigSupported({codec:t.videoCodec,width:1280,height:720})];case 1:n=null!==(e=s.sent().supported)&&void 0!==e&&e,s.label=2;case 2:if(!(r=n))return[3,4];return[4,self.AudioEncoder.isConfigSupported({codec:r$.codec,sampleRate:r$.sampleRate,numberOfChannels:r$.channelCount})];case 3:r=s.sent().supported,s.label=4;case 4:return[2,r]}})})()}}]),t}();er=new WeakMap,ei=new WeakMap,en=new WeakMap,es=new WeakMap,ea=new WeakMap,eo=new WeakMap,eu=new WeakMap,el=new WeakMap,ec=new WeakMap,eh=new WeakSet,ef=function(t){var e=eM(this,eu),r=e.width,n=e.height,s=e.videoCodec,a=e.bitrate,o=e.audio,u=e.metaDataTags;return iA({video:eM(this,el)?{width:r,height:n,expectFPS:30,codec:s,bitrate:a,__unsafe_hardwareAcceleration__:eM(this,eu).__unsafe_hardwareAcceleration__}:null,audio:!1===o?null:{codec:"aac",sampleRate:r$.sampleRate,channelCount:r$.channelCount},duration:t,metaDataTags:u})},ed=function(t,e,r){var n=this,s=r.onProgress,a=r.onEnded,o=r.onError,u=0,l=!1,c=null,h=this;(0,ey._)(function(){var r,n,s,o,f,p,m,_;return(0,eB._)(this,function(y){switch(y.label){case 0:r=function(){var r,s,_,y,g,v,b,w,S,x,E,U,T;return(0,eB._)(this,function(A){switch(A.label){case 0:if(null!=c)return[2,{v:void 0}];if(!(l||-1!==e&&m>e||0===eM(h,en).length))return[3,2];return d(),[4,a()];case 1:return A.sent(),[2,{v:void 0}];case 2:u=m/e,p.fillStyle=eM(h,eu).bgColor,p.fillRect(0,0,o,f),r=[],s=!0,_=!1,y=void 0,A.label=3;case 3:A.trys.push([3,10,11,12]),g=eM(h,en)[Symbol.iterator](),A.label=4;case 4:if((s=(v=g.next()).done)||(b=v.value,l))return[3,9];if(m<b.time.offset||b.expired)return[3,8];return p.save(),[4,b.offscreenRender(p,m-b.time.offset)];case 5:if(S=(w=A.sent()).audio,x=w.done,r.push(S),p.restore(),(!(b.time.duration>0)||!(m>b.time.offset+b.time.duration))&&!x)return[3,8];if(!b.main)return[3,7];return d(),[4,a()];case 6:return A.sent(),[2,{v:void 0}];case 7:b.destroy(),b.expired=!0,A.label=8;case 8:return s=!0,[3,4];case 9:return[3,12];case 10:return E=A.sent(),_=!0,y=E,[3,12];case 11:try{s||null==g.return||g.return()}finally{if(_)throw y}return[7];case 12:var I,k,C;if(l)return[2,{v:void 0}];return!1!==eM(h,eu).audio&&(r.flat().every(function(t){return 0===t.length})?t.encodeAudio((I=m,C=Math.floor(33e3*(k=r$.sampleRate)/1e6),new AudioData({timestamp:I,numberOfChannels:r$.channelCount,numberOfFrames:C,sampleRate:k,format:"f32-planar",data:new Float32Array(2*C)}))):(U=rY(r),t.encodeAudio(new AudioData({timestamp:m,numberOfChannels:r$.channelCount,numberOfFrames:U.length/r$.channelCount,sampleRate:r$.sampleRate,format:"f32-planar",data:U})))),eM(h,el)&&(T=new VideoFrame(eM(h,es),{duration:33e3,timestamp:m}),t.encodeVideo(T,{keyFrame:n%150==0}),p.resetTransform(),p.clearRect(0,0,o,f),n+=1),m+=33e3,[4,i8(t.getEncodeQueueSize)];case 13:return A.sent(),[2]}})},n=0,o=(s=eM(h,es)).width,f=s.height,p=eM(h,ea),m=0,y.label=1;case 1:return[5,(0,eP._)(r())];case 2:if(_=y.sent(),"object"===(0,ek._)(_))return[2,_.v];y.label=3;case 3:return[3,1];case 4:return[2]}})})().catch(function(t){c=t,eM(n,er).error(t),d(),o(t)});var f=setInterval(function(){s(u)},500),d=function(){l||(l=!0,clearInterval(f),eM(n,en).forEach(function(t){return t.destroy()}))};return d}},{"@swc/helpers/_/_assert_this_initialized":"jgeid","@swc/helpers/_/_async_iterator":"kdyGG","@swc/helpers/_/_async_to_generator":"eONSn","@swc/helpers/_/_class_call_check":"9iJMm","@swc/helpers/_/_create_class":"21IOT","@swc/helpers/_/_define_property":"3NGsL","@swc/helpers/_/_get":"hMhPd","@swc/helpers/_/_get_prototype_of":"dAKgy","@swc/helpers/_/_inherits":"3pfgY","@swc/helpers/_/_object_spread":"9agdF","@swc/helpers/_/_object_spread_props":"gJNH2","@swc/helpers/_/_possible_constructor_return":"iVdhB","@swc/helpers/_/_sliced_to_array":"uVQht","@swc/helpers/_/_to_consumable_array":"iwLF0","@swc/helpers/_/_type_of":"felZi","@swc/helpers/_/_create_super":"86fte","@swc/helpers/_/_ts_generator":"6Xyd0","@swc/helpers/_/_ts_values":"1Y0br","718a311db185ef08":"gp9kd","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],jgeid:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],kdyGG:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t){var e,r,n,s=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);s--;){if(r&&null!=(e=t[r]))return e.call(t);if(n&&null!=(e=t[n]))return new a(e.call(t));r="@@asyncIterator",n="@@iterator"}throw TypeError("Object is not async iterable")}function a(t){function e(t){if(Object(t)!==t)return Promise.reject(TypeError(t+" is not an object."));var e=t.done;return Promise.resolve(t.value).then(function(t){return{value:t,done:e}})}return(a=function(t){this.s=t,this.n=t.next}).prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(t){var r=this.s.return;return void 0===r?Promise.resolve({value:t,done:!0}):e(r.apply(this.s,arguments))},throw:function(t){var r=this.s.return;return void 0===r?Promise.reject(t):e(r.apply(this.s,arguments))}},new a(t)}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"9iJMm":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"21IOT":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function a(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),t}n.defineInteropFlag(r),n.export(r,"_",function(){return a})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"3NGsL":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],hMhPd:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return a});var s=t("./_super_prop_base.js");function a(t,e,r){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=(0,s._)(t,e);if(n){var a=Object.getOwnPropertyDescriptor(n,e);return a.get?a.get.call(r||t):a.value}})(t,e,r||t)}},{"./_super_prop_base.js":"64JoP","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"64JoP":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return a});var s=t("./_get_prototype_of.js");function a(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=(0,s._)(t)););return t}},{"./_get_prototype_of.js":"dAKgy","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],dAKgy:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"3pfgY":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return a});var s=t("./_set_prototype_of.js");function a(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&(0,s._)(t,e)}},{"./_set_prototype_of.js":"j4HiF","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],j4HiF:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"9agdF":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return a});var s=t("./_define_property.js");function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){(0,s._)(t,e,r[e])})}return t}},{"./_define_property.js":"3NGsL","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],gJNH2:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r.push.apply(r,n)}return r})(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],iVdhB:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return o});var s=t("./_assert_this_initialized.js"),a=t("./_type_of.js");function o(t,e){return e&&("object"===(0,a._)(e)||"function"==typeof e)?e:(0,s._)(t)}},{"./_assert_this_initialized.js":"jgeid","./_type_of.js":"felZi","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],uVQht:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return l});var s=t("./_array_with_holes.js"),a=t("./_iterable_to_array_limit.js"),o=t("./_non_iterable_rest.js"),u=t("./_unsupported_iterable_to_array.js");function l(t,e){return(0,s._)(t)||(0,a._)(t,e)||(0,u._)(t,e)||(0,o._)()}},{"./_array_with_holes.js":"hF14e","./_iterable_to_array_limit.js":"loYCM","./_non_iterable_rest.js":"2Mjp1","./_unsupported_iterable_to_array.js":"5m31D","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],hF14e:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t){if(Array.isArray(t))return t}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],loYCM:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t,e){var r,n,s=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=s){var a=[],o=!0,u=!1;try{for(s=s.call(t);!(o=(r=s.next()).done)&&(a.push(r.value),!e||a.length!==e);o=!0);}catch(t){u=!0,n=t}finally{try{o||null==s.return||s.return()}finally{if(u)throw n}}return a}}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"2Mjp1":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"5m31D":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return a});var s=t("./_array_like_to_array.js");function a(t,e){if(t){if("string"==typeof t)return(0,s._)(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return(0,s._)(t,e)}}},{"./_array_like_to_array.js":"djwRR","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],djwRR:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],iwLF0:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return l});var s=t("./_array_without_holes.js"),a=t("./_iterable_to_array.js"),o=t("./_non_iterable_spread.js"),u=t("./_unsupported_iterable_to_array.js");function l(t){return(0,s._)(t)||(0,a._)(t)||(0,u._)(t)||(0,o._)()}},{"./_array_without_holes.js":"cuL6A","./_iterable_to_array.js":"2thrs","./_non_iterable_spread.js":"a8nO2","./_unsupported_iterable_to_array.js":"5m31D","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],cuL6A:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return a});var s=t("./_array_like_to_array.js");function a(t){if(Array.isArray(t))return(0,s._)(t)}},{"./_array_like_to_array.js":"djwRR","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"2thrs":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],a8nO2:[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"86fte":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return u});var s=t("./_get_prototype_of.js"),a=t("./_is_native_reflect_construct.js"),o=t("./_possible_constructor_return.js");function u(t){var e=(0,a._)();return function(){var r,n=(0,s._)(t);return r=e?Reflect.construct(n,arguments,(0,s._)(this).constructor):n.apply(this,arguments),(0,o._)(this,r)}}},{"./_get_prototype_of.js":"dAKgy","./_is_native_reflect_construct.js":"7fioR","./_possible_constructor_return.js":"iVdhB","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"7fioR":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function s(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}n.defineInteropFlag(r),n.export(r,"_",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"1Y0br":[function(t,e,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"_",function(){return s.__values});var s=t("tslib")},{tslib:"c0d7h","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],gp9kd:[function(t,e,r){/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <https://feross.org>* @license MIT */var n=t("@swc/helpers/_/_type_of"),s=t("9c62938f1dccc73c"),a=t("aceacb6a4531a9d2"),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function u(t){if(t>2147483647)throw RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,l.prototype),e}function l(t,e,r){if("number"==typeof t){if("string"==typeof e)throw TypeError('The "string" argument must be of type string. Received type number');return f(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if(("string"!=typeof e||""===e)&&(e="utf8"),!l.isEncoding(e))throw TypeError("Unknown encoding: "+e);var r=0|_(t,e),n=u(r),s=n.write(t,e);return s!==r&&(n=n.slice(0,s)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(B(t,Uint8Array)){var e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return d(t)}(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+(void 0===t?"undefined":(0,n._)(t)));if(B(t,ArrayBuffer)||t&&B(t.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(B(t,SharedArrayBuffer)||t&&B(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw TypeError('The "value" argument must not be of type number. Received type number');var s=t.valueOf&&t.valueOf();if(null!=s&&s!==t)return l.from(s,e,r);var a=function(t){if(l.isBuffer(t)){var e,r=0|m(t.length),n=u(r);return 0===n.length||t.copy(n,0,0,r),n}return void 0!==t.length?"number"!=typeof t.length||(e=t.length)!=e?u(0):d(t):"Buffer"===t.type&&Array.isArray(t.data)?d(t.data):void 0}(t);if(a)return a;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return l.from(t[Symbol.toPrimitive]("string"),e,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+(void 0===t?"undefined":(0,n._)(t)))}function h(t){if("number"!=typeof t)throw TypeError('"size" argument must be of type number');if(t<0)throw RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return h(t),u(t<0?0:0|m(t))}function d(t){for(var e=t.length<0?0:0|m(t.length),r=u(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){var n;if(e<0||t.byteLength<e)throw RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),l.prototype),n}function m(t){if(t>=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|t}function _(t,e){if(l.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||B(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+(void 0===t?"undefined":(0,n._)(t)));var r=t.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===r)return 0;for(var a=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return I(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return k(t).length;default:if(a)return s?-1:I(t).length;e=(""+e).toLowerCase(),a=!0}}function y(t,e,r){var n,a,o=!1;if((void 0===e||e<0)&&(e=0),e>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(e>>>=0)))return"";for(t||(t="utf8");;)switch(t){case"hex":return function(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var s="",a=e;a<r;++a)s+=P[t[a]];return s}(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return function(t,e,r){var n="";r=Math.min(t.length,r);for(var s=e;s<r;++s)n+=String.fromCharCode(127&t[s]);return n}(this,e,r);case"latin1":case"binary":return function(t,e,r){var n="";r=Math.min(t.length,r);for(var s=e;s<r;++s)n+=String.fromCharCode(t[s]);return n}(this,e,r);case"base64":return n=e,a=r,0===n&&a===this.length?s.fromByteArray(this):s.fromByteArray(this.slice(n,a));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(t,e,r){for(var n=t.slice(e,r),s="",a=0;a<n.length-1;a+=2)s+=String.fromCharCode(n[a]+256*n[a+1]);return s}(this,e,r);default:if(o)throw TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),o=!0}}function g(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,s){var a;if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),(a=r=+r)!=a&&(r=s?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(s)return -1;r=t.length-1}else if(r<0){if(!s)return -1;r=0}if("string"==typeof e&&(e=l.from(e,n)),l.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,s);if("number"==typeof e)return(e&=255,"function"==typeof Uint8Array.prototype.indexOf)?s?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,s);throw TypeError("val must be string, number or Buffer")}function b(t,e,r,n,s){var a,o=1,u=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;o=2,u/=2,l/=2,r/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(s){var h=-1;for(a=r;a<u;a++)if(c(t,a)===c(e,-1===h?0:a-h)){if(-1===h&&(h=a),a-h+1===l)return h*o}else -1!==h&&(a-=a-h),h=-1}else for(r+l>u&&(r=u-l),a=r;a>=0;a--){for(var f=!0,d=0;d<l;d++)if(c(t,a+d)!==c(e,d)){f=!1;break}if(f)return a}return -1}function w(t,e,r){r=Math.min(t.length,r);for(var n=[],s=e;s<r;){var a,o,u,l,c=t[s],h=null,f=c>239?4:c>223?3:c>191?2:1;if(s+f<=r)switch(f){case 1:c<128&&(h=c);break;case 2:(192&(a=t[s+1]))==128&&(l=(31&c)<<6|63&a)>127&&(h=l);break;case 3:a=t[s+1],o=t[s+2],(192&a)==128&&(192&o)==128&&(l=(15&c)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:a=t[s+1],o=t[s+2],u=t[s+3],(192&a)==128&&(192&o)==128&&(192&u)==128&&(l=(15&c)<<18|(63&a)<<12|(63&o)<<6|63&u)>65535&&l<1114112&&(h=l)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),s+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}function S(t,e,r){if(t%1!=0||t<0)throw RangeError("offset is not uint");if(t+e>r)throw RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,s,a){if(!l.isBuffer(t))throw TypeError('"buffer" argument must be a Buffer instance');if(e>s||e<a)throw RangeError('"value" argument is out of bounds');if(r+n>t.length)throw RangeError("Index out of range")}function E(t,e,r,n,s,a){if(r+n>t.length||r<0)throw RangeError("Index out of range")}function U(t,e,r,n,s){return e=+e,r>>>=0,s||E(t,e,r,4,34028234663852886e22,-34028234663852886e22),a.write(t,e,r,n,23,4),r+4}function T(t,e,r,n,s){return e=+e,r>>>=0,s||E(t,e,r,8,17976931348623157e292,-17976931348623157e292),a.write(t,e,r,n,52,8),r+8}r.Buffer=l,r.SlowBuffer=function(t){return+t!=t&&(t=0),l.alloc(+t)},r.INSPECT_MAX_BYTES=50,r.kMaxLength=2147483647,l.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),l.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(t,e,r){return(h(t),t<=0)?u(t):void 0!==e?"string"==typeof r?u(t).fill(e,r):u(t).fill(e):u(t)},l.allocUnsafe=function(t){return f(t)},l.allocUnsafeSlow=function(t){return f(t)},l.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==l.prototype},l.compare=function(t,e){if(B(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),B(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(t)||!l.isBuffer(e))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,s=0,a=Math.min(r,n);s<a;++s)if(t[s]!==e[s]){r=t[s],n=e[s];break}return r<n?-1:n<r?1:0},l.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(t,e){if(!Array.isArray(t))throw TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return l.alloc(0);if(void 0===e)for(r=0,e=0;r<t.length;++r)e+=t[r].length;var r,n=l.allocUnsafe(e),s=0;for(r=0;r<t.length;++r){var a=t[r];if(B(a,Uint8Array))s+a.length>n.length?l.from(a).copy(n,s):Uint8Array.prototype.set.call(n,a,s);else if(l.isBuffer(a))a.copy(n,s);else throw TypeError('"list" argument must be an Array of Buffers');s+=a.length}return n},l.byteLength=_,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)g(this,e,e+1);return this},l.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},l.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},l.prototype.toString=function(){var t=this.length;return 0===t?"":0==arguments.length?w(this,0,t):y.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(t){if(!l.isBuffer(t))throw TypeError("Argument must be a Buffer");return this===t||0===l.compare(this,t)},l.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},o&&(l.prototype[o]=l.prototype.inspect),l.prototype.compare=function(t,e,r,s,a){if(B(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+(void 0===t?"undefined":(0,n._)(t)));if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===s&&(s=0),void 0===a&&(a=this.length),e<0||r>t.length||s<0||a>this.length)throw RangeError("out of range index");if(s>=a&&e>=r)return 0;if(s>=a)return -1;if(e>=r)return 1;if(e>>>=0,r>>>=0,s>>>=0,a>>>=0,this===t)return 0;for(var o=a-s,u=r-e,c=Math.min(o,u),h=this.slice(s,a),f=t.slice(e,r),d=0;d<c;++d)if(h[d]!==f[d]){o=h[d],u=f[d];break}return o<u?-1:u<o?1:0},l.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},l.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},l.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},l.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s,a,o,u,l,c,h,f,d=this.length-e;if((void 0===r||r>d)&&(r=d),t.length>0&&(r<0||e<0)||e>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var p=!1;;)switch(n){case"hex":return function(t,e,r,n){r=Number(r)||0;var s=t.length-r;n?(n=Number(n))>s&&(n=s):n=s;var a=e.length;n>a/2&&(n=a/2);for(var o=0;o<n;++o){var u=parseInt(e.substr(2*o,2),16);if(u!=u)break;t[r+o]=u}return o}(this,t,e,r);case"utf8":case"utf-8":return s=e,a=r,C(I(t,this.length-s),this,s,a);case"ascii":case"latin1":case"binary":return o=e,u=r,C(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(t),this,o,u);case"base64":return l=e,c=r,C(k(t),this,l,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h=e,f=r,C(function(t,e){for(var r,n,s=[],a=0;a<t.length&&!((e-=2)<0);++a)n=(r=t.charCodeAt(a))>>8,s.push(r%256),s.push(n);return s}(t,this.length-h),this,h,f);default:if(p)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),p=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},l.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,l.prototype),n},l.prototype.readUintLE=l.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],s=1,a=0;++a<e&&(s*=256);)n+=this[t+a]*s;return n},l.prototype.readUintBE=l.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t+--e],s=1;e>0&&(s*=256);)n+=this[t+--e]*s;return n},l.prototype.readUint8=l.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=this[t],s=1,a=0;++a<e&&(s*=256);)n+=this[t+a]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*e)),n},l.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);for(var n=e,s=1,a=this[t+--n];n>0&&(s*=256);)a+=this[t+--n]*s;return a>=(s*=128)&&(a-=Math.pow(2,8*e)),a},l.prototype.readInt8=function(t,e){return(t>>>=0,e||S(t,1,this.length),128&this[t])?-((255-this[t]+1)*1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),a.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),a.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),a.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),a.read(this,t,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){var s=Math.pow(2,8*r)-1;x(this,t,e,r,s,0)}var a=1,o=0;for(this[e]=255&t;++o<r&&(a*=256);)this[e+o]=t/a&255;return e+r},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){var s=Math.pow(2,8*r)-1;x(this,t,e,r,s,0)}var a=r-1,o=1;for(this[e+a]=255&t;--a>=0&&(o*=256);)this[e+a]=t/o&255;return e+r},l.prototype.writeUint8=l.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var s=Math.pow(2,8*r-1);x(this,t,e,r,s-1,-s)}var a=0,o=1,u=0;for(this[e]=255&t;++a<r&&(o*=256);)t<0&&0===u&&0!==this[e+a-1]&&(u=1),this[e+a]=(t/o>>0)-u&255;return e+r},l.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var s=Math.pow(2,8*r-1);x(this,t,e,r,s-1,-s)}var a=r-1,o=1,u=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===u&&0!==this[e+a+1]&&(u=1),this[e+a]=(t/o>>0)-u&255;return e+r},l.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeFloatLE=function(t,e,r){return U(this,t,e,!0,r)},l.prototype.writeFloatBE=function(t,e,r){return U(this,t,e,!1,r)},l.prototype.writeDoubleLE=function(t,e,r){return T(this,t,e,!0,r)},l.prototype.writeDoubleBE=function(t,e,r){return T(this,t,e,!1,r)},l.prototype.copy=function(t,e,r,n){if(!l.isBuffer(t))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r||0===t.length||0===this.length)return 0;if(e<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var s=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),s},l.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!l.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===t.length){var s,a=t.charCodeAt(0);("utf8"===n&&a<128||"latin1"===n)&&(t=a)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw RangeError("Out of range index");if(r<=e)return this;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var o=l.isBuffer(t)?t:l.from(t,n),u=o.length;if(0===u)throw TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<r-e;++s)this[s+e]=o[s%u]}return this};var A=/[^+/0-9A-Za-z-_]/g;function I(t,e){e=e||1/0;for(var r,n=t.length,s=null,a=[],o=0;o<n;++o){if((r=t.charCodeAt(o))>55295&&r<57344){if(!s){if(r>56319||o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}s=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&(e-=3)>-1&&a.push(239,191,189);if(s=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return a}function k(t){return s.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(A,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function C(t,e,r,n){for(var s=0;s<n&&!(s+r>=e.length)&&!(s>=t.length);++s)e[s+r]=t[s];return s}function B(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}var P=function(){for(var t="0123456789abcdef",e=Array(256),r=0;r<16;++r)for(var n=16*r,s=0;s<16;++s)e[n+s]=t[r]+t[s];return e}()},{"@swc/helpers/_/_type_of":"felZi","9c62938f1dccc73c":"8CZvr",aceacb6a4531a9d2:"kxjGq"}],"8CZvr":[function(t,e,r){r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return(r+n)*3/4-n},r.toByteArray=function(t){var e,r,n=c(t),o=n[0],u=n[1],l=new a((o+u)*3/4-u),h=0,f=u>0?o-4:o;for(r=0;r<f;r+=4)e=s[t.charCodeAt(r)]<<18|s[t.charCodeAt(r+1)]<<12|s[t.charCodeAt(r+2)]<<6|s[t.charCodeAt(r+3)],l[h++]=e>>16&255,l[h++]=e>>8&255,l[h++]=255&e;return 2===u&&(e=s[t.charCodeAt(r)]<<2|s[t.charCodeAt(r+1)]>>4,l[h++]=255&e),1===u&&(e=s[t.charCodeAt(r)]<<10|s[t.charCodeAt(r+1)]<<4|s[t.charCodeAt(r+2)]>>2,l[h++]=e>>8&255,l[h++]=255&e),l},r.fromByteArray=function(t){for(var e,r=t.length,s=r%3,a=[],o=0,u=r-s;o<u;o+=16383)a.push(function(t,e,r){for(var s,a=[],o=e;o<r;o+=3)a.push(n[(s=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]))>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return a.join("")}(t,o,o+16383>u?u:o+16383));return 1===s?a.push(n[(e=t[r-1])>>2]+n[e<<4&63]+"=="):2===s&&a.push(n[(e=(t[r-2]<<8)+t[r-1])>>10]+n[e>>4&63]+n[e<<2&63]+"="),a.join("")};for(var n=[],s=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,l=o.length;u<l;++u)n[u]=o[u],s[o.charCodeAt(u)]=u;function c(t){var e=t.length;if(e%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");-1===r&&(r=e);var n=r===e?0:4-r%4;return[r,n]}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},{}],kxjGq:[function(t,e,r){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh<https://feross.org/opensource>*/r.read=function(t,e,r,n,s){var a,o,u=8*s-n-1,l=(1<<u)-1,c=l>>1,h=-7,f=r?s-1:0,d=r?-1:1,p=t[e+f];for(f+=d,a=p&(1<<-h)-1,p>>=-h,h+=u;h>0;a=256*a+t[e+f],f+=d,h-=8);for(o=a&(1<<-h)-1,a>>=-h,h+=n;h>0;o=256*o+t[e+f],f+=d,h-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,s,a){var o,u,l,c=8*a-s-1,h=(1<<c)-1,f=h>>1,d=23===s?5960464477539062e-23:0,p=n?0:a-1,m=n?1:-1,_=e<0||0===e&&1/e<0?1:0;for(isNaN(e=Math.abs(e))||e===1/0?(u=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+f>=1?e+=d/l:e+=d*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=h?(u=0,o=h):o+f>=1?(u=(e*l-1)*Math.pow(2,s),o+=f):(u=e*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;t[r+p]=255&u,p+=m,u/=256,s-=8);for(o=o<<s|u,c+=s;c>0;t[r+p]=255&o,p+=m,o/=256,c-=8);t[r+p-m]|=128*_}},{}]},["c4SNP"],"c4SNP","parcelRequire4dc0"); |