UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

2 lines • 710 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import i from"../../core/Error.js";import s from"../../core/Logger.js";import{clamp as n}from"../../core/mathUtils.js";import{watch as r,initial as a,on as o}from"../../core/reactiveUtils.js";import{XHRAdapter as l}from"../../core/XHRAdapter.js";import{property as h,subclass as u}from"../../core/accessorSupport/decorators.js";import d from"./VideoCameraSensorModel.js";import{getVideoMetadataFromCueList as c,videoMetadataEntryId as p,getVideoMimeType as m}from"./videoUtils.js";import{c as g,g as f}from"../../chunks/_commonjsHelpers.js";var y,_;function v(){return _?y:(_=1,e="undefined"!=typeof window?window:void 0!==g?g:"undefined"!=typeof self?self:{},y=e);var e}const b=f(v());var T,S,E,w,C,k,I,x,A,D,P,L,O,N,R,M,U,B,F,q,j,$,H,V,z,W;function G(){if(S)return T;S=1;var e=Array.prototype.slice;function t(t,i){"length"in t||(t=[t]),t=e.call(t);for(;t.length;){var s=t.shift(),n=i(s);if(n)return n;s.childNodes&&s.childNodes.length&&(t=e.call(s.childNodes).concat(t))}}return T=t}function X(){if(w)return E;function e(t,i){if(!(this instanceof e))return new e(t,i);this.data=t,this.nodeValue=t,this.length=t.length,this.ownerDocument=i||null}return w=1,E=e,e.prototype.nodeType=8,e.prototype.nodeName="#comment",e.prototype.toString=function(){return"[object Comment]"},E}function K(){if(k)return C;function e(t,i){if(!(this instanceof e))return new e(t);this.data=t||"",this.length=this.data.length,this.ownerDocument=i||null}return k=1,C=e,e.prototype.type="DOMTextNode",e.prototype.nodeType=3,e.prototype.nodeName="#text",e.prototype.toString=function(){return this.data},e.prototype.replaceData=function(e,t,i){var s=this.data,n=s.substring(0,e),r=s.substring(e+t,s.length);this.data=n+i+r,this.length=this.data.length},C}function Y(){if(x)return I;function e(e){var t=this,i=e.type;e.target||(e.target=t),t.listeners||(t.listeners={});var s=t.listeners[i];if(s)return s.forEach(function(i){e.currentTarget=t,"function"==typeof i?i(e):i.handleEvent(e)});t.parentNode&&t.parentNode.dispatchEvent(e)}return x=1,I=e}function Q(){if(D)return A;function e(e,t){var i=this;i.listeners||(i.listeners={}),i.listeners[e]||(i.listeners[e]=[]),-1===i.listeners[e].indexOf(t)&&i.listeners[e].push(t)}return D=1,A=e}function J(){if(L)return P;function e(e,t){var i=this;if(i.listeners&&i.listeners[e]){var s=i.listeners[e],n=s.indexOf(t);-1!==n&&s.splice(n,1)}}return L=1,P=e}function Z(){if(N)return O;N=1;var e=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function t(e){switch(e.nodeType){case 3:return l(e.data);case 8:return"\x3c!--"+e.data+"--\x3e";default:return i(e)}}function i(i){var s=[],n=i.tagName;return"http://www.w3.org/1999/xhtml"===i.namespaceURI&&(n=n.toLowerCase()),s.push("<"+n+o(i)+r(i)),e.indexOf(n)>-1?s.push(" />"):(s.push(">"),i.childNodes.length?s.push.apply(s,i.childNodes.map(t)):i.textContent||i.innerText?s.push(l(i.textContent||i.innerText)):i.innerHTML&&s.push(i.innerHTML),s.push("</"+n+">")),s.join("")}function s(e,t){var i=typeof e[t];return"style"===t&&Object.keys(e.style).length>0||e.hasOwnProperty(t)&&("string"===i||"boolean"===i||"number"===i)&&"nodeName"!==t&&"className"!==t&&"tagName"!==t&&"textContent"!==t&&"innerText"!==t&&"namespaceURI"!==t&&"innerHTML"!==t}function n(e){if("string"==typeof e)return e;var t="";return Object.keys(e).forEach(function(i){var s=e[i];i=i.replace(/[A-Z]/g,function(e){return"-"+e.toLowerCase()}),t+=i+":"+s+";"}),t}function r(e){var t=e.dataset,i=[];for(var s in t)i.push({name:"data-"+s,value:t[s]});return i.length?a(i):""}function a(e){var t=[];return e.forEach(function(e){var i=e.name,s=e.value;"style"===i&&(s=n(s)),t.push(i+'="'+h(s)+'"')}),t.length?" "+t.join(" "):""}function o(e){var t=[];for(var i in e)s(e,i)&&t.push({name:i,value:e[i]});for(var n in e._attributes)for(var r in e._attributes[n]){var o=e._attributes[n][r],l=(o.prefix?o.prefix+":":"")+r;t.push({name:l,value:o.value})}return e.className&&t.push({name:"class",value:e.className}),t.length?a(t):""}function l(e){var t="";return"string"==typeof e?t=e:e&&(t=e.toString()),t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function h(e){return l(e).replace(/"/g,"&quot;")}return O=t}function ee(){if(M)return R;M=1;var e=G(),t=Y(),i=Q(),s=J(),n=Z(),r="http://www.w3.org/1999/xhtml";function a(e,t,i){if(!(this instanceof a))return new a(e);var s=void 0===i?r:i||null;this.tagName=s===r?String(e).toUpperCase():e,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=t||null,this.namespaceURI=s,this._attributes={},"INPUT"===this.tagName&&(this.type="text")}return R=a,a.prototype.type="DOMElement",a.prototype.nodeType=1,a.prototype.appendChild=function(e){return e.parentNode&&e.parentNode.removeChild(e),this.childNodes.push(e),e.parentNode=this,e},a.prototype.replaceChild=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=this.childNodes.indexOf(t);return t.parentNode=null,this.childNodes[i]=e,e.parentNode=this,t},a.prototype.removeChild=function(e){var t=this.childNodes.indexOf(e);return this.childNodes.splice(t,1),e.parentNode=null,e},a.prototype.insertBefore=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=null==t?-1:this.childNodes.indexOf(t);return i>-1?this.childNodes.splice(i,0,e):this.childNodes.push(e),e.parentNode=this,e},a.prototype.setAttributeNS=function(e,t,i){var s=null,n=t,r=t.indexOf(":");(r>-1&&(s=t.substr(0,r),n=t.substr(r+1)),"INPUT"===this.tagName&&"type"===t)?this.type=i:(this._attributes[e]||(this._attributes[e]={}))[n]={value:i,prefix:s}},a.prototype.getAttributeNS=function(e,t){var i=this._attributes[e],s=i&&i[t]&&i[t].value;return"INPUT"===this.tagName&&"type"===t?this.type:"string"!=typeof s?null:s},a.prototype.removeAttributeNS=function(e,t){var i=this._attributes[e];i&&Object.prototype.hasOwnProperty.call(i,t)&&delete i[t]},a.prototype.hasAttributeNS=function(e,t){var i=this._attributes[e];return!!i&&t in i},a.prototype.setAttribute=function(e,t){return this.setAttributeNS(null,e,t)},a.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)},a.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)},a.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)},a.prototype.removeEventListener=s,a.prototype.addEventListener=i,a.prototype.dispatchEvent=t,a.prototype.focus=function(){},a.prototype.toString=function(){return n(this)},a.prototype.getElementsByClassName=function(t){var i=t.split(" "),s=[];return e(this,function(e){if(1===e.nodeType){var t=(e.className||"").split(" ");i.every(function(e){return-1!==t.indexOf(e)})&&s.push(e)}}),s},a.prototype.getElementsByTagName=function(t){t=t.toLowerCase();var i=[];return e(this.childNodes,function(e){1!==e.nodeType||"*"!==t&&e.tagName.toLowerCase()!==t||i.push(e)}),i},a.prototype.contains=function(t){return e(this,function(e){return t===e})||!1},R}function te(){if(B)return U;B=1;var e=ee();function t(e){if(!(this instanceof t))return new t;this.childNodes=[],this.parentNode=null,this.ownerDocument=e||null}return U=t,t.prototype.type="DocumentFragment",t.prototype.nodeType=11,t.prototype.nodeName="#document-fragment",t.prototype.appendChild=e.prototype.appendChild,t.prototype.replaceChild=e.prototype.replaceChild,t.prototype.removeChild=e.prototype.removeChild,t.prototype.toString=function(){return this.childNodes.map(function(e){return String(e)}).join("")},U}function ie(){if(q)return F;function e(e){}return q=1,F=e,e.prototype.initEvent=function(e,t,i){this.type=e,this.bubbles=t,this.cancelable=i},e.prototype.preventDefault=function(){},F}function se(){if($)return j;$=1;var e=G(),t=X(),i=K(),s=ee(),n=te(),r=ie(),a=Y(),o=Q(),l=J();function h(){if(!(this instanceof h))return new h;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}j=h;var u=h.prototype;return u.createTextNode=function(e){return new i(e,this)},u.createElementNS=function(e,t){var i=null===e?null:String(e);return new s(t,this,i)},u.createElement=function(e){return new s(e,this)},u.createDocumentFragment=function(){return new n(this)},u.createEvent=function(e){return new r(e)},u.createComment=function(e){return new t(e,this)},u.getElementById=function(t){return t=String(t),e(this.childNodes,function(e){if(String(e.id)===t)return e})||null},u.getElementsByClassName=s.prototype.getElementsByClassName,u.getElementsByTagName=s.prototype.getElementsByTagName,u.contains=s.prototype.contains,u.removeEventListener=l,u.addEventListener=o,u.dispatchEvent=a,j}function ne(){if(V)return H;V=1;var e=se();return H=new e}function re(){if(W)return z;W=1;var e,t=void 0!==g?g:"undefined"!=typeof window?window:{},i=ne();return"undefined"!=typeof document?e=document:(e=t["__GLOBAL_DOCUMENT_CACHE@4"])||(e=t["__GLOBAL_DOCUMENT_CACHE@4"]=i),z=e}const ae=f(re());var oe,le,he,ue,de,ce,pe,me,ge,fe,ye={exports:{}},_e={exports:{}};function ve(){return oe||(oe=1,function(e){function t(){return e.exports=t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,t.apply(null,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(_e)),_e.exports}function be(){if(he)return le;he=1,le=t;var e=Object.prototype.toString;function t(t){if(!t)return!1;var i=e.call(t);return"[object Function]"===i||"function"==typeof t&&"[object RegExp]"!==i||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}return le}function Te(){if(de)return ue;function e(e,i){var s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return(s=s.call(e)).next.bind(s);if(Array.isArray(e)||(s=t(e))||i){s&&(e=s);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function t(e,t){if(e){if("string"==typeof e)return i(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);return"Object"===s&&e.constructor&&(s=e.constructor.name),"Map"===s||"Set"===s?Array.from(e):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=new Array(t);i<t;i++)s[i]=e[i];return s}return de=1,ue=function(){function t(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var i=t.prototype;return i.getIsEnabled=function(){return this.enabled_},i.enable=function(){this.enabled_=!0},i.disable=function(){this.enabled_=!1},i.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},i.addInterceptor=function(e,t){this.typeToInterceptorsMap_.has(e)||this.typeToInterceptorsMap_.set(e,new Set);var i=this.typeToInterceptorsMap_.get(e);return!i.has(t)&&(i.add(t),!0)},i.removeInterceptor=function(e,t){var i=this.typeToInterceptorsMap_.get(e);return!(!i||!i.has(t))&&(i.delete(t),!0)},i.clearInterceptorsByType=function(e){return!!this.typeToInterceptorsMap_.get(e)&&(this.typeToInterceptorsMap_.delete(e),this.typeToInterceptorsMap_.set(e,new Set),!0)},i.clear=function(){return!!this.typeToInterceptorsMap_.size&&(this.typeToInterceptorsMap_=new Map,!0)},i.getForType=function(e){return this.typeToInterceptorsMap_.get(e)||new Set},i.execute=function(t,i){for(var s,n=e(this.getForType(t));!(s=n()).done;){var r=s.value;try{i=r(i)}catch(a){}}return i},t}()}function Se(){if(pe)return ce;pe=1;var e=function(){function e(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1}var i=e.prototype;return i.getIsEnabled=function(){return this.enabled_},i.enable=function(){this.enabled_=!0},i.disable=function(){this.enabled_=!1},i.reset=function(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1},i.getMaxAttempts=function(){return this.maxAttempts_},i.setMaxAttempts=function(e){this.maxAttempts_=e},i.getDelayFactor=function(){return this.delayFactor_},i.setDelayFactor=function(e){this.delayFactor_=e},i.getFuzzFactor=function(){return this.fuzzFactor_},i.setFuzzFactor=function(e){this.fuzzFactor_=e},i.getInitialDelay=function(){return this.initialDelay_},i.setInitialDelay=function(e){this.initialDelay_=e},i.createRetry=function(e){var i=void 0===e?{}:e,s=i.maxAttempts,n=i.delayFactor,r=i.fuzzFactor,a=i.initialDelay;return new t({maxAttempts:s||this.maxAttempts_,delayFactor:n||this.delayFactor_,fuzzFactor:r||this.fuzzFactor_,initialDelay:a||this.initialDelay_})},e}(),t=function(){function e(e){this.maxAttempts_=e.maxAttempts,this.delayFactor_=e.delayFactor,this.fuzzFactor_=e.fuzzFactor,this.currentDelay_=e.initialDelay,this.currentAttempt_=1}var t=e.prototype;return t.moveToNextAttempt=function(){this.currentAttempt_++;var e=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+e},t.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},t.getCurrentDelay=function(){return this.currentDelay_},t.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},t.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},t.getCurrentFuzzedDelay=function(){var e=this.getCurrentMinPossibleDelay(),t=this.getCurrentMaxPossibleDelay();return e+Math.random()*(t-e)},e}();return ce=e}function Ee(){if(ge)return me;ge=1;var e=v();function t(e){return void 0===e&&(e=""),e.toLowerCase().split(";").reduce(function(e,t){var i=t.split("="),s=i[0],n=i[1];return"charset"===s.trim()?n.trim():e},"utf-8")}return me=function(i,s){return void 0===s&&(s=!1),function(n,r,a){if(n)i(n);else if(r.statusCode>=400&&r.statusCode<=599){var o=a;if(s)if(e.TextDecoder){var l=t(r.headers&&r.headers["content-type"]);try{o=new TextDecoder(l).decode(a)}catch(h){}}else o=String.fromCharCode.apply(null,new Uint8Array(a));i({cause:o})}else i(null,a)}}}function we(){if(fe)return ye.exports;fe=1;var e=v(),t=ve(),i=be(),s=Te(),n=Se();h.httpHandler=Ee(),h.requestInterceptorsStorage=new s,h.responseInterceptorsStorage=new s,h.retryManager=new n;var r=function(e){var t={};return e?(e.trim().split("\n").forEach(function(e){var i=e.indexOf(":"),s=e.slice(0,i).trim().toLowerCase(),n=e.slice(i+1).trim();void 0===t[s]?t[s]=n:Array.isArray(t[s])?t[s].push(n):t[s]=[t[s],n]}),t):t};function a(e,t){for(var i=0;i<e.length;i++)t(e[i])}function o(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function l(e,s,n){var r=e;return i(s)?(n=s,"string"==typeof e&&(r={uri:e})):r=t({},s,{uri:e}),r.callback=n,r}function h(e,t,i){return u(t=l(e,t,i))}function u(e){if(void 0===e.callback)throw new Error("callback argument missing");if(e.requestType&&h.requestInterceptorsStorage.getIsEnabled()){var t={uri:e.uri||e.url,headers:e.headers||{},body:e.body,metadata:e.metadata||{},retry:e.retry,timeout:e.timeout},i=h.requestInterceptorsStorage.execute(e.requestType,t);e.uri=i.uri,e.headers=i.headers,e.body=i.body,e.metadata=i.metadata,e.retry=i.retry,e.timeout=i.timeout}var s=!1,n=function(t,i,n){s||(s=!0,e.callback(t,i,n))};function a(){4!==f.readyState||h.responseInterceptorsStorage.getIsEnabled()||setTimeout(p,0)}function l(){var e=void 0;if(e=f.response?f.response:f.responseText||d(f),E)try{e=JSON.parse(e)}catch(t){}return e}function c(t){if(clearTimeout(y),clearTimeout(e.retryTimeout),t instanceof Error||(t=new Error(""+(t||"Unknown XMLHttpRequest Error"))),t.statusCode=0,g||!h.retryManager.getIsEnabled()||!e.retry||!e.retry.shouldRetry()){if(e.requestType&&h.responseInterceptorsStorage.getIsEnabled()){var i={headers:w.headers||{},body:w.body,responseUrl:f.responseURL,responseType:f.responseType},s=h.responseInterceptorsStorage.execute(e.requestType,i);w.body=s.body,w.headers=s.headers}return n(t,w)}e.retryTimeout=setTimeout(function(){e.retry.moveToNextAttempt(),e.xhr=f,u(e)},e.retry.getCurrentFuzzedDelay())}function p(){if(!g){var t;clearTimeout(y),clearTimeout(e.retryTimeout),t=e.useXDR&&void 0===f.status?200:1223===f.status?204:f.status;var i=w,s=null;if(0!==t?(i={body:l(),statusCode:t,method:v,headers:{},url:_,rawRequest:f},f.getAllResponseHeaders&&(i.headers=r(f.getAllResponseHeaders()))):s=new Error("Internal XMLHttpRequest Error"),e.requestType&&h.responseInterceptorsStorage.getIsEnabled()){var a={headers:i.headers||{},body:i.body,responseUrl:f.responseURL,responseType:f.responseType},o=h.responseInterceptorsStorage.execute(e.requestType,a);i.body=o.body,i.headers=o.headers}return n(s,i,i.body)}}var m,g,f=e.xhr||null;f||(f=e.cors||e.useXDR?new h.XDomainRequest:new h.XMLHttpRequest);var y,_=f.url=e.uri||e.url,v=f.method=e.method||"GET",b=e.body||e.data,T=f.headers=e.headers||{},S=!!e.sync,E=!1,w={body:void 0,headers:{},statusCode:0,method:v,url:_,rawRequest:f};if("json"in e&&!1!==e.json&&(E=!0,T.accept||T.Accept||(T.Accept="application/json"),"GET"!==v&&"HEAD"!==v&&(T["content-type"]||T["Content-Type"]||(T["Content-Type"]="application/json"),b=JSON.stringify(!0===e.json?b:e.json))),f.onreadystatechange=a,f.onload=p,f.onerror=c,f.onprogress=function(){},f.onabort=function(){g=!0,clearTimeout(e.retryTimeout)},f.ontimeout=c,f.open(v,_,!S,e.username,e.password),S||(f.withCredentials=!!e.withCredentials),!S&&e.timeout>0&&(y=setTimeout(function(){if(!g){g=!0,f.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",c(e)}},e.timeout)),f.setRequestHeader)for(m in T)T.hasOwnProperty(m)&&f.setRequestHeader(m,T[m]);else if(e.headers&&!o(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(f.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(f),f.send(b||null),f}function d(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(i){}return null}function c(){}return ye.exports=h,ye.exports.default=h,h.XMLHttpRequest=e.XMLHttpRequest||c,h.XDomainRequest="withCredentials"in new h.XMLHttpRequest?h.XMLHttpRequest:e.XDomainRequest,a(["get","put","post","patch","head","delete"],function(e){h["delete"===e?"del":e]=function(t,i,s){return(i=l(t,i,s)).method=e.toUpperCase(),u(i)}}),ye.exports}const Ce=f(we());var ke,Ie,xe,Ae,De,Pe,Le,Oe={exports:{}};function Ne(){if(Ie)return ke;Ie=1;var e=re(),t=Object.create||function(){function e(){}return function(t){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return e.prototype=t,new e}}();function i(e,t){this.name="ParsingError",this.code=e.code,this.message=t||e.message}function s(e){function t(e,t,i,s){return 3600*(0|e)+60*(0|t)+(0|i)+(0|s)/1e3}var i=e.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return i?i[3]?t(i[1],i[2],i[3].replace(":",""),i[4]):i[1]>59?t(i[1],i[2],0,i[4]):t(0,i[1],i[2],i[4]):null}function n(){this.values=t(null)}function r(e,t,i,s){var n=s?e.split(s):[e];for(var r in n)if("string"==typeof n[r]){var a=n[r].split(i);if(2===a.length)t(a[0].trim(),a[1].trim())}}function a(e,t,a){var o=e;function l(){var t=s(e);if(null===t)throw new i(i.Errors.BadTimeStamp,"Malformed timestamp: "+o);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function h(e,t){var i=new n;r(e,function(e,t){switch(e){case"region":for(var s=a.length-1;s>=0;s--)if(a[s].id===t){i.set(e,a[s].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":var n=t.split(","),r=n[0];i.integer(e,r),i.percent(e,r)&&i.set("snapToLines",!1),i.alt(e,r,["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start","center","end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start","center","end"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start","center","end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");try{t.line=i.get("line","auto")}catch(s){}t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100);try{t.align=i.get("align","center")}catch(s){t.align=i.get("align","middle")}try{t.position=i.get("position","auto")}catch(s){t.position=i.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},t.align)}t.positionAlign=i.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},t.align)}function u(){e=e.replace(/^\s+/,"")}if(u(),t.startTime=l(),u(),"--\x3e"!==e.substr(0,3))throw new i(i.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+o);e=e.substr(3),u(),t.endTime=l(),u(),h(e,t)}i.prototype=t(Error.prototype),i.prototype.constructor=i,i.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},n.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,i){for(var s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}},integer:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},percent:function(e,t){return!!(t.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(t=parseFloat(t))>=0&&t<=100)&&(this.set(e,t),!0)}};var o=e.createElement&&e.createElement("textarea"),l={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},h={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},u={v:"title",lang:"lang"},d={rt:"ruby"};function c(e,t){function i(){if(!t)return null;function e(e){return t=t.substr(e.length),e}var i=t.match(/^([^<]*)(<[^>]*>?)?/);return e(i[1]?i[1]:i[2])}function n(e){return o.innerHTML=e,e=o.textContent,o.textContent="",e}function r(e,t){return!d[t.localName]||d[t.localName]===e.localName}function a(t,i){var s=l[t];if(!s)return null;var n=e.document.createElement(s),r=u[t];return r&&i&&(n[r]=i.trim()),n}for(var c,p=e.document.createElement("div"),m=p,g=[];null!==(c=i());)if("<"!==c[0])m.appendChild(e.document.createTextNode(n(c)));else{if("/"===c[1]){g.length&&g[g.length-1]===c.substr(2).replace(">","")&&(g.pop(),m=m.parentNode);continue}var f,y=s(c.substr(1,c.length-2));if(y){f=e.document.createProcessingInstruction("timestamp",y),m.appendChild(f);continue}var _=c.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!_)continue;if(!(f=a(_[1],_[3])))continue;if(!r(m,f))continue;if(_[2]){var v=_[2].split(".");v.forEach(function(e){var t=/^bg_/.test(e),i=t?e.slice(3):e;if(h.hasOwnProperty(i)){var s=t?"background-color":"color",n=h[i];f.style[s]=n}}),f.className=v.join(" ")}g.push(_[1]),m.appendChild(f),m=f}return p}var p=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function m(e){for(var t=0;t<p.length;t++){var i=p[t];if(e>=i[0]&&e<=i[1])return!0}return!1}function g(e){var t=[],i="";if(!e||!e.childNodes)return"ltr";function s(e,t){for(var i=t.childNodes.length-1;i>=0;i--)e.push(t.childNodes[i])}function n(e){if(!e||!e.length)return null;var t=e.pop(),i=t.textContent||t.innerText;if(i){var r=i.match(/^.*(\n|\r)/);return r?(e.length=0,r[0]):i}return"ruby"===t.tagName?n(e):t.childNodes?(s(e,t),n(e)):void 0}for(s(t,e);i=n(t);)for(var r=0;r<i.length;r++)if(m(i.charCodeAt(r)))return"rtl";return"ltr"}function f(e){if("number"==typeof e.line&&(e.snapToLines||e.line>=0&&e.line<=100))return e.line;if(!e.track||!e.track.textTrackList||!e.track.textTrackList.mediaElement)return-1;for(var t=e.track,i=t.textTrackList,s=0,n=0;n<i.length&&i[n]!==t;n++)"showing"===i[n].mode&&s++;return-1*++s}function y(){}function _(e,t,i){y.call(this),this.cue=t,this.cueDiv=c(e,t.text);var s={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(s,this.cueDiv),this.div=e.document.createElement("div"),s={direction:g(this.cueDiv),writingMode:""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:"middle"===t.align?"center":t.align,font:i.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(s),this.div.appendChild(this.cueDiv);var n=0;switch(t.positionAlign){case"start":case"line-left":n=t.position;break;case"center":n=t.position-t.size/2;break;case"end":case"line-right":n=t.position-t.size}""===t.vertical?this.applyStyles({left:this.formatStyle(n,"%"),width:this.formatStyle(t.size,"%")}):this.applyStyles({top:this.formatStyle(n,"%"),height:this.formatStyle(t.size,"%")}),this.move=function(e){this.applyStyles({top:this.formatStyle(e.top,"px"),bottom:this.formatStyle(e.bottom,"px"),left:this.formatStyle(e.left,"px"),right:this.formatStyle(e.right,"px"),height:this.formatStyle(e.height,"px"),width:this.formatStyle(e.width,"px")})}}function v(e){var t,i,s,n;if(e.div){i=e.div.offsetHeight,s=e.div.offsetWidth,n=e.div.offsetTop;var r=(r=e.div.childNodes)&&(r=r[0])&&r.getClientRects&&r.getClientRects();e=e.div.getBoundingClientRect(),t=r?Math.max(r[0]&&r[0].height||0,e.height/r.length):0}this.left=e.left,this.right=e.right,this.top=e.top||n,this.height=e.height||i,this.bottom=e.bottom||n+(e.height||i),this.width=e.width||s,this.lineHeight=void 0!==t?t:e.lineHeight}function b(e,t,i,s){function n(e,t){for(var n,r=new v(e),a=1,o=0;o<t.length;o++){for(;e.overlapsOppositeAxis(i,t[o])||e.within(i)&&e.overlapsAny(s);)e.move(t[o]);if(e.within(i))return e;var l=e.intersectPercentage(i);a>l&&(n=new v(e),a=l),e=new v(r)}return n||r}var r=new v(t),a=t.cue,o=f(a),l=[];if(a.snapToLines){var h;switch(a.vertical){case"":l=["+y","-y"],h="height";break;case"rl":l=["+x","-x"],h="width";break;case"lr":l=["-x","+x"],h="width"}var u=r.lineHeight,d=u*Math.round(o),c=i[h]+u,p=l[0];Math.abs(d)>c&&(d=d<0?-1:1,d*=Math.ceil(c/u)*u),o<0&&(d+=""===a.vertical?i.height:i.width,l=l.reverse()),r.move(p,d)}else{var m=r.lineHeight/i.height*100;switch(a.lineAlign){case"center":o-=m/2;break;case"end":o-=m}switch(a.vertical){case"":t.applyStyles({top:t.formatStyle(o,"%")});break;case"rl":t.applyStyles({left:t.formatStyle(o,"%")});break;case"lr":t.applyStyles({right:t.formatStyle(o,"%")})}l=["+y","-x","+x","-y"],r=new v(t)}var g=n(r,l);t.move(g.toCSSCompatValues(i))}function T(){}y.prototype.applyStyles=function(e,t){for(var i in t=t||this.div,e)e.hasOwnProperty(i)&&(t.style[i]=e[i])},y.prototype.formatStyle=function(e,t){return 0===e?0:e+t},_.prototype=t(y.prototype),_.prototype.constructor=_,v.prototype.move=function(e,t){switch(t=void 0!==t?t:this.lineHeight,e){case"+x":this.left+=t,this.right+=t;break;case"-x":this.left-=t,this.right-=t;break;case"+y":this.top+=t,this.bottom+=t;break;case"-y":this.top-=t,this.bottom-=t}},v.prototype.overlaps=function(e){return this.left<e.right&&this.right>e.left&&this.top<e.bottom&&this.bottom>e.top},v.prototype.overlapsAny=function(e){for(var t=0;t<e.length;t++)if(this.overlaps(e[t]))return!0;return!1},v.prototype.within=function(e){return this.top>=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right},v.prototype.overlapsOppositeAxis=function(e,t){switch(t){case"+x":return this.left<e.left;case"-x":return this.right>e.right;case"+y":return this.top<e.top;case"-y":return this.bottom>e.bottom}},v.prototype.intersectPercentage=function(e){return Math.max(0,Math.min(this.right,e.right)-Math.max(this.left,e.left))*Math.max(0,Math.min(this.bottom,e.bottom)-Math.max(this.top,e.top))/(this.height*this.width)},v.prototype.toCSSCompatValues=function(e){return{top:this.top-e.top,bottom:e.bottom-this.bottom,left:this.left-e.left,right:e.right-this.right,height:this.height,width:this.width}},v.getSimpleBoxPosition=function(e){var t=e.div?e.div.offsetHeight:e.tagName?e.offsetHeight:0,i=e.div?e.div.offsetWidth:e.tagName?e.offsetWidth:0,s=e.div?e.div.offsetTop:e.tagName?e.offsetTop:0;return{left:(e=e.div?e.div.getBoundingClientRect():e.tagName?e.getBoundingClientRect():e).left,right:e.right,top:e.top||s,height:e.height||t,bottom:e.bottom||s+(e.height||t),width:e.width||i}},T.StringDecoder=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}},T.convertCueToDOMTree=function(e,t){return e&&t?c(e,t):null};var S=.05,E="sans-serif",w="1.5%";return T.processCues=function(e,t,i){if(!e||!t||!i)return null;for(;i.firstChild;)i.removeChild(i.firstChild);var s=e.document.createElement("div");function n(e){for(var t=0;t<e.length;t++)if(e[t].hasBeenReset||!e[t].displayState)return!0;return!1}if(s.style.position="absolute",s.style.left="0",s.style.right="0",s.style.top="0",s.style.bottom="0",s.style.margin=w,i.appendChild(s),n(t)){var r=[],a=v.getSimpleBoxPosition(s),o={font:Math.round(a.height*S*100)/100+"px "+E};!function(){for(var i,n,l=0;l<t.length;l++)n=t[l],i=new _(e,n,o),s.appendChild(i.div),b(e,i,a,r),n.displayState=i.div,r.push(v.getSimpleBoxPosition(i))}()}else for(var l=0;l<t.length;l++)s.appendChild(t[l].displayState)},T.Parser=function(e,t,i){i||(i=t,t={}),t||(t={}),this.window=e,this.vttjs=t,this.state="INITIAL",this.buffer="",this.decoder=i||new TextDecoder("utf8"),this.regionList=[]},T.Parser.prototype={reportOrThrowError:function(e){if(!(e instanceof i))throw e;this.onparsingerror&&this.onparsingerror(e)},parse:function(e){var t=this;function o(){for(var e=t.buffer,i=0;i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;var s=e.substr(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.substr(i),s}function l(e){var i=new n;if(r(e,function(e,t){switch(e){case"id":i.set(e,t);break;case"width":i.percent(e,t);break;case"lines":i.integer(e,t);break;case"regionanchor":case"viewportanchor":var s=t.split(",");if(2!==s.length)break;var r=new n;if(r.percent("x",s[0]),r.percent("y",s[1]),!r.has("x")||!r.has("y"))break;i.set(e+"X",r.get("x")),i.set(e+"Y",r.get("y"));break;case"scroll":i.alt(e,t,["up"])}},/=/,/\s/),i.has("id")){var s=new(t.vttjs.VTTRegion||t.window.VTTRegion);s.width=i.get("width",100),s.lines=i.get("lines",3),s.regionAnchorX=i.get("regionanchorX",0),s.regionAnchorY=i.get("regionanchorY",100),s.viewportAnchorX=i.get("viewportanchorX",0),s.viewportAnchorY=i.get("viewportanchorY",100),s.scroll=i.get("scroll",""),t.onregion&&t.onregion(s),t.regionList.push({id:i.get("id"),region:s})}}function h(e){var i=new n;r(e,function(e,t){switch(e){case"MPEGT":i.integer(e+"S",t);break;case"LOCA":i.set(e+"L",s(t))}},/[^\d]:/,/,/),t.ontimestampmap&&t.ontimestampmap({MPEGTS:i.get("MPEGTS"),LOCAL:i.get("LOCAL")})}function u(e){e.match(/X-TIMESTAMP-MAP/)?r(e,function(e,t){if("X-TIMESTAMP-MAP"===e)h(t)},/=/):r(e,function(e,t){if("Region"===e)l(t)},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var d;if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var c=(d=o()).match(/^WEBVTT([ \t].*)?$/);if(!c||!c[0])throw new i(i.Errors.BadSignature);t.state="HEADER"}for(var p=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(p?p=!1:d=o(),t.state){case"HEADER":/:/.test(d)?u(d):d||(t.state="ID");continue;case"NOTE":d||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(d)){t.state="NOTE";break}if(!d)continue;t.cue=new(t.vttjs.VTTCue||t.window.VTTCue)(0,0,"");try{t.cue.align="center"}catch(g){t.cue.align="middle"}if(t.state="CUE",-1===d.indexOf("--\x3e")){t.cue.id=d;continue}case"CUE":try{a(d,t.cue,t.regionList)}catch(g){t.reportOrThrowError(g),t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var m=-1!==d.indexOf("--\x3e");if(!d||m&&(p=!0)){t.oncue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}t.cue.text&&(t.cue.text+="\n"),t.cue.text+=d.replace(/\u2028/g,"\n").replace(/u2029/g,"\n");continue;case"BADCUE":d||(t.state="ID");continue}}}catch(g){t.reportOrThrowError(g),"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var e=this;try{if(e.buffer+=e.decoder.decode(),(e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state)throw new i(i.Errors.BadSignature)}catch(t){e.reportOrThrowError(t)}return e.onflush&&e.onflush(),this}},ke=T}function Re(){if(Ae)return xe;Ae=1;var e="auto",t={"":1,lr:1,rl:1},i={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function s(e){return"string"==typeof e&&(!!t[e.toLowerCase()]&&e.toLowerCase())}function n(e){return"string"==typeof e&&(!!i[e.toLowerCase()]&&e.toLowerCase())}function r(t,i,r){this.hasBeenReset=!1;var a="",o=!1,l=t,h=i,u=r,d=null,c="",p=!0,m="auto",g="start",f="auto",y="auto",_=100,v="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return a},set:function(e){a=""+e}},pauseOnExit:{enumerable:!0,get:function(){return o},set:function(e){o=!!e}},startTime:{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");l=e,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return u},set:function(e){u=""+e,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return d},set:function(e){d=e,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return c},set:function(e){var t=s(e);if(!1===t)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");c=t,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return m},set:function(t){if("number"!=typeof t&&t!==e)throw new SyntaxError("Line: an invalid number or illegal string was specified.");m=t,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return g},set:function(e){var t=n(e);t?(g=t,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return f},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");f=e,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return y},set:function(e){var t=n(e);t?(y=t,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return _},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");_=e,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return v},set:function(e){var t=n(e);if(!t)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");v=t,this.hasBeenReset=!0}}}),this.displayState=void 0}return r.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)},xe=r}function Me(){if(Pe)return De;Pe=1;var e={"":!0,up:!0};function t(t){return"string"==typeof t&&(!!e[t.toLowerCase()]&&t.toLowerCase())}function i(e){return"number"==typeof e&&e>=0&&e<=100}function s(){var e=100,s=3,n=0,r=100,a=0,o=100,l="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return e},set:function(t){if(!i(t))throw new Error("Width must be between 0 and 100.");e=t}},lines:{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e)throw new TypeError("Lines must be set to a number.");s=e}},regionAnchorY:{enumerable:!0,get:function(){return r},set:function(e){if(!i(e))throw new Error("RegionAnchorX must be between 0 and 100.");r=e}},regionAnchorX:{enumerable:!0,get:function(){return n},set:function(e){if(!i(e))throw new Error("RegionAnchorY must be between 0 and 100.");n=e}},viewportAnchorY:{enumerable:!0,get:function(){return o},set:function(e){if(!i(e))throw new Error("ViewportAnchorY must be between 0 and 100.");o=e}},viewportAnchorX:{enumerable:!0,get:function(){return a},set:function(e){if(!i(e))throw new Error("ViewportAnchorX must be between 0 and 100.");a=e}},scroll:{enumerable:!0,get:function(){return l},set:function(e){var i=t(e);!1===i?console.warn("Scroll: an invalid or illegal string was specified."):l=i}}})}return De=s}function Ue(){if(Le)return Oe.exports;Le=1;var e=v(),t=Oe.exports={WebVTT:Ne(),VTTCue:Re(),VTTRegion:Me()};e.vttjs=t,e.WebVTT=t.WebVTT;var i=t.VTTCue,s=t.VTTRegion,n=e.VTTCue,r=e.VTTRegion;return t.shim=function(){e.VTTCue=i,e.VTTRegion=s},t.restore=function(){e.VTTCue=n,e.VTTRegion=r},e.VTTCue||t.shim(),Oe.exports}const Be=f(Ue());function Fe(){return Fe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},Fe.apply(null,arguments)}var qe="https://example.com",je=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=b.location&&b.location.href||"");var i=/^\/\//.test(e),s=!b.location&&!/\/\//i.test(e);e=new b.URL(e,b.location||qe);var n=new URL(t,e);return s?n.href.slice(qe.length):i?n.href.slice(n.protocol.length):n.href},$e=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){if(!this.listeners[e])return!1;var i=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(i,1),i>-1},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,s=0;s<i;++s)t[s].call(this,arguments[1]);else for(var n=Array.prototype.slice.call(arguments,1),r=t.length,a=0;a<r;++a)t[a].apply(this,n)},t.dispose=function(){this.listeners={}},t.pipe=function(e){this.on("data",function(t){e.push(t)})},e}(),He=function(e){return b.atob?b.atob(e):Buffer.from(e,"base64").toString("binary")};function Ve(e){for(var t=He(e),i=new Uint8Array(t.length),s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return i}class ze extends $e{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf("\n");t>-1;t=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const We=String.fromCharCode(9),Ge=function(e){const t=/([0-9.]*)?@?([0-9.]*)?/.exec(e||""),i={};return t[1]&&(i.length=parseInt(t[1],10)),t[2]&&(i.offset=parseInt(t[2],10)),i},Xe=function(){return new RegExp("(?:^|,)("+("(?:"+"[^=]*"+")=(?:"+'"[^"]*"|[^,]*'+")")+")")},Ke=function(e){const t={};if(!e)return t;const i=e.split(Xe());let s,n=i.length;for(;n--;)""!==i[n]&&(s=/([^=]*)=(.*)/.exec(i[n]).slice(1),s[0]=s[0].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^['"](.*)['"]$/g,"$1"),t[s[0]]=s[1]);return t},Ye=e=>{const t=e.split("x"),i={};return t[0]&&(i.width=parseInt(t[0],10)),t[1]&&(i.height=parseInt(t[1],10)),i};class Qe extends $e{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,i;if(0===(e=e.trim()).length)return;if("#"!==e[0])return void this.trigger("data",{type:"uri",uri:e});this.tagMappers.reduce((t,i)=>{const s=i(e);return s===e?t:t.concat([s])},[e]).forEach(e=>{for(let t=0;t<this.customParsers.length;t++)if(this.customParsers[t].call(this,e))return;if(0===e.indexOf("#EXT"))if(e=e.replace("\r",""),t=/^#EXTM3U/.exec(e),t)this.trigger("data",{type:"tag",tagType:"m3u"});else{if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(e),t)return i={type:"tag",tagType:"inf"},t[1]&&(i.duration=parseFloat(t[1])),t[2]&&(i.title=t[2]),void this.trigger("data",i);if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(e),t)return i={type:"tag",tagType:"targetduration"},t[1]&&(i.duration=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(e),t)return i={type:"tag",tagType:"version"},t[1]&&(i.version=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(e),t)return i={type:"tag",tagType:"media-sequence"},t[1]&&(i.number=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(e),t)return i={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(i.number=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(e),t)return i={type:"tag",tagType:"playlist-type"},t[1]&&(i.playlistType=t[1]),void this.trigger("data",i);if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(e),t)return i=Fe(Ge(t[1]),{type:"tag",tagType:"byterange"}),void this.trigger("data",i);if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(e),t)return i={type:"tag",tagType:"allow-cache"},t[1]&&(i.allowed=!/NO/.test(t[1])),void this.trigger("data",i);if(t=/^#EXT-X-MAP:(.*)$/.exec(e),t){if(i={type:"tag",tagType:"map"},t[1]){const e=Ke(t[1]);e.URI&&(i.uri=e.URI),e.BYTERANGE&&(i.byterange=Ge(e.BYTERANGE))}this.trigger("data",i)}else{if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(e),t)return i={type:"tag",tagType:"stream-inf"},t[1]&&(i.attributes=Ke(t[1]),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=Ye(i.attributes.RESOLUTION)),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),i.attributes["PROGRAM-ID"]&&(i.attributes["PROGRAM-ID"]=parseInt(i.attributes["PROGRAM-ID"],10))),void this.trigger("data",i);if(t=/^#EXT-X-MEDIA:(.*)$/.exec(e),t)return i={type:"tag",tagType:"media"},t[1]&&(i.attributes=Ke(t[1])),void this.trigger("data",i);if(t=/^#EXT-X-ENDLIST/.exec(e),t)this.trigger("data",{type:"tag",tagType:"endlist"});else if(t=/^#EXT-X-DISCONTINUITY/.exec(e),t)this.trigger("data",{type:"tag",tagType:"discontinuity"});else{if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(e),t)return i={type:"tag",tagType:"program-date-time"},t[1]&&(i.dateTimeString=t[1],i.dateTimeObject=new Date(t[1])),void this.trigger("data",i);if(t=/^#EXT-X-KEY:(.*)$/.exec(e),t)return i={type:"tag",tagType:"key"},t[1]&&(i.attributes=Ke(t[1]),i.attributes.IV&&("0x"===i.attributes.IV.substring(0,2).toLowerCase()&&(i.attributes.IV=i.attributes.IV.substring(2)),i.attributes.IV=i.attributes.IV.match(/.{8}/g),i.attributes.IV[0]=parseInt(i.attributes.IV[0],16),i.attributes.IV[1]=parseInt(i.attributes.IV[1],16),i.attributes.IV[2]=parseInt(i.attributes.IV[2],16),i.attributes.IV[3]=parseInt(i.attributes.IV[3],16),i.attributes.IV=new Uint32Array(i.attributes.IV))),void this.trigger("data",i);if(t=/^#EXT-X-START:(.*)$/.exec(e),t)return i={type:"tag",tagType:"start"},t[1]&&(i.attributes=Ke(t[1]),i.attributes["TIME-OFFSET"]=parseFloat(i.attributes["TIME-OFFSET"]),i.attributes.PRECISE=/YES/.test(i.attributes.PRECISE)),void this.trigger("data",i);if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(e),t)return i={type:"tag",tagType:"cue-out-cont"},t[1]?i.data=t[1]:i.data="",void this.trigger("data",i);if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(e),t)return i={type:"tag",tagType:"cue-out"},t[1]?i.data=t[1]:i.data="",void this.trigger("data",i);if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(e),t)return i={type:"tag",tagType:"cue-in"},t[1]?i.data=t[1]:i.data="",void this.trigger("data",i);if(t=/^#EXT-X-SKIP:(.*)$/.exec(e),t&&t[1])return i={type:"tag",tagType:"skip"},i.attributes=Ke(t[1]),i.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(i.attributes["SKIPPED-SEGMENTS"]=parseInt(i.attributes["SKIPPED-SEGMENTS"],10)),i.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(i.attributes["RECENTLY-REMOVED-DATERANGES"]=i.attributes["RECENTLY-REMOVED-DATERANGES"].split(We)),void this.trigger("data",i);if(t=/^#EXT-X-PART:(.*)$/.exec(e),t&&t[1])return i={type:"tag",tagType:"part"},i.attributes=Ke(t[1]),["DURATION"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=parseFloat(i.attributes[e]))}),["INDEPENDENT","GAP"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=/YES/.test(i.attributes[e]))}),i.attributes.hasOwnProperty("BYTERANGE")&&(i.attributes.byterange=Ge(i.attributes.BYTERANGE)),void this.trigger("data",i);if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(e),t&&t[1])return i={type:"tag",tagType:"server-control"},i.attributes=Ke(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=parseFloat(i.attributes[e]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=/YES/.test(i.attributes[e]))}),void this.trigger("data",i);if(t=/^#EXT-X-PART-INF:(.*)$/.exec(e),t&&t[1])return i={type:"tag",tagType:"part-inf"},i.attributes=Ke(t[1]),["PART-TARGET"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=parseFloat(i.attributes[e]))}),void this.trigger("data",i);if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(e),t&&t[1])return i={type:"tag",tagType:"preload-hint"},i.attributes=Ke(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(e){if(i.attributes.hasOwnProperty(e)){i.attributes[e]=parseInt(i.attributes[e],10);const t="BYTERANGE-LENGTH"===e?"length":"offset";i.attributes.byterange=i.attributes.byterange||{},i.attributes.byterange[t]=i.attributes[e],delete i.attributes[e]}}),void this.trigger("data",i);if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(e),t&&t[1])return i={type:"tag",tagType:"rendition-report"},i.attributes=Ke(t[1]),["LAST-MSN","LAST-PART"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=parseInt(i.attributes[e],10))}),void this.trigger("data",i);if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(e),t&&t[1]){i={type:"tag",tagType:"daterange"},i.attributes=Ke(t[1]),["ID","CLASS"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=String(i.attributes[e]))}),["START-DATE","END-DATE"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=new Date(i.attributes[e]))}),["DURATION","PLANNED-DURATION"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=parseFloat(i.attributes[e]))}),["END-ON-NEXT"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=/YES/i.test(i.attributes[e]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(e){i.attributes.hasOwnProperty(e)&&(i.attributes[e]=i.attributes[e].toString(16))});const e=/^X-([A-Z]+-)+[A-Z]+$/;for(const t in i.attributes){if(!e.test(t))continue;const s=/[0-9A-Fa-f]{6}/g.test(i.attributes[t]),n=/^\d+(\.\d+)?$/.test(i.attributes[t]);i.attributes[t]=s?i.attributes[t].toString(16):n?parseFloat(i.attributes[t]):String(i.attributes[t])}return void this.trigger("data",i)}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(e),t)this.trigger("data",{type:"tag",tagType:"independent-segments"});else if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(e),t)this.trigger("data",{type:"tag",tagType:"i-frames-only"});else{if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(e),t)return i={type:"tag",tagType:"content-steering"},i.attributes=Ke(t[1]),void this.trigger("data",i);if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(e),t)return i={type:"tag",tagType:"i-frame-playlist"},i.attributes=Ke(t[1]),i.attributes.URI&&(i.uri=i.attributes.URI),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=Ye(i.attributes.RESOLUTION)),i.attributes["AVERAGE-BANDWIDTH"]&&(i.attributes["AVERAGE-BANDWIDTH"]=parseInt(i.attributes["AVERAGE-BANDWIDTH"],10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),void this.trigger("data",i);if(t=/^#EXT-X-DEFINE:(.*)$/.exec(e),t)return i={type:"tag",tagType:"define"},i.attributes=Ke(t[1]),void this.trigger("data",i);this.trigger("data",{type:"tag",data:e.slice(4)})}}}}else this.trigger("data",{type:"comment",text:e.slice(1)})})}addParser({expression:e,customType:t,dataParser:i,segment:s}){"function"!=typeof i&&(i=e=>e),this.customParsers.push(n=>{if(e.exec(n))return this.trigger("data",{type:"custom",data:i(n),customType:t,segment:s}),!0})}addTagMapper({expression:e,map:t}){const i=i=>e.test(i)?t(i):i;this.tagMappers.push(i)}}const Je=e=>e.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),Ze=function(e){const t={};return Object.keys(e).forEach(function(i){t[Je(i)]=e[i]}),t},et=function(e){const{serverControl:t,targetDuration:i,partTargetDuration:s}=e;if(!t)return;const n="#EXT-X-SERVER-CONTROL",r="holdBack",a="partHoldBack",o=i&&3*i,l=s&&2*s;i&&!t.hasOwnPr