general-basic-videoplayer
Version:
基于video.js和tcplayer.js等多个播放器封装的视频播放器
18 lines (17 loc) • 1.37 MB
JavaScript
(function(n,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.Index={},n.Vue))})(this,(function(exports,vue){"use strict";var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function getAugmentedNamespace(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),t}var window_1,hasRequiredWindow;function requireWindow(){if(hasRequiredWindow)return window_1;hasRequiredWindow=1;var n;return typeof window<"u"?n=window:typeof commonjsGlobal<"u"?n=commonjsGlobal:typeof self<"u"?n=self:n={},window_1=n,window_1}var windowExports=requireWindow();const window$1=getDefaultExportFromCjs(windowExports),__viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(__viteBrowserExternal$1);var document_1,hasRequiredDocument;function requireDocument(){if(hasRequiredDocument)return document_1;hasRequiredDocument=1;var n=typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:{},e=require$$0,t;return typeof document<"u"?t=document:(t=n["__GLOBAL_DOCUMENT_CACHE@4"],t||(t=n["__GLOBAL_DOCUMENT_CACHE@4"]=e)),document_1=t,document_1}var documentExports=requireDocument();const document$1=getDefaultExportFromCjs(documentExports);var lib$1={exports:{}},_extends$1={exports:{}},hasRequired_extends;function require_extends(){return hasRequired_extends||(hasRequired_extends=1,(function(n){function e(){return n.exports=e=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var a in s)({}).hasOwnProperty.call(s,a)&&(t[a]=s[a])}return t},n.exports.__esModule=!0,n.exports.default=n.exports,e.apply(null,arguments)}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports})(_extends$1)),_extends$1.exports}var isFunction_1,hasRequiredIsFunction;function requireIsFunction(){if(hasRequiredIsFunction)return isFunction_1;hasRequiredIsFunction=1,isFunction_1=e;var n=Object.prototype.toString;function e(t){if(!t)return!1;var r=n.call(t);return r==="[object Function]"||typeof t=="function"&&r!=="[object RegExp]"||typeof window<"u"&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}return isFunction_1}var interceptors,hasRequiredInterceptors;function requireInterceptors(){if(hasRequiredInterceptors)return interceptors;hasRequiredInterceptors=1;function n(s,a){var l=typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(l)return(l=l.call(s)).next.bind(l);if(Array.isArray(s)||(l=e(s))||a){l&&(s=l);var u=0;return function(){return u>=s.length?{done:!0}:{done:!1,value:s[u++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function e(s,a){if(s){if(typeof s=="string")return t(s,a);var l=Object.prototype.toString.call(s).slice(8,-1);if(l==="Object"&&s.constructor&&(l=s.constructor.name),l==="Map"||l==="Set")return Array.from(s);if(l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return t(s,a)}}function t(s,a){(a==null||a>s.length)&&(a=s.length);for(var l=0,u=new Array(a);l<a;l++)u[l]=s[l];return u}var r=(function(){function s(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var a=s.prototype;return a.getIsEnabled=function(){return this.enabled_},a.enable=function(){this.enabled_=!0},a.disable=function(){this.enabled_=!1},a.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},a.addInterceptor=function(u,c){this.typeToInterceptorsMap_.has(u)||this.typeToInterceptorsMap_.set(u,new Set);var d=this.typeToInterceptorsMap_.get(u);return d.has(c)?!1:(d.add(c),!0)},a.removeInterceptor=function(u,c){var d=this.typeToInterceptorsMap_.get(u);return d&&d.has(c)?(d.delete(c),!0):!1},a.clearInterceptorsByType=function(u){var c=this.typeToInterceptorsMap_.get(u);return c?(this.typeToInterceptorsMap_.delete(u),this.typeToInterceptorsMap_.set(u,new Set),!0):!1},a.clear=function(){return this.typeToInterceptorsMap_.size?(this.typeToInterceptorsMap_=new Map,!0):!1},a.getForType=function(u){return this.typeToInterceptorsMap_.get(u)||new Set},a.execute=function(u,c){for(var d=this.getForType(u),p=n(d),f;!(f=p()).done;){var E=f.value;try{c=E(c)}catch{}}return c},s})();return interceptors=r,interceptors}var retry,hasRequiredRetry;function requireRetry(){if(hasRequiredRetry)return retry;hasRequiredRetry=1;var n=(function(){function t(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1}var r=t.prototype;return r.getIsEnabled=function(){return this.enabled_},r.enable=function(){this.enabled_=!0},r.disable=function(){this.enabled_=!1},r.reset=function(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1},r.getMaxAttempts=function(){return this.maxAttempts_},r.setMaxAttempts=function(a){this.maxAttempts_=a},r.getDelayFactor=function(){return this.delayFactor_},r.setDelayFactor=function(a){this.delayFactor_=a},r.getFuzzFactor=function(){return this.fuzzFactor_},r.setFuzzFactor=function(a){this.fuzzFactor_=a},r.getInitialDelay=function(){return this.initialDelay_},r.setInitialDelay=function(a){this.initialDelay_=a},r.createRetry=function(a){var l=a===void 0?{}:a,u=l.maxAttempts,c=l.delayFactor,d=l.fuzzFactor,p=l.initialDelay;return new e({maxAttempts:u||this.maxAttempts_,delayFactor:c||this.delayFactor_,fuzzFactor:d||this.fuzzFactor_,initialDelay:p||this.initialDelay_})},t})(),e=(function(){function t(s){this.maxAttempts_=s.maxAttempts,this.delayFactor_=s.delayFactor,this.fuzzFactor_=s.fuzzFactor,this.currentDelay_=s.initialDelay,this.currentAttempt_=1}var r=t.prototype;return r.moveToNextAttempt=function(){this.currentAttempt_++;var a=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+a},r.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},r.getCurrentDelay=function(){return this.currentDelay_},r.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},r.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},r.getCurrentFuzzedDelay=function(){var a=this.getCurrentMinPossibleDelay(),l=this.getCurrentMaxPossibleDelay();return a+Math.random()*(l-a)},t})();return retry=n,retry}var httpHandler,hasRequiredHttpHandler;function requireHttpHandler(){if(hasRequiredHttpHandler)return httpHandler;hasRequiredHttpHandler=1;var n=requireWindow(),e=function(s,a){return a===void 0&&(a=!1),function(l,u,c){if(l){s(l);return}if(u.statusCode>=400&&u.statusCode<=599){var d=c;if(a)if(n.TextDecoder){var p=t(u.headers&&u.headers["content-type"]);try{d=new TextDecoder(p).decode(c)}catch{}}else d=String.fromCharCode.apply(null,new Uint8Array(c));s({cause:d});return}s(null,c)}};function t(r){return r===void 0&&(r=""),r.toLowerCase().split(";").reduce(function(s,a){var l=a.split("="),u=l[0],c=l[1];return u.trim()==="charset"?c.trim():s},"utf-8")}return httpHandler=e,httpHandler}var hasRequiredLib$1;function requireLib$1(){if(hasRequiredLib$1)return lib$1.exports;hasRequiredLib$1=1;var n=requireWindow(),e=require_extends(),t=requireIsFunction(),r=requireInterceptors(),s=requireRetry();d.httpHandler=requireHttpHandler(),d.requestInterceptorsStorage=new r,d.responseInterceptorsStorage=new r,d.retryManager=new s;/**
* @license
* slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/>
* Copyright (c) 2014 David Björklund
* Available under the MIT license
* <https://github.com/kesla/parse-headers/blob/master/LICENCE>
*/var a=function(S){var v={};return S&&S.trim().split(`
`).forEach(function(A){var R=A.indexOf(":"),L=A.slice(0,R).trim().toLowerCase(),M=A.slice(R+1).trim();typeof v[L]>"u"?v[L]=M:Array.isArray(v[L])?v[L].push(M):v[L]=[v[L],M]}),v};lib$1.exports=d,lib$1.exports.default=d,d.XMLHttpRequest=n.XMLHttpRequest||E,d.XDomainRequest="withCredentials"in new d.XMLHttpRequest?d.XMLHttpRequest:n.XDomainRequest,l(["get","put","post","patch","head","delete"],function(m){d[m==="delete"?"del":m]=function(S,v,A){return v=c(S,v,A),v.method=m.toUpperCase(),p(v)}});function l(m,S){for(var v=0;v<m.length;v++)S(m[v])}function u(m){for(var S in m)if(m.hasOwnProperty(S))return!1;return!0}function c(m,S,v){var A=m;return t(S)?(v=S,typeof m=="string"&&(A={uri:m})):A=e({},S,{uri:m}),A.callback=v,A}function d(m,S,v){return S=c(m,S,v),p(S)}function p(m){if(typeof m.callback>"u")throw new Error("callback argument missing");if(m.requestType&&d.requestInterceptorsStorage.getIsEnabled()){var S={uri:m.uri||m.url,headers:m.headers||{},body:m.body,metadata:m.metadata||{},retry:m.retry,timeout:m.timeout},v=d.requestInterceptorsStorage.execute(m.requestType,S);m.uri=v.uri,m.headers=v.headers,m.body=v.body,m.metadata=v.metadata,m.retry=v.retry,m.timeout=v.timeout}var A=!1,R=function(K,J,ie){A||(A=!0,m.callback(K,J,ie))};function L(){w.readyState===4&&!d.responseInterceptorsStorage.getIsEnabled()&&setTimeout(O,0)}function M(){var se=void 0;if(w.response?se=w.response:se=w.responseText||f(w),ne)try{se=JSON.parse(se)}catch{}return se}function G(se){if(clearTimeout(le),clearTimeout(m.retryTimeout),se instanceof Error||(se=new Error(""+(se||"Unknown XMLHttpRequest Error"))),se.statusCode=0,!D&&d.retryManager.getIsEnabled()&&m.retry&&m.retry.shouldRetry()){m.retryTimeout=setTimeout(function(){m.retry.moveToNextAttempt(),m.xhr=w,p(m)},m.retry.getCurrentFuzzedDelay());return}if(m.requestType&&d.responseInterceptorsStorage.getIsEnabled()){var K={headers:fe.headers||{},body:fe.body,responseUrl:w.responseURL,responseType:w.responseType},J=d.responseInterceptorsStorage.execute(m.requestType,K);fe.body=J.body,fe.headers=J.headers}return R(se,fe)}function O(){if(!D){var se;clearTimeout(le),clearTimeout(m.retryTimeout),m.useXDR&&w.status===void 0?se=200:se=w.status===1223?204:w.status;var K=fe,J=null;if(se!==0?(K={body:M(),statusCode:se,method:B,headers:{},url:b,rawRequest:w},w.getAllResponseHeaders&&(K.headers=a(w.getAllResponseHeaders()))):J=new Error("Internal XMLHttpRequest Error"),m.requestType&&d.responseInterceptorsStorage.getIsEnabled()){var ie={headers:K.headers||{},body:K.body,responseUrl:w.responseURL,responseType:w.responseType},Z=d.responseInterceptorsStorage.execute(m.requestType,ie);K.body=Z.body,K.headers=Z.headers}return R(J,K,K.body)}}var w=m.xhr||null;w||(m.cors||m.useXDR?w=new d.XDomainRequest:w=new d.XMLHttpRequest);var C,D,b=w.url=m.uri||m.url,B=w.method=m.method||"GET",j=m.body||m.data,U=w.headers=m.headers||{},z=!!m.sync,ne=!1,le,fe={body:void 0,headers:{},statusCode:0,method:B,url:b,rawRequest:w};if("json"in m&&m.json!==!1&&(ne=!0,U.accept||U.Accept||(U.Accept="application/json"),B!=="GET"&&B!=="HEAD"&&(U["content-type"]||U["Content-Type"]||(U["Content-Type"]="application/json"),j=JSON.stringify(m.json===!0?j:m.json))),w.onreadystatechange=L,w.onload=O,w.onerror=G,w.onprogress=function(){},w.onabort=function(){D=!0,clearTimeout(m.retryTimeout)},w.ontimeout=G,w.open(B,b,!z,m.username,m.password),z||(w.withCredentials=!!m.withCredentials),!z&&m.timeout>0&&(le=setTimeout(function(){if(!D){D=!0,w.abort("timeout");var se=new Error("XMLHttpRequest timeout");se.code="ETIMEDOUT",G(se)}},m.timeout)),w.setRequestHeader)for(C in U)U.hasOwnProperty(C)&&w.setRequestHeader(C,U[C]);else if(m.headers&&!u(m.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in m&&(w.responseType=m.responseType),"beforeSend"in m&&typeof m.beforeSend=="function"&&m.beforeSend(w),w.send(j||null),w}function f(m){try{if(m.responseType==="document")return m.responseXML;var S=m.responseXML&&m.responseXML.documentElement.nodeName==="parsererror";if(m.responseType===""&&!S)return m.responseXML}catch{}return null}function E(){}return lib$1.exports}var libExports$1=requireLib$1();const XHR=getDefaultExportFromCjs(libExports$1);var browserIndex={exports:{}},vtt$1,hasRequiredVtt;function requireVtt(){if(hasRequiredVtt)return vtt$1;hasRequiredVtt=1;var n=requireDocument(),e=Object.create||(function(){function b(){}return function(B){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return b.prototype=B,new b}})();function t(b,B){this.name="ParsingError",this.code=b.code,this.message=B||b.message}t.prototype=e(Error.prototype),t.prototype.constructor=t,t.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function r(b){function B(U,z,ne,le){return(U|0)*3600+(z|0)*60+(ne|0)+(le|0)/1e3}var j=b.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return j?j[3]?B(j[1],j[2],j[3].replace(":",""),j[4]):j[1]>59?B(j[1],j[2],0,j[4]):B(0,j[1],j[2],j[4]):null}function s(){this.values=e(null)}s.prototype={set:function(b,B){!this.get(b)&&B!==""&&(this.values[b]=B)},get:function(b,B,j){return j?this.has(b)?this.values[b]:B[j]:this.has(b)?this.values[b]:B},has:function(b){return b in this.values},alt:function(b,B,j){for(var U=0;U<j.length;++U)if(B===j[U]){this.set(b,B);break}},integer:function(b,B){/^-?\d+$/.test(B)&&this.set(b,parseInt(B,10))},percent:function(b,B){return B.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(B=parseFloat(B),B>=0&&B<=100)?(this.set(b,B),!0):!1}};function a(b,B,j,U){var z=U?b.split(U):[b];for(var ne in z)if(typeof z[ne]=="string"){var le=z[ne].split(j);if(le.length===2){var fe=le[0].trim(),se=le[1].trim();B(fe,se)}}}function l(b,B,j){var U=b;function z(){var fe=r(b);if(fe===null)throw new t(t.Errors.BadTimeStamp,"Malformed timestamp: "+U);return b=b.replace(/^[^\sa-zA-Z-]+/,""),fe}function ne(fe,se){var K=new s;a(fe,function(J,ie){switch(J){case"region":for(var Z=j.length-1;Z>=0;Z--)if(j[Z].id===ie){K.set(J,j[Z].region);break}break;case"vertical":K.alt(J,ie,["rl","lr"]);break;case"line":var re=ie.split(","),me=re[0];K.integer(J,me),K.percent(J,me)&&K.set("snapToLines",!1),K.alt(J,me,["auto"]),re.length===2&&K.alt("lineAlign",re[1],["start","center","end"]);break;case"position":re=ie.split(","),K.percent(J,re[0]),re.length===2&&K.alt("positionAlign",re[1],["start","center","end"]);break;case"size":K.percent(J,ie);break;case"align":K.alt(J,ie,["start","center","end","left","right"]);break}},/:/,/\s/),se.region=K.get("region",null),se.vertical=K.get("vertical","");try{se.line=K.get("line","auto")}catch{}se.lineAlign=K.get("lineAlign","start"),se.snapToLines=K.get("snapToLines",!0),se.size=K.get("size",100);try{se.align=K.get("align","center")}catch{se.align=K.get("align","middle")}try{se.position=K.get("position","auto")}catch{se.position=K.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},se.align)}se.positionAlign=K.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},se.align)}function le(){b=b.replace(/^\s+/,"")}if(le(),B.startTime=z(),le(),b.substr(0,3)!=="-->")throw new t(t.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+U);b=b.substr(3),le(),B.endTime=z(),le(),ne(b,B)}var u=n.createElement&&n.createElement("textarea"),c={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},d={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)"},p={v:"title",lang:"lang"},f={rt:"ruby"};function E(b,B){function j(){if(!B)return null;function me(Se){return B=B.substr(Se.length),Se}var _e=B.match(/^([^<]*)(<[^>]*>?)?/);return me(_e[1]?_e[1]:_e[2])}function U(me){return u.innerHTML=me,me=u.textContent,u.textContent="",me}function z(me,_e){return!f[_e.localName]||f[_e.localName]===me.localName}function ne(me,_e){var Se=c[me];if(!Se)return null;var Qe=b.document.createElement(Se),Me=p[me];return Me&&_e&&(Qe[Me]=_e.trim()),Qe}for(var le=b.document.createElement("div"),fe=le,se,K=[];(se=j())!==null;){if(se[0]==="<"){if(se[1]==="/"){K.length&&K[K.length-1]===se.substr(2).replace(">","")&&(K.pop(),fe=fe.parentNode);continue}var J=r(se.substr(1,se.length-2)),ie;if(J){ie=b.document.createProcessingInstruction("timestamp",J),fe.appendChild(ie);continue}var Z=se.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!Z||(ie=ne(Z[1],Z[3]),!ie)||!z(fe,ie))continue;if(Z[2]){var re=Z[2].split(".");re.forEach(function(me){var _e=/^bg_/.test(me),Se=_e?me.slice(3):me;if(d.hasOwnProperty(Se)){var Qe=_e?"background-color":"color",Me=d[Se];ie.style[Qe]=Me}}),ie.className=re.join(" ")}K.push(Z[1]),fe.appendChild(ie),fe=ie;continue}fe.appendChild(b.document.createTextNode(U(se)))}return le}var m=[[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 S(b){for(var B=0;B<m.length;B++){var j=m[B];if(b>=j[0]&&b<=j[1])return!0}return!1}function v(b){var B=[],j="",U;if(!b||!b.childNodes)return"ltr";function z(fe,se){for(var K=se.childNodes.length-1;K>=0;K--)fe.push(se.childNodes[K])}function ne(fe){if(!fe||!fe.length)return null;var se=fe.pop(),K=se.textContent||se.innerText;if(K){var J=K.match(/^.*(\n|\r)/);return J?(fe.length=0,J[0]):K}if(se.tagName==="ruby")return ne(fe);if(se.childNodes)return z(fe,se),ne(fe)}for(z(B,b);j=ne(B);)for(var le=0;le<j.length;le++)if(U=j.charCodeAt(le),S(U))return"rtl";return"ltr"}function A(b){if(typeof b.line=="number"&&(b.snapToLines||b.line>=0&&b.line<=100))return b.line;if(!b.track||!b.track.textTrackList||!b.track.textTrackList.mediaElement)return-1;for(var B=b.track,j=B.textTrackList,U=0,z=0;z<j.length&&j[z]!==B;z++)j[z].mode==="showing"&&U++;return++U*-1}function R(){}R.prototype.applyStyles=function(b,B){B=B||this.div;for(var j in b)b.hasOwnProperty(j)&&(B.style[j]=b[j])},R.prototype.formatStyle=function(b,B){return b===0?0:b+B};function L(b,B,j){R.call(this),this.cue=B,this.cueDiv=E(b,B.text);var U={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:B.vertical===""?"horizontal-tb":B.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(U,this.cueDiv),this.div=b.document.createElement("div"),U={direction:v(this.cueDiv),writingMode:B.vertical===""?"horizontal-tb":B.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:B.align==="middle"?"center":B.align,font:j.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(U),this.div.appendChild(this.cueDiv);var z=0;switch(B.positionAlign){case"start":case"line-left":z=B.position;break;case"center":z=B.position-B.size/2;break;case"end":case"line-right":z=B.position-B.size;break}B.vertical===""?this.applyStyles({left:this.formatStyle(z,"%"),width:this.formatStyle(B.size,"%")}):this.applyStyles({top:this.formatStyle(z,"%"),height:this.formatStyle(B.size,"%")}),this.move=function(ne){this.applyStyles({top:this.formatStyle(ne.top,"px"),bottom:this.formatStyle(ne.bottom,"px"),left:this.formatStyle(ne.left,"px"),right:this.formatStyle(ne.right,"px"),height:this.formatStyle(ne.height,"px"),width:this.formatStyle(ne.width,"px")})}}L.prototype=e(R.prototype),L.prototype.constructor=L;function M(b){var B,j,U,z;if(b.div){j=b.div.offsetHeight,U=b.div.offsetWidth,z=b.div.offsetTop;var ne=(ne=b.div.childNodes)&&(ne=ne[0])&&ne.getClientRects&&ne.getClientRects();b=b.div.getBoundingClientRect(),B=ne?Math.max(ne[0]&&ne[0].height||0,b.height/ne.length):0}this.left=b.left,this.right=b.right,this.top=b.top||z,this.height=b.height||j,this.bottom=b.bottom||z+(b.height||j),this.width=b.width||U,this.lineHeight=B!==void 0?B:b.lineHeight}M.prototype.move=function(b,B){switch(B=B!==void 0?B:this.lineHeight,b){case"+x":this.left+=B,this.right+=B;break;case"-x":this.left-=B,this.right-=B;break;case"+y":this.top+=B,this.bottom+=B;break;case"-y":this.top-=B,this.bottom-=B;break}},M.prototype.overlaps=function(b){return this.left<b.right&&this.right>b.left&&this.top<b.bottom&&this.bottom>b.top},M.prototype.overlapsAny=function(b){for(var B=0;B<b.length;B++)if(this.overlaps(b[B]))return!0;return!1},M.prototype.within=function(b){return this.top>=b.top&&this.bottom<=b.bottom&&this.left>=b.left&&this.right<=b.right},M.prototype.overlapsOppositeAxis=function(b,B){switch(B){case"+x":return this.left<b.left;case"-x":return this.right>b.right;case"+y":return this.top<b.top;case"-y":return this.bottom>b.bottom}},M.prototype.intersectPercentage=function(b){var B=Math.max(0,Math.min(this.right,b.right)-Math.max(this.left,b.left)),j=Math.max(0,Math.min(this.bottom,b.bottom)-Math.max(this.top,b.top)),U=B*j;return U/(this.height*this.width)},M.prototype.toCSSCompatValues=function(b){return{top:this.top-b.top,bottom:b.bottom-this.bottom,left:this.left-b.left,right:b.right-this.right,height:this.height,width:this.width}},M.getSimpleBoxPosition=function(b){var B=b.div?b.div.offsetHeight:b.tagName?b.offsetHeight:0,j=b.div?b.div.offsetWidth:b.tagName?b.offsetWidth:0,U=b.div?b.div.offsetTop:b.tagName?b.offsetTop:0;b=b.div?b.div.getBoundingClientRect():b.tagName?b.getBoundingClientRect():b;var z={left:b.left,right:b.right,top:b.top||U,height:b.height||B,bottom:b.bottom||U+(b.height||B),width:b.width||j};return z};function G(b,B,j,U){function z(Se,Qe){for(var Me,Ue=new M(Se),tt=1,Ke=0;Ke<Qe.length;Ke++){for(;Se.overlapsOppositeAxis(j,Qe[Ke])||Se.within(j)&&Se.overlapsAny(U);)Se.move(Qe[Ke]);if(Se.within(j))return Se;var Ze=Se.intersectPercentage(j);tt>Ze&&(Me=new M(Se),tt=Ze),Se=new M(Ue)}return Me||Ue}var ne=new M(B),le=B.cue,fe=A(le),se=[];if(le.snapToLines){var K;switch(le.vertical){case"":se=["+y","-y"],K="height";break;case"rl":se=["+x","-x"],K="width";break;case"lr":se=["-x","+x"],K="width";break}var J=ne.lineHeight,ie=J*Math.round(fe),Z=j[K]+J,re=se[0];Math.abs(ie)>Z&&(ie=ie<0?-1:1,ie*=Math.ceil(Z/J)*J),fe<0&&(ie+=le.vertical===""?j.height:j.width,se=se.reverse()),ne.move(re,ie)}else{var me=ne.lineHeight/j.height*100;switch(le.lineAlign){case"center":fe-=me/2;break;case"end":fe-=me;break}switch(le.vertical){case"":B.applyStyles({top:B.formatStyle(fe,"%")});break;case"rl":B.applyStyles({left:B.formatStyle(fe,"%")});break;case"lr":B.applyStyles({right:B.formatStyle(fe,"%")});break}se=["+y","-x","+x","-y"],ne=new M(B)}var _e=z(ne,se);B.move(_e.toCSSCompatValues(j))}function O(){}O.StringDecoder=function(){return{decode:function(b){if(!b)return"";if(typeof b!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(b))}}},O.convertCueToDOMTree=function(b,B){return!b||!B?null:E(b,B)};var w=.05,C="sans-serif",D="1.5%";return O.processCues=function(b,B,j){if(!b||!B||!j)return null;for(;j.firstChild;)j.removeChild(j.firstChild);var U=b.document.createElement("div");U.style.position="absolute",U.style.left="0",U.style.right="0",U.style.top="0",U.style.bottom="0",U.style.margin=D,j.appendChild(U);function z(J){for(var ie=0;ie<J.length;ie++)if(J[ie].hasBeenReset||!J[ie].displayState)return!0;return!1}if(!z(B)){for(var ne=0;ne<B.length;ne++)U.appendChild(B[ne].displayState);return}var le=[],fe=M.getSimpleBoxPosition(U),se=Math.round(fe.height*w*100)/100,K={font:se+"px "+C};(function(){for(var J,ie,Z=0;Z<B.length;Z++)ie=B[Z],J=new L(b,ie,K),U.appendChild(J.div),G(b,J,fe,le),ie.displayState=J.div,le.push(M.getSimpleBoxPosition(J))})()},O.Parser=function(b,B,j){j||(j=B,B={}),B||(B={}),this.window=b,this.vttjs=B,this.state="INITIAL",this.buffer="",this.decoder=j||new TextDecoder("utf8"),this.regionList=[]},O.Parser.prototype={reportOrThrowError:function(b){if(b instanceof t)this.onparsingerror&&this.onparsingerror(b);else throw b},parse:function(b){var B=this;b&&(B.buffer+=B.decoder.decode(b,{stream:!0}));function j(){for(var J=B.buffer,ie=0;ie<J.length&&J[ie]!=="\r"&&J[ie]!==`
`;)++ie;var Z=J.substr(0,ie);return J[ie]==="\r"&&++ie,J[ie]===`
`&&++ie,B.buffer=J.substr(ie),Z}function U(J){var ie=new s;if(a(J,function(re,me){switch(re){case"id":ie.set(re,me);break;case"width":ie.percent(re,me);break;case"lines":ie.integer(re,me);break;case"regionanchor":case"viewportanchor":var _e=me.split(",");if(_e.length!==2)break;var Se=new s;if(Se.percent("x",_e[0]),Se.percent("y",_e[1]),!Se.has("x")||!Se.has("y"))break;ie.set(re+"X",Se.get("x")),ie.set(re+"Y",Se.get("y"));break;case"scroll":ie.alt(re,me,["up"]);break}},/=/,/\s/),ie.has("id")){var Z=new(B.vttjs.VTTRegion||B.window.VTTRegion);Z.width=ie.get("width",100),Z.lines=ie.get("lines",3),Z.regionAnchorX=ie.get("regionanchorX",0),Z.regionAnchorY=ie.get("regionanchorY",100),Z.viewportAnchorX=ie.get("viewportanchorX",0),Z.viewportAnchorY=ie.get("viewportanchorY",100),Z.scroll=ie.get("scroll",""),B.onregion&&B.onregion(Z),B.regionList.push({id:ie.get("id"),region:Z})}}function z(J){var ie=new s;a(J,function(Z,re){switch(Z){case"MPEGT":ie.integer(Z+"S",re);break;case"LOCA":ie.set(Z+"L",r(re));break}},/[^\d]:/,/,/),B.ontimestampmap&&B.ontimestampmap({MPEGTS:ie.get("MPEGTS"),LOCAL:ie.get("LOCAL")})}function ne(J){J.match(/X-TIMESTAMP-MAP/)?a(J,function(ie,Z){switch(ie){case"X-TIMESTAMP-MAP":z(Z);break}},/=/):a(J,function(ie,Z){switch(ie){case"Region":U(Z);break}},/:/)}try{var le;if(B.state==="INITIAL"){if(!/\r\n|\n/.test(B.buffer))return this;le=j();var fe=le.match(/^WEBVTT([ \t].*)?$/);if(!fe||!fe[0])throw new t(t.Errors.BadSignature);B.state="HEADER"}for(var se=!1;B.buffer;){if(!/\r\n|\n/.test(B.buffer))return this;switch(se?se=!1:le=j(),B.state){case"HEADER":/:/.test(le)?ne(le):le||(B.state="ID");continue;case"NOTE":le||(B.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(le)){B.state="NOTE";break}if(!le)continue;B.cue=new(B.vttjs.VTTCue||B.window.VTTCue)(0,0,"");try{B.cue.align="center"}catch{B.cue.align="middle"}if(B.state="CUE",le.indexOf("-->")===-1){B.cue.id=le;continue}case"CUE":try{l(le,B.cue,B.regionList)}catch(J){B.reportOrThrowError(J),B.cue=null,B.state="BADCUE";continue}B.state="CUETEXT";continue;case"CUETEXT":var K=le.indexOf("-->")!==-1;if(!le||K&&(se=!0)){B.oncue&&B.oncue(B.cue),B.cue=null,B.state="ID";continue}B.cue.text&&(B.cue.text+=`
`),B.cue.text+=le.replace(/\u2028/g,`
`).replace(/u2029/g,`
`);continue;case"BADCUE":le||(B.state="ID");continue}}}catch(J){B.reportOrThrowError(J),B.state==="CUETEXT"&&B.cue&&B.oncue&&B.oncue(B.cue),B.cue=null,B.state=B.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var b=this;try{if(b.buffer+=b.decoder.decode(),(b.cue||b.state==="HEADER")&&(b.buffer+=`
`,b.parse()),b.state==="INITIAL")throw new t(t.Errors.BadSignature)}catch(B){b.reportOrThrowError(B)}return b.onflush&&b.onflush(),this}},vtt$1=O,vtt$1}var vttcue,hasRequiredVttcue;function requireVttcue(){if(hasRequiredVttcue)return vttcue;hasRequiredVttcue=1;var n="auto",e={"":1,lr:1,rl:1},t={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function r(l){if(typeof l!="string")return!1;var u=e[l.toLowerCase()];return u?l.toLowerCase():!1}function s(l){if(typeof l!="string")return!1;var u=t[l.toLowerCase()];return u?l.toLowerCase():!1}function a(l,u,c){this.hasBeenReset=!1;var d="",p=!1,f=l,E=u,m=c,S=null,v="",A=!0,R="auto",L="start",M="auto",G="auto",O=100,w="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return d},set:function(C){d=""+C}},pauseOnExit:{enumerable:!0,get:function(){return p},set:function(C){p=!!C}},startTime:{enumerable:!0,get:function(){return f},set:function(C){if(typeof C!="number")throw new TypeError("Start time must be set to a number.");f=C,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return E},set:function(C){if(typeof C!="number")throw new TypeError("End time must be set to a number.");E=C,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return m},set:function(C){m=""+C,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return S},set:function(C){S=C,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return v},set:function(C){var D=r(C);if(D===!1)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");v=D,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return A},set:function(C){A=!!C,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return R},set:function(C){if(typeof C!="number"&&C!==n)throw new SyntaxError("Line: an invalid number or illegal string was specified.");R=C,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return L},set:function(C){var D=s(C);D?(L=D,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return M},set:function(C){if(C<0||C>100)throw new Error("Position must be between 0 and 100.");M=C,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return G},set:function(C){var D=s(C);D?(G=D,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return O},set:function(C){if(C<0||C>100)throw new Error("Size must be between 0 and 100.");O=C,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return w},set:function(C){var D=s(C);if(!D)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");w=D,this.hasBeenReset=!0}}}),this.displayState=void 0}return a.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)},vttcue=a,vttcue}var vttregion,hasRequiredVttregion;function requireVttregion(){if(hasRequiredVttregion)return vttregion;hasRequiredVttregion=1;var n={"":!0,up:!0};function e(s){if(typeof s!="string")return!1;var a=n[s.toLowerCase()];return a?s.toLowerCase():!1}function t(s){return typeof s=="number"&&s>=0&&s<=100}function r(){var s=100,a=3,l=0,u=100,c=0,d=100,p="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return s},set:function(f){if(!t(f))throw new Error("Width must be between 0 and 100.");s=f}},lines:{enumerable:!0,get:function(){return a},set:function(f){if(typeof f!="number")throw new TypeError("Lines must be set to a number.");a=f}},regionAnchorY:{enumerable:!0,get:function(){return u},set:function(f){if(!t(f))throw new Error("RegionAnchorX must be between 0 and 100.");u=f}},regionAnchorX:{enumerable:!0,get:function(){return l},set:function(f){if(!t(f))throw new Error("RegionAnchorY must be between 0 and 100.");l=f}},viewportAnchorY:{enumerable:!0,get:function(){return d},set:function(f){if(!t(f))throw new Error("ViewportAnchorY must be between 0 and 100.");d=f}},viewportAnchorX:{enumerable:!0,get:function(){return c},set:function(f){if(!t(f))throw new Error("ViewportAnchorX must be between 0 and 100.");c=f}},scroll:{enumerable:!0,get:function(){return p},set:function(f){var E=e(f);E===!1?console.warn("Scroll: an invalid or illegal string was specified."):p=E}}})}return vttregion=r,vttregion}var hasRequiredBrowserIndex;function requireBrowserIndex(){if(hasRequiredBrowserIndex)return browserIndex.exports;hasRequiredBrowserIndex=1;var n=requireWindow(),e=browserIndex.exports={WebVTT:requireVtt(),VTTCue:requireVttcue(),VTTRegion:requireVttregion()};n.vttjs=e,n.WebVTT=e.WebVTT;var t=e.VTTCue,r=e.VTTRegion,s=n.VTTCue,a=n.VTTRegion;return e.shim=function(){n.VTTCue=t,n.VTTRegion=r},e.restore=function(){n.VTTCue=s,n.VTTRegion=a},n.VTTCue||e.shim(),browserIndex.exports}var browserIndexExports=requireBrowserIndex();const vtt=getDefaultExportFromCjs(browserIndexExports);function _extends(){return _extends=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},_extends.apply(null,arguments)}var DEFAULT_LOCATION="https://example.com",resolveUrl$1=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=window$1.location&&window$1.location.href||"");var r=/^\/\//.test(e),s=!window$1.location&&!/\/\//i.test(e);e=new window$1.URL(e,window$1.location||DEFAULT_LOCATION);var a=new URL(t,e);return s?a.href.slice(DEFAULT_LOCATION.length):r?a.href.slice(a.protocol.length):a.href},Stream=(function(){function n(){this.listeners={}}var e=n.prototype;return e.on=function(r,s){this.listeners[r]||(this.listeners[r]=[]),this.listeners[r].push(s)},e.off=function(r,s){if(!this.listeners[r])return!1;var a=this.listeners[r].indexOf(s);return this.listeners[r]=this.listeners[r].slice(0),this.listeners[r].splice(a,1),a>-1},e.trigger=function(r){var s=this.listeners[r];if(s)if(arguments.length===2)for(var a=s.length,l=0;l<a;++l)s[l].call(this,arguments[1]);else for(var u=Array.prototype.slice.call(arguments,1),c=s.length,d=0;d<c;++d)s[d].apply(this,u)},e.dispose=function(){this.listeners={}},e.pipe=function(r){this.on("data",function(s){r.push(s)})},n})(),atob$1=function(e){return window$1.atob?window$1.atob(e):Buffer.from(e,"base64").toString("binary")};function decodeB64ToUint8Array(n){for(var e=atob$1(n),t=new Uint8Array(e.length),r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}/*! @name m3u8-parser @version 7.2.0 @license Apache-2.0 */class LineStream extends Stream{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf(`
`);t>-1;t=this.buffer.indexOf(`
`))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const TAB=" ",parseByterange=function(n){const e=/([0-9.]*)?@?([0-9.]*)?/.exec(n||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t},attributeSeparator=function(){const t="(?:"+"[^=]*"+")=(?:"+'"[^"]*"|[^,]*'+")";return new RegExp("(?:^|,)("+t+")")},parseAttributes$1=function(n){const e={};if(!n)return e;const t=n.split(attributeSeparator());let r=t.length,s;for(;r--;)t[r]!==""&&(s=/([^=]*)=(.*)/.exec(t[r]).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"),e[s[0]]=s[1]);return e},parseResolution=n=>{const e=n.split("x"),t={};return e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),t};class ParseStream extends Stream{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,r;if(e=e.trim(),e.length===0)return;if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((a,l)=>{const u=l(e);return u===e?a:a.concat([u])},[e]).forEach(a=>{for(let l=0;l<this.customParsers.length;l++)if(this.customParsers[l].call(this,a))return;if(a.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:a.slice(1)});return}if(a=a.replace("\r",""),t=/^#EXTM3U/.exec(a),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(a),t){r={type:"tag",tagType:"inf"},t[1]&&(r.duration=parseFloat(t[1])),t[2]&&(r.title=t[2]),this.trigger("data",r);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(a),t){r={type:"tag",tagType:"targetduration"},t[1]&&(r.duration=parseInt(t[1],10)),this.trigger("data",r);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(a),t){r={type:"tag",tagType:"version"},t[1]&&(r.version=parseInt(t[1],10)),this.trigger("data",r);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(a),t){r={type:"tag",tagType:"media-sequence"},t[1]&&(r.number=parseInt(t[1],10)),this.trigger("data",r);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(a),t){r={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(r.number=parseInt(t[1],10)),this.trigger("data",r);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(a),t){r={type:"tag",tagType:"playlist-type"},t[1]&&(r.playlistType=t[1]),this.trigger("data",r);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(a),t){r=_extends(parseByterange(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",r);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(a),t){r={type:"tag",tagType:"allow-cache"},t[1]&&(r.allowed=!/NO/.test(t[1])),this.trigger("data",r);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(a),t){if(r={type:"tag",tagType:"map"},t[1]){const l=parseAttributes$1(t[1]);l.URI&&(r.uri=l.URI),l.BYTERANGE&&(r.byterange=parseByterange(l.BYTERANGE))}this.trigger("data",r);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(a),t){r={type:"tag",tagType:"stream-inf"},t[1]&&(r.attributes=parseAttributes$1(t[1]),r.attributes.RESOLUTION&&(r.attributes.RESOLUTION=parseResolution(r.attributes.RESOLUTION)),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))),this.trigger("data",r);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(a),t){r={type:"tag",tagType:"media"},t[1]&&(r.attributes=parseAttributes$1(t[1])),this.trigger("data",r);return}if(t=/^#EXT-X-ENDLIST/.exec(a),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(a),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(a),t){r={type:"tag",tagType:"program-date-time"},t[1]&&(r.dateTimeString=t[1],r.dateTimeObject=new Date(t[1])),this.trigger("data",r);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(a),t){r={type:"tag",tagType:"key"},t[1]&&(r.attributes=parseAttributes$1(t[1]),r.attributes.IV&&(r.attributes.IV.substring(0,2).toLowerCase()==="0x"&&(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))),this.trigger("data",r);return}if(t=/^#EXT-X-START:(.*)$/.exec(a),t){r={type:"tag",tagType:"start"},t[1]&&(r.attributes=parseAttributes$1(t[1]),r.attributes["TIME-OFFSET"]=parseFloat(r.attributes["TIME-OFFSET"]),r.attributes.PRECISE=/YES/.test(r.attributes.PRECISE)),this.trigger("data",r);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(a),t){r={type:"tag",tagType:"cue-out-cont"},t[1]?r.data=t[1]:r.data="",this.trigger("data",r);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(a),t){r={type:"tag",tagType:"cue-out"},t[1]?r.data=t[1]:r.data="",this.trigger("data",r);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(a),t){r={type:"tag",tagType:"cue-in"},t[1]?r.data=t[1]:r.data="",this.trigger("data",r);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(a),t&&t[1]){r={type:"tag",tagType:"skip"},r.attributes=parseAttributes$1(t[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(TAB)),this.trigger("data",r);return}if(t=/^#EXT-X-PART:(.*)$/.exec(a),t&&t[1]){r={type:"tag",tagType:"part"},r.attributes=parseAttributes$1(t[1]),["DURATION"].forEach(function(l){r.attributes.hasOwnProperty(l)&&(r.attributes[l]=parseFloat(r.attributes[l]))}),["INDEPENDENT","GAP"].forEach(function(l){r.attributes.hasOwnProperty(l)&&(r.attributes[l]=/YES/.test(r.attributes[l]))}),r.attributes.hasOwnProperty("BYTERANGE")&&(r.attributes.byterange=parseByterange(r.attributes.BYTERANGE)),this.trigger("data",r);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(a),t&&t[1]){r={type:"tag",tagType:"server-control"},r.attributes=parseAttributes$1(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(l){r.attributes.hasOwnProperty(l)&&(r.attributes[l]=parseFloat(r.attributes[l]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(l){r.attributes.hasOwnProperty(l)&&(r.attributes[l]=/YES/.test(r.attributes[l]))}),this.trigger("data",r);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(a),t&&t[1]){r={type:"tag",tagType:"part-inf"},r.attributes=parseAttributes$1(t[1]),["PART-TARGET"].forEach(function(l){r.attributes.hasOwnProperty(l)&&(r.attributes[l]=parseFloat(r.attributes[l]))}),this.trigger("data",r);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(a),t&&t[1]){r={type:"tag",tagType:"preload-hint"},r.attributes=parseAttributes$1(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(l){if(r.attributes.hasOwnProperty(l)){r.attributes[l]=parseInt(r.attributes[l],10);const u=l==="BYTERANGE-LENGTH"?"length":"offset";r.attributes.byterange=r.attributes.byterange||{},r.attributes.byterange[u]=r.attributes[l],delete r.attributes[l]}}),this.trigger("data",r);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(a),t&&t[1]){r={type:"tag",tagType:"rendition-report"},r.attributes=parseAttributes$1(t[1]),["LAST-MSN","LAST-PART"].forEach(function(l){r.attributes.hasOwnProperty(l)&&(r.attributes[l]=parseInt(r.attributes[l],10))}),this.trigger("data",r);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(a),t&&t[1]){r={type:"tag",tagType:"daterange"},r.attributes=parseAttributes$1(t[1]),["ID","CLASS"].forEach(function(u){r.attributes.hasOwnProperty(u)&&(r.attributes[u]=String(r.attributes[u]))}),["START-DATE","END-DATE"].forEach(function(u){r.attributes.hasOwnProperty(u)&&(r.attributes[u]=new Date(r.attributes[u]))}),["DURATION","PLANNED-DURATION"].forEach(function(u){r.attributes.hasOwnProperty(u)&&(r.attributes[u]=parseFloat(r.attributes[u]))}),["END-ON-NEXT"].forEach(function(u){r.attributes.hasOwnProperty(u)&&(r.attributes[u]=/YES/i.test(r.attributes[u]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(u){r.attributes.hasOwnProperty(u)&&(r.attributes[u]=r.attributes[u].toString(16))});const l=/^X-([A-Z]+-)+[A-Z]+$/;for(const u in r.attributes){if(!l.test(u))continue;const c=/[0-9A-Fa-f]{6}/g.test(r.attributes[u]),d=/^\d+(\.\d+)?$/.test(r.attributes[u]);r.attributes[u]=c?r.attributes[u].toString(16):d?parseFloat(r.attributes[u]):String(r.attributes[u])}this.trigger("data",r);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(a),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(a),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(a),t){r={type:"tag",tagType:"content-steering"},r.attributes=parseAttributes$1(t[1]),this.trigger("data",r);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(a),t){r={type:"tag",tagType:"i-frame-playlist"},r.attributes=parseAttributes$1(t[1]),r.attributes.URI&&(r.uri=r.attributes.URI),r.attributes.BANDWIDTH&&(r.attributes.BANDWIDTH=parseInt(r.attributes.BANDWIDTH,10)),r.attributes.RESOLUTION&&(r.attributes.RESOLUTION=parseResolution(r.attributes.RESOLUTION)),r.attributes["AVERAGE-BANDWIDTH"]&&(r.attributes["AVERAGE-BANDWIDTH"]=parseInt(r.attributes["AVERAGE-BANDWIDTH"],10)),r.attributes["FRAME-RATE"]&&(r.attributes["FRAME-RATE"]=parseFloat(r.attributes["FRAME-RATE"])),this.trigger("data",r);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(a),t){r={type:"tag",tagType:"define"},r.attributes=parseAttributes$1(t[1]),this.trigger("data",r);return}this.trigger("data",{type:"tag",data:a.slice(4)})})}addParser({expression:e,customType:t,dataParser:r,segment:s}){typeof r!="function"&&(r=a=>a),this.customParsers.push(a=>{if(e.exec(a))return this.trigger("data",{type:"custom",data:r(a),customType:t,segment:s}),!0})}addTagMapper({expression:e,map:t}){const r=s=>e.test(s)?t(s):s;this.tagMappers.push(r)}}const camelCase=n=>n.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),camelCaseKeys=function(n){const e={};return Object.keys(n).forEach(function(t){e[camelCase(t)]=n[t]}),e},setHoldBack=function(n){const{serverControl:e,targetDuration:t,partTargetDuration:r}=n;if(!e)return;const s="#EXT-X-SERVER-CONTROL",a="holdBack",l="partHoldBack",u=t&&t*3,c=r&&r*2;t&&!e.hasOwnProperty(a)&&(e[a]=u,this.trigger("info",{message:`${s} defaulting HOLD-BACK to targetDuration * 3 (${u}).`})),u&&e[a]<u&&(this.trigger("warn",{message:`${s} clamping HOLD-BACK (${e[a]}) to targetDuration * 3 (${u})`}),e[a]=u),r&&!e.hasOwnProperty(l)&&(e[l]=r*3,this.trigger("info",{message:`${s} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[l]}).`})),r&&e[l]<c&&(this.trigger("warn",{message:`${s} clamping PART-HOLD-BACK (${e[l]}) to partTargetDuration * 2 (${c}).`}),e[l]=c)};class Parser extends Stream{constructor(e={}){super(),this.lineStream=new LineStream,this.parseStream=new ParseStream,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;const t=this,r=[];let s={},a,l,u=!1;const c=function(){},d={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},p="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let f=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let E=0,m=0;const S={};this.on("end",()=>{s.uri||!s.parts&&!s.preloadHints||(!s.map&&a&&(s.map=a),!s.key&&l&&(s.key=l),!s.timeline&&typeof f=="number"&&(s.timeline=f),this.manifest.preloadSegment=s)}),this.parseStream.on("data",function(v){let A,R;if(t.manifest.definitions){for(const L in t.manifest.definitions)if(v.uri&&(v.uri=v.uri.replace(`{$${L}}`,t.manifest.definitions[L])),v.attributes)for(const M in v.attributes)typeof v.attributes[M]=="string"&&(v.attributes[M]=v.attributes[M].replace(`{$${L}}`,t.manifest.definitions[L]))}({tag(){({version(){v.version&&(this.manifest.version=v.version)},"allow-cache"(){this.manifest.allowCache=v.allowed,"allowed"in v||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const L={};"length"in v&&(s.byterange=L,L.length=v.length,"offset"in v||(v.offset=E)),"offset"in v&&(s.byterange=L,L.offset=v.offset),E=L.offset+L.length},endlist(){this.manifest.endList=!0},inf(){"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"})),v.title&&(s.title=v.title),v.duration>0&&(s.duration=v.duration),v.duration===0&&(s.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=r},key(){if(!v.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(v.attributes.METHOD==="NONE"){l=null;return}if(!v.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(v.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:v.attributes};return}if(v.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:v.attributes.URI};return}if(v.attributes.KEYFORMAT===p){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(v.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(v.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),v.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(v.attributes.KEYID&&v.attributes.KEYID.substring(0,2)==="0x")){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:v.attributes.KEYFORMAT,keyId:v.attributes.KEYID.substring(2)},pssh:decodeB64ToUint8Array(v.attributes.URI.split(",")[1])};return}v.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),l={method:v.attributes.METHOD||"AES-128",uri:v.attributes.URI},typeof v.attributes.IV<"u"&&(l.iv=v.attributes.IV)},"media-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+v.number});return}this.manifest.mediaSequence=v.number},"discontinuity-sequence"(){if(!isFinite(v.number)){this.trigg