1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,171797,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.helmetJsonLdProp=r.jsonLdScriptProps=r.JsonLd=void 0;let i=e.r(271645);function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e,l,t.space)}}}r.JsonLd=function(e){return i.createElement("script",Object.assign({},s(e.item,e)))},r.jsonLdScriptProps=s,r.helmetJsonLdProp=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{type:"application/ld+json",innerHTML:JSON.stringify(e,l,t.space)}};let a=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),n=RegExp(`[${Object.keys(a).join("")}]`,"g"),o=e=>a[e],l=(e,t)=>{switch(typeof t){case"object":if(null===t)return;return t;case"number":case"boolean":case"bigint":return t;case"string":return t.replace(n,o);default:return}}},285206,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.jsonLdScriptProps=r.JsonLd=r.helmetJsonLdProp=void 0;var i=e.r(171797);Object.defineProperty(r,"helmetJsonLdProp",{enumerable:!0,get:function(){return i.helmetJsonLdProp}}),Object.defineProperty(r,"JsonLd",{enumerable:!0,get:function(){return i.JsonLd}}),Object.defineProperty(r,"jsonLdScriptProps",{enumerable:!0,get:function(){return i.jsonLdScriptProps}})},958818,209096,e=>{"use strict";e.s([],958818),e.s(["default",()=>i],209096);var t=e.i(857727),r=e.i(285206);function i(e){return(0,t.jsx)("script",{...(0,r.jsonLdScriptProps)({"@context":"https://schema.org","@graph":e.item}),"data-testid":"product-jsonld"})}},991791,e=>{e.v({leaderboardAdContainer:"LeaderboardAdContainer-module__pVdecG__leaderboardAdContainer",leaderboardHomepage:"LeaderboardAdContainer-module__pVdecG__leaderboardHomepage",leaderboardPortal:"LeaderboardAdContainer-module__pVdecG__leaderboardPortal"})},882183,e=>{"use strict";e.s(["default",()=>o]);var t=e.i(857727),r=e.i(575726),i=e.i(236692),s=e.i(245685),a=e.i(207670),n=e.i(991791);function o(e){let{id:o,index:l=1,path:h,changeToMrec:d,variant:u,isHomePage:c}=e,f=(0,s.default)(`(max-width: ${i.BREAKPOINT_MD}px)`);return(0,t.jsx)("div",{id:o,className:(0,a.default)(n.default.leaderboardAdContainer,c&&n.default.leaderboardHomepage),"data-variant":u,"data-adslot":`ad-slot-${l}`,children:(0,t.jsx)(r.default,{"data-testid":"leaderBoardAdUnit",id:l,path:h,smallMrecOnly:d??f??!0,variant:u})})}},107917,e=>{"use strict";e.s(["default",()=>r]);var t=e.i(857727);let r=e=>{let{config:r}=e,{accountID:i,applicationID:s,licenseKey:a}=r;return(0,t.jsx)("script",{id:"newrelic-agent",dangerouslySetInnerHTML:function(e){let{sa:t=1,beacon:r="bam.nr-data.net",errorBeacon:i="bam.nr-data.net",accountID:s,licenseKey:a,applicationID:n}=e;return{__html:`;window.NREUM||(NREUM={});NREUM.init={session_replay:{enabled:true,block_selector:'',mask_text_selector:'*',sampling_rate:10.0,error_sampling_rate:100.0,mask_all_inputs:true,collect_fonts:true,inline_images:false,inline_stylesheet:true,fix_stylesheets:true,mask_input_options:{}},privacy:{cookies_enabled:true},ajax:{deny_list:["bam-cell.nr-data.net", "*"]}}; 2 ;NREUM.loader_config={accountID:"${s}",trustKey:"${s}",agentID:"${n}",licenseKey:"${a}",applicationID:"${n}"}; 3 ;NREUM.info={beacon:"${r}",errorBeacon:"${i}",licenseKey:"${a}",applicationID:"${n}",sa:${t}}; 4 ;/*! For license information please see nr-loader-spa-1.281.0.min.js.LICENSE.txt */ 5 (()=>{var e,t,r={8122:(e,t,r)=>{"use strict";r.d(t,{a:()=>i});var n=r(944);function i(e,t){try{if(!e||"object"!=typeof e)return(0,n.R)(3);if(!t||"object"!=typeof t)return(0,n.R)(4);const r=Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t)),o=0===Object.keys(r).length?e:r;for(let a in o)if(void 0!==e[a])try{if(null===e[a]){r[a]=null;continue}Array.isArray(e[a])&&Array.isArray(t[a])?r[a]=Array.from(new Set([...e[a],...t[a]])):"object"==typeof e[a]&&"object"==typeof t[a]?r[a]=i(e[a],t[a]):r[a]=e[a]}catch(e){(0,n.R)(1,e)}return r}catch(e){(0,n.R)(2,e)}}},2555:(e,t,r)=>{"use strict";r.d(t,{Vp:()=>c,fn:()=>s,x1:()=>u});var n=r(384),i=r(8122);const o={beacon:n.NT.beacon,errorBeacon:n.NT.errorBeacon,licenseKey:void 0,applicationID:void 0,sa:void 0,queueTime:void 0,applicationTime:void 0,ttGuid:void 0,user:void 0,account:void 0,product:void 0,extra:void 0,jsAttributes:{},userAttributes:void 0,atts:void 0,transactionName:void 0,tNamePlain:void 0},a={};function s(e){try{const t=c(e);return!!t.licenseKey&&!!t.errorBeacon&&!!t.applicationID}catch(e){return!1}}function c(e){if(!e)throw new Error("All info objects require an agent identifier!");if(!a[e])throw new Error("Info for ".concat(e," was never set"));return a[e]}function u(e,t){if(!e)throw new Error("All info objects require an agent identifier!");a[e]=(0,i.a)(t,o);const r=(0,n.nY)(e);r&&(r.info=a[e])}},9417:(e,t,r)=>{"use strict";r.d(t,{D0:()=>p,gD:()=>m,xN:()=>g});var n=r(3333),i=r(993);const o=e=>{if(!e||"string"!=typeof e)return!1;try{document.createDocumentFragment().querySelector(e)}catch{return!1}return!0};var a=r(2614),s=r(944),c=r(384),u=r(8122);const d="[data-nr-mask]",l=()=>{const e={feature_flags:[],experimental:{marks:!1,measures:!1,resources:!1},mask_selector:"*",block_selector:"[data-nr-block]",mask_input_options:{color:!1,date:!1,"datetime-local":!1,email:!1,month:!1,number:!1,range:!1,search:!1,tel:!1,text:!1,time:!1,url:!1,week:!1,textarea:!1,select:!1,password:!0}};return{ajax:{deny_list:void 0,block_internal:!0,enabled:!0,autoStart:!0},distributed_tracing:{enabled:void 0,exclude_newrelic_header:void 0,cors_use_newrelic_header:void 0,cors_use_tracecontext_headers:void 0,allowed_origins:void 0},get feature_flags(){return e.feature_flags},set feature_flags(t){e.feature_flags=t},generic_events:{enabled:!0,autoStart:!0},harvest:{interval:30},jserrors:{enabled:!0,autoStart:!0},logging:{enabled:!0,autoStart:!0,level:i.p_.INFO},metrics:{enabled:!0,autoStart:!0},obfuscate:void 0,page_action:{enabled:!0},page_view_event:{enabled:!0,autoStart:!0},page_view_timing:{enabled:!0,autoStart:!0},performance:{get capture_marks(){return e.feature_flags.includes(n.$v.MARKS)||e.experimental.marks},set capture_marks(t){e.experimental.marks=t},get capture_measures(){return e.feature_flags.includes(n.$v.MEASURES)||e.experimental.measures},set capture_measures(t){e.experimental.measures=t},capture_detail:!0,resources:{get enabled(){return e.feature_flags.includes(n.$v.RESOURCES)||e.experimental.resources},set enabled(t){e.experimental.resources=t},asset_types:[],first_party_domains:[],ignore_newrelic:!0}},privacy:{cookies_enabled:!0},proxy:{assets:void 0,beacon:void 0},session:{expiresMs:a.wk,inactiveMs:a.BB},session_replay:{autoStart:!0,enabled:!1,preload:!1,sampling_rate:10,error_sampling_rate:100,collect_fonts:!1,inl
5ine_images:!1,fix_stylesheets:!0,mask_all_inputs:!0,get mask_text_selector(){return e.mask_selector},set mask_text_selector(t){o(t)?e.mask_selector="".concat(t,",").concat(d):""===t||null===t?e.mask_selector=d:(0,s.R)(5,t)},get block_class(){return"nr-block"},get ignore_class(){return"nr-ignore"},get mask_text_class(){return"nr-mask"},get block_selector(){return e.block_selector},set block_selector(t){o(t)?e.block_selector+=",".concat(t):""!==t&&(0,s.R)(6,t)},get mask_input_options(){return e.mask_input_options},set mask_input_options(t){t&&"object"==typeof t?e.mask_input_options={...t,password:!0}:(0,s.R)(7,t)}},session_trace:{enabled:!0,autoStart:!0},soft_navigations:{enabled:!0,autoStart:!0},spa:{enabled:!0,autoStart:!0},ssl:void 0,user_actions:{enabled:!0,elementAttributes:["id","className","tagName","type"]}}},f={},h="All configuration objects require an agent identifier!";function p(e){if(!e)throw new Error(h);if(!f[e])throw new Error("Configuration for ".concat(e," was never set"));return f[e]}function g(e,t){if(!e)throw new Error(h);f[e]=(0,u.a)(t,l());const r=(0,c.nY)(e);r&&(r.init=f[e])}function m(e,t){if(!e)throw new Error(h);var r=p(e);if(r){for(var n=t.split("."),i=0;i<n.length-1;i++)if("object"!=typeof(r=r[n[i]]))return;r=r[n[n.length-1]]}return r}},5603:(e,t,r)=>{"use strict";r.d(t,{a:()=>c,o:()=>s});var n=r(384),i=r(8122);const o={accountID:void 0,trustKey:void 0,agentID:void 0,licenseKey:void 0,applicationID:void 0,xpid:void 0},a={};function s(e){if(!e)throw new Error("All loader-config objects require an agent identifier!");if(!a[e])throw new Error("LoaderConfig for ".concat(e," was never set"));return a[e]}function c(e,t){if(!e)throw new Error("All loader-config objects require an agent identifier!");a[e]=(0,i.a)(t,o);const r=(0,n.nY)(e);r&&(r.loader_config=a[e])}},3371:(e,t,r)=>{"use strict";r.d(t,{V:()=>f,f:()=>l});var n=r(8122),i=r(384),o=r(6154),a=r(9324);let s=0;const c={buildEnv:a.F3,distMethod:a.Xs,version:a.xv,originTime:o.WN},u={customTransaction:void 0,disabled:!1,isolatedBacklog:!1,loaderType:void 0,maxBytes:3e4,onerror:void 0,ptid:void 0,releaseIds:{},appMetadata:{},session:void 0,denyList:void 0,timeKeeper:void 0,obfuscator:void 0,harvester:void 0},d={};function l(e){if(!e)throw new Error("All runtime objects require an agent identifier!");if(!d[e])throw new Error("Runtime for ".concat(e," was never set"));return d[e]}function f(e,t){if(!e)throw new Error("All runtime objects require an agent identifier!");d[e]={...(0,n.a)(t,u),...c},Object.hasOwnProperty.call(d[e],"harvestCount")||Object.defineProperty(d[e],"harvestCount",{get:()=>++s});const r=(0,i.nY)(e);r&&(r.runtime=d[e])}},9324:(e,t,r)=>{"use strict";r.d(t,{F3:()=>i,Xs:()=>o,Yq:()=>a,xv:()=>n});const n="1.281.0",i="PROD",o="CDN",a="^2.0.0-alpha.17"},6154:(e,t,r)=>{"use strict";r.d(t,{A4:()=>s,OF:()=>d,RI:()=>i,WN:()=>h,bv:()=>o,gm:()=>a,lR:()=>f,m:()=>u,mw:()=>c,sb:()=>l});var n=r(1863);const i="undefined"!=typeof window&&!!window.document,o="undefined"!=typeof WorkerGlobalScope&&("undefined"!=typeof self&&self instanceof WorkerGlobalScope&&self.navigator instanceof WorkerNavigator||"undefined"!=typeof globalThis&&globalThis instanceof WorkerGlobalScope&&globalThis.navigator instanceof WorkerNavigator),a=i?window:"undefined"!=typeof WorkerGlobalScope&&("undefined"!=typeof self&&self instanceof WorkerGlobalScope&&self||"undefined"!=typeof globalThis&&globalThis instanceof WorkerGlobalScope&&globalThis),s="complete"===a?.document?.readyState,c=Boolean("hidden"===a?.document?.visibilityState),u=""+a?.location,d=/iPad|iPhone|iPod/.test(a.navigator?.userAgent),l=d&&"undefined"==typeof SharedWorker,f=(()=>{const e=a.navigator?.userAgent?.match(/Firefox[/\\s](\\d+\\.\\d+)/);return Array.isArray(e)&&e.length>=2?+e[1]:0})(),h=Date.now()-(0,n.t)()},7295:(e,t,r)=>{"use strict";r.d(t,{Xv:()=>a,gX:()=>i,iW:()=>o});var n=[];function i(e){if(!e||o(e))return!1;if(0===n.length)return!0;for(var t=0;t<n.length;t++){var r=n[t];if("*"===r.hostname)return!1;if(s(r.hostname,e.hostname)&&c(r.pathname,e.pathname))return!1}return!0}function o(e){return void 0===e.hostname}function a(e){if(n=[],e&&e.length)for(var t=0;t<e.length;t++){let r=e[t];if(!r)continue;0===r.indexOf("http://")?r=r.substring(7):0===r.indexOf("https://")&&(r=r.substring(8));const i=r.indexOf("/");let o,a;i>0?(o=r.substring(0,i),a=r.substring(i)):(o=r,a="");let[s]=o.split(":");n.push({hostname:s,pathname:a})}}function s(e,t){return!(e.length>t.length)&&t.indexOf(e)===t.length-e.length}function c(e,t){return 0===e.indexOf("/")&&(e=e.substring(1)),0===t.indexOf("/")&&(t=t.
5substring(1)),""===e||e===t}},1687:(e,t,r)=>{"use strict";r.d(t,{Ak:()=>c,Ze:()=>l,x3:()=>u});var n=r(7836),i=r(3606),o=r(860),a=r(2646);const s={};function c(e,t){const r={staged:!1,priority:o.P3[t]||0};d(e),s[e].get(t)||s[e].set(t,r)}function u(e,t){e&&s[e]&&(s[e].get(t)&&s[e].delete(t),h(e,t,!1),s[e].size&&f(e))}function d(e){if(!e)throw new Error("agentIdentifier required");s[e]||(s[e]=new Map)}function l(e="",t="feature",r=!1){if(d(e),!e||!s[e].get(t)||r)return h(e,t);s[e].get(t).staged=!0,f(e)}function f(e){const t=Array.from(s[e]);t.every((([e,t])=>t.staged))&&(t.sort(((e,t)=>e[1].priority-t[1].priority)),t.forEach((([t])=>{s[e].delete(t),h(e,t)})))}function h(e,t,r=!0){const o=e?n.ee.get(e):n.ee,s=i.i.handlers;if(!o.aborted&&o.backlog&&s){if(r){const e=o.backlog[t],r=s[t];if(r){for(let t=0;e&&t<e.length;++t)p(e[t],r);Object.entries(r).forEach((([e,t])=>{Object.values(t||{}).forEach((t=>{t[0]?.on&&t[0]?.context()instanceof a.y&&t[0].on(e,t[1])}))}))}}o.isolatedBacklog||delete s[t],o.backlog[t]=null,o.emit("drain-"+t,[])}}function p(e,t){var r=e[1];Object.values(t[r]||{}).forEach((t=>{var r=e[0];if(t[0]===r){var n=t[1],i=e[3],o=e[2];n.apply(i,o)}}))}},7836:(e,t,r)=>{"use strict";r.d(t,{P:()=>c,ee:()=>u});var n=r(384),i=r(8990),o=r(3371),a=r(2646),s=r(5607);const c="nr@context:".concat(s.W),u=function e(t,r){var n={},s={},d={},l=!1;try{l=16===r.length&&(0,o.f)(r).isolatedBacklog}catch(e){}var f={on:p,addEventListener:p,removeEventListener:function(e,t){var r=n[e];if(!r)return;for(var i=0;i<r.length;i++)r[i]===t&&r.splice(i,1)},emit:function(e,r,n,i,o){!1!==o&&(o=!0);if(u.aborted&&!i)return;t&&o&&t.emit(e,r,n);for(var a=h(n),c=g(e),d=c.length,l=0;l<d;l++)c[l].apply(a,r);var p=v()[s[e]];p&&p.push([f,e,r,a]);return a},get:m,listeners:g,context:h,buffer:function(e,t){const r=v();if(t=t||"feature",f.aborted)return;Object.entries(e||{}).forEach((([e,n])=>{s[n]=t,t in r||(r[t]=[])}))},abort:function(){f._aborted=!0,Object.keys(f.backlog).forEach((e=>{delete f.backlog[e]}))},isBuffering:function(e){return!!v()[s[e]]},debugId:r,backlog:l?{}:t&&"object"==typeof t.backlog?t.backlog:{},isolatedBacklog:l};return Object.defineProperty(f,"aborted",{get:()=>{let e=f._aborted||!1;return e||(t&&(e=t.aborted),e)}}),f;function h(e){return e&&e instanceof a.y?e:e?(0,i.I)(e,c,(()=>new a.y(c))):new a.y(c)}function p(e,t){n[e]=g(e).concat(t)}function g(e){return n[e]||[]}function m(t){return d[t]=d[t]||e(f,t)}function v(){return f.backlog}}(void 0,"globalEE"),d=(0,n.Zm)();d.ee||(d.ee=u)},2646:(e,t,r)=>{"use strict";r.d(t,{y:()=>n});class n{constructor(e){this.contextId=e}}},9908:(e,t,r)=>{"use strict";r.d(t,{d:()=>n,p:()=>i});var n=r(7836).ee.get("handle");function i(e,t,r,i,o){o?(o.buffer([e],i),o.emit(e,t,r)):(n.buffer([e],i),n.emit(e,t,r))}},3606:(e,t,r)=>{"use strict";r.d(t,{i:()=>o});var n=r(9908);o.on=a;var i=o.handlers={};function o(e,t,r,o){a(o||n.d,i,e,t,r)}function a(e,t,r,i,o){o||(o="feature"),e||(e=n.d);var a=t[o]=t[o]||{};(a[r]=a[r]||[]).push([e,i])}},3878:(e,t,r)=>{"use strict";function n(e,t){return{capture:e,passive:!1,signal:t}}function i(e,t,r=!1,i){window.addEventListener(e,t,n(r,i))}function o(e,t,r=!1,i){document.addEventListener(e,t,n(r,i))}r.d(t,{DD:()=>o,jT:()=>n,sp:()=>i})},5607:(e,t,r)=>{"use strict";r.d(t,{W:()=>n});const n=(0,r(9566).bz)()},9566:(e,t,r)=>{"use strict";r.d(t,{LA:()=>s,ZF:()=>c,bz:()=>a,el:()=>u});var n=r(6154);const i="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";function o(e,t){return e?15&e[t]:16*Math.random()|0}function a(){const e=n.gm?.crypto||n.gm?.msCrypto;let t,r=0;return e&&e.getRandomValues&&(t=e.getRandomValues(new Uint8Array(30))),i.split("").map((e=>"x"===e?o(t,r++).toString(16):"y"===e?(3&o()|8).toString(16):e)).join("")}function s(e){const t=n.gm?.crypto||n.gm?.msCrypto;let r,i=0;t&&t.getRandomValues&&(r=t.getRandomValues(new Uint8Array(e)));const a=[];for(var s=0;s<e;s++)a.push(o(r,i++).toString(16));return a.join("")}function c(){return s(16)}function u(){return s(32)}},2614:(e,t,r)=>{"use strict";r.d(t,{BB:()=>a,H3:()=>n,g:()=>u,iL:()=>c,tS:()=>s,uh:()=>i,wk:()=>o});const n="NRBA",i="SESSION",o=144e5,a=18e5,s={STARTED:"session-started",PAUSE:"session-pause",RESET:"session-reset",RESUME:"session-resume",UPDATE:"session-update"},c={SAME_TAB:"same-tab",CROSS_TAB:"cross-tab"}
5,u={OFF:0,FULL:1,ERROR:2}},1863:(e,t,r)=>{"use strict";function n(){return Math.floor(performance.now())}r.d(t,{t:()=>n})},7485:(e,t,r)=>{"use strict";r.d(t,{D:()=>i});var n=r(6154);function i(e){if(0===(e||"").indexOf("data:"))return{protocol:"data"};try{const t=new URL(e,location.href),r={port:t.port,hostname:t.hostname,pathname:t.pathname,search:t.search,protocol:t.protocol.slice(0,t.protocol.indexOf(":")),sameOrigin:t.protocol===n.gm?.location?.protocol&&t.host===n.gm?.location?.host};return r.port&&""!==r.port||("http:"===t.protocol&&(r.port="80"),"https:"===t.protocol&&(r.port="443")),r.pathname&&""!==r.pathname?r.pathname.startsWith("/")||(r.pathname="/".concat(r.pathname)):r.pathname="/",r}catch(e){return{}}}},944:(e,t,r)=>{"use strict";function n(e,t){"function"==typeof console.debug&&console.debug("New Relic Warning: https://github.com/newrelic/newrelic-browser-agent/blob/main/docs/warning-codes.md#".concat(e),t)}r.d(t,{R:()=>n})},5284:(e,t,r)=>{"use strict";r.d(t,{t:()=>c,B:()=>s});var n=r(7836),i=r(6154);const o="newrelic";const a=new Set,s={};function c(e,t){const r=n.ee.get(t);s[t]??={},e&&"object"==typeof e&&(a.has(t)||(r.emit("rumresp",[e]),s[t]=e,a.add(t),function(e={}){try{i.gm.dispatchEvent(new CustomEvent(o,{detail:e}))}catch(e){}}({loaded:!0})))}},8990:(e,t,r)=>{"use strict";r.d(t,{I:()=>i});var n=Object.prototype.hasOwnProperty;function i(e,t,r){if(n.call(e,t))return e[t];var i=r();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(e,t,{value:i,writable:!0,enumerable:!1}),i}catch(e){}return e[t]=i,i}},6389:(e,t,r)=>{"use strict";function n(e,t=500,r={}){const n=r?.leading||!1;let i;return(...r)=>{n&&void 0===i&&(e.apply(this,r),i=setTimeout((()=>{i=clearTimeout(i)}),t)),n||(clearTimeout(i),i=setTimeout((()=>{e.apply(this,r)}),t))}}function i(e){let t=!1;return(...r)=>{t||(t=!0,e.apply(this,r))}}r.d(t,{J:()=>i,s:()=>n})},3304:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=r(7836);const i=()=>{const e=new WeakSet;return(t,r)=>{if("object"==typeof r&&null!==r){if(e.has(r))return;e.add(r)}return r}};function o(e){try{return JSON.stringify(e,i())??""}catch(e){try{n.ee.emit("internal-error",[e])}catch(e){}return""}}},5289:(e,t,r)=>{"use strict";r.d(t,{GG:()=>o,sB:()=>a});var n=r(3878);function i(){return"undefined"==typeof document||"complete"===document.readyState}function o(e,t){if(i())return e();(0,n.sp)("load",e,t)}function a(e){if(i())return e();(0,n.DD)("DOMContentLoaded",e)}},384:(e,t,r)=>{"use strict";r.d(t,{NT:()=>o,US:()=>d,Zm:()=>a,bQ:()=>c,dV:()=>s,nY:()=>u,pV:()=>l});var n=r(6154),i=r(1863);const o={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net"};function a(){return n.gm.NREUM||(n.gm.NREUM={}),void 0===n.gm.newrelic&&(n.gm.newrelic=n.gm.NREUM),n.gm.NREUM}function s(){let e=a();return e.o||(e.o={ST:n.gm.setTimeout,SI:n.gm.setImmediate,CT:n.gm.clearTimeout,XHR:n.gm.XMLHttpRequest,REQ:n.gm.Request,EV:n.gm.Event,PR:n.gm.Promise,MO:n.gm.MutationObserver,FETCH:n.gm.fetch,WS:n.gm.WebSocket}),e}function c(e,t){let r=a();r.initializedAgents??={},t.initializedAt={ms:(0,i.t)(),date:new Date},r.initializedAgents[e]=t}function u(e){let t=a();return t.initializedAgents?.[e]}function d(e,t){a()[e]=t}function l(){return function(){let e=a();const t=e.info||{};e.info={beacon:o.beacon,errorBeacon:o.errorBeacon,...t}}(),function(){let e=a();const t=e.init||{};e.init={...t}}(),s(),function(){let e=a();const t=e.loader_config||{};e.loader_config={...t}}(),a()}},2843:(e,t,r)=>{"use strict";r.d(t,{u:()=>i});var n=r(3878);function i(e,t=!1,r,i){(0,n.DD)("visibilitychange",(function(){if(t)return void("hidden"===document.visibilityState&&e());e(document.visibilityState)}),r,i)}},8139:(e,t,r)=>{"use strict";r.d(t,{u:()=>f});var n=r(7836),i=r(3434),o=r(8990),a=r(6154);const s={},c=a.gm.XMLHttpRequest,u="addEventListener",d="removeEventListener",l="nr@wrapped:".concat(n.P);function f(e){var t=function(e){return(e||n.ee).get("events")}(e);if(s[t.debugId]++)return t;s[t.debugId]=1;var r=(0,i.YM)(t,!0);function f(e){r.inPlace(e,[u,d],"-",p)}function p(e,t){return e[1]}return"getPrototypeOf"in Object&&(a.RI&&h(document,f),c&&h(c.prototype,f),h(a.gm,f)),t.on(u+"-start",(function(e,t){var n=e[1];if(null!==n&&("function"==typeof n||"object"==typeof n)){var i=(0,o.I)(n,l,(function(){var e={object:function(){if("function"!=typeof n.handleEvent)return;return n.handleEvent.apply(n,arguments)},function:n}[typeof n];return e?r(e,"fn-",null,e.name||"anonymous"):n}));this.wrapped=e[1]=i}})),t.on(d+"-start",(function(e){e[1]=this.wrapped||e[1]})),t}function h(e,t,...r){let n=e;for(;"object"==typeof n&&!Object.prototype.hasOwnProperty.call(n,u);)n=Object.getPrototypeOf(n);n&&t(n,...r)}},3434:(e,t,r)=>{"use strict";r.d(t,{Jt:()=>o,YM:()=>c});var n=r(7836),i=r(5607);const o="nr@original:".concat(i.W);var a=Object.prototype.hasOwnProperty,s=!1;function c(e,t){return e||(e=n.ee),r.inPlace=function(e,t,n,i,o){n||(n="");const a="-"===n.charAt(0);for(let s=0;s<t.length;s++){const c=t[s],u=e[c];d(u)||(e[c]=r(u,a?c+n:n,i,c,o))}},r.flag=o,r;function r(t,r,n,s,c){return d(t)?t:(r||(r=""),nrWrapper[o]=t,function(e,t,r){if(Object.defineProperty&&Object.keys)try{return Object.keys(e).forEach((function(r){Object.defineProperty(t,r,{get:function(){return e[r]},set:function(t){return e[r]=t,t}})})),t}catch(e){u([e],r)}for(var n in e)a.call(e,n)&&(t[n]=e[n])}
5(t,nrWrapper,e),nrWrapper);function nrWrapper(){var o,a,d,l;try{a=this,o=[...arguments],d="function"==typeof n?n(o,a):n||{}}catch(t){u([t,"",[o,a,s],d],e)}i(r+"start",[o,a,s],d,c);try{return l=t.apply(a,o)}catch(e){throw i(r+"err",[o,a,e],d,c),e}finally{i(r+"end",[o,a,l],d,c)}}}function i(r,n,i,o){if(!s||t){var a=s;s=!0;try{e.emit(r,n,i,t,o)}catch(t){u([t,r,n,i],e)}s=a}}}function u(e,t){t||(t=n.ee);try{t.emit("internal-error",e)}catch(e){}}function d(e){return!(e&&"function"==typeof e&&e.apply&&!e[o])}},9300:(e,t,r)=>{"use strict";r.d(t,{T:()=>n});const n=r(860).K7.ajax},3333:(e,t,r)=>{"use strict";r.d(t,{$v:()=>u,TZ:()=>n,Zp:()=>i,kd:()=>c,mq:()=>s,nf:()=>a,qN:()=>o});const n=r(860).K7.genericEvents,i=["auxclick","click","copy","keydown","paste","scrollend"],o=["focus","blur"],a=4,s=1e3,c=["PageAction","UserAction","BrowserPerformance"],u={MARKS:"experimental.marks",MEASURES:"experimental.measures",RESOURCES:"experimental.resources"}},6774:(e,t,r)=>{"use strict";r.d(t,{T:()=>n});const n=r(860).K7.jserrors},993:(e,t,r)=>{"use strict";r.d(t,{ET:()=>o,TZ:()=>a,p_:()=>i});var n=r(860);const i={ERROR:"ERROR",WARN:"WARN",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"},o="log",a=n.K7.logging},3785:(e,t,r)=>{"use strict";r.d(t,{R:()=>c,b:()=>u});var n=r(9908),i=r(1863),o=r(860),a=r(3969),s=r(993);function c(e,t,r={},c=s.p_.INFO){(0,n.p)(a.xV,["API/logging/".concat(c.toLowerCase(),"/called")],void 0,o.K7.metrics,e),(0,n.p)(s.ET,[(0,i.t)(),t,r,c],void 0,o.K7.logging,e)}function u(e){return"string"==typeof e&&Object.values(s.p_).some((t=>t===e.toUpperCase().trim()))}},3969:(e,t,r)=>{"use strict";r.d(t,{TZ:()=>n,XG:()=>s,rs:()=>i,xV:()=>a,z_:()=>o});const n=r(860).K7.metrics,i="sm",o="cm",a="storeSupportabilityMetrics",s="storeEventMetrics"},6630:(e,t,r)=>{"use strict";r.d(t,{T:()=>n});const n=r(860).K7.pageViewEvent},782:(e,t,r)=>{"use strict";r.d(t,{T:()=>n});const n=r(860).K7.pageViewTiming},6344:(e,t,r)=>{"use strict";r.d(t,{BB:()=>d,G4:()=>o,Qb:()=>l,TZ:()=>i,Ug:()=>a,_s:()=>s,bc:()=>u,yP:()=>c});var n=r(2614);const i=r(860).K7.sessionReplay,o={RECORD:"recordReplay",PAUSE:"pauseReplay",REPLAY_RUNNING:"replayRunning",ERROR_DURING_REPLAY:"errorDuringReplay"},a=.12,s={DomContentLoaded:0,Load:1,FullSnapshot:2,IncrementalSnapshot:3,Meta:4,Custom:5},c={[n.g.ERROR]:15e3,[n.g.FULL]:3e5,[n.g.OFF]:0}
5,u={RESET:{message:"Session was reset",sm:"Reset"},IMPORT:{message:"Recorder failed to import",sm:"Import"},TOO_MANY:{message:"429: Too Many Requests",sm:"Too-Many"},TOO_BIG:{message:"Payload was too large",sm:"Too-Big"},CROSS_TAB:{message:"Session Entity was set to OFF on another tab",sm:"Cross-Tab"},ENTITLEMENTS:{message:"Session Replay is not allowed and will not be started",sm:"Entitlement"}},d=5e3,l={API:"api"}},5270:(e,t,r)=>{"use strict";r.d(t,{Aw:()=>c,CT:()=>u,SR:()=>s});var n=r(384),i=r(9417),o=r(7767),a=r(6154);function s(e){return!!(0,n.dV)().o.MO&&(0,o.V)(e)&&!0===(0,i.gD)(e,"session_trace.enabled")}function c(e){return!0===(0,i.gD)(e,"session_replay.preload")&&s(e)}function u(e,t){const r=t.correctAbsoluteTimestamp(e);return{originalTimestamp:e,correctedTimestamp:r,timestampDiff:e-r,originTime:a.WN,correctedOriginTime:t.correctedOriginTime,originTimeDiff:Math.floor(a.WN-t.correctedOriginTime)}}},3738:(e,t,r)=>{"use strict";r.d(t,{He:()=>i,Kp:()=>s,Lc:()=>u,Rz:()=>d,TZ:()=>n,bD:()=>o,d3:()=>a,jx:()=>l,uP:()=>c});const n=r(860).K7.sessionTrace,i="bstResource",o="resource",a="-start",s="-end",c="fn"+a,u="fn"+s,d="pushState",l=1e3},3962:(e,t,r)=>{"use strict";r.d(t,{AM:()=>o,O2:()=>c,Qu:()=>u,TZ:()=>s,ih:()=>d,pP:()=>a,tC:()=>i});var n=r(860);const i=["click","keydown","submit","popstate"],o="api",a="initialPageLoad",s=n.K7.softNav,c={INITIAL_PAGE_LOAD:"",ROUTE_CHANGE:1,UNSPECIFIED:2},u={INTERACTION:1,AJAX:2,CUSTOM_END:3,CUSTOM_TRACER:4},d={IP:"in progress",FIN:"finished",CAN:"cancelled"}},7378:(e,t,r)=>{"use strict";r.d(t,{$p:()=>x,BR:()=>b,Kp:()=>R,L3:()=>y,Lc:()=>c,NC:()=>o,SG:()=>d,TZ:()=>i,U6:()=>p,UT:()=>m,d3:()=>w,dT:()=>f,e5:()=>T,gx:()=>v,l9:()=>l,oW:()=>h,op:()=>g,rw:()=>u,tH:()=>A,uP:()=>s,wW:()=>E,xq:()=>a});var n=r(384);const i=r(860).K7.spa,o=["click","submit","keypress","keydown","keyup","change"],a=999,s="fn-start",c="fn-end",u="cb-start",d="api-ixn-",l="remaining",f="interaction",h="spaNode",p="jsonpNode",g="fetch-start",m="fetch-done",v="fetch-body-",b="jsonp-end",y=(0,n.dV)().o.ST,w="-start",R="-end",x="-body",E="cb"+R,T="jsTime",A="fetch"},4234:(e,t,r)=>{"use strict";r.d(t,{W:()=>o});var n=r(7836),i=r(1687);class o{constructor(e,t){this.agentIdentifier=e,this.ee=n.ee.get(e),this.featureName=t,this.blocked=!1}deregisterDrain(){(0,i.x3)(this.agentIdentifier,this.featureName)}}},7767:(e,t,r)=>{"use strict";r.d(t,{V:()=>o});var n=r(9417),i=r(6154);const o=e=>i.RI&&!0===(0,n.gD)(e,"privacy.cookies_enabled")},425:(e,t,r)=>{"use strict";r.d(t,{j:()=>j});var n=r(860),i=r(2555),o=r(3371),a=r(9908),s=r(7836),c=r(1687),u=r(5289),d=r(6154),l=r(944),f=r(3969),h=r(384),p=r(6344);const g=["setErrorHandler","finished","addToTrace","addRelease","recordCustomEvent","addPageAction","setCurrentRouteName","setPageViewName","setCustomAttribute","interaction","noticeError","setUserId","setApplicationVersion","start",p.G4.RECORD,p.G4.PAUSE,"log","wrapLogger"],m=["setErrorHandler","finished","addToTrace","addRelease"];var v=r(1863),b=r(2614),y=r(993),w=r(3785),R=r(2646),x=r(3434);const E=new Map;function T(e,t,r,n){if("object"!=typeof t||!t||"string"!=typeof r||!r||"function"!=typeof t[r])return(0,l.R)(29);const i=function(e){return(e||s.ee).get("logger")}(e),o=(0,x.YM)(i),a=new R.y(s.P);a.level=n.level,a.customAttributes=n.customAttributes;const c=t[r]?.[x.Jt]||t[r];return E.set(c,a),o.inPlace(t,[r],"wrap-logger-",(()=>E.get(c))),i}function A(){const e=(0,h.pV)();g.forEach((t=>{e[t]=(...r)=>function(t,...r){let n=[];return Object.values(e.initializedAgents).forEach((e=>{e&&e.api?e.exposed&&e.api[t]&&n.push(e.api[t](...r)):(0,l.R)(38,t)})),n.length>1?n:n[0]}(t,...r)}))}const S={};var N=r(9417),_=r(5603),O=r(5284);const I=e=>{const t=e.startsWith("http");e+="/",r.p=t?e:"https://"+e};let P=!1;function j(e,t={},g,R){let{init:x,info:E,loader_config:j,runtime:C={},exposed:k=!0}=t;C.loaderType=g;const L=(0,h.pV)();E||(x=L.init,E=L.info,j=L.loader_config),(0,N.xN)(e.agentIdentifier,x||{}),(0,_.a)(e.agentIdentifier,j||{}),E.jsAttributes??={},d.bv&&(E.jsAttributes.isWorker=!0),(0,i.x1)(e.agentIdentifier,E);const H=(0,N.D0)(e.agentIdentifier),M=[E.beacon,E.errorBeacon];P||(H.proxy.assets&&(I(H.proxy.assets),M.push(H.proxy.assets)),H.proxy.beacon&&M.push(H.proxy.beacon),A(),(0,h.US)("activatedFeatures",O.B),e.runSoftNavOverSpa&&=!0===H.soft_navigations.enabled&&H.feature_flags.includes("soft_nav")),C.denyList=[...H.ajax.deny_list||[],...H.ajax.block_internal?M:[]],C.ptid=e.agentIdentifier,(0,o.V)(e.agentIdentifier,C),e.ee=s.ee.get(e.agentIdentifier),void 0===e.api&&(e.api=function(e,t,h=!1){t||(0,c.Ak)(e,"api");const g={};var R=s.ee.get(e),x=R.get("tracer");S[e]=b.g.OFF,R.on(p.G4.REPLAY_RUNNING,(t=>{S[e]=t}));
5var E="api-",A=E+"ixn-";function N(t,r,n,o){const a=(0,i.Vp)(e);return null===r?delete a.jsAttributes[t]:(0,i.x1)(e,{...a,jsAttributes:{...a.jsAttributes,[t]:r}}),I(E,n,!0,o||null===r?"session":void 0)(t,r)}function _(){}g.log=function(e,{customAttributes:t={},level:r=y.p_.INFO}={}){(0,a.p)(f.xV,["API/log/called"],void 0,n.K7.metrics,R),(0,w.R)(R,e,t,r)},g.wrapLogger=(e,t,{customAttributes:r={},level:i=y.p_.INFO}={})=>{(0,a.p)(f.xV,["API/wrapLogger/called"],void 0,n.K7.metrics,R),T(R,e,t,{customAttributes:r,level:i})},m.forEach((e=>{g[e]=I(E,e,!0,"api")})),g.addPageAction=I(E,"addPageAction",!0,n.K7.genericEvents),g.recordCustomEvent=I(E,"recordCustomEvent",!0,n.K7.genericEvents),g.setPageViewName=function(t,r){if("string"==typeof t)return"/"!==t.charAt(0)&&(t="/"+t),(0,o.f)(e).customTransaction=(r||"http://custom.transaction")+t,I(E,"setPageViewName",!0)()},g.setCustomAttribute=function(e,t,r=!1){if("string"==typeof e){if(["string","number","boolean"].includes(typeof t)||null===t)return N(e,t,"setCustomAttribute",r);(0,l.R)(40,typeof t)}else(0,l.R)(39,typeof e)},g.setUserId=function(e){if("string"==typeof e||null===e)return N("enduser.id",e,"setUserId",!0);(0,l.R)(41,typeof e)},g.setApplicationVersion=function(e){if("string"==typeof e||null===e)return N("application.version",e,"setApplicationVersion",!1);(0,l.R)(42,typeof e)},g.start=()=>{try{(0,a.p)(f.xV,["API/start/called"],void 0,n.K7.metrics,R),R.emit("manual-start-all")}catch(e){(0,l.R)(23,e)}},g[p.G4.RECORD]=function(){(0,a.p)(f.xV,["API/recordReplay/called"],void 0,n.K7.metrics,R),(0,a.p)(p.G4.RECORD,[],void 0,n.K7.sessionReplay,R)},g[p.G4.PAUSE]=function(){(0,a.p)(f.xV,["API/pauseReplay/called"],void 0,n.K7.metrics,R),(0,a.p)(p.G4.PAUSE,[],void 0,n.K7.sessionReplay,R)},g.interaction=function(e){return(new _).get("object"==typeof e?e:{})};const O=_.prototype={createTracer:function(e,t){var r={},i=this,o="function"==typeof t;return(0,a.p)(f.xV,["API/createTracer/called"],void 0,n.K7.metrics,R),h||(0,a.p)(A+"tracer",[(0,v.t)(),e,r],i,n.K7.spa,R),function(){if(x.emit((o?"":"no-")+"fn-start",[(0,v.t)(),i,o],r),o)try{return t.apply(this,arguments)}catch(e){const t="string"==typeof e?new Error(e):e;throw x.emit("fn-err",[arguments,this,t],r),t}finally{x.emit("fn-end",[(0,v.t)()],r)}}}};function I(e,t,r,i){return function(){return(0,a.p)(f.xV,["API/"+t+"/called"],void 0,n.K7.metrics,R),i&&(0,a.p)(e+t,[r?(0,v.t)():performance.now(),...arguments],r?null:this,i,R),r?void 0:this}}function P(){r.e(478).then(r.bind(r,8778)).then((({setAPI:t})=>{t(e),(0,c.Ze)(e,"api")})).catch((e=>{(0,l.R)(27,e),R.abort()}))}return["actionText","setName","setAttribute","save","ignore","onEnd","getContext","end","get"].forEach((e=>{O[e]=I(A,e,void 0,h?n.K7.softNav:n.K7.spa)})),g.setCurrentRouteName=h?I(A,"routeName",void 0,n.K7.softNav):I(E,"routeName",!0,n.K7.spa),g.noticeError=function(t,r){"string"==typeof t&&(t=new Error(t)),(0,a.p)(f.xV,["API/noticeError/called"],void 0,n.K7.metrics,R),(0,a.p)("err",[t,(0,v.t)(),!1,r,!!S[e]],void 0,n.K7.jserrors,R)},d.RI?(0,u.GG)((()=>P()),!0):P(),g}(e.agentIdentifier,R,e.runSoftNavOverSpa)),void 0===e.exposed&&(e.exposed=k),P=!0}},8374:(e,t,r)=>{r.nc=(()=>{try{return document?.currentScript?.nonce}catch(e){}return""})()},860:(e,t,r)=>{"use strict";r.d(t,{$J:()=>u,K7:()=>s,P3:()=>c,XX:()=>i,qY:()=>n,v4:()=>a});const n="events",i="jserrors",o="browser/blobs",a="rum",s={ajax:"ajax",genericEvents:"generic_events",jserrors:i,logging:"logging",metrics:"metrics",pageAction:"page_action",pageViewEvent:"page_view_event",pageViewTiming:"page_view_timing",sessionReplay:"session_replay",sessionTrace:"session_trace",softNav:"soft_navigations",spa:"spa"},c={[s.pageViewEvent]:1,[s.pageViewTiming]:2,[s.metrics]:3,[s.jserrors]:4,[s.spa]:5,[s.ajax]:6,[s.sessionTrace]:7,[s.softNav]:8,[s.sessionReplay]:9,[s.logging]:10,[s.genericEvents]:11},u={[s.pageViewEvent]:a,[s.pageViewTiming]:n,[s.ajax]:n,[s.spa]:n,[s.softNav]:n,[s.metrics]:i,[s.jserrors]:i,[s.sessionTrace]:o,[s.sessionReplay]:o,[s.logging]:"browser/logs",[s.genericEvents]:"ins"}}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.m=r,i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>({212:"nr-spa-compressor",249:"nr-spa-recorder",478:"nr-spa"}[e]+"-1.281.0.min.js"),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="NRBA-1.281.0.PROD:",i.l=(r,n,o,a)=>
5{if(e[r])e[r].push(n);else{var s,c;if(void 0!==o)for(var u=document.getElementsByTagName("script"),d=0;d<u.length;d++){var l=u[d];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+o){s=l;break}}if(!s){c=!0;var f={478:"sha512-jmvAlmjCn64ans8tLueqHRlBI/iWekylsDWb94A77CG0ukSriVDvgD3dThx+XjUSBBBMYhFn8B1a18fViyBPEQ==",249:"sha512-ICY/ZrcytM/86t5KFy+9OAWVYmNNJy10EBtxoSUGjQWuZx53p/eLo+L8HfrGjvHuRHRnutqLTGSnvNttffJkaA==",212:"sha512-pQSn+X/RfBOvx/49HvlghaiXMLhhDQXTi13n1N2XMpDquWJgs9U0pbqE3RbAnYC9nsdaTu/RVGvneEPv1fpCxA=="};(s=document.createElement("script")).charset="utf-8",s.timeout=120,i.nc&&s.setAttribute("nonce",i.nc),s.setAttribute("data-webpack",t+o),s.src=r,0!==s.src.indexOf(window.location.origin+"/")&&(s.crossOrigin="anonymous"),f[a]&&(s.integrity=f[a])}e[r]=[n];var h=(t,n)=>{s.onerror=s.onload=null,clearTimeout(p);var i=e[r];if(delete e[r],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach((e=>e(n))),t)return t(n)},p=setTimeout(h.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=h.bind(null,s.onerror),s.onload=h.bind(null,s.onload),c&&document.head.appendChild(s)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.p="https://js-agent.newrelic.com/",(()=>{var e={38:0,788:0};i.f.j=(t,r)=>{var n=i.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var o=new Promise(((r,i)=>n=e[t]=[r,i]));r.push(n[2]=o);var a=i.p+i.u(t),s=new Error;i.l(a,(r=>{if(i.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\\n("+o+": "+a+")",s.name="ChunkLoadError",s.type=o,s.request=a,n[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var n,o,[a,s,c]=r,u=0;if(a.some((t=>0!==e[t]))){for(n in s)i.o(s,n)&&(i.m[n]=s[n]);if(c)c(i)}for(t&&t(r);u<a.length;u++)o=a[u],i.o(e,o)&&e[o]&&e[o][0](),e[o]=0},r=self["webpackChunk:NRBA-1.281.0.PROD"]=self["webpackChunk:NRBA-1.281.0.PROD"]||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})(),(()=>{"use strict";i(8374);var e=i(944),t=i(6344),r=i(9566);class n{agentIdentifier;constructor(){this.agentIdentifier=(0,r.LA)(16)}#e(t,...r){if("function"==typeof this.api?.[t])return this.api[t](...r);(0,e.R)(35,t)}addPageAction(e,t){return this.#e("addPageAction",e,t)}recordCustomEvent(e,t){return this.#e("recordCustomEvent",e,t)}setPageViewName(e,t){return this.#e("setPageViewName",e,t)}setCustomAttribute(e,t,r){return this.#e("setCustomAttribute",e,t,r)}noticeError(e,t){return this.#e("noticeError",e,t)}setUserId(e){return this.#e("setUserId",e)}setApplicationVersion(e){return this.#e("setApplicationVersion",e)}setErrorHandler(e){return this.#e("setErrorHandler",e)}addRelease(e,t){return this.#e("addRelease",e,t)}log(e,t){return this.#e("log",e,t)}}class o extends n{#e(t,...r){if("function"==typeof this.api?.[t])return this.api[t](...r);(0,e.R)(35,t)}start(){return this.#e("start")}finished(e){return this.#e("finished",e)}recordReplay(){return this.#e(t.G4.RECORD)}pauseReplay(){return this.#e(t.G4.PAUSE)}addToTrace(e){return this.#e("addToTrace",e)}setCurrentRouteName(e){return this.#e("setCurrentRouteName",e)}interaction(){return this.#e("interaction")}wrapLogger(e,t,r){return this.#e("wrapLogger",e,t,r)}}var a=i(860),s=i(9417);const c=Object.values(a.K7);function u(e){const t={};return c.forEach((r=>{t[r]=function(e,t){return!0===(0,s.gD)(t,"".concat(e,".enabled"))}(r,e)})),t}var d=i(425);var l=i(1687),f=i(4234),h=i(5289),p=i(6154),g=i(5270),m=i(7767),v=i(6389);class b extends f.W{constructor(e,t,r=!0){super(e.agentIdentifier,t),this.auto=r,this.abortHandler=void 0,this.featAggregate=void 0,this.onAggregateImported=void 0,!1===e.init[this.featureName].autoStart&&(this.auto=!1),this.auto?(0,l.Ak)(e.agentIdentifier,t):this.ee.on("manual-start-all",(0,v.J)((()=>{(0,l.Ak)(e.agentIdentifier,this.featureName),this.auto=!0,this.importAggregator(e)})))}importAggregator(t,r={}){if(this.featAggregate||!this.auto)return;let n;this.onAggregateImported=new Promise((e=>{n=e}));const o=async()=>{let o;try{if((0,m.V)(this.agentIdentifier)){const{setupAgentSession:e}=await i.e(478).then(i.bind(i,6526));o=e(t)}}catch(t){(0,e.R)(20,t),this.ee.emit("internal-error",[t]),this.featureName===a.K7.sessionReplay&&this.abortHandler?.()}try{if(!this.#t(this.featureName,o))return(0,l.Ze)(this.agentIdentifier,this.featureName),void n(!1);const{lazyFeatureLoader:e}=await i.e(478).then(i.bind(i,6103)),{Aggregate:a}=await e(this.featureName,"aggregate");this.featAggregate=new a(t,r),t.runtime.harvester.initializedAggregates.push(this.featAggregate),n(!0)}catch(t){(0,e.R)(34,t),this.abortHandler?.(),(0,l.Ze)(this.agentIdentifier,this.featureName,!0),n(!1),this.ee&&this.ee.abort()}};p.RI?(0,h.GG)((()=>o()),!0):o()}#t(e,t){switch(e){case a.K7.sessionReplay:return(0,g.SR)(this.agentIdentifier)&&!!t;case a.K7.sessionTrace:return!!t;default:return!0}}}var y=i(6630);class w extends b{static featureName=y.T;constructor(e,t=!0){super(e,y.T,t),this.importAggregator(e)}}var R=i(384);var x=i(9908),E=i(2843),T=i(3878),A=i(782),S=i(1863);class N extends b{static featureName=A.T;constructor(e,t=!0){super(e,A.T,t),p.RI&&((0,E.u)((()=>(0,x.p)("docHidden",[(0,S.t)()],void 0,A.T,this.ee)),!0),(0,T.sp)("pagehide",(()=>(0,x.p)("winPagehide",[(0,S.t)()],void 0,A.T,this.ee))),this.importAggregator(e))}}var _=i(3969);class O extends b{static featureName=_.TZ;constructor(e,t=!0){super(e,_.TZ,t),this.importAggregator(e)}}var I=i(6774),P=i(3304);class j{constructor(e,t,r,n,i){this.name="UncaughtError",this.message="string"==typeof e?e:(0,P.A)(e),this.sourceURL=t,this.line=r,this.column=n,this.__newrelic=i}}function C(e){return H(e)?e:new j(void 0!==e?.message?e.message:e,e?.filename||e?.sourceURL,e?.lineno||e?.line,e?.colno||e?.col,e?.__newrelic)}function k(e){const t="Unhandled Promise Rejection";if(!e?.reason)return;if(H(e.reason))try{return e.reason.message=t+": "+e.reason.message,C(e.reason)}catch(t){return C(e.reason)}const r=C(e.reason);return r.message=t+": "+r?.message,r}function L(e){if(e.error instanceof SyntaxError&&!/:\\d+$/.test(e.error.stack?.trim())){const t=new j(e.message,e.filename,e.lineno,e.colno,e.error.__newrelic);return t.name=SyntaxError.name,t}return H(e.error)?e.error:C(e)}function H(e){return e instanceof Error&&!!e.stack}class M extends b{static featureName=I.T;#r=!1;constructor(e,r=!0){super(e,I.T,r);try{this.removeOnAbort=new AbortController}catch(e){}this.ee.on("internal-error",((e,t)=>
5{this.abortHandler&&(0,x.p)("ierr",[C(e),(0,S.t)(),!0,{},this.#r,t],void 0,this.featureName,this.ee)})),this.ee.on(t.G4.REPLAY_RUNNING,(e=>{this.#r=e})),p.gm.addEventListener("unhandledrejection",(e=>{this.abortHandler&&(0,x.p)("err",[k(e),(0,S.t)(),!1,{unhandledPromiseRejection:1},this.#r],void 0,this.featureName,this.ee)}),(0,T.jT)(!1,this.removeOnAbort?.signal)),p.gm.addEventListener("error",(e=>{this.abortHandler&&(0,x.p)("err",[L(e),(0,S.t)(),!1,{},this.#r],void 0,this.featureName,this.ee)}),(0,T.jT)(!1,this.removeOnAbort?.signal)),this.abortHandler=this.#n,this.importAggregator(e)}#n(){this.removeOnAbort?.abort(),this.abortHandler=void 0}}var D=i(8990);let K=1;const U="nr@id";function V(e){const t=typeof e;return!e||"object"!==t&&"function"!==t?-1:e===p.gm?0:(0,D.I)(e,U,(function(){return K++}))}function G(e){if("string"==typeof e&&e.length)return e.length;if("object"==typeof e){if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer&&e.byteLength)return e.byteLength;if("undefined"!=typeof Blob&&e instanceof Blob&&e.size)return e.size;if(!("undefined"!=typeof FormData&&e instanceof FormData))try{return(0,P.A)(e).length}catch(e){return}}}var F=i(8139),B=i(7836),W=i(3434);const z={},q=["open","send"];function Z(t){var r=t||B.ee;const n=function(e){return(e||B.ee).get("xhr")}(r);if(void 0===p.gm.XMLHttpRequest)return n;if(z[n.debugId]++)return n;z[n.debugId]=1,(0,F.u)(r);var i=(0,W.YM)(n),o=p.gm.XMLHttpRequest,a=p.gm.MutationObserver,s=p.gm.Promise,c=p.gm.setInterval,u="readystatechange",d=["onload","onerror","onabort","onloadstart","onloadend","onprogress","ontimeout"],l=[],f=p.gm.XMLHttpRequest=function(t){const r=new o(t),a=n.context(r);try{n.emit("new-xhr",[r],a),r.addEventListener(u,(s=a,function(){var e=this;e.readyState>3&&!s.resolved&&(s.resolved=!0,n.emit("xhr-resolved",[],e)),i.inPlace(e,d,"fn-",y)}),(0,T.jT)(!1))}catch(t){(0,e.R)(15,t);try{n.emit("internal-error",[t])}catch(e){}}var s;return r};function h(e,t){i.inPlace(t,["onreadystatechange"],"fn-",y)}if(function(e,t){for(var r in e)t[r]=e[r]}(o,f),f.prototype=o.prototype,i.inPlace(f.prototype,q,"-xhr-",y),n.on("send-xhr-start",(function(e,t){h(e,t),function(e){l.push(e),a&&(g?g.then(b):c?c(b):(m=-m,v.data=m))}(t)})),n.on("open-xhr-start",h),a){var g=s&&s.resolve();if(!c&&!s){var m=1,v=document.createTextNode(m);new a(b).observe(v,{characterData:!0})}}else r.on("fn-end",(function(e){e[0]&&e[0].type===u||b()}));function b(){for(var e=0;e<l.length;e++)h(0,l[e]);l.length&&(l=[])}function y(e,t){return t}return n}var Y="fetch-",X=Y+"body-",J=["arrayBuffer","blob","json","text","formData"],Q=p.gm.Request,ee=p.gm.Response,te="prototype";const re={};function ne(e){const t=function(e){return(e||B.ee).get("fetch")}(e);if(!(Q&&ee&&p.gm.fetch))return t;if(re[t.debugId]++)return t;function r(e,r,n){var i=e[r];"function"==typeof i&&(e[r]=function(){var e,r=[...arguments],o={};t.emit(n+"before-start",[r],o),o[B.P]&&o[B.P].dt&&(e=o[B.P].dt);var a=i.apply(this,r);return t.emit(n+"start",[r,e],a),a.then((function(e){return t.emit(n+"end",[null,e],a),e}),(function(e){throw t.emit(n+"end",[e],a),e}))})}return re[t.debugId]=1,J.forEach((e=>{r(Q[te],e,X),r(ee[te],e,X)})),r(p.gm,"fetch",Y),t.on(Y+"end",(function(e,r){var n=this;if(r){var i=r.headers.get("content-length");null!==i&&(n.rxSize=i),t.emit(Y+"done",[null,r],n)}else t.emit(Y+"done",[e],n)})),t}var ie=i(7485),oe=i(5603);class ae{constructor(e){this.agentIdentifier=e}generateTracePayload(e){if(!this.shouldGenerateTrace(e))return null;var t=(0,oe.o)(this.agentIdentifier);if(!t)return null;var n=(t.accountID||"").toString()||null,i=(t.agentID||"").toString()||null,o=(t.trustKey||"").toString()||null;if(!n||!i)return null;var a=(0,r.ZF)(),s=(0,r.el)(),c=Date.now(),u={spanId:a,traceId:s,timestamp:c};return(e.sameOrigin||this.isAllowedOrigin(e)&&this.useTraceContextHeadersForCors())&&(u.traceContextParentHeader=this.generateTraceContextParentHeader(a,s),u.traceContextStateHeader=this.generateTraceContextStateHeader(a,c,n,i,o)),(e.sameOrigin&&!this.excludeNewrelicHeader()||!e.sameOrigin&&this.isAllowedOrigin(e)&&this.useNewrelicHeaderForCors())&&(u.newrelicHeader=this.generateTraceHeader(a,s,c,n,i,o)),u}generateTraceContextParentHeader(e,t){return"00-"+t+"-"+e+"-01"}generateTraceContextStateHeader(e,t,r,n,i){return i+"@nr=0-1-"+r+"-"+n+"-"+e+"----"+t}generateTraceHeader(e,t,r,n,i,o){if(!("function"==typeof p.gm?.btoa))return null;var a={v:[0,1],d:{ty:"Browser",ac:n,ap:i,id:e,tr:t,ti:r}};return o&&n!==o&&(a.d.tk=o),btoa((0,P.A)(a))}shouldGenerateTrace(e){return this.isDtEnabled()&&this.isAllowedOrigin(e)}isAllowedOrigin(e){var t=!1,r={};if((0,s.gD)(this.agentIdentifier,"distributed_tracing")&&(r=(0,s.D0)(this.agentIdentifier).distributed_tracing),e.sameOrigin)t=!0;else if(r.allowed_origins instanceof Array)for(var n=0;n<r.allowed_origins.length;n++){var i=(0,ie.D)(r.allowed_origins[n]);if(e.hostname===i.hostname&&e.protocol===i.protocol&&e.port===i.port){t=!0;break}}return t}isDtEnabled(){var e=(0,s.gD)(this.agentIdentifier,"distributed_tracing");return!!e&&!!e.enabled}excludeNewrelicHeader(){var e=(0,s.gD)(this.agentIdentifier,"distributed_tracing");return!!e&&!!e.exclude_newrelic_header}useNewrelicHeaderForCors(){var e=(0,s.gD)(this.agentIdentifier,"distributed_tracing");return!!e&&!1!==e.cors_use_newrelic_header}useTraceContextHeadersForCors(){var e=(0,s.gD)(this.agentIdentifier,"distributed_tracing");return!!e&&!!e.cors_use_tracecontext_headers}}var se=i(9300),ce=i(7295),ue=["load","error","abort","timeout"],de=ue.length,le=(0,R.dV)().o.REQ,fe=(0,R.dV)().o.XHR;class he extends b{static featureName=se.T;constructor(e,t=!0){super(e,se.T,t),this.dt=new ae(e.agentIdentifier),this.handler=(e,t,r,n)=>(0,x.p)(e,t,r,n,this.ee);try{const e={xmlhttprequest:"xhr",fetch:"fetch",beacon:"beacon"};p.gm?.performance?.getEntriesByType("resource").forEach((t=>{if(t.initiatorType in e&&0!==t.responseStatus){const r={status:t.responseStatus},n={rxSize:t.transferSize,duration:Math.floor(t.duration),cbTime:0};pe(r,t.name),this.handler("xhr",[r,n,t.startTime,t.responseEnd,e[t.initiatorType]],void 0,a.K7.ajax)}}))}catch(e){}ne(this.ee),Z(this.ee),function(e,t,r,n){function i(e){var t=this;t.totalCbs=0,t.called=0,t.cbTime=0,t.end=R,t.ended=!1,t.xhrGuids={},t.lastSize=null,t.loadCaptureCalled=!1,t.params=this.params||{},t.metrics=this.metrics||{},e.addEventListener("load",(function(r){E(t,e)}),(0,T.jT)(!1)),p.lR||e.addEventListener("progress",(function(e){t.lastSize=e.loaded}),(0,T.jT)(!1))}function o(e){this.params={method:e[0]},pe(this,e[1]),this.metrics={}}function s(t,r){e.loader_config.xpid&&this.sameOrigin&&r.setRequestHeader("X-NewRelic-ID",e.loader_config.xpid);var i=n.generateTracePayload(this.parsedOrigin);if(i){var o=!1;i.newrelicHeader&&(r.setRequestHeader("newrelic",i.newrelicHeader),o=!0),i.traceContextParentHeader&&(r.setRequestHeader("traceparent",i.traceContextParentHeader),i.traceContextStateHeader&&r.setRequestHeader("tracestate",i.traceContextStateHeader),o=!0),o&&(this.dt=i)}}function c(e,r){var n=this.metrics,i=e[0],o=this;if(n&&i){var a=G(i);a&&(n.txSize=a)}this.startTime=(0,S.t)(),this.body=i,this.listener=function(e){try{"abort"!==e.type||o.loadCaptureCalled||(o.params.aborted=!0),("load"
5!==e.type||o.called===o.totalCbs&&(o.onloadCalled||"function"!=typeof r.onload)&&"function"==typeof o.end)&&o.end(r)}catch(e){try{t.emit("internal-error",[e])}catch(e){}}};for(var s=0;s<de;s++)r.addEventListener(ue[s],this.listener,(0,T.jT)(!1))}function u(e,t,r){this.cbTime+=e,t?this.onloadCalled=!0:this.called+=1,this.called!==this.totalCbs||!this.onloadCalled&&"function"==typeof r.onload||"function"!=typeof this.end||this.end(r)}function d(e,t){var r=""+V(e)+!!t;this.xhrGuids&&!this.xhrGuids[r]&&(this.xhrGuids[r]=!0,this.totalCbs+=1)}function l(e,t){var r=""+V(e)+!!t;this.xhrGuids&&this.xhrGuids[r]&&(delete this.xhrGuids[r],this.totalCbs-=1)}function f(){this.endTime=(0,S.t)()}function h(e,r){r instanceof fe&&"load"===e[0]&&t.emit("xhr-load-added",[e[1],e[2]],r)}function g(e,r){r instanceof fe&&"load"===e[0]&&t.emit("xhr-load-removed",[e[1],e[2]],r)}function m(e,t,r){t instanceof fe&&("onload"===r&&(this.onload=!0),("load"===(e[0]&&e[0].type)||this.onload)&&(this.xhrCbStart=(0,S.t)()))}function v(e,r){this.xhrCbStart&&t.emit("xhr-cb-time",[(0,S.t)()-this.xhrCbStart,this.onload,r],r)}function b(e){var t,r=e[1]||{};if("string"==typeof e[0]?0===(t=e[0]).length&&p.RI&&(t=""+p.gm.location.href):e[0]&&e[0].url?t=e[0].url:p.gm?.URL&&e[0]&&e[0]instanceof URL?t=e[0].href:"function"==typeof e[0].toString&&(t=e[0].toString()),"string"==typeof t&&0!==t.length){t&&(this.parsedOrigin=(0,ie.D)(t),this.sameOrigin=this.parsedOrigin.sameOrigin);var i=n.generateTracePayload(this.parsedOrigin);if(i&&(i.newrelicHeader||i.traceContextParentHeader))if(e[0]&&e[0].headers)s(e[0].headers,i)&&(this.dt=i);else{var o={};for(var a in r)o[a]=r[a];o.headers=new Headers(r.headers||{}),s(o.headers,i)&&(this.dt=i),e.length>1?e[1]=o:e.push(o)}}function s(e,t){var r=!1;return t.newrelicHeader&&(e.set("newrelic",t.newrelicHeader),r=!0),t.traceContextParentHeader&&(e.set("traceparent",t.traceContextParentHeader),t.traceContextStateHeader&&e.set("tracestate",t.traceContextStateHeader),r=!0),r}}function y(e,t){this.params={},this.metrics={},this.startTime=(0,S.t)(),this.dt=t,e.length>=1&&(this.target=e[0]),e.length>=2&&(this.opts=e[1]);var r,n=this.opts||{},i=this.target;"string"==typeof i?r=i:"object"==typeof i&&i instanceof le?r=i.url:p.gm?.URL&&"object"==typeof i&&i instanceof URL&&(r=i.href),pe(this,r);var o=(""+(i&&i instanceof le&&i.method||n.method||"GET")).toUpperCase();this.params.method=o,this.body=n.body,this.txSize=G(n.body)||0}function w(e,t){if(this.endTime=(0,S.t)(),this.params||(this.params={}),(0,ce.iW)(this.params))return;let n;this.params.status=t?t.status:0,"string"==typeof this.rxSize&&this.rxSize.length>0&&(n=+this.rxSize);const i={txSize:this.txSize,rxSize:n,duration:(0,S.t)()-this.startTime};r("xhr",[this.params,i,this.startTime,this.endTime,"fetch"],this,a.K7.ajax)}function R(e){const t=this.params,n=this.metrics;if(!this.ended){this.ended=!0;for(let t=0;t<de;t++)e.removeEventListener(ue[t],this.listener,!1);t.aborted||(0,ce.iW)(t)||(n.duration=(0,S.t)()-this.startTime,this.loadCaptureCalled||4!==e.readyState?null==t.status&&(t.status=0):E(this,e),n.cbTime=this.cbTime,r("xhr",[t,n,this.startTime,this.endTime,"xhr"],this,a.K7.ajax))}}function E(e,r){e.params.status=r.status;var n=function(e,t){var r=e.responseType;return"json"===r&&null!==t?t:"arraybuffer"===r||"blob"===r||"json"===r?G(e.response):"text"===r||""===r||void 0===r?G(e.responseText):void 0}(r,e.lastSize);if(n&&(e.metrics.rxSize=n),e.sameOrigin){var i=r.getResponseHeader("X-NewRelic-App-Data");i&&((0,x.p)(_.rs,["Ajax/CrossApplicationTracing/Header/Seen"],void 0,a.K7.metrics,t),e.params.cat=i.split(", ").pop())}e.loadCaptureCalled=!0}t.on("new-xhr",i),t.on("open-xhr-start",o),t.on("open-xhr-end",s),t.on("send-xhr-start",c),t.on("xhr-cb-time",u),t.on("xhr-load-added",d),t.on("xhr-load-removed",l),t.on("xhr-resolved",f),t.on("addEventListener-end",h),t.on("removeEventListener-end",g),t.on("fn-end",v),t.on("fetch-before-start",b),t.on("fetch-start",y),t.on("fn-start",m),t.on("fetch-done",w)}(e,this.ee,this.handler,this.dt),this.importAggregator(e)}}function pe(e,t){var r=(0,ie.D)(t),n=e.params||e;n.hostname=r.hostname,n.port=r.port,n.protocol=r.protocol,n.host=r.hostname+":"+r.port,n.pathname=r.pathname,e.parsedOrigin=r,e.sameOrigin=r.sameOrigin}const ge={},me=["pushState","replaceState"];function ve(e){const t=function(e){return(e||B.ee).get("history")}(e);return!p.RI||ge[t.debugId]++||(ge[t.debugId]=1,(0,W.YM)(t).inPlace(window.history,me,"-")),t}var be=i(3738);const{He:ye,bD:we,d3:Re,Kp:xe,TZ:Ee,Lc:Te,uP:Ae,Rz:Se}=be;class Ne extends b{static featureName=Ee;constructor(e,t=!0){super(e,Ee,t);if(!(0,m.V)(this.agentIdentifier))return void this.deregisterDrain();const r=this.ee;let n;ve(r),this.eventsEE=(0,F.u)(r),this.eventsEE.on(Ae,(function(e,t){this.bstStart=(0,S.t)()})),this.eventsEE.on(Te,(function(e,t){(0,x.p)("bst",[e[0],t,this.bstStart,(0,S.t)()],void 0,a.K7.sessionTrace,r)})),r.on(Se+Re,(function(e){this.time=(0,S.t)(),this.startPath=location.pathname+location.hash})),r.on(Se+xe,(function(e){(0,x.p)("bstHist",[location.pathname+location.hash,this.startPath,this.time],void 0,a.K7.sessionTrace,r)}));try{n=new PerformanceObserver((e=>{const t=e.getEntries();(0,x.p)(ye,[t],void 0,a.K7.sessionTrace,r)})),n.observe({type:we,buffered:!0})}catch(e){}this.importAggregator(e,{resourceObserver:n})}}var _e=i(2614);class Oe extends b{static featureName=t.TZ;#i;#o;constructor(e,r=!0){let n;super(e,t.TZ,r),this.replayRunning=!1,this.#o=e;try{n=JSON.parse(localStorage.getItem("".concat(_e.H3,"_").concat(_e.uh))
5)}catch(e){}(0,g.SR)(e.agentIdentifier)&&this.ee.on(t.G4.RECORD,(()=>this.#a())),this.#s(n)?(this.#i=n?.sessionReplayMode,this.#c()):this.importAggregator(e),this.ee.on("err",(e=>{this.replayRunning&&(this.errorNoticed=!0,(0,x.p)(t.G4.ERROR_DURING_REPLAY,[e],void 0,this.featureName,this.ee))})),this.ee.on(t.G4.REPLAY_RUNNING,(e=>{this.replayRunning=e}))}#s(e){return e&&(e.sessionReplayMode===_e.g.FULL||e.sessionReplayMode===_e.g.ERROR)||(0,g.Aw)(this.agentIdentifier)}#u=!1;async#c(e){if(!this.#u){this.#u=!0;try{const{Recorder:t}=await Promise.all([i.e(478),i.e(249)]).then(i.bind(i,8589));this.recorder??=new t({mode:this.#i,agentIdentifier:this.agentIdentifier,trigger:e,ee:this.ee,agentRef:this.#o}),this.recorder.startRecording(),this.abortHandler=this.recorder.stopRecording}catch(e){}this.importAggregator(this.#o,{recorder:this.recorder,errorNoticed:this.errorNoticed})}}#a(){this.featAggregate?this.featAggregate.mode!==_e.g.FULL&&this.featAggregate.initializeRecording(_e.g.FULL,!0):(this.#i=_e.g.FULL,this.#c(t.Qb.API),this.recorder&&this.recorder.parent.mode!==_e.g.FULL&&(this.recorder.parent.mode=_e.g.FULL,this.recorder.stopRecording(),this.recorder.startRecording(),this.abortHandler=this.recorder.stopRecording))}}var Ie=i(3962);class Pe extends b{static featureName=Ie.TZ;constructor(e,t=!0){if(super(e,Ie.TZ,t),!p.RI||!(0,R.dV)().o.MO)return;const r=ve(this.ee);Ie.tC.forEach((e=>{(0,T.sp)(e,(e=>{a(e)}),!0)}));const n=()=>(0,x.p)("newURL",[(0,S.t)(),""+window.location],void 0,this.featureName,this.ee);r.on("pushState-end",n),r.on("replaceState-end",n);try{this.removeOnAbort=new AbortController}catch(e){}(0,T.sp)("popstate",(e=>(0,x.p)("newURL",[e.timeStamp,""+window.location],void 0,this.featureName,this.ee)),!0,this.removeOnAbort?.signal);let i=!1;const o=new((0,R.dV)().o.MO)(((e,t)=>{i||(i=!0,requestAnimationFrame((()=>{(0,x.p)("newDom",[(0,S.t)()],void 0,this.featureName,this.ee),i=!1})))})),a=(0,v.s)((e=>{(0,x.p)("newUIEvent",[e],void 0,this.featureName,this.ee),o.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})}),100,{leading:!0});this.abortHandler=function(){this.removeOnAbort?.abort(),o.disconnect(),this.abortHandler=void 0},this.importAggregator(e,{domObserver:o})}}var je=i(7378);const Ce={},ke=["appendChild","insertBefore","replaceChild"];function Le(e){const t=function(e){return(e||B.ee).get("jsonp")}(e);if(!p.RI||Ce[t.debugId])return t;Ce[t.debugId]=!0;var r=(0,W.YM)(t),n=/[?&](?:callback|cb)=([^&#]+)/,i=/(.*)\\.([^.]+)/,o=/^(\\w+)(\\.|$)(.*)$/;function a(e,t){if(!e)return t;const r=e.match(o),n=r[1];return a(r[3],t[n])}return r.inPlace(Node.prototype,ke,"dom-"),t.on("dom-start",(function(e){!function(e){if(!e||"string"!=typeof e.nodeName||"script"!==e.nodeName.toLowerCase())return;if("function"!=typeof e.addEventListener)return;var o=(s=e.src,c=s.match(n),c?c[1]:null);var s,c;if(!o)return;var u=function(e){var t=e.match(i);if(t&&t.length>=3)return{key:t[2],parent:a(t[1],window)};return{key:e,parent:window}}(o);if("function"!=typeof u.parent[u.key])return;var d={};function l(){t.emit("jsonp-end",[],d),e.removeEventListener("load",l,(0,T.jT)(!1)),e.removeEventListener("error",f,(0,T.jT)(!1))}function f(){t.emit("jsonp-error",[],d),t.emit("jsonp-end",[],d),e.removeEventListener("load",l,(0,T.jT)(!1)),e.removeEventListener("error",f,(0,T.jT)(!1))}
5r.inPlace(u.parent,[u.key],"cb-",d),e.addEventListener("load",l,(0,T.jT)(!1)),e.addEventListener("error",f,(0,T.jT)(!1)),t.emit("new-jsonp",[e.src],d)}(e[0])})),t}const He={};function Me(e){const t=function(e){return(e||B.ee).get("promise")}(e);if(He[t.debugId])return t;He[t.debugId]=!0;var r=t.context,n=(0,W.YM)(t),i=p.gm.Promise;return i&&function(){function e(r){var o=t.context(),a=n(r,"executor-",o,null,!1);const s=Reflect.construct(i,[a],e);return t.context(s).getCtx=function(){return o},s}p.gm.Promise=e,Object.defineProperty(e,"name",{value:"Promise"}),e.toString=function(){return i.toString()},Object.setPrototypeOf(e,i),["all","race"].forEach((function(r){const n=i[r];e[r]=function(e){let i=!1;[...e||[]].forEach((e=>{this.resolve(e).then(a("all"===r),a(!1))}));const o=n.apply(this,arguments);return o;function a(e){return function(){t.emit("propagate",[null,!i],o,!1,!1),i=i||!e}}}})),["resolve","reject"].forEach((function(r){const n=i[r];e[r]=function(e){const r=n.apply(this,arguments);return e!==r&&t.emit("propagate",[e,!0],r,!1,!1),r}})),e.prototype=i.prototype;const o=i.prototype.then;i.prototype.then=function(...e){var i=this,a=r(i);a.promise=i,e[0]=n(e[0],"cb-",a,null,!1),e[1]=n(e[1],"cb-",a,null,!1);const s=o.apply(this,e);return a.nextPromise=s,t.emit("propagate",[i,!0],s,!1,!1),s},i.prototype.then[W.Jt]=o,t.on("executor-start",(function(e){e[0]=n(e[0],"resolve-",this,null,!1),e[1]=n(e[1],"resolve-",this,null,!1)})),t.on("executor-err",(function(e,t,r){e[1](r)})),t.on("cb-end",(function(e,r,n){t.emit("propagate",[n,!0],this.nextPromise,!1,!1)})),t.on("propagate",(function(e,r,n){this.getCtx&&!r||(this.getCtx=function(){if(e instanceof Promise)var r=t.context(e);return r&&r.getCtx?r.getCtx():this})}))}(),t}const De={},Ke="setTimeout",Ue="setInterval",Ve="clearTimeout",Ge="-start",Fe=[Ke,"setImmediate",Ue,Ve,"clearImmediate"];function Be(e){const t=function(e){return(e||B.ee).get("timer")}(e);if(De[t.debugId]++)return t;De[t.debugId]=1;var r=(0,W.YM)(t);return r.inPlace(p.gm,Fe.slice(0,2),Ke+"-"),r.inPlace(p.gm,Fe.slice(2,3),Ue+"-"),r.inPlace(p.gm,Fe.slice(3),Ve+"-"),t.on(Ue+Ge,(function(e,t,n){e[0]=r(e[0],"fn-",null,n)})),t.on(Ke+Ge,(function(e,t,n){this.method=n,this.timerDuration=isNaN(e[1])?0:+e[1],e[0]=r(e[0],"fn-",this,n)})),t}const We={};function ze(e){const t=function(e){return(e||B.ee).get("mutation")}(e);if(!p.RI||We[t.debugId])return t;We[t.debugId]=!0;var r=(0,W.YM)(t),n=p.gm.MutationObserver;return n&&(window.MutationObserver=function(e){return this instanceof n?new n(r(e,"fn-")):n.apply(this,arguments)},MutationObserver.prototype=n.prototype),t}const{TZ:qe,d3:Ze,Kp:Ye,$p:Xe,wW:$e,e5:Je,tH:Qe,uP:et,rw:tt,Lc:rt}=je;class nt extends b{static featureName=qe;constructor(e,t=!0){if(super(e,qe,t),!p.RI)return;try{this.removeOnAbort=new AbortController}catch(e){}let r,n=0;const i=this.ee.get("tracer"),o=Le(this.ee),a=Me(this.ee),s=Be(this.ee),c=Z(this.ee),u=this.ee.get("events"),d=ne(this.ee),l=ve(this.ee),f=ze(this.ee);function h(e,t){l.emit("newURL",[""+window.location,t])}function g(){n++,r=window.location.hash,this[et]=(0,S.t)()}function m(){n--,window.location.hash!==r&&h(0,!0);var e=(0,S.t)();this[Je]=~~this[Je]+e-this[et],this[rt]=e}function v(e,t){e.on(t,(function(){this[t]=(0,S.t)()}))}this.ee.on(et,g),a.on(tt,g),o.on(tt,g),this.ee.on(rt,m),a.on($e,m),o.on($e,m),this.ee.on("fn-err",((...t)=>{t[2]?.__newrelic?.[e.agentIdentifier]||(0,x.p)("function-err",[...t],void 0,this.featureName,this.ee)})),this.ee.buffer([et,rt,"xhr-resolved"],this.featureName),u.buffer([et],this.featureName),s.buffer(["setTimeout"+Ye,"clearTimeout"+Ze,et],this.featureName),c.buffer([et,"new-xhr","send-xhr"+Ze],this.featureName),d.buffer([Qe+Ze,Qe+"-done",Qe+Xe+Ze,Qe+Xe+Ye],this.featureName),l.buffer(["newURL"],this.featureName),f.buffer([et],this.featureName),a.buffer(["propagate",tt,$e,"executor-err","resolve"+Ze],this.featureName),i.buffer([et,"no-"+et],this.featureName),o.buffer(["new-jsonp","cb-start","jsonp-error","jsonp-end"],this.featureName),v(d,Qe+Ze),v(d,Qe+"-d
5one"),v(o,"new-jsonp"),v(o,"jsonp-end"),v(o,"cb-start"),l.on("pushState-end",h),l.on("replaceState-end",h),window.addEventListener("hashchange",h,(0,T.jT)(!0,this.removeOnAbort?.signal)),window.addEventListener("load",h,(0,T.jT)(!0,this.removeOnAbort?.signal)),window.addEventListener("popstate",(function(){h(0,n>1)}),(0,T.jT)(!0,this.removeOnAbort?.signal)),this.abortHandler=this.#n,this.importAggregator(e)}#n(){this.removeOnAbort?.abort(),this.abortHandler=void 0}}var it=i(3333);class ot extends b{static featureName=it.TZ;constructor(e,t=!0){super(e,it.TZ,t);const r=[e.init.page_action.enabled,e.init.performance.capture_marks,e.init.performance.capture_measures,e.init.user_actions.enabled,e.init.performance.resources.enabled];if(p.RI&&(e.init.user_actions.enabled&&(it.Zp.forEach((e=>(0,T.sp)(e,(e=>(0,x.p)("ua",[e],void 0,this.featureName,this.ee)),!0))),it.qN.forEach((e=>{const t=(0,v.s)((e=>{(0,x.p)("ua",[e],void 0,this.featureName,this.ee)}),500,{leading:!0});(0,T.sp)(e,t)}))),e.init.performance.resources.enabled&&p.gm.PerformanceObserver?.supportedEntryTypes.includes("resource"))){new PerformanceObserver((e=>{e.getEntries().forEach((e=>{(0,x.p)("browserPerformance.resource",[e],void 0,this.featureName,this.ee)}))})).observe({type:"resource",buffered:!0})}r.some((e=>e))?this.importAggregator(e):this.deregisterDrain()}}var at=i(993),st=i(3785);class ct extends b{static featureName=at.TZ;constructor(e,t=!0){super(e,at.TZ,t);const r=this.ee;this.ee.on("wrap-logger-end",(function([e]){const{level:t,customAttributes:n}=this;(0,st.R)(r,e,n,t)})),this.importAggregator(e)}}new class extends o{constructor(t){super(),p.gm?(this.features={},(0,R.bQ)(this.agentIdentifier,this),this.desiredFeatures=new Set(t.features||[]),this.desiredFeatures.add(w),this.runSoftNavOverSpa=[...this.desiredFeatures].some((e=>e.featureName===a.K7.softNav)),(0,d.j)(this,t,t.loaderType||"agent"),this.run()):(0,e.R)(21)}get config(){return{info:this.info,init:this.init,loader_config:this.loader_config,runtime:this.runtime}}run(){try{const t=u(this.agentIdentifier),r=[...this.desiredFeatures];r.sort(((e,t)=>a.P3[e.featureName]-a.P3[t.featureName])),r.forEach((r=>{if(!t[r.featureName]&&r.featureName!==a.K7.pageViewEvent)return;if(this.runSoftNavOverSpa&&r.featureName===a.K7.spa)return;if(!this.runSoftNavOverSpa&&r.featureName===a.K7.softNav)return;const n=function(e){switch(e){case a.K7.ajax:return[a.K7.jserrors];case a.K7.sessionTrace:return[a.K7.ajax,a.K7.pageViewEvent];case a.K7.sessionReplay:return[a.K7.sessionTrace];case a.K7.pageViewTiming:return[a.K7.pageViewEvent];default:return[]}}(r.featureName).filter((e=>!(e in this.features)));n.length>0&&(0,e.R)(36,{targetFeature:r.featureName,missingDependencies:n}),this.features[r.featureName]=new r(this)}))}catch(t){(0,e.R)(22,t);for(const e in this.features)this.features[e].abortHandler?.();const r=(0,R.Zm)();delete r.initializedAgents[this.agentIdentifier]?.api,delete r.initializedAgents[this.agentIdentifier]?.features,delete this.sharedAggregator;return r.ee.get(this.agentIdentifier).abort(),!1}}}({features:[he,w,N,Ne,Oe,O,M,ot,ct,Pe,nt],loaderType:"spa"})})()})();`}}({accountID:i,applicationID:s,licenseKey:a})})}},948007,e=>{"use strict";e.s(["default",()=>i]);var t=e.i(857727),r=e.i(3303);let i=()=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.default,{src:"https://synchrobox.adswizz.com/register2.php"}),(0,t.jsx)(r.default,{src:"https://cdn.adswizz.com/adswizz/js/SynchroClient2.js"})]})},260988,e=>{"use strict";e.s(["default",()=>n],260988);var t=e.i(174080),r=e.i(271645),i=e.i(494094);let s={[i.SITES.sbsHomepage]:()=>e.A(663459),[i.SITES.food]:()=>e.A(847166),[i.SITES.language]:()=>e.A(80934),[i.SITES.audio]:()=>e.A(819994),[i.SITES.news]:()=>e.A(314319),[i.SITES.nitv]:()=>e.A(732615),[i.SITES.sport]:()=>e.A(101366),[i.SITES.voices]:()=>e.A(126523),[i.SITES.whatsOn]:()=>e.A(147263),[i.SITES.screeningRoom]:()=>e.A(373517)},a=async e=>(await s[e]()).default;function n(e){let{imageUrl:i,site:s}=e;return(0,r.useEffect)(()=>{a(s)},[]),t.default.preconnect(i),t.default.prefetchDNS("//fonts.googleapis.com"),null}},995290,e=>{"use strict";e.s(["default",()=>s]);var t=e.i(21019),r=e.i(551041),i=e.i(53946);function s(){let e,{schemaLogo:s,pathName:a,siteKey:n,displayName:o}=(0,t.useConfigContext)(),{origin:l}=(0,i.default)(),h=r.default[n];h&&(e=Object.keys(h).map(e=>h[e]));let d=a&&"/"!==a?`${l}/${a}`:l,u={"@id":d,name:o,url:d,logo:s?.url.endsWith("/")?void 0:{"@type":"ImageObject",url:s?.url,width:s?.width.toString(),height:s?.height.toString()},sameAs:e};if("news"===n){let e=function(){let{origin:e}=(0,i.default)();return{"@id":e,"@type":"Organization",name:"Special Broadcasting Service (SBS)",url:e}}();return{"@type":"NewsMediaOrganization",...u,parentOrganization:e,foundingDate:"1975",publishingPrinciples:"https://www.sbs.com.au/aboutus/sbs-code-of-practice/",diversityPolicy:"https://www.sbs.com.au/aboutus/how-we-operate/diversity-inclusion/",masthead:"https://www.sbs.com.au/news"}}return{"@type":"Organization",...u}}},891843,e=>{"use strict";
5e.s(["findAndFormatSeoAudioObjects",()=>a,"formatSeoArticleBody",()=>o,"formatSeoVideos",()=>s,"orgRef",()=>r]);var t=e.i(149451);let r=e=>({"@id":e["@id"]}),i=e=>{if(!e||!e?.contentUrl)return;let r=e&&(0,t.getDateObject)(e?.date.toString()).toISOString();return{"@type":"VideoObject",name:e?.title,uploadDate:r,embedUrl:e?.contentUrl,description:e?.title,thumbnailUrl:e.thumbnailUrl}},s=e=>{if(0!==e.length)return 1===e.length?i(e[0]):e.map(e=>i(e))},a=e=>{let t=[],r=e?.filter(e=>"audio"===e.type||"PodcastEpisode"===e.type);return r?.forEach(e=>{let r=n(e);r&&t.push(r)}),t},n=e=>{let r=e?.value?.audio||e?.value?.podcastEpisode?.audio;if(r?.url)return{"@type":"AudioObject",duration:(0,t.convertSecondsToISO8601)(r?.duration),contentUrl:r.url,name:r?.title,description:e?.value?.description,thumbnailUrl:e?.value?.thumbnail?.size?.src}},o=e=>e.filter(e=>"string"==typeof e||e?.type==="Link").map(e=>e?.value?.body?.html||e).join(" ")},811342,e=>{"use strict";e.s(["default",()=>n]);var t=e.i(857727),r=e.i(53946);e.i(958818);var i=e.i(209096),s=e.i(995290),a=e.i(891843);let n=e=>{let{pageContent:n}=e,o=(0,s.default)(),{origin:l}=(0,r.default)(),{articleSeoSchema:h,mpx:d=[],route:u}=n||{},c=(0,a.findAndFormatSeoAudioObjects)(n.parsedBody);if(!h)return null;let f={...h,articleBody:(0,a.formatSeoArticleBody)(n.parsedBody),publisher:(0,a.orgRef)(o),url:`${l}${u?.formattedRoute}`,...d.length>0&&{video:(0,a.formatSeoVideos)(d)},...c.length>0&&{audio:c}};return(0,t.jsx)(i.default,{item:[o,f]})}},533576,e=>{"use strict";e.s(["default",()=>o]);var t=e.i(857727),r=e.i(53946),i=e.i(738286);e.i(958818);var s=e.i(209096),a=e.i(995290),n=e.i(891843);let o=e=>{let{seoSchema:o,route:l}=e,h=(0,a.default)(),{origin:d}=(0,r.default)();if((0,i.default)(o))return null;let u={...o,publisher:(0,n.orgRef)(h),url:`${d}${l?.formattedRoute??l?.permalink}`};return(0,t.jsx)(s.default,{item:[h,u]})}},962717,e=>{"use strict";e.s(["default",()=>i]);var t=e.i(857727),r=e.i(533576);let i=e=>{let{pageContent:i}=e,{collectionSeoSchema:s,route:a}=i??{};return(0,t.jsx)(r.default,{seoSchema:s,route:a})}},420917,e=>{"use strict";e.s(["default",()=>i]);var t=e.i(857727),r=e.i(533576);let i=e=>{let{pageContent:i}=e,{pageSeoSchema:s,route:a}=i??{};return(0,t.jsx)(r.default,{seoSchema:s,route:a})}},862520,e=>{"use strict";e.s(["default",()=>l],862520);var t=e.i(857727);e.i(958818);var r=e.i(209096);let i={src:e.i(168410).default,width:1056,height:595,blurWidth:8,blurHeight:5,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAPUlEQVR42n3KSwoAEBRGYfvflZQkCbkesRa/kaIwOJPTx2Jp4xej2rFyMcMGwv4OwKWGUOYNPBWEVN/g1gRBMIykbz6LygAAAABJRU5ErkJggg=="};var s=e.i(738286),a=e.i(717720),n=e.i(995290),o=e.i(891843);let l=e=>{let{pageContent:l}=e,h=(0,n.default)();if(!l?.recipeSeoSchema)return null;let{recipeSeoSchema:d}=l,u=l.recipeDetails?.parsedBody,c={...d,image:(0,s.default)(d?.image)?`https://www.sbs.com.au${(0,a.default)(i)}`:d.image,audio:u?(0,o.findAndFormatSeoAudioObjects)(u):void 0};return(0,t.jsx)(r.default,{item:[h,c]})}},891384,e=>{"use strict";e.s(["default",()=>i]);var t=e.i(857727),r=e.i(533576);let i=e=>{let{pageContent:i}=e,{tagSeoSchema:s,route:a}=i??{};return(0,t.jsx)(r.default,{seoSchema:s,route:a})}},503560,e=>{"use strict";e.s(["default",()=>s]);var t=e.i(857727);e.i(958818);var r=e.i(209096),i=e.i(995290);let s=e=>{let{pageContent:s}=e,a=(0,i.default)();if(!s?.seoSchema)return null;let n=s?.seoSchema;return(0,t.jsx)(r.default,{item:[a,n]})}},403683,e=>{"use strict";e.s(["default",()=>a]);var t=e.i(857727);e.i(958818);var r=e.i(209096),i=e.i(995290),s=e.i(891843);let a=e=>{let{pageContent:a}=e,n=(0,i.default)();if(!a?.seoSchema)return null;let{seoSchema:o}=a,l=Object.values(a?.parsedPosts||[]).flat(),[h,...d]=o;if(!h)return(0,t.jsx)(r.default,{item:[n,...o]});let u={...h,publisher:(0,s.orgRef)(n),...l.length>0&&{audio:(0,s.findAndFormatSeoAudioObjects)(l)}};return(0,t.jsx)(r.default,{item:[n,u,...d]})}},489198,e=>{"use strict";e.s(["default",()=>n]);var t=e.i(857727),r=e.i(53946);e.i(958818);var i=e.i(209096),s=e.i(995290),a=e.i(891843);let n=e=>{let{pageContent:n}=e,o=(0,s.default)(),{origin:l}=(0,r.default)(),{mpx:h=[]}=n;if(!n?.podcastEpisodeSeoSchema)return null;let d={...n.podcastEpisodeSeoSchema,url:`${l}${n?.route?.permalink}`,partOfSeries:{...n?.podcastEpisodeSeoSchema?.partOfSeries,url:`${l}${n?.podcastSeries?.[0]?.route?.permalink}`,publisher:(0,a.orgRef)(o)},audio:[n?.podcastEpisodeSeoSchema?.audio,...(0,a.findAndFormatSeoAudioObjects)(n.parsedBody)],publisher:(0,a.orgRef)(o),...h.length>0&&{video:(0,a.formatSeoVideos)(h)}};return(0,t.jsx)(i.default,{item:[o,d]})}},891656,e=>{"use strict";e.s(["default",()=>o]);var t=e.i(857727);e.i(958818);var r=e.i(209096),i=e.i(738286),s=e.i(53946),a=e.i(995290),n=e.i(891843);let o=e=>{let{pageContent:o}=e,l=(0,a.default)(),{origin:h}=(0,s.default)(),{podcastEpisodeSeriesSchema:d}=o??{};if((0,i.default)(d))return null;let u={...d,publisher:(0,n.orgRef)(l),url:`${h}${o?.route?.permalink}`};return(0,t.jsx)(r.default,{item:[l,u]})}},70543,e=>{"use strict";e.s(["default",()=>a]);var t=e.i(857727),r=e.i(738286);e.i(958818);var i=e.i(209096),s=e.i(995290);let a=e=>{let{pageContent:a}=e,n=(0,s.default)(),{authorPageSeoSchema:o}=a??{};if((0,r.default)(o))return null;let l={...o};return(0,t.jsx)(i.default,{item:[n,l]})}},274107,e=>{"use strict";e.s(["VideoSessionProvider",()=>o,"useVideoSessionContext",()=>l]);var t=e.i(857727),r=e.i(271645);let i=(0,r.createContext)(void 0),s="originalVideoId",a="videoPlaylistScrollTop",n=()=>{let e=parseInt(sessionStorage.getItem(a)??"",10);return Number.isNaN(e)?0:e},o=e=>{let{children:o,contentType:l}=e,[h,d]=(0,r.useState)(sessionStorage.getItem(s));(0,r.useEffect)(()=>{let e=()=>{d(null),sessionStorage.removeItem(s),sessionStorage.removeItem(a)};return"video"!==l&&e(),window.addEventListener("pagehide",e),()=>{window.removeEventListener("pagehide",e)}},[l]);let u=(0,r.useCallback)(e=>{sessionStorage.setItem(a,e?.toString())},[]),c=(0,r.useCallback)(e=>{e&&(sessionStorage.setItem(s,e),d(e))},[]);return(0,t.jsx)(i.Provider,{value:{originalVideoId:h,getStoredVideoPlaylistScrollTop:n,storeVideoPlaylistScrollTop:u,storeOriginalVideoId:c},children:o})},l=()=>{let e=(0,r.useContext)(i);if(!e)throw Error("Components using VideoSessionContext must be rendered within VideoSessionProvider");return e}},169800,e=>
5{e.v({newsletterSection:"NewsletterShelf-module__4zLG-G__newsletterSection"})},456091,e=>{e.v({description:"NewsletterContent-module__usFAPa__description",formContainer:"NewsletterContent-module__usFAPa__formContainer",heading:"NewsletterContent-module__usFAPa__heading",submitButton:"NewsletterContent-module__usFAPa__submitButton",submitButtonComplete:"NewsletterContent-module__usFAPa__submitButtonComplete"})},793806,443352,e=>{"use strict";e.s(["default",()=>s],793806);var t=e.i(271645),r=e.i(746690),i=e.i(206359);let s=(e,s,a)=>{let{setCookie:n}=(0,r.default)();(0,t.useEffect)(()=>{s&&n("showNewsletterModal","false",i.default.YEAR),a&&n("showNewsletterModal","false",26298e5),e&&n("userSubscribed","true",i.default.YEAR)},[e,s,a])};e.s(["default",()=>m],443352);var a=e.i(857727),n=e.i(311182),o=e.i(494094),l=e.i(585264),h=e.i(207670),d=e.i(250194),u=e.i(546921),c=e.i(793306),f=e.i(456091),g=e.i(787551);function m(e){var t,r,i;let{clickEventData:s,subscriptions:m,setStateAction:p,onEmailChange:v,onCheckboxChange:E,onSubmit:y,title:T,description:S,complete:A,validationMessage:R,valid:L,loading:b,isDialog:D}=e,{site:I}=(0,n.useSiteContext)(),_=m.filter(e=>!e.hidden).length>0,k=(0,l.useTranslations)("newsletter"),w=(t=T,r=I,i=k("block-title"),t||(r===o.LANGUAGE?i:`SBS ${i} in your Inbox`)),C=S||k("subscribe-title"),x=k("email-address",{default:"Enter email address"}),P=A?k("subscribe-successful",{default:"Success"}):k("subscribe-button",{default:"Subscribe"});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h2",{id:"newsletter-form-heading",className:(0,h.default)("h4",f.default.heading),children:w}),(0,a.jsx)("p",{className:(0,h.default)("body1",f.default.description),children:C}),(0,a.jsxs)("form",{onSubmit:y,noValidate:!0,"data-testid":"form",id:"newsletter-form",className:f.default.formContainer,method:D?"dialog":void 0,"aria-labelledby":"newsletter-form-heading",children:[(0,a.jsx)(g.default,{id:`${s.elementType}
5-email-input`,onEmailChange:v,setStateAction:p,inputLabel:x,validationMessage:R}),(0,a.jsx)(u.default,{subscriptions:m,onCheckboxChange:E,complete:A,hasSubscriptions:_}),(0,a.jsxs)("button",{type:"submit",className:(0,h.default)("body1",f.default.submitButton,A&&f.default.submitButtonComplete),disabled:!L||b||A,"aria-live":"polite",children:[A&&(0,a.jsx)(d.CheckIcon,{className:f.default.checkIcon}),P]}),(0,a.jsx)(c.default,{clickEventData:s})]})]})}},492780,e=>{"use strict";e.s(["default",()=>u]);var t=e.i(857727),r=e.i(336811),i=e.i(311182),s=e.i(494094),a=e.i(793806),n=e.i(38721),o=e.i(504165),l=e.i(738286),h=e.i(169800),d=e.i(443352);function u(){let{brand:e,site:u}=(0,i.useSiteContext)(),c=u===s.LANGUAGE?e?.toLowerCase():u,{title:f,description:g,vertical:m,subscriptions:p=[],mailchimpUrl:v}=r.default[c||""]||{},E=(0,n.default)(m),{valid:y,loading:T,complete:S,validationMessage:A,setState:R,onEmailChange:L,onCheckboxChange:b,onSubmit:D}=(0,o.default)(p,E,v);return((0,a.default)(S),c&&!Object.keys(r.default).includes(c)||(0,l.default)(r.default[c||""]))?null:(0,t.jsx)("section",{className:h.default.newsletterSection,"data-testid":"newsletter-block",children:(0,t.jsx)(d.default,{clickEventData:{elementType:"NewsletterShelf"},complete:S,setStateAction:R,valid:y,loading:T,validationMessage:A,onEmailChange:L,onCheckboxChange:b,onSubmit:D,title:f,description:g,subscriptions:p})})}},162299,e=>
5{e.v({newsletterOverlayDialog:"NewsletterOverlay-module__LrYDOW__newsletterOverlayDialog",newsletterOverlayDialogContainer:"NewsletterOverlay-module__LrYDOW__newsletterOverlayDialogContainer"})},133627,e=>{"use strict";e.s(["default",()=>g],133627);var t=e.i(857727),r=e.i(494094),i=e.i(271645),s=e.i(336811);e.i(50019);var a=e.i(381894),n=e.i(793806),o=e.i(38721),l=e.i(746690),h=e.i(504165),d=e.i(162299),u=e.i(443352),c=e.i(397584);function f(e){let{site:f,brand:g}=e,m=(0,i.useRef)(null),p=f===r.LANGUAGE?g?.toLowerCase():f,{vertical:v,title:E,description:y,subscriptions:T=[],mailchimpUrl:S}=s.default[p||""]||{},A=(0,o.default)(v,"popup"),{valid:R,loading:L,complete:b,validationMessage:D,setState:I,onEmailChange:_,onCheckboxChange:k,onSubmit:w}=(0,h.default)(T,A,S),[{askLater:C,dismiss:x,showModalCheck:P},O]=(0,a.useBatchState)({askLater:!1,dismiss:!1,showModalCheck:!1}),{getCookie:M}=(0,l.default)();if((0,i.useEffect)(()=>{if("false"===M("showNewsletterModal")||"true"===M("userSubscribed"))return void O({showModalCheck:!1});let e=setTimeout(()=>{O({showModalCheck:!0})},1e4);return()=>{clearTimeout(e)}},[M,O]),(0,n.default)(b,x,C),(0,i.useEffect)(()=>{m.current?.open&&!P?m.current?.close():!m.current?.open&&P&&m.current?.showModal()},[P]),p&&!Object.keys(s.default).includes(p))return null;let F=()=>{O({askLater:!0,showModalCheck:!1})};return(0,t.jsx)("dialog",{ref:m,className:d.default.newsletterOverlayDialog,"data-testid":"newsletterModal",onClose:F,"aria-modal":!0,"aria-label":"Newsletter",onClick:e=>{e.target instanceof HTMLElement&&"DIALOG"===e.target.nodeName&&F()},children:(0,t.jsxs)("div",{className:d.default.newsletterOverlayDialogContainer,children:[(0,t.jsx)(c.MobileDrawerCloseButton,{"aria-label":"Close Newsletter Signup Dialog","data-testid":"closeModal",onClick:F}),(0,t.jsx)(u.default,{clickEventData:{elementType:"NewsletterOverlay"},complete:b,setStateAction:I,valid:R,loading:L,validationMessage:D,onEmailChange:_,onCheckboxChange:k,onSubmit:w,title:E,description:y,subscriptions:T})]})})}function g(e){let{site:s,brand:a}=e,[n,o]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{let e=setTimeout(()=>{s===r.SITES.language&&o(!0)},5e3);return()=>{clearTimeout(e)}},[s]),n?(0,t.jsx)(f,{site:s,brand:a}):null}},54479,(e,t,r)=>{var i="Expected a function",s=0/0,a=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,l=/^0o[0-7]+$/i,h=parseInt,d=e.g&&e.g.Object===Object&&e.g,u="object"==typeof self&&self&&self.Object===Object&&self,c=d||u||Function("return this")(),f=Object.prototype.toString,g=Math.max,m=Math.min,p=function(){return c.Date.now()};function v(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function E(e){if("number"==typeof e)return e;if("symbol"==typeof(t=e)||t&&"object"==typeof t&&"[object Symbol]"==f.call(t))return s;if(v(e)){var t,r="function"==typeof e.valueOf?e.valueOf():e;e=v(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(a,"");var i=o.test(e);return i||l.test(e)?h(e.slice(2),i?2:8):n.test(e)?s:+e}t.exports=function(e,t,r){var s=!0,a=!0;if("function"!=typeof e)throw TypeError(i);return v(r)&&(s="leading"in r?!!r.leading:s,a="trailing"in r?!!r.trailing:a),function(e,t,r){var s,a,n,o,l,h,d=0,u=!1,c=!1,f=!0;if("function"!=typeof e)throw TypeError(i);function y(t){var r=s,i=a;return s=a=void 0,d=t,o=e.apply(i,r)}function T(e){var r=e-h,i=e-d;return void 0===h||r>=t||r<0||c&&i>=n}function S(){var e,r,i,s=p();if(T(s))return A(s);l=setTimeout(S,(e=s-h,r=s-d,i=t-e,c?m(i,n-r):i))}function A(e){return(l=void 0,f&&s)?y(e):(s=a=void 0,o)}function R(){var e,r=p(),i=T(r);if(s=arguments,a=this,h=r,i){if(void 0===l)return d=e=h,l=setTimeout(S,t),u?y(e):o;if(c)return l=setTimeout(S,t),y(h)}return void 0===l&&(l=setTimeout(S,t)),o}return t=E(t)||0,v(r)&&(u=!!r.leading,n=(c="maxWait"in r)?g(E(r.maxWait)||0,t):n,f="trailing"in r?!!r.trailing:f),R.cancel=function(){void 0!==l&&clearTimeout(l),d=0,s=h=a=l=void 0},R.flush=function(){return void 0===l?o:A(p())},R}(e,t,{leading:s,maxWait:t,trailing:a})}},410078,e=>{"use strict";let t,r,i;e.s(["default",()=>s_],410078);var s,a,n,o=e.i(857727),l={exports:{}};!function(e,t){var r,i,s,a,n;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,e.exports=n={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var s=n.parseURL(e);if(!s)throw Error("Error trying to parse base URL.");return s.path=n.normalizePath(s.path),n.buildURLFromParts(s)}var a=n.parseURL(t);if(!a)throw Error("Error trying to parse relative URL.");
5if(a.scheme)return r.alwaysNormalize?(a.path=n.normalizePath(a.path),n.buildURLFromParts(a)):t;var o=n.parseURL(e);if(!o)throw Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var h={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(h.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var d=o.path,u=d.substring(0,d.lastIndexOf("/")+1)+a.path;h.path=n.normalizePath(u)}else h.path=o.path,!a.params&&(h.params=o.params,a.query||(h.query=o.query));return null===h.path&&(h.path=r.alwaysNormalize?n.normalizePath(a.path):a.path),n.buildURLFromParts(h)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(s,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}}}(l);var h=l.exports;function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach(function(t){!function(e,t,r){var i;(t="symbol"==typeof(i=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?i:String(i))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function c(){return(c=Object.assign.bind()).apply(this,arguments)}let f=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},g=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=m},m=Number.MAX_SAFE_INTEGER||0x1fffffffffffff,p=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hl
5sFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e}({}),v=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),E=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({}),y=function(){},T={trace:y,debug:y,log:y,warn:y,info:y,error:y},S=T,A=S,R=/^(\d+)x(\d+)$/,L=/(.+?)=(".*?"|.*?)(?:,|$)/g;class b{constructor(e){"string"==typeof e&&(e=b.parseAttrList(e)),c(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(!this[e])return null;{let t=(this[e]||"0x").slice(2),r=new Uint8Array((t=(1&t.length?"0":"")+t).length/2);for(let e=0;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){let t=R.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={};for(L.lastIndex=0;null!==(t=L.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1)),r[t[1].trim()]=e}return r}}class D{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){A.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=c(new b({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let e=new Date(this.attr["END-DATE"]);f(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(f(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&f(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class I{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var _={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class k{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[_.AUDIO]:null,[_.VIDEO]:null,[_.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=h.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class w extends k{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new I,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{let e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime||!f(this.programDateTime))return null;let e=f(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;
5if(this.levelkeys){let e=Object.keys(this.levelkeys),t=e.length;if(t>1||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,r,i,s){let a=arguments.length>5&&void 0!==arguments[5]&&arguments[5],{elementaryStreams:n}=this,o=n[e];if(!o){n[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:s,partial:a};return}o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,s)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[_.AUDIO]=null,e[_.VIDEO]=null,e[_.AUDIOVIDEO]=null}}class C extends k{constructor(e,t,r,i,s){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new I,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,s),s&&(this.fragOffset=s.fragOffset+s.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}class x{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&f(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}
5get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function P(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function O(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}let M="undefined"!=typeof self?self:void 0;var F={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},N={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function U(e){switch(e){case N.FAIRPLAY:return F.FAIRPLAY;case N.PLAYREADY:return F.PLAYREADY;case N.WIDEVINE:return F.WIDEVINE;case N.CLEARKEY:return F.CLEARKEY}}var B={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function $(e){switch(e){case F.FAIRPLAY:return N.FAIRPLAY;case F.PLAYREADY:return N.PLAYREADY;case F.WIDEVINE:return N.WIDEVINE;case F.CLEARKEY:return N.CLEARKEY}}function G(e){let{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[F.FAIRPLAY,F.WIDEVINE,F.PLAYREADY,F.CLEARKEY].filter(e=>!!t[e]):[];return!i[F.WIDEVINE]&&r&&i.push(F.WIDEVINE),i}let K=function(e){return null!=M&&null!=(e=M.navigator)&&e.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function H(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}let V=(e,t)=>t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128||!1,j=(e,t)=>t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128||!1,W=(e,t)=>{let r=t,i=0;for(;V(e,t);)i+=10,i+=Y(e,t+6),j(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},Y=(e,t)=>(127&e[t])<<21|(127&e[t+1])<<14|(127&e[t+2])<<7|127&e[t+3],q=(e,t)=>V(e,t)&&Y(e,t+6)+10<=e.length-t,z=e=>{let t=Q(e);for(let e=0;e<t.length;e++){let r=t[e];if(X(r))return ei(r)}},X=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,J=e=>{let t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=Y(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},Q=e=>{let t=0,r=[];for(;V(e,t);){let i=Y(e,t+6),s=(t+=10)+i;for(;t+8<s;){let i=J(e.subarray(t)),s=Z(i);s&&r.push(s),t+=i.size+10}j(e,t)&&(t+=10)}return r},Z=e=>"PRIV"===e.type?ee(e):"W"===e.type[0]?er(e):et(e),ee=e=>{if(e.size<2)return;let t=es(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}},et=e=>{if(e.size<2)return;if("TXXX"===e.type){let t=1,r=es(e.data.subarray(t),!0);t+=r.length+1;let i=es(e.data.subarray(t));return{key:e.type,info:r,data:i}}let t=es(e.data.subarray(1));return{key:e.type,data:t}},er=e=>{if("WXXX"===e.type){if(e.size<2)return;let t=1,r=es(e.data.subarray(t),!0);t+=r.length+1;let i=es(e.data.subarray(t));return{key:e.type,info:r,data:i}}let t=es(e.data);return{key:e.type,data:t}},ei=e=>{if(8===e.data.byteLength){let t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},es=function(e){let r,i,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=function(){if(!navigator.userAgent.includes("PlayStation 4"))return t||void 0===self.TextDecoder||(t=new self.TextDecoder("utf-8")),t}();if(a){let t=a.decode(e);if(s){let e=t.indexOf("\0");return -1!==e?t.substring(0,e):t}return t.replace(/\0/g,"")}let n=e.length,o="",l=0;for(;l<n&&(0!==(r=e[l++])||!s);)if(0!==r&&3!==r)switch(r>>
54){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:o+=String.fromCharCode((31&r)<<6|63&(i=e[l++]));break;case 14:o+=String.fromCharCode((15&r)<<12|(63&(i=e[l++]))<<6|63&e[l++])}return o},ea={hexDump:function(e){let t="";for(let r=0;r<e.length;r++){let i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},en=[].push,eo={video:1,audio:2,id3:3,text:4};function el(e){return String.fromCharCode.apply(null,e)}function eh(e,t){let r=e[t]<<8|e[t+1];return r<0?65536+r:r}function ed(e,t){let r=ec(e,t);return r<0?0x100000000+r:r}function eu(e,t){let r=ed(e,t);return r*=0x100000000,r+=ed(e,t+4)}function ec(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function ef(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function eg(e,t){let r=[];if(!t.length)return r;let i=e.byteLength;for(let s=0;s<i;){let a=ed(e,s),n=el(e.subarray(s+4,s+8)),o=a>1?s+a:i;if(n===t[0])if(1===t.length)r.push(e.subarray(s+8,o));else{let i=eg(e.subarray(s+8,o),t.slice(1));i.length&&en.apply(r,i)}s=o}return r}function em(e){let t=[],r=eg(e,["moov","trak"]);for(let e=0;e<r.length;e++){let i=r[e],s=eg(i,["tkhd"])[0];if(s){let e=s[0],r=ed(s,0===e?12:20),a=eg(i,["mdia","mdhd"])[0];if(a){e=a[0];let s=ed(a,0===e?12:20),n=eg(i,["mdia","hdlr"])[0];if(n){let e=el(n.subarray(8,12)),a={soun:_.AUDIO,vide:_.VIDEO}[e];if(a){let e=function(e){let t=e.subarray(8),r=t.subarray(86),i=el(t.subarray(4,8)),s=i,a="enca"===i||"encv"===i;if(a){let e=eg(t,[i])[0].subarray("enca"===i?28:78);eg(e,["sinf"]).forEach(e=>{let t=eg(e,["schm"])[0];if(t){let r=el(t.subarray(4,8));if("cbcs"===r||"cenc"===r){let t=eg(e,["frma"])[0];t&&(s=el(t))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{let e=eg(r,["avcC"])[0];s+="."+ev(e[1])+ev(e[2])+ev(e[3]);break}case"mp4a":{let e=eg(t,[i])[0],r=eg(e.subarray(28),["esds"])[0];if(r&&r.length>12){let e=4;if(3!==r[e++])break;e=ep(r,e)+2;let t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=ep(r,e);let i=r[e++];if(64===i)s+="."+ev(i);else break;if(e+=12,5!==r[e++])break;e=ep(r,e);let a=r[e++],n=(248&a)>>3;31===n&&(n+=1+((7&a)<<3)+((224&r[e])>>5)),s+="."+n}break}case"hvc1":case"hev1":{let e=eg(r,["hvcC"])[0],t=e[1],i=["","A","B","C"][t>>6],a=ed(e,2),n=e[12],o=e.subarray(6,12);s+="."+i+(31&t),s+="."+a.toString(16).toUpperCase(),s+="."+((32&t)>>5?"H":"L")+n;let l="";for(let e=o.length;e--;){let t=o[e];(t||l)&&(l="."+t.toString(16).toUpperCase()+l)}s+=l;break}case"dvh1":case"dvhe":{let e=eg(r,["dvcC"])[0],t=e[2]>>1&127,i=e[2]<<5&32|e[3]>>3&31;s+="."+eE(t)+"."+eE(i);break}case"vp09":{let e=eg(r,["vpcC"])[0],t=e[4],i=e[5],a=e[6]>>4&15;s+="."+eE(t)+"."+eE(i)+"."+eE(a);break}case"av01":{let e=eg(r,["av1C"])[0],t=e[1]>>>5,i=31&e[1],a=e[2]>>>7?"H":"M",n=(64&e[2])>>6,o=(32&e[2])>>5,l=(16&e[2])>>4,h=(8&e[2])>>3,d=(4&e[2])>>2,u=3&e[2];s+="."+t+"."+eE(i)+a+"."+eE(2===t&&n?o?12:10:n?10:8)+"."+l+"."+h+d+u+"."+eE(1)+"."+eE(1)+"."+eE(1)+".0"}}return{codec:s,encrypted:a}}(eg(i,["mdia","minf","stbl","stsd"])[0]);t[r]={timescale:s,type:a},t[a]=u({timescale:s,id:r},e)}}}}}return eg(e,["moov","mvex","trex"]).forEach(e=>{let r=t[ed(e,4)];r&&(r.default={duration:ed(e,12),flags:ed(e,20)})}),t}function ep(e,t){let r=t+5;for(;128&e[t++]&&t<r;);return t}function ev(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function eE(e){return(e<10?"0":"")+e}function ey(e){let t=eg(e,["schm"])[0];if(t){let r=el(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return eg(e,["schi","tenc"])[0]}return A.error("[eme] missing 'schm' box"),null}function eT(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function eS(e,t){let r=[],i=t.samples,s=t.timescale,a=t.id,n=!1;return eg(i,["moof"]).map(o=>{let l=o.byteOffset-8;eg(o,["traf"]).map(o=>{let h=eg(o,["tfdt"]).map(e=>{let t=e[0],r=ed(e,4);return 1===t&&(r*=0x100000000,r+=ed(e,8)),r/s})[0];return void 0!==h&&(e=h),eg(o,["tfhd"]).map(h=>{let d=ed(h,4),u=0xffffff&ed(h,0),c=0,f=0,g=8;d===a&&((1&u)!=0&&(g+=8),(2&u)!=0&&(g+=4),(8&u)!=0&&(c=ed(h,g),g+=4),(16&u)!=0&&(f=ed(h,g),g+=4),(32&u)!=0&&(g+=4),"video"===t.type&&(n=function(e){if(!e)return!1;let t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),eg(o,["trun"]).map(a=>{let o=a[0],h=0xffffff&ed(a,0),d=0,u=(256&h)!=0,g=0,m=(512&h)!=0,p=0,v=(1024&h)!=0,E=(2048&h)!=0,y=0,T=ed(a,4),S=8;(1&h)!=0&&(d=ed(a,S),S+=4),(4&h)!=0&&(S+=4);let A=d+l;for(let l=0;l<T;l++){if(u?(g=ed(a,S),S+=4):g=c,m?(p=ed(a,S),S+=4):p=f,v&&(S+=4),E&&(y=0===o?ed(a,S):ec(a,S),S+=4),t.type===_.VIDEO){let t=0;for(;t<p;){let a=ed(i,A);A+=4,function(e,t){if(!e)return 6==(31&t);{let e=t>>1&63;return 39===e||40===e}}(n,i[A])&&eA(i.subarray(A,A+a),n?2:1,e+y/s,r),A+=a,t+=a+4}}e+=g/s}}))})})}),r}
5function eA(e,t,r,i){let s,a=eR(e);s=0+t;let n=0,o=0,l=0;for(;s<a.length;){n=0;do{if(s>=a.length)break;n+=l=a[s++]}while(255===l)o=0;do{if(s>=a.length)break;o+=l=a[s++]}while(255===l)let e=a.length-s,t=s;if(o<e)s+=o;else if(o>e){A.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===n){if(181===a[t++]){let e=eh(a,t);if(t+=2,49===e){let e=ed(a,t);if(t+=4,0x47413934===e){let e=a[t++];if(3===e){let s=a[t++],o=31&s,l=64&s,h=l?2+3*o:0,d=new Uint8Array(h);if(l){d[0]=s;for(let e=1;e<h;e++)d[e]=a[t++]}i.push({type:e,payloadType:n,pts:r,bytes:d})}}}}}else if(5===n&&o>16){let e=[];for(let r=0;r<16;r++){let i=a[t++].toString(16);e.push(1==i.length?"0"+i:i),(3===r||5===r||7===r||9===r)&&e.push("-")}let s=o-16,l=new Uint8Array(s);for(let e=0;e<s;e++)l[e]=a[t++];i.push({payloadType:n,pts:r,uuid:e.join(""),userData:es(l),userDataBytes:l})}}}function eR(e){let t=e.byteLength,r=[],i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;let s=t-r.length,a=new Uint8Array(s),n=0;for(i=0;i<s;n++,i++)n===r[0]&&(n++,r.shift()),a[i]=e[n];return a}let eL={};class eb{static clearKeyUriToKeyIdMap(){eL={}}constructor(e,t,r,i=[1],s=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=s,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case N.FAIRPLAY:case N.WIDEVINE:case N.PLAYREADY:case N.CLEARKEY:return -1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||A.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let t=function(e){let t=new Uint8Array(16);for(let r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(e);return new eb(this.method,this.uri,"identity",this.keyFormatVersions,t)}let t=function(e){let t=e.split(":"),r=null;if("data"===t[0]&&2===t.length){let e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){let t="base64"===i[0],s=i[1];t?(e.splice(-1,1),r=P(s)):r=function(e){let t=O(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(s)}}return r}(this.uri);if(t)switch(this.keyFormat){case N.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case N.PLAYREADY:{let e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(e,t,r){let i,s;if(16!==e.byteLength)throw RangeError("Invalid system id");i=new Uint8Array,s=new Uint8Array;let a=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];let s=r.length,a=8,n=s;for(;n--;)a+=r[n].byteLength;let o=new Uint8Array(a);for(o[0]=a>>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(e,4),n=0,a=8;n<s;n++)o.set(r[n],a),a+=r[n].byteLength;return o}([112,115,115,104],new Uint8Array([0,0,0,0]),e,s,i,a,r||new Uint8Array)}(e,null,t);let r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),i=String.fromCharCode.apply(null,Array.from(r)),s=i.substring(i.indexOf("<"),i.length),a=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(a){let e=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(e){let t=P(e).subarray(0,16),r=function(e,t,r){let i=e[t];e[t]=e[r],e[r]=i};r(t,0,3),r(t,1,2),r(t,4,5),r(t,6,7),this.keyId=t}}break}default:{let e=t.subarray(0,16);if(16!==e.length){let t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e}}if(!this.keyId||16!==this.keyId.byteLength){let e=eL[this.uri];if(!e){let t=Object.keys(eL).length%Number.MAX_SAFE_INTEGER;new DataView((e=new Uint8Array(16)).buffer,12,4).setUint32(0,t),eL[this.uri]=e}this.keyId=e}return this}}let eD=/\{\$([a-zA-Z0-9-_]+)\}/g;function eI(e,t,r){if(null!==e.variableList||e.hasVariableRefs)for(let i=r.length;i--;){let s=r[i],a=t[s];a&&(t[s]=e_(e,a))}}function e_(e,t){if(null!==e.variableList||e.hasVariableRefs){let r=e.variableList;return t.replace(eD,t=>{let i=t.substring(2,t.length-1),s=null==r?void 0:r[i];return void 0===s?(e.playlistParsingError||(e.playlistParsingError=Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):s})}return t}function ek(e,t,r){let i,s,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{let e=new self.URL(r).searchParams;if(e.has(i))s=e.get(i);else throw Error(`"${i}" does not match any query parameter in URI: "${r}"`)}catch(t){e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,s=t.VALUE;i in a?e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):a[i]=s||""}function ew(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if("undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}let eC={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv
560:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function ex(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return!e.split(",").some(e=>!eP(e,t,r))}function eP(e,t){var r;let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2],s=ew(i);return null!=(r=null==s?void 0:s.isTypeSupported(eO(e,t)))&&r}function eO(e,t){return`${t}/mp4;codecs="${e}"`}function eM(e){if(e){let t=e.substring(0,4);return eC.video[t]}return 2}function eF(e){return e.split(",").reduce((e,t)=>{let r=eC.video[t];return r?(2*r+e)/(e?3:2):(eC.audio[t]+e)/(e?2:1)},0)}let eN={},eU=/flac|opus/i;function eB(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return e.replace(eU,e=>(function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(eN[e])return eN[e];let r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e];for(let i=0;i<r.length;i++)if(eP(r[i],"audio",t))return eN[e]=r[i],r[i];return e})(e.toLowerCase(),t))}function e$(e,t){return e&&"mp4a"!==e?e:t?t.split(",")[0]:t}let eG=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,eK=/#EXT-X-MEDIA:(.*)/g,eH=/^#EXT(?:INF|-X-TARGETDURATION):/m,eV=RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ej=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class eW{static findGroup(e,t){for(let r=0;r<e.length;r++){let i=e[r];if(i.id===t)return i}}static resolve(e,t){return h.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return eH.test(e)}static parseMasterPlaylist(e,t){var r;let i,s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:eD.test(e)},a=[];for(eG.lastIndex=0;null!=(i=eG.exec(e));)if(i[1]){let e=new b(i[1]);eI(s,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let n=e_(s,i[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:eW.resolve(n,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),function(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{let i=r.filter(t=>(function(e,t){let r=eC[t];return!!r&&!!r[e.slice(0,4)]})(t,e));i.length&&(t[`${e}Codec`]=i.join(","),r=r.filter(e=>-1===i.indexOf(e)))}),t.unknownCodecs=r}(e.CODECS,o),null!=(r=o.unknownCodecs)&&r.length||a.push(o),s.levels.push(o)}else if(i[3]){let e=i[3],r=i[4];switch(e){case"SESSION-DATA":{let e=new b(r);eI(s,e,["DATA-ID","LANGUAGE","VALUE","URI"]);let t=e["DATA-ID"];t&&(null===s.sessionData&&(s.sessionData={}),s.sessionData[t]=e);break}case"SESSION-KEY":{let e=eY(r,t,s);e.encrypted&&e.isSupported()?(null===s.sessionKeys&&(s.sessionKeys=[]),s.sessionKeys.push(e)):A.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${r}"`);break}case"DEFINE":{let e=new b(r);eI(s,e,["NAME","VALUE","QUERYPARAM"]),ek(s,e,t)}break;case"CONTENT-STEERING":{let e=new b(r);eI(s,e,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:eW.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":s.startTimeOffset=eq(r)}}let n=a.length>0&&a.length<s.levels.length;return s.levels=n?a:s.levels,0===s.levels.length&&(s.playlistParsingError=Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let i,s={},a=r.levels,n={AUDIO:a.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:a.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},o=0;for(eK.lastIndex=0;null!==(i=eK.exec(e));){let e=new b(i[1]),a=e.TYPE;if(a){let i=n[a],l=s[a]||[];s[a]=l,eI(r,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let h=e.LANGUAGE,d=e["ASSOC-LANGUAGE"],u=e.CHANNELS,c=e.CHARACTERISTICS,f=e["INSTREAM-ID"],g={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",name:e.NAME||h||"",type:a,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:h,url:e.URI?eW.resolve(e.URI,t):""};if(d&&(g.assocLang=d),u&&(g.channels=u),c&&(g.characteristics=c),f&&(g.instreamId=f),null!=i&&i.length){let e=eW.findGroup(i,g.groupId)||i[0];ez(g,e,"audioCodec"),ez(g,e,"textCodec")}l.push(g)}}return s}static parseLevelPlaylist(e,t,r,i,s,a){let n,o,l,h=new x(t),d=h.fragments,u=null,g=0,m=0,p=0,v=0,E=null,y=new w(i,t),T=-1,S=!1,R=null;for(eV.lastIndex=0,h.m3u8=e,h.hasVariableRefs=eD.test(e);null!==(n=eV.exec(e));){S&&(S=!1,(y=new w(i,t)).start=p,y.sn=g,y.cc=v,y.level=r,u&&(y.initSegment=u,y.rawProgramDateTime=u.rawProgramDateTime,u.rawProgramDateTime=null,R&&(y.setByteRange(R),R=null)));let e=n[1];if(e){y.duration=parseFloat(e);let t=(" "+n[2]).slice(1);y.title=t||null,y.tagList.push(t?["INF",e,t]:["INF",e])}else if(n[3]){if(f(y.duration)){y.start=p,l&&eQ(y,l,h),y.sn=g,y.level=r,y.cc=v,d.push(y);let e=(" "+n[3]).slice(1);y.relurl=e_(h,e),eX(y,E),E=y,p+=y.duration,g++,m=0,S=!0}}else if(n[4]){let e=(" "+n[4]).slice(1);E?y.setByteRange(e,E):y.setByteRange(e)}else if(n[5])y.rawProgramDateTime=(" "+n[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]),-1===T&&(T=d.length);
5else{if(!(n=n[0].match(ej))){A.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<n.length&&void 0===n[o];o++);let e=(" "+n[o]).slice(1),s=(" "+n[o+1]).slice(1),p=n[o+2]?(" "+n[o+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":h.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":g=h.startSN=parseInt(s);break;case"SKIP":{let e=new b(s);eI(h,e,["RECENTLY-REMOVED-DATERANGES"]);let t=e.decimalInteger("SKIPPED-SEGMENTS");if(f(t)){h.skippedSegments=t;for(let e=t;e--;)d.unshift(null);g+=t}let r=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(h.recentlyRemovedDateranges=r.split(" "));break}case"TARGETDURATION":h.targetduration=Math.max(parseInt(s),1);break;case"VERSION":h.version=parseInt(s);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(s||p)&&y.tagList.push(p?[s,p]:[s]);break;case"DISCONTINUITY":v++,y.tagList.push(["DIS"]);break;case"GAP":y.gap=!0,y.tagList.push([e]);break;case"BITRATE":y.tagList.push([e,s]);break;case"DATERANGE":{let e=new b(s);eI(h,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),eI(h,e,e.clientAttrs);let t=new D(e,h.dateRanges[e.ID]);t.isValid||h.skippedSegments?h.dateRanges[t.id]=t:A.warn(`Ignoring invalid DATERANGE tag: "${s}"`),y.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{let e=new b(s);eI(h,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e?function(e,t,r){let i=t.IMPORT;if(r&&i in r){let t=e.variableList;t||(e.variableList=t={}),t[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}(h,e,a):ek(h,e,t)}break;case"DISCONTINUITY-SEQUENCE":v=parseInt(s);break;case"KEY":{let e=eY(s,t,h);if(e.isSupported()){if("NONE"===e.method){l=void 0;break}l||(l={}),l[e.keyFormat]&&(l=c({},l)),l[e.keyFormat]=e}else A.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${s}"`);break}case"START":h.startTimeOffset=eq(s);break;case"MAP":{let e=new b(s);if(eI(h,e,["BYTERANGE","URI"]),y.duration){let s=new w(i,t);eJ(s,e,r,l),u=s,y.initSegment=u,u.rawProgramDateTime&&!y.rawProgramDateTime&&(y.rawProgramDateTime=u.rawProgramDateTime)}else{let t=y.byteRangeEndOffset;if(t){let e=y.byteRangeStartOffset;R=`${t-e}@${e}`}else R=null;eJ(y,e,r,l),u=y,S=!0}break}case"SERVER-CONTROL":{let e=new b(s);h.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&e.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),h.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":h.partTarget=new b(s).decimalFloatingPoint("PART-TARGET");break;case"PART":{let e=h.partList;e||(e=h.partList=[]);let r=m>0?e[e.length-1]:void 0,i=m++,a=new b(s);eI(h,a,["BYTERANGE","URI"]);let n=new C(a,y,t,i,r);e.push(n),y.duration+=n.duration;break}case"PRELOAD-HINT":{let e=new b(s);eI(h,e,["URI"]),h.preloadHint=e;break}case"RENDITION-REPORT":{let e=new b(s);eI(h,e,["URI"]),h.renditionReports=h.renditionReports||[],h.renditionReports.push(e);break}default:A.warn(`line parsed but not handled: ${n}`)}}}E&&!E.relurl?(d.pop(),p-=E.duration,h.partList&&(h.fragmentHint=E)):h.partList&&(eX(y,E),y.cc=v,h.fragmentHint=y,l&&eQ(y,l,h));let L=d.length,I=d[0],_=d[L-1];if((p+=h.skippedSegments*h.targetduration)>0&&L&&_){h.averagetargetduration=p/L;let e=_.sn;h.endSN="initSegment"!==e?e:0,h.live||(_.endList=!0),I&&(h.startCC=I.cc)}else h.endSN=0,h.startCC=0;
5return h.fragmentHint&&(p+=h.fragmentHint.duration),h.totalduration=p,h.endCC=v,T>0&&function(e,t){let r=e[t];for(let i=t;i--;){let t=e[i];if(!t)return;t.programDateTime=r.programDateTime-1e3*t.duration,r=t}}(d,T),h}}function eY(e,t,r){var i,s;let a=new b(e);eI(r,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let n=null!=(i=a.METHOD)?i:"",o=a.URI,l=a.hexadecimalInteger("IV"),h=a.KEYFORMATVERSIONS,d=null!=(s=a.KEYFORMAT)?s:"identity";return o&&a.IV&&!l&&A.error(`Invalid IV: ${a.IV}`),new eb(n,o?eW.resolve(o,t):"",d,(h||"1").split("/").map(Number).filter(Number.isFinite),l)}function eq(e){let t=new b(e).decimalFloatingPoint("TIME-OFFSET");return f(t)?t:null}function ez(e,t,r){let i=t[r];i&&(e[r]=i)}function eX(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),f(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function eJ(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function eQ(e,t,r){e.levelkeys=t;let{encryptedFragments:i}=r;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(e=>t[e].isCommonEncryption)&&i.push(e)}var eZ={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},e0={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function e1(e){let{type:t}=e;switch(t){case eZ.AUDIO_TRACK:return e0.AUDIO;case eZ.SUBTITLE_TRACK:return e0.SUBTITLE;default:return e0.MAIN}}function e2(e,t){let r=e.url;return(void 0===r||0===r.indexOf("data:"))&&(r=t.url),r}class e3{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,i=t.loader,s=new(r||i)(t);return this.loaders[e.type]=s,s}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:eZ.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:i,pathwayId:s,url:a,deliveryDirectives:n}=t;this.load({id:r,level:i,pathwayId:s,responseType:"text",type:eZ.LEVEL,url:a,deliveryDirectives:n})}onAudioTrackLoading(e,t){let{id:r,groupId:i,url:s,deliveryDirectives:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:eZ.AUDIO_TRACK,url:s,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:i,url:s,deliveryDirectives:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:eZ.SUBTITLE_TRACK,url:s,deliveryDirectives:a})}load(e){var t;let r,i=this.hls.config,s=this.getInternalLoader(e);if(s){let t=s.context;if(t&&t.url===e.url&&t.level===e.level)return void A.trace("[playlist-loader]: playlist request ongoing");A.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}if(r=e.type===eZ.MANIFEST?i.manifestLoadPolicy.default:c({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),f(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===eZ.LEVEL&&null!==e.level?t=this.hls.levels[e.level].details:e.type===eZ.AUDIO_TRACK&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===eZ.SUBTITLE_TRACK&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){let e=t.partTarget,i=t.targetduration;if(e&&i){let t=1e3*Math.max(3*e,.8*i);r=c({},r,{maxTimeToFirstByteMs:Math.min(t,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,r.maxTimeToFirstByteMs)})}}}let a=r.errorRetry||r.timeoutRetry||{},n={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0};s.load(e,n,{onSuccess:(e,t,r,i)=>{let s=this.getInternalLoader(r);this.resetInternalLoader(r.type);let a=e.data;if(0!==a.indexOf("#EXTM3U"))return void this.handleManifestParsingError(e,r,Error("no EXTM3U delimiter"),i||null,t);t.parsing.start=performance.now(),eW.isMediaPlaylist(a)?this.handleTrackOrLevelPlaylist(e,t,r,i||null,s):this.handleMasterPlaylist(e,t,r,i
5)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}})}handleMasterPlaylist(e,t,r,i){let s=this.hls,a=e.data,n=e2(e,r),o=eW.parseMasterPlaylist(a,n);if(o.playlistParsingError)return void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);let{contentSteering:l,levels:h,sessionData:d,sessionKeys:u,startTimeOffset:c,variableList:f}=o;this.variableList=f;let{AUDIO:g=[],SUBTITLES:m,"CLOSED-CAPTIONS":v}=eW.parseMasterPlaylistMedia(a,n,o);g.length&&(g.some(e=>!e.url)||!h[0].audioCodec||h[0].attrs.AUDIO||(A.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new b({}),bitrate:0,url:""}))),s.trigger(p.MANIFEST_LOADED,{levels:h,audioTracks:g,subtitles:m,captions:v,contentSteering:l,url:n,stats:t,networkDetails:i,sessionData:d,sessionKeys:u,startTimeOffset:c,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,s){let a=this.hls,{id:n,level:o,type:l}=r,h=e2(e,r),d=f(o)?o:f(n)?n:0,u=e1(r),c=eW.parseLevelPlaylist(e.data,h,d,u,0,this.variableList);if(l===eZ.MANIFEST){let e={attrs:new b({}),bitrate:0,details:c,name:"",url:h};a.trigger(p.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:h,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=c,this.handlePlaylistLoaded(c,e,t,r,i,s)}handleManifestParsingError(e,t,r,i,s){this.hls.trigger(p.ERROR,{type:v.NETWORK_ERROR,details:E.MANIFEST_PARSING_ERROR,fatal:t.type===eZ.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:s})}handleNetworkError(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,a=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===eZ.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===eZ.AUDIO_TRACK||e.type===eZ.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let n=Error(a);A.warn(`[playlist-loader]: ${a}`);let o=E.UNKNOWN,l=!1,h=this.getInternalLoader(e);switch(e.type){case eZ.MANIFEST:o=r?E.MANIFEST_LOAD_TIMEOUT:E.MANIFEST_LOAD_ERROR,l=!0;break;case eZ.LEVEL:o=r?E.LEVEL_LOAD_TIMEOUT:E.LEVEL_LOAD_ERROR,l=!1;break;case eZ.AUDIO_TRACK:o=r?E.AUDIO_TRACK_LOAD_TIMEOUT:E.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case eZ.SUBTITLE_TRACK:o=r?E.SUBTITLE_TRACK_LOAD_TIMEOUT:E.SUBTITLE_LOAD_ERROR,l=!1}h&&this.resetInternalLoader(e.type);let d={type:v.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:h,context:e,error:n,networkDetails:t,stats:s};i&&(d.response=u({url:(null==t?void 0:t.url)||e.url,data:void 0},i)),this.hls.trigger(p.ERROR,d)}handlePlaylistLoaded(e,t,r,i,s,a){let n=this.hls,{type:o,level:l,id:h,groupId:d,deliveryDirectives:u}=i,c=e2(t,i),f=e1(i),g="number"==typeof i.level&&f===e0.MAIN?l:void 0;if(!e.fragments.length){let e=Error("No Segments found in Playlist");n.trigger(p.ERROR,{type:v.NETWORK_ERROR,details:E.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:e,reason:e.message,response:t,context:i,level:g,parent:f,networkDetails:s,stats:r});return}e.targetduration||(e.playlistParsingError=Error("Missing Target Duration"));let m=e.playlistParsingError;if(m)return void n.trigger(p.ERROR,{type:v.NETWORK_ERROR,details:E.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:m,reason:m.message,response:t,context:i,level:g,parent:f,networkDetails:s,stats:r});switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),o){case eZ.MANIFEST:case eZ.LEVEL:n.trigger(p.LEVEL_LOADED,{details:e,level:g||0,id:h||0,stats:r,networkDetails:s,deliveryDirectives:u});break;case eZ.AUDIO_TRACK:n.trigger(p.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:d||"",stats:r,networkDetails:s,deliveryDirectives:u});break;case eZ.SUBTITLE_TRACK:n.trigger(p.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:d||"",stats:r,networkDetails:s,deliveryDirectives:u})}}}function e4(e,t){let r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function e8(e,t){let r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if
5(e.addCue(t),!e.cues.getCueById(t.id))throw Error(`addCue is failed for: ${t}`)}catch(r){A.debug(`[texttrack-utils]: ${r}`);try{let r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){A.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function e5(e){let t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function e6(e,t,r,i){let s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&e.cues.length>0){let s=function(e,t,r){let i=[],s=function(e,t){if(t<e[0].startTime)return 0;let r=e.length-1;if(t>e[r].endTime)return -1;let i=0,s=r;for(;i<=s;){let a=Math.floor((s+i)/2);if(t<e[a].startTime)s=a-1;else{if(!(t>e[a].startTime)||!(i<r))return a;i=a+1}}return e[i].startTime-t<t-e[s].startTime?i:s}(e,t);if(s>-1)for(let a=s,n=e.length;a<n;a++){let s=e[a];if(s.startTime>=t&&s.endTime<=r)i.push(s);else if(s.startTime>r)break}return i}(e.cues,t,r);for(let t=0;t<s.length;t++)(!i||i(s[t]))&&e.removeCue(s[t])}"disabled"===s&&(e.mode=s)}function e9(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];("subtitles"===i.kind||"captions"===i.kind)&&i.label&&t.push(e[r])}return t}var e7={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};function te(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function tt(e,t,r,i,s){let a=new e(t,r,"");try{a.value=i,s&&(a.type=s)}catch(n){a=new e(t,r,JSON.stringify(s?u({type:s},i):i))}return a}let tr=(()=>{let e=te();try{e&&new e(0,1/0,"")}catch(e){return Number.MAX_VALUE}return 1/0})();function ti(e,t){return e.getTime()/1e3-t}class ts{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(e5(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if("metadata"===r.kind&&"id3"===r.label)return e4(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:i}}}=this;if(!r&&!i)return;let{samples:s}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=te();if(a)for(let e=0;e<s.length;e++){let t=s[e].type;if(t===e7.emsg&&!r||!i)continue;let n=Q(s[e].data);{let r=s[e].pts,i=r+s[e].duration;i>tr&&(i=tr),i-r<=0&&(i=r+.25);for(let e=0;e<n.length;e++){let s=n[e];if(!X(s)){this.updateId3CueEnds(r,t);let e=tt(a,r,i,s,t);e&&this.id3Track.addCue(e)}}}}}updateId3CueEnds(e,t){var r;let i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(let r=i.length;r--;){let s=i[r];s.type===t&&s.startTime<e&&s.endTime===tr&&(s.endTime=e)}}onBufferFlushing(e,t){let{startOffset:r,endOffset:i,type:s}=t,{id3Track:a,hls:n}=this;if(!n)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=n;a&&(o||l)&&e6(a,r,i,"audio"===s?e=>e.type===e7.audioId3&&l:"video"===s?e=>e.type===e7.emsg&&o:e=>e.type===e7.audioId3&&l||e.type===e7.emsg&&o)}onLevelUpdated(e,t){let{details:r}=t;if(!this.media||!r.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:a}=r,n=Object.keys(a);if(s){let e=Object.keys(i).filter(e=>!n.includes(e));for(let t=e.length;t--;){let r=e[t];
5Object.keys(i[r].cues).forEach(e=>{s.removeCue(i[r].cues[e])}),delete i[r]}}let o=r.fragments[r.fragments.length-1];if(0===n.length||!f(null==o?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,h=te();for(let e=0;e<n.length;e++){let t=n[e],r=a[t],s=ti(r.startDate,l),o=i[t],u=(null==o?void 0:o.cues)||{},c=(null==o?void 0:o.durationKnown)||!1,f=tr,g=r.endDate;if(g)f=ti(g,l),c=!0;else if(r.endOnNext&&!c){let e=n.reduce((e,t)=>{if(t!==r.id){let i=a[t];if(i.class===r.class&&i.startDate>r.startDate&&(!e||r.startDate<e.startDate))return i}return e},null);e&&(f=ti(e.startDate,l),c=!0)}let m=Object.keys(r.attr);for(let e=0;e<m.length;e++){var d;let i=m[e];if("ID"===i||"CLASS"===i||"START-DATE"===i||"DURATION"===i||"END-DATE"===i||"END-ON-NEXT"===i)continue;let a=u[i];if(a)c&&!o.durationKnown&&(a.endTime=f);else if(h){let e=r.attr[i];("SCTE35-OUT"===i||"SCTE35-IN"===i)&&(d=e,e=Uint8Array.from(d.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);let a=tt(h,s,f,{key:i,data:e},e7.dateRange);a&&(a.id=t,this.id3Track.addCue(a),u[i]=a)}}i[t]={cues:u,dateRange:r,durationKnown:c}}}}class ta{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(null===e)return null;let{holdBack:t,partHoldBack:r,targetduration:i}=e,{liveSyncDuration:s,liveSyncDurationCount:a,lowLatencyMode:n}=this.config,o=this.hls.userConfig,l=n&&r||t;return(o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==s?s:a*i),l+Math.min(+this.stallCount,i)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;let i=r.edge,s=e-t-this.edgeStalled;return Math.min(Math.max(i-r.totalduration,s),i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration))}get drift(){let{levelDetails:e}=this;return null===e?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(null===e)return 0;let t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(p.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,t){let{details:r}=t;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===E.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&A.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(null===r)return;this._latency=r;let{lowLatencyMode:i,maxLiveSyncPlaybackRate:s}=this.config;if(!i||1===s||!t.live)return;let a=this.targetLatency;if(null===a)return;let n=r-a;n<Math.min(this.maxLatency,a+t.targetduration)&&n>.05&&this.forwardBufferLength>1?e.playbackRate=Math.min(Math.min(2,Math.max(1,s)),Math.max(1,Math.round(2/(1+Math.exp(-.75*n-this.edgeStalled))*20)/20)):1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return null===e?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}let tn=["NONE","TYPE-0","TYPE-1",null],to=["SDR","PQ","HLG"];var tl={No:"",Yes:"YES",v2:"v2"};function th(e){let{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?tl.v2:tl.Yes:tl.No}class td{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class tu{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return tc(this._audioGroups,e)}hasSubtitleGroup(e){return tc(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function tc(e,t){return!!t&&!!e&&-1!==e.indexOf(t)}function tf(e,t){let r=t.startPTS;if(f(r)){let i,s=0;t.sn>e.sn?(s=r-e.start,i=e):(s=e.start-r,i=t),i.duration!==s&&(i.duration=s)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function tg(e,t,r,i,s,a){let n;i-r<=0&&(A.warn("Fragment should have a positive duration",t),i=r+t.duration,a=s+t.duration);let o=r,l=i,h=t.startPTS,d=t.endPTS;if(f(h)){let e=Math.abs(h-r);f(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,o=Math.max(r,h),r=Math.min(r,h),s=Math.min(s,t.startDTS),l=Math.min(i,d),i=Math.max(i,d),a=Math.max(a,t.endDTS)}let u=r-t.start;0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=o,t.startDTS=s,t.endPTS=i,t.minEndPTS=l,t.endDTS=a;let c=t.sn;if(!e||c<e.startSN||c>e.endSN)return 0;let g=c-e.startSN,m=e.fragments;for(m[g]=t,n=g;n>0;n--)tf(m[n],m[n-1]);for(n=g;n<m.length-1;n++)tf(m[n],m[n+1]);return e.fragmentHint&&tf(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function tm(e,t){let r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||tp(t,i[r].start)}function tp(e,t){if(t){let r=e.fragments;for(let i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function tv(e,t,r){var i;return null!=e&&e.details?tE(null==(i=e.details)?void 0:i.partList,t,r):null}function tE(e,t,r){if(e)for(let i=e.length;i--;){let s=e[i];if(s.index===r&&s.fragment.sn===t)return s}return null}function ty(e){e.forEach((e,t)=>{let{details:r}=e;
5null!=r&&r.fragments&&r.fragments.forEach(e=>{e.level=t})})}function tT(e){switch(e.details){case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_TIMEOUT:case E.LEVEL_LOAD_TIMEOUT:case E.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function tS(e,t){let r=tT(t);return e.default[`${r?"timeout":"error"}Retry`]}function tA(e,t){return Math.min(("linear"===e.backoff?1:Math.pow(2,t))*e.retryDelayMs,e.maxRetryDelayMs)}function tR(e){return u(u({},e),{errorRetry:null,timeoutRetry:null})}function tL(e,t,r,i){var s;if(!e)return!1;let a=null==i?void 0:i.code,n=t<e.maxNumRetry&&(0===(s=a)&&!1===navigator.onLine||!!s&&(s<400||s>499)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,n):n}let tb={search:function(e,t){let r=0,i=e.length-1,s=null,a=null;for(;r<=i;){let n=t(a=e[s=(r+i)/2|0]);if(n>0)r=s+1;else{if(!(n<0))return a;i=s-1}}return null}};function tD(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.005,a=null;if(e){a=t[e.sn-t[0].sn+1]||null;let i=e.endDTS-r;i>0&&i<15e-7&&(r+=15e-7)}else 0===r&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===tI(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){let i=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),r);return e.start<=i}return!1}(a,e,Math.min(s,i))))return a;let n=tb.search(t,tI.bind(null,r,i));return n&&(n!==e||!a)?n:a}function tI(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;if(r.start<=e&&r.start+r.duration>e)return 0;let i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}var t_={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},tk={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2};class tw{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=A.log.bind(A,`${t}:`),this.warn=A.warn.bind(A,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){let i=null==t?void 0:t.renditionReports;if(i){let s=-1;for(let r=0;r<i.length;r++){let a,n=i[r];try{a=new self.URL(n.URI,t.url).href}catch(e){A.warn(`Could not construct new URL for Rendition Report: ${e}`),a=n.URI||""}if(a===e){s=r;break}a===e.substring(0,a.length)&&(s=r)}if(-1!==s){let e=i[s],a=parseInt(e["LAST-MSN"])||(null==t?void 0:t.lastPartSn),n=parseInt(e["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let e=Math.min(t.age-t.partTarget,t.targetduration);n>=0&&e>t.partTarget&&(n+=1)}return new td(a,n>=0?n:void 0,r&&th(r))}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return -1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:i,stats:s}=t,a=self.performance.now(),n=s.loading.first?Math.max(0,a-s.loading.first):0;if(i.advancedDateTime=Date.now()-n,i.live||null!=r&&r.live){let n,o,l;if(i.reloaded(r),r&&this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),r&&i.fragments.length>0&&function(e,t){let r,i=null,s=e.fragments;for(let e=s.length-1;e>=0;e--){let t=s[e].initSegment;if(t){i=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let a=0;if(function(e,t,r){let i=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,a=+!!e.fragmentHint+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,n=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let e=s;e<=a;e++){let s=l[n+e],a=o[e];i&&!a&&e<i&&(a=t.fragments[e]=s),s&&a&&r(s,a)}}(e,t,(e,s)=>{e.relurl&&(a=e.cc-s.cc),f(e.startPTS)&&f(e.endPTS)&&(s.start=s.startPTS=e.startPTS,s.startDTS=e.startDTS,s.maxStartPTS=e.maxStartPTS,s.endPTS=e.endPTS,s.endDTS=e.endDTS,s.minEndPTS=e.minEndPTS,s.duration=e.endPTS-e.startPTS,s.duration&&(r=s),t.PTSKnown=t.alignedSliding=!0),s.elementaryStreams=e.elementaryStreams,s.loader=e.loader,s.stats=e.stats,e.initSegment&&(s.initSegment=e.initSegment,i=e.initSegment)}),i&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEac
5h(e=>{var t;e&&(!e.initSegment||e.initSegment.relurl===(null==(t=i)?void 0:t.relurl))&&(e.initSegment=i)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(e=>!e),t.deltaUpdateFailed){A.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=function(e,t,r){let i=c({},e);return r&&r.forEach(e=>{delete i[e]}),Object.keys(t).forEach(e=>{let r=new D(t[e].attr,i[e]);r.isValid?i[e]=r:A.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[e].attr)}"`)}),i}(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));let n=t.fragments;if(a){A.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e<n.length;e++)n[e].cc+=a}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t){let i=0;for(let s=0,a=e.length;s<=a;s++){let a=e[s],n=t[s+i];a&&n&&a.index===n.index&&a.fragment.sn===n.fragment.sn?r(a,n):i--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),r?tg(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):tm(e,t),n.length&&(t.totalduration=t.edge-n[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;let o=t.advancedDateTime;if(t.advanced&&o){let e=t.edge;t.driftStart||(t.driftStartTime=o,t.driftStart=e),t.driftEndTime=o,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}(r,i),!this.canLoad||!i.live)return;if(i.canBlockReload&&i.endSN&&i.advanced){let e=this.hls.config.lowLatencyMode,s=i.lastPartSn,a=i.endSN,h=i.lastPartIndex,d=s===a;-1!==h?(o=d?a+1:s,l=d?e?0:h:h+1):o=a+1;let u=i.age,c=Math.min(u+i.ageHeader-i.partTarget,1.5*i.targetduration);if(c>0){if(r&&c>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${c} with playlist age: ${i.age}`),c=0;else{let e=Math.floor(c/i.targetduration);o+=e,void 0!==l&&(l+=Math.round(c%i.targetduration/i.partTarget)),this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${u.toFixed(2)}s goal: ${c} skip sn ${e} to part ${l}`)}i.tuneInGoal=c}if(n=this.getDeliveryDirectives(i,t.deliveryDirectives,o,l),e||!d)return void this.loadPlaylist(n)}else(i.canBlockReload||i.canSkipUntil)&&(n=this.getDeliveryDirectives(i,t.deliveryDirectives,o,l));let h=this.hls.mainForwardBufferInfo,d=h?h.end-h.len:0,u=(i.edge-d)*1e3,g=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=1e3*e.targetduration;if(e.updated){let i=e.fragments;if(i.length&&4*r>t){let e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}(i,u);i.updated&&a>this.requestScheduled+g&&(this.requestScheduled=s.loading.start),void 0!==o&&i.canBlockReload?this.requestScheduled=s.loading.first+g-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+g<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=g);let m=this.requestScheduled-a;m=Math.max(0,m),this.log(`reload live playlist ${e} in ${Math.round(m)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(n),m)}else this.clearTimer()}getDeliveryDirectives(e,t,r,i){let s=th(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,s=tl.No),new td(r,i,s)}checkRetry(e){let t=e.details,r=tT(e),i=e.errorAction,{action:s,retryCount:a=0,retryConfig:n}=i||{},o=!!i&&!!n&&(s===t_.RetryRequest||!i.resolved&&s===t_.SendAlternateToPenaltyBox);if(o){var l;if(this.requestScheduled=-1,a>=n.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let e=tA(n,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}class tC{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}
5getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class tx{constructor(e,t,r,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new tC(e),this.fast_=new tC(t),this.defaultTTFB_=i,this.ttfb_=new tC(e)}update(e,t){let{slow_:r,fast_:i,ttfb_:s}=this;r.halfLife!==e&&(this.slow_=new tC(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new tC(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.ttfb_=new tC(e,s.getEstimate(),s.getTotalWeight()))}sample(e,t){let r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}sampleTTFB(e){let t=Math.sqrt(2)*Math.exp(-Math.pow(e/1e3,2)/2);this.ttfb_.sample(t,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}let tP={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},tO={};function tM(e,t){A.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function tF(e,t,r){if("attrs"in e){let r=t.indexOf(e);if(-1!==r)return r}for(let i=0;i<t.length;i++)if(tN(e,t[i],r))return i;return -1}function tN(e,t,r){let{groupId:i,name:s,lang:a,assocLang:n,characteristics:o,default:l}=e,h=e.forced;return(void 0===i||t.groupId===i)&&(void 0===s||t.name===s)&&(void 0===a||t.lang===a)&&(void 0===a||t.assocLang===n)&&(void 0===l||t.default===l)&&(void 0===h||t.forced===h)&&(void 0===o||function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split(","),i=t.split(",");return r.length===i.length&&!r.some(e=>-1===i.indexOf(e))}(o,t.characteristics))&&(void 0===r||r(e,t))}function tU(e,t){let{audioCodec:r,channels:i}=e;return(void 0===r||(t.audioCodec||"").substring(0,4)===r.substring(0,4))&&(void 0===i||i===(t.channels||"2"))}function tB(e,t,r){for(let i=t;i;i--)if(r(e[i]))return i;for(let i=t+1;i<e.length;i++)if(r(e[i]))return i;return -1}class t${constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var tG={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class tK{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(p.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(p.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let t=r.length;t--;){let i=r[t];if(!i)break;let s=i.end;if(i.start<=e&&null!==s&&e<=s)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,i=Object.keys(r);for(let s=i.length;s--;){let a=r[i[s]];if((null==a?void 0:a.body.type)===t&&a.buffered){let t=a.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,r,i){this.timeRanges&&(this.timeRanges[e]=t);let s=(null==i?void 0:i.fragment.sn)||-1;
5Object.keys(this.fragments).forEach(i=>{let a=this.fragments[i];if(!a||s>=a.body.sn)return;if(!a.buffered&&!a.loaded){a.body.type===r&&this.removeFragment(a.body);return}let n=a.range[e];n&&n.time.some(e=>{let r=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&this.removeFragment(a.body),r})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:i}=e;if(!t||"initSegment"===r.sn)return;let s=tV(r),a=this.fragments[s];if(!a||a.buffered&&r.gap)return;let n=!r.relurl;Object.keys(t).forEach(e=>{let s=r.elementaryStreams[e];if(!s)return;let o=t[e],l=n||!0===s.partial;a.range[e]=this.getBufferedTimes(r,i,l,o)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),tH(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(t=>t.fragment.sn>=e))}fragBuffered(e,t){let r=tV(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(e,t,r,i){let s={time:[],partial:r},a=e.start,n=e.end,o=e.minEndPTS||n,l=e.maxStartPTS||a;for(let e=0;e<i.length;e++){let t=i.start(e)-this.bufferPadding,r=i.end(e)+this.bufferPadding;if(l>=t&&o<=r){s.time.push({startPTS:Math.max(a,i.start(e)),endPTS:Math.min(n,i.end(e))});break}if(a<r&&n>t){let t=Math.max(a,i.start(e)),r=Math.min(n,i.end(e));r>t&&(s.partial=!0,s.time.push({startPTS:t,endPTS:r}))}else if(n<=t)break}return s}getPartialFragment(e){let t,r,i,s=null,a=0,{bufferPadding:n,fragments:o}=this;return Object.keys(o).forEach(l=>{let h=o[l];h&&tH(h)&&(r=h.body.start-n,i=h.body.end+n,e>=r&&e<=i&&a<=(t=Math.min(e-r,i-e))&&(s=h.body,a=t))}),s}isEndListAppended(e){let t=this.endListFragments[e];return void 0!==t&&(t.buffered||tH(t))}getState(e){let t=tV(e),r=this.fragments[t];if(r)if(!r.buffered)return tG.APPENDING;else if(tH(r))return tG.PARTIAL;else return tG.OK;return tG.NOT_LOADED}isTimeBuffered(e,t,r){let i,s;for(let a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,s=r.end(a)+this.bufferPadding,e>=i&&t<=s)return!0;if(t<=i)break}return!1}onFragLoaded(e,t){let{frag:r,part:i}=t;if("initSegment"===r.sn||r.bitrateTest)return;let s=tV(r);this.fragments[s]={body:r,appendedPTS:null,loaded:i?null:t,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:i,timeRanges:s}=t;if("initSegment"===r.sn)return;let a=r.type;if(i){let e=this.activePartLists[a];e||(this.activePartLists[a]=e=[]),e.push(i)}this.timeRanges=s,Object.keys(s).forEach(e=>{let t=s[e];this.detectEvictedFragments(e,t,a,i)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=tV(e);return!!this.fragments[t]}hasParts(e){var t;return!!(null!=(t=this.activePartLists[e])&&t.length)}removeFragmentsInRange(e,t,r,i,s){(!i||this.hasGaps)&&Object.keys(this.fragments).forEach(a=>{let n=this.fragments[a];if(!n)return;let o=n.body;o.type===r&&(!i||o.gap)&&o.start<t&&o.end>e&&(n.buffered||s)&&this.removeFragment(o)})}removeFragment(e){let t=tV(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let t=e.sn;this.activePartLists[e.type]=r.filter(e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function tH(e){var t,r,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function tV(e){return`${e.type}_${e.level}_${e.sn}`}let tj={length:0,start:()=>0,end:()=>0};class tW{static isBuffered(e,t){try{if(e){let r=tW.getBuffered(e);for(let e=0;e<r.length;e++)if(t>=r.start(e)&&t<=r.end(e))return!0}}catch(e){}return!1}static bufferInfo(e,t,r){try{if(e){let i,s=tW.getBuffered(e),a=[];for(i=0;i<s.length;i++)a.push({start:s.start(i),end:s.end(i)});return this.bufferedInfo(a,t,r)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){let i;t=Math.max(0,t),e.sort(function(e,t){let r=e.start-t.start;return r||t.end-e.end});let s=[];if(r)for(let t=0;t<e.length;t++){let i=s.length;if(i){let a=s[i-1].end;e[t].start-a<r?e[t].end>a&&(s[i-1].end=e[t].end):s.push(e[t])}else s.push(e[t])}else s=e;let a=0,n=t,o=t;for(let e=0;e<s.length;e++){let l=s[e].start,h=s[e].end;if(t+r>=l&&t<h)n=l,a=(o=h)-t;else if(t+r<l){i=l;break}}return{len:a,start:n||0,end:o||0,nextStart:i}}static getBuffered(e){try{return e.buffered}catch(e){return A.log("failed to get media.buffered",e),tj}}}class tY{constructor(e,t,r,i=0,s=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=tq(),this.buffering={audio:tq(),video:tq(),audiovideo:tq()},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=s,this.partial=a}}function tq(){return{start:0,executeStart:0,executeEnd:0,end:0}}function tz(e,t){for(let i=0,s=e.length;i<s;i++){var r;if((null==(r=e[i])?void 0:r.cc)===t)return e[i]}return null}function tX(e,t){if(e){let r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function tJ(e,t){let r=t.fragments;for(let t=0,i=r.length;t<i;t++)tX(r[t],e);t.fragmentHint&&tX(t.fragmentHint,e),t.alignedSliding=!0}function tQ(e,t){let r,i;if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;let s=e.fragments,a=t.fragments;if(!s.length||!a.length)return;let n=Math.min(t.endCC,e.endCC);t.startCC<n&&e.startCC<n&&(r=tz(a,n),i=tz(s,n)),r&&i||(i=tz(s,(r=a[Math.floor(a.length/2)]).cc)||s[Math.floor(s.length/2)]);let o=r.programDateTime,l=i.programDateTime;o&&l&&tJ((l-o)/1e3-(i.start-r.start),e)}class tZ{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;
5if(!r)return Promise.reject(new t2({type:v.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let i=this.config,s=i.fLoader,a=i.loader;return new Promise((n,o)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(e=>"GAP"===e[0]))return void o(t1(e));else e.gap=!1;let l=this.loader=e.loader=s?new s(i):new a(i),h=t0(e),d=tR(i.fragLoadPolicy.default),c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:131072};e.stats=l.stats,l.load(h,c,{onSuccess:(t,r,i,s)=>{this.resetLoader(e,l);let a=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(a.slice(0,16)),a=a.slice(16)),n({frag:e,part:null,payload:a,networkDetails:s})},onError:(t,i,s,a)=>{this.resetLoader(e,l),o(new t2({type:v.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:u({url:r,data:void 0},t),error:Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:s,stats:a}))},onAbort:(t,r,i)=>{this.resetLoader(e,l),o(new t2({type:v.NETWORK_ERROR,details:E.INTERNAL_ABORTED,fatal:!1,frag:e,error:Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new t2({type:v.NETWORK_ERROR,details:E.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:Error(`Timeout after ${c.timeout}ms`),networkDetails:i,stats:t}))},onProgress:(r,i,s,a)=>{t&&t({frag:e,part:null,payload:s,networkDetails:a})}})})}loadPart(e,t,r){this.abort();let i=this.config,s=i.fLoader,a=i.loader;return new Promise((n,o)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void o(t1(e,t));let l=this.loader=e.loader=s?new s(i):new a(i),h=t0(e,t),d=tR(i.fragLoadPolicy.default),c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:131072};t.stats=l.stats,l.load(h,c,{onSuccess:(i,s,a,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);let h={frag:e,part:t,payload:i.data,networkDetails:o};r(h),n(h)},onError:(r,i,s,a)=>{this.resetLoader(e,l),o(new t2({type:v.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:u({url:h.url,data:void 0},r),error:Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:s,stats:a}))},onAbort:(r,i,s)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),o(new t2({type:v.NETWORK_ERROR,details:E.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:Error("Aborted"),networkDetails:s,stats:r}))},onTimeout:(r,i,s)=>{this.resetLoader(e,l),o(new t2({type:v.NETWORK_ERROR,details:E.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:Error(`Timeout after ${c.timeout}ms`),networkDetails:s,stats:r}))}})})}updateStatsFromPart(e,t){let r=e.stats,i=t.stats,s=i.total;if(r.loaded+=i.loaded,s){let i=Math.round(e.duration/t.duration),a=Math.min(Math.round(r.loaded/s),i),n=(i-a)*Math.round(r.loaded/a);r.total=r.loaded+n}else r.total=Math.max(r.loaded,r.total);let a=r.loading,n=i.loading;a.start?a.first+=n.first-n.start:(a.start=n.start,a.first=n.first),a.end=n.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function t0(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},s=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if(f(s)&&f(a)){var n;let t=s,r=a;if("initSegment"===e.sn&&(null==(n=e.decryptdata)?void 0:n.method)==="AES-128"){let e=a-s;e%16&&(r=a+(16-e%16)),0!==s&&(i.resetIV=!0,t=s-16)}i.rangeStart=t,i.rangeEnd=r}return i}function t1(e,t){let r=Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:v.MEDIA_ERROR,details:E.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new t2(i)}class t2 extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class t3{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class t4{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class t8{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let e=0;e<4;e++)r[e]=t.getUint32(4*e);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],s=r[1],a=r[2],n=r[3],o=this.invSubMix,l=o[0],h=o[1],d=o[2],u=o[3],c=new Uint32Array(256),f=0,g=0,m=0;for(m=0;m<256;m++)m<128?c[m]=m<<1:c[m]=m<<1^283;for(m=0;m<256;m++){let r=g^g<<1^g<<2^g<<3^g<<4;r=r>>>8^255&r^99,e[f]=r,t[r]=f;let o=c[f],m=c[o],p=c[m],v=257*c[r]^0x1010100*r;i[f]=v<<24|v>>>8,s[f]=v<<16|v>>>16,a[f]=v<<8|v>>>24,n[f]=v,v=0x1010101*p^65537*m^257*o^0x1010100*f,l[r]=v<<24|v>>>8,h[r]=v<<16|v>>>16,d[r]=v<<8|v>>>24,u[r]=v,f?(f=o^c[c[c[p^o]]],g^=c[c[g]]):f=g=1}}expandKey(e){let t,r,i,s,a=this.uint8ArrayToUint32Array_(e),n=!0,o=0;for(;o<a.length&&n;)n=a[o]===this.key[o],o++;if(n)return;this.key=a;let l=this.keySize=a.length;if(4!==l&&6!==l&&8!==l)throw Error("Invalid aes key size="+l);let h=this.ksRows=(l+6+1)*4,d=this.keySchedule=new Uint32Array(h),u=this.invKeySchedule=new Uint32Array(h),c=this.sBox,f=this.rcon,g=this.invSubMix,m=g[0],p=g[1],v=g[2],E=g[3];for(t=0;t<h;t++){if(t<l){i=d[t]=a[t];continue}s=i,t%l==0?s=(c[(s=s<<8|s>>>24)>>>24]<<24|c[s>>>16&255]<<16|c[s>>>8&255]<<8|c[255&s])^f[t/l|0]<<24:l>6&&t%l==4&&(s=c[s>>>24]<<24|c[s>>>16&255]<<16|c[s>>>8&255]<<8|c[255&s]),d[t]=i=(d[t-l]^s)>>>0}for(r=0;r<h;r++)t=h-r,s=3&r?d[t]:d[t-4],r<4||t<=4?u[r]=s:u[r]=m[c[s>>>24]]^p[c[s>>>16&255]]^v[c[s>>>8&255]]^E[c[255&s]],u[r]=u[r]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(0xff0000&e)>>8|e>>>24}decrypt(e,t,r){let i,s,a,n,o,l,h,d,u,c,f,g,m,p,v=this.keySize+6,E=this.invKeySchedule,y=this.invSBox,T=this.invSubMix,S=T[0],A=T[1],R=T[2],L=T[3],b=this.uint8ArrayToUint32Array_(r),D=b[0],I=b[1],_=b[2],k=b[3],w=new Int32Array(e),C=new Int32Array(w.length),x=this.networkToHostOrderSwap;for(;t<w.length;){for(p=1,u=x(w[t]),c=x(w[t+1]),f=x(w[t+2]),g=x(w[t+3]),o=u^E[0],l=g^E[1],h=f^E[2],d=c^E[3],m=4;p<v;p++)i=S[o>>>24]^A[l>>16&255]^R[h>>8&255]^L[255&d]^E[m],s=S[l>>>24]^A[h>>16&255]^R[d>>8&255]^L[255&o]^E[m+1],a=S[h>>>24]^A[d>>16&255]^R[o>>8&255]^L[255&l]^E[m+2],n=S[d>>>24]^A[o>>16&255]^R[l>>8&255]^L[255&h]^E[m+3],o=i,l=s,h=a,d=n,m+=4;i=y[o>>>24]<<24^y[l>>16&255]<<16^y[h>>8&255]<<8^y[255&d]^E[m],s=y[l>>>24]<<24^y[h>>16&255]<<16^y[d>>8&255]<<8^y[255&o]^E[m+1],a=y[h>>>24]<<24^y[d>>16&255]<<16^y[o>>8&255]<<8^y[255&l]^E[m+2],n=y[d>>>24]<<24^y[o>>16&255]<<16^y[l>>8&255]<<8^y[255&h]^E[m+3],C[t]=x(i^D),C[t+1]=x(n^I),C[t+2]=x(a^_),C[t+3]=x(s^k),D=u,I=c,_=f,k=g,t+=4}return C.buffer}}class t5{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftw
5areAES,this.removePKCS7Padding=t,t)try{let e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);if(this.reset(),this.removePKCS7Padding){let e=r.byteLength,t=e&&new DataView(r.buffer).getUint8(e-1);return t?H(r,0,e-t):r}return r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((i,s)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?i(a.buffer):s(Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:i,currentResult:s,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=eT(a,e),this.remainderData=null);let n=this.getValidChunk(e);if(!n.length)return null;i&&(r=i);let o=this.softwareDecrypter;return(o||(o=this.softwareDecrypter=new t8),o.expandKey(t),this.currentResult=o.decrypt(n.buffer,0,r),this.currentIV=H(n,-16).buffer,s)?s:null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new t4(this.subtle,t)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new t3(this.subtle,new Uint8Array(r)).decrypt(e.buffer,t)):Promise.reject(Error("web crypto not initialized"))).catch(i=>(A.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${i.name}: ${i.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let i=this.flush();if(i)return i.buffer;throw Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%16;return r!==e.length&&(t=H(e,0,r),this.remainderData=H(e,r)),t}logOnce(e){this.logEnabled&&(A.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}let t6={toString:function(e){let t="",r=e.length;for(let i=0;i<r;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t}},t9={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class t7 extends t${constructor(e,t,r,i,s){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=t9.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=s,this.logPrefix=i,this.log=A.log.bind(A,`${i}:`),this.warn=A.warn.bind(A,`${i}:`),this.hls=e,this.fragmentLoader=new tZ(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new t5(e.config),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=t9.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(null!=r&&r.length){let e=r[r.length-1];return tW.isBuffered(this.media,e.start+e.duration/2)}let i=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(i)}
5getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded){var e;return null==(e=this.levelLastLoaded)?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let i=this.config;this.levels&&i.autoStartLoad&&this.state===t9.STOPPED&&this.startLoad(i.startPosition)}onMediaDetaching(){let e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:s}=this,a=r?r.currentTime:0,n=tW.bufferInfo(i||r,a,e.maxBufferHole);if(this.log(`media seeking to ${f(a)?a.toFixed(3):a}, state: ${s}`),this.state===t9.ENDED)this.resetLoadingState();else if(t){let r=e.maxFragLookUpTolerance,i=t.start-r,s=t.start+t.duration+r;if(!n.len||s<n.start||i>n.end){let e=a>s;(a<i||e)&&(e&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),this.loadedmetadata||n.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=t9.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let i=t=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${t.part?" p: "+t.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(t)};this._doFragLoad(e,t,r,i).then(t=>{if(!t)return;let r=this.state;if(this.fragContextChanged(e)){r!==t9.FRAG_LOADING&&(this.fragCurrent||r!==t9.PARSING)||(this.fragmentTracker.removeFragment(e),this.state=t9.IDLE);return}"payload"in t&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(p.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t)}).catch(t=>{this.state!==t9.STOPPED&&this.state!==t9.ERROR&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===tG.APPENDING){let t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=Math.max(e.duration,i?i.len:this.config.maxBufferLength),a=this.backtrackFragment;(1==(a?e.sn-a.sn:0)||this.reduceMaxBufferLength(s,e.duration))&&r.removeFragment(e)}else(null==(t=this.mediaBuffer)?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===tG.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;e-t&&this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:e,endOffset:t,type:r})}_loadInitSegment(e,t){this._doFragLoad(e,t).then(t=>{if(!t||this.fragContextChanged(e)||!this.levels)throw Error("init load aborted");return t}).then(t=>{let{hls:r}=this,{payload:i}=t,s=e.decryptdata;if(i&&i.byteLength>0&&null!=s&&s.key&&s.iv&&"AES-128"===s.method){let a=self.performance.now();
5return this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(t=>{throw r.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t}).then(i=>{let s=self.performance.now();return r.trigger(p.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:a,tdecrypt:s}}),t.payload=i,this.completeInitSegmentLoad(t)})}return this.completeInitSegmentLoad(t)}).catch(t=>{this.state!==t9.STOPPED&&this.state!==t9.ERROR&&(this.warn(t),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw Error("init load aborted, missing levels");let r=e.frag.stats;this.state=t9.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,i,s,a,n;let o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===e0.MAIN?"level":"track"} ${e.level} (frag:[${(null!=(r=e.startPTS)?r:NaN).toFixed(3)}-${(null!=(i=e.endPTS)?i:NaN).toFixed(3)}] > buffer:${o?t6.toString(tW.getBuffered(o)):"(detached)"})`),"initSegment"!==e.sn){if(e.type!==e0.SUBTITLE){let t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e])){this.state=t9.IDLE;return}}let t=null==(n=this.levels)?void 0:n[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=t9.IDLE,o&&(!this.loadedmetadata&&e.type==e0.MAIN&&o.buffered.length&&(null==(s=this.fragCurrent)?void 0:s.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:i,partsLoaded:s}=e,a=!s||0===s.length||s.some(e=>!e),n=new tY(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(n)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t){var r;let i,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3?arguments[3]:void 0,n=null==t?void 0:t.details;if(!this.levels||!n)throw Error(`frag load aborted, missing level${n?"":" detail"}s`);let o=null;if(e.encrypted&&!(null!=(r=e.decryptdata)&&r.key)?(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${e.level}`),this.state=t9.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(p.KEY_LOADED,e),this.state===t9.KEY_LOADING&&(this.state=t9.IDLE),e}),this.hls.trigger(p.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(e,n.encryptedFragments),s=Math.max(e.start,s||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){let r=n.partList;if(r&&a){s>e.end&&n.fragmentHint&&(e=n.fragmentHint);let i=this.getNextPart(r,e,s);if(i>-1){let l,h=r[i];return(this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${n.startSN}-${n.endSN}] parts [0-${i}-${r.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=t9.FRAG_LOADING,l=o?o.then(r=>!r||this.fragContextChanged(r.frag)?null:this.doFragPartsLoad(e,h,t,a)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,h,t,a).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(p.FRAG_LOADING,{frag:e,part:h,targetBufferTime:s}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING parts")):l}if(!e.url||this.loadedEndOfParts(r,s))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${n?"of ["+n.startSN+"-"+n.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),f(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=t9.FRAG_LOADING;let l=this.config.progressive;return(i=l&&o?o.then(t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,a)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,l?a:void 0),o]).then(e=>{let[t]=e;return!l&&t&&a&&a(t),t}).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(p.FRAG_LOADING,{frag:e,targetBufferTime:s}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING")):i}doFragPartsLoad(e,t,r,i){return new Promise((s,a)=>{var n;let o=[],l=null==(n=r.details)?void 0:n.partList,h=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;let a=i.part;this.hls.trigger(p.FRAG_LOADED,i);let n=tv(r,e.sn,t.index+1)||tE(l,e.sn,t.index+1);if(!n)return s({frag:e,part:a,partsLoaded:o});h(n)}).catch(a)};h(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===E.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(p.ERROR,t)}else this.hls.trigger(p.ERROR,{type:v.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==t9.PARSING){this.fragCurrent||this.state===t9.STOPPED||this.state===t9.ERROR||(this.state=t9.IDLE);return}let{frag:r,part:i,level:s}=t,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,s,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:i,sn:s,part:a}=e;if(!(null!=t&&t[i]))return this.warn(`Levels object was unset while buffering fragment ${s} of level ${i}. The current chunk will not be buffered.`),null;let n=t[i],o=a>-1?tv(n,s,a):null,l=o?o.fragment:function(e,t,r){if(!(null!=e&&e.details))return null;let i=e.details,s=i.fragments[t-i.startSN];return s||(s=i.fragmentHint)&&s.sn===t?s:t<i.startSN&&r&&r.sn===t?r:null}(n,s,r);return l?(r&&r!==l&&(l.stats=r.stats),{frag:l,part:o,level:n}):null}bufferFragmentData(e,t,r,i,s){var a;if(!e||this.state!==t9.PARSING)return;let{data1:n,data2:o}=e,l=n;if(n&&o&&(l=eT(n,o)),!(null!=(a=l)&&a.length))return;let h={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:l};if(this.hls.trigger(p.BUFFER_APPENDING,h),e.dropped&&e.independent&&!r){if(s)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!tW.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);let r=t.currentTime,i=tW.bufferInfo(t,r,0),s=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*s),n=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-n>a&&this.flushMainBuffer(n,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return f(r)?this.getFwdBufferInfoAtPos(e,r,t):null}
5getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:i}}=this,s=tW.bufferInfo(e,t,i);if(0===s.len&&void 0!==s.nextStart){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&s.nextStart<a.end)return tW.bufferInfo(e,t,Math.max(s.nextStart,i))}return s}getMaxBufferLength(e){let{config:t}=this;return Math.min(e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),s=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return s>=i&&(r.maxMaxBufferLength=s,this.warn(`Reduce max buffer length to ${s}s`),!0)}getAppendedFrag(e){arguments.length>1&&void 0!==arguments[1]?arguments[1]:e0.MAIN;let t=this.fragmentTracker.getAppendedFrag(e,e0.MAIN);return t&&"fragment"in t?t.fragment:t}getNextFragment(e,t){let r,i=t.fragments,s=i.length;if(!s)return null;let{config:a}=this,n=i[0].start;if(t.live){let o=a.initialLiveManifestSize;if(s<o)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${o})`),null;(t.PTSKnown||this.startFragRequested||-1!==this.startPosition)&&!(e<n)||(r=this.getInitialLiveFragment(t,i),this.startPosition=this.nextLoadPosition=r?this.hls.liveSyncPosition||r.start:e)}else e<=n&&(r=i[0]);if(!r){let i=a.lowLatencyMode?t.partEnd:t.fragmentEnd;r=this.getFragmentAtPosition(e,i,t)}return this.mapToInitFragWhenRequired(r)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===tG.OK||r===tG.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,s){let a=e.gap,n=this.getNextFragment(this.nextLoadPosition,t);if(null===n)return n;if(e=n,a&&e&&!e.gap&&r.nextStart){let t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==t&&r.len+t.len>=s)return this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,r){let i=-1,s=!1,a=!0;for(let n=0,o=e.length;n<o;n++){let o=e[n];if(a=a&&!o.independent,i>-1&&r<o.start)break;let l=o.loaded;l?i=-1:(s||o.independent||a)&&o.fragment===t&&(i=n),s=l}return i}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!f(t)||t<(e[0].programDateTime||0)||t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(let i=0;i<e.length;++i){let s=e[i];if(function(e,t,r){let i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}(t,r,s))return s}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){let a=r.sn+1;if(a>=e.startSN&&a<=e.endSN){let s=t[a-e.startSN];r.cc===s.cc&&(i=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}if(!i){var s;s=r.cc,(i=tb.search(t,e=>e.cc<s?1:e.cc>s?-1:0))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`)}}}else{let t=this.hls.liveSyncPosition;null!==t&&(i=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,r){let i,{config:s}=this,{fragPrevious:a}=this,{fragments:n,endSN:o}=r,{fragmentHint:l}=r,{maxFragLookUpTolerance:h}=s,d=r.partList,u=!!(s.lowLatencyMode&&null!=d&&d.length&&l);if(u&&l&&!this.bitrateTest&&(n=n.concat(l),o=l.sn),i=e<t?tD(a,n,e,e>t-h?0:h):n[n.length-1]){let e=i.sn-r.startSN,t=this.fragmentTracker.getState(i);if((t===tG.OK||t===tG.PARTIAL&&i.gap)&&(a=i),a&&i.sn===a.sn&&(!u||d[0].fragment.sn>i.sn)&&a&&i.level===a.level){let t=n[e+1];i=i.sn<o&&this.fragmentTracker.getState(t)!==tG.OK?t:null}}return i}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let i=this.hls.liveSyncPosition,s=r.currentTime,a=e.fragments[0].start,n=e.edge,o=s>=a-t.maxFragLookUpTolerance&&s<=n;if(null!==i&&r.duration>i&&(s<i||!o)){let a=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||s<n-a)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${n}, reset currentTime to : ${i.toFixed(3)}`),r.currentTime=i))}}alignPlaylists(e,t,r){let i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;let s=e.fragments[0].start,a=!t,n=e.alignedSliding&&f(s);if(a||!n&&!s){let{fragPrevious:s}=this;r&&(function(e,t,r){if(r&&(t.endCC>t.startCC||e&&e.cc<t.startCC)){let e=function(e,t){let r=e.fragments,i=t.fragments;if(!i.length||!r.length)return void A.log("No fragments to align");let s=tz(r,i[0].cc);return s&&(!s||s.startPTS)?s:void A.log("No frag in previous level to align on")}(r,t);e&&f(e.start)&&(A.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),tJ(e.start,t))}}(s,e,r),!e.alignedSliding&&r&&tQ(e,r),e.alignedSliding||!r||e.skippedSegments||tm(r,e));let a=e.fragments[0].start;return this.log(`Live playlist sliding: ${a.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${s?s.sn:"na"} fragments: ${i}`),a}return s}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){let i=null!==this.startTimeOffset,s=i?this.startTimeOffset:e.startTimeOffset;null!==s&&f(s)?(r=t+s,s<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${s} found in ${i?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===t9.FRAG_LOADING_WAITING_RETRY)||(this.state=t9.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var i;this.warn(`Frag load error must match current frag to retry ${r.url} > ${null==(i=this.fragCurrent)?void 0:i.url}`);return}let s=t.details===E.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:n,retryCount:o=0,retryConfig:l}=a||{};if(a&&n===t_.RetryRequest&&l){this.resetStartWhenNotLoaded(this.levelLastLoaded);let i=tA(l,o);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${o+1}/${l.maxNumRetry} in ${i}ms`),a.resolved=!0,this.retryDate=self.performance.now()+i,this.state=t9.FRAG_LOADING_WAITING_RETRY}else if(l&&a){if(this.resetFragmentErrors(e),!(o<l.maxNumRetry))return void A.warn(`${t.details} reached or exceeded max retry (${o})`);s||n===t_.RemoveAlternatePermanently||(a.resolved=!0)}else(null==a?void 0:a.action)===t_.SendAlternateToPenaltyBox?this.state=t9.WAITING_LEVEL:this.state=t9.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===t9.PARSING||this.state===t9.PARSED){let t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);let a=!s;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===e0.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==t9.STOPPED&&(this.state=t9.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let i=tW.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===t9.ENDED&&this.resetLoadingState()}
5resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=t9.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,i){var s;let a=r.details;if(!a)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,s)=>{let n=e.elementaryStreams[s];if(n){let o=n.endPTS-n.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${o})`),t||!1;let l=i?0:tg(a,e,n.startPTS,n.endPTS,n.startDTS,n.endDTS);return this.hls.trigger(p.LEVEL_PTS_UPDATED,{details:a,level:r,drift:l,type:s,frag:e,start:n.startPTS,end:n.endPTS}),!0}return t},!1)&&(null==(s=this.transmuxer)?void 0:s.error)===null){let t=Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(0===r.fragmentError&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(t.message),this.hls.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=t9.PARSED,this.hls.trigger(p.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class re{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let e,{chunks:t,dataLength:r}=this;return t.length?(e=1===t.length?t[0]:function(e,t){let r=new Uint8Array(t),i=0;for(let t=0;t<e.length;t++){let s=e[t];r.set(s,i),i+=s.length}return r}(t,r),this.reset(),e):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function rt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class rr{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){let r;this.cachedData&&(e=eT(this.cachedData,e),this.cachedData=null);let i=W(e,0),s=i?i.length:0,a=this._audioTrack,n=this._id3Track,o=i?z(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&f(o))&&(this.basePTS=ri(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:e7.audioId3,duration:1/0});s<l;){if(this.canParse(e,s)){let t=this.appendFrame(a,e,s);t?(this.frameIndex++,this.lastPTS=t.sample.pts,s+=t.length,r=s):s=l}else q(e,s)?(i=W(e,s),n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:e7.audioId3,duration:1/0}),s+=i.length,r=s):s++;if(s===l&&r!==l){let t=H(e,r);this.cachedData?this.cachedData=eT(this.cachedData,t):this.cachedData=t}}return{audioTrack:a,videoTrack:rt(),id3Track:n,textTrack:rt()}}demuxSampleAes(e,t,r){return Promise.reject(Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:rt(),id3Track:this._id3Track,textTrack:rt()}}destroy(){}}let ri=(e,t,r)=>f(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0);function rs(e,t){return 255===e[t]&&(246&e[t+1])==240}function ra(e,t){return 1&e[t+1]?7:9}function rn(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function ro(e,t){return t+1<e.length&&rs(e,t)}function rl(e,t,r,i,s){if(!e.samplerate){let a=function(e,t,r,i){let s,a,n,o,l=navigator.userAgent.toLowerCase(),h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((192&t[r+2])>>>6)+1;let d=(60&t[r+2])>>>2;if(d>h.length-1){let t=Error(`invalid ADTS sampling index:${d}`);e.emit(p.ERROR,p.ERROR,{type:v.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message});return}return n=(1&t[r+2])<<2|(192&t[r+3])>>>6,A.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${d}`),/firefox/i.test(l)?d>=6?(s=5,o=[,,,,],a=d-3):(s=2,o=[,,],a=d):-1!==l.indexOf("android")?(s=2,o=[,,],a=d):(s=5,o=[,,,,],i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&d>=6?a=d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(d>=6&&1===n||/vivaldi/i.test(l))||!i&&1===n)&&(s=2,o=[,,]),a=d)),o[0]=s<<3,o[0]|=(14&d)>>1,o[1]|=(1&d)<<7,o[1]|=n<<3,5===s&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[d],channelCount:n,codec:"mp4a.40."+s,manifestCodec:i}}(t,r,i,s);a&&(e.config=a.config,e.samplerate=a.samplerate,e.channelCount=a.channelCount,e.codec=a.codec,e.manifestCodec=a.manifestCodec,A.log(`parsed codec:${e.codec}, rate:${a.samplerate}, channels:${a.channelCount}`))}}function rh(e,t,r,i,s){let a,n=i+s*(9216e4/e.samplerate),o=function(e,t){let r=ra(e,t);if(t+r<=e.length){let i=rn(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){let{frameLength:i,headerLength:s}=o,l=s+i,h=Math.max(0,r+l-t.length);h?(a=new Uint8Array(l-s)).set(t.subarray(r+s,t.length),0):a=t.subarray(r+s,r+l);let d={unit:a,pts:n};return h||e.samples.push(d),{sample:d,length:l,missing:h}}let l=t.length-r;return(a=new Uint8Array(l)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:n},length:l,missing:-1}}let rd=null,ru=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],rc=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],rf=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],rg=[0,1,1,4];function rm(e,t,r,i,s){if(r+24>t.length)return;let a=rp(t,r);if(a&&r+a.frameLength<=t.length){let n=i+s*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:n,dts:n};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}function rp(e,t){let r=e[t+1]>>3&3,i=e[t+1]>>1&3,s=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==r&&0!==s&&15!==s&&3!==a){let n=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*ru[14*(3===r?3-i:3===i?3:4)+s-1],h=rc[3*(3===r?0:2===r?1:2)+a],d=rf[r][i],u=rg[i],c=Math.floor(d*l/h+n)*u;if(null===rd){let e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);rd=e?parseInt(e[1]):0}return rd&&rd<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:h,channelCount:3===o?1:2,frameLength:c,samplesPerFrame:8*d*u}}}
5function rv(e,t){return 255===e[t]&&(224&e[t+1])==224&&(6&e[t+1])!=0}function rE(e,t){return t+1<e.length&&rv(e,t)}function ry(e,t){if(t+1<e.length&&rv(e,t)){let r=rp(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);let s=t+i;return s===e.length||rE(e,s)}return!1}let rT=/\/emsg[-/]ID3/i,rS=(e,t)=>{let r=0,i=5;t+=5;let s=new Uint32Array(1),a=new Uint32Array(1),n=new Uint8Array(1);for(;i>0;){n[0]=e[t];let o=Math.min(i,8),l=8-o;a[0]=0xff000000>>>24+l<<l,s[0]=(n[0]&a[0])>>l,r=r?r<<o|s[0]:s[0],t+=1,i-=o}return r};function rA(e,t,r,i,s){if(r+8>t.length||11!==t[r]||119!==t[r+1])return -1;let a=t[r+4]>>6;if(a>=3)return -1;let n=[48e3,44100,32e3][a],o=63&t[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+a];if(r+l>t.length)return -1;let h=t[r+6]>>5,d=0;2===h?d+=2:(1&h&&1!==h&&(d+=2),4&h&&(d+=2));let u=(t[r+6]<<8|t[r+7])>>12-d&1,c=[2,1,2,3,3,4,4,5][h]+u,f=t[r+5]>>3,g=7&t[r+5],m=new Uint8Array([a<<6|f<<1|g>>2,(3&g)<<6|h<<3|u<<2|o>>4,o<<4&224]),p=t.subarray(r,r+l);return e.config=m,e.channelCount=c,e.samplerate=n,e.samples.push({unit:p,pts:i+1536/n*9e4*s}),l}class rR{constructor(){this.VideoSample=null}createVideoSample(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}}getLastNalUnit(e){var t;let r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){let e=i.units;r=e[e.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){let r=t.samples,i=r.length;if(!i)return void t.dropped++;{let t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}e.debug.length&&A.log(e.pts+"/"+e.dts+":"+e.debug)}}class rL{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw Error("no bytes available");i.set(e.subarray(r,r+s)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*s,this.bytesAvailable-=s}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e||(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&A.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw Error("no bits available");return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&0x80000000>>>e)!=0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8;for(let i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}readSPS(){let e,t,r,i=0,s=0,a=0,n=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),h=this.readUEG.bind(this),d=this.readBoolean.bind(this),u=this.skipBits.bind(this),c=this.skipEG.bind(this),f=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);o();let m=o();if(l(5),u(3),o(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){let e=h();if(3===e&&u(1),f(),f(),u(1),d())for(r=0,t=3!==e?8:12;r<t;r++)d()&&g(r<6?16:64)}f();let p=h();if(0===p)h();else if(1===p)for(u(1),c(),c(),e=h(),r=0;r<e;r++)c();f(),u(1);let v=h(),E=h(),y=l(1);0===y&&u(1),u(1),d()&&(i=h(),s=h(),a=h(),n=h());let T=[1,1];if(d()&&d())switch(o()){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:T=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil((v+1)*16-2*i-2*s),height:(2-y)*(E+1)*16-(y?2:4)*(a+n),pixelRatio:T}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}
5class rb extends rR{parseAVCPES(e,t,r,i,s){let a,n=this.parseAVCNALu(e,r.data),o=this.VideoSample,l=!1;r.data=null,o&&n.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),n.forEach(i=>{var n,h,d,u;switch(i.type){case 1:{let t=!1;a=!0;let s=i.data;if(l&&s.length>4){let e=new rL(s).readSliceType();(2===e||4===e||7===e||9===e)&&(t=!0)}t&&null!=(h=o)&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=t;break}case 5:a=!0,null!=(n=o)&&n.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:a=!0,eA(i.data,1,r.pts,t.samples);break;case 7:{a=!0,l=!0;let t=i.data,r=new rL(t).readSPS();if(!e.sps||e.width!==r.width||e.height!==r.height||(null==(d=e.pixelRatio)?void 0:d[0])!==r.pixelRatio[0]||(null==(u=e.pixelRatio)?void 0:u[1])!==r.pixelRatio[1]){e.width=r.width,e.height=r.height,e.pixelRatio=r.pixelRatio,e.sps=[t],e.duration=s;let i=t.subarray(1,4),a="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),a+=t}e.codec=a}break}case 8:a=!0,e.pps=[i.data];break;case 9:a=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+i.type+" ")}o&&a&&o.units.push(i)}),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){let r,i,s,a=t.byteLength,n=e.naluState||0,o=n,l=[],h=0,d=-1,u=0;for(-1===n&&(d=0,u=31&t[0],n=0,h=1);h<a;){if(r=t[h++],!n){n=+!r;continue}if(1===n){n=2*!r;continue}if(r)if(1===r){if(i=h-n-1,d>=0){let e={data:t.subarray(d,i),type:u};l.push(e)}else{let r=this.getLastNalUnit(e.samples);r&&(o&&h<=4-o&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-o)),i>0&&(r.data=eT(r.data,t.subarray(0,i)),r.state=0))}h<a?(s=31&t[h],d=h,u=s,n=0):n=-1}else n=0;else n=3}if(d>=0&&n>=0){let e={data:t.subarray(d,a),type:u,state:n};l.push(e)}if(0===l.length){let r=this.getLastNalUnit(e.samples);r&&(r.data=eT(r.data,t))}return e.naluState=n,l}}class rD{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new t5(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let i=e[t].unit;if(i.length<=16)return;let s=i.subarray(16,i.length-i.length%16),a=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(a).then(s=>{let a=new Uint8Array(s);i.set(a,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=new Int8Array(16*Math.floor((e.length-48)/160)+16),r=0;for(let i=32;i<e.length-16;i+=160,r+=16)t.set(e.subarray(i,i+16),r);return t}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(r.subarray(i,i+16),t);return e}decryptAvcSample(e,t,r,i,s){let a=eR(s.data),n=this.getAvcEncryptedData(a);this.decryptBuffer(n.buffer).then(n=>{s.data=this.getAvcDecryptedUnit(a,n),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,i)})}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();let s=e[t].units;for(;!(r>=s.length);r++){let a=s[r];if(!(a.data.length<=48)&&(1===a.type||5===a.type)&&(this.decryptAvcSample(e,t,r,i,a),!this.decrypter.isSync()))return}}}}class rI{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new rb}static probe(e){let t=rI.syncOffset(e);return t>
50&&A.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),-1!==t}static syncOffset(e){let t=e.length,r=Math.min(940,t-188)+1,i=0;for(;i<r;){let s=!1,a=-1,n=0;for(let o=i;o<t;o+=188)if(71===e[o]&&(t-o==188||71===e[o+188])){if(n++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-188)+1),s||(s=0===r_(e,o)),s&&n>1&&(0===a&&n>2||o+188>r))return a}else if(n)return -1;else break;i++}return -1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:eo[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=rI.createTrack("video"),this._audioTrack=rI.createTrack("audio",i),this._id3Track=rI.createTrack("id3"),this._txtTrack=rI.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t){let r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i||(this.sampleAes=null);let a=this._videoTrack,n=this._audioTrack,o=this._id3Track,l=this._txtTrack,h=a.pid,d=a.pesData,u=n.pid,c=o.pid,f=n.pesData,g=o.pesData,m=null,p=this.pmtParsed,v=this._pmtId,E=e.length;if(this.remainderData&&(E=(e=eT(this.remainderData,e)).length,this.remainderData=null),E<188&&!s)return this.remainderData=e,{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l};let y=Math.max(0,rI.syncOffset(e));(E-=(E-y)%188)<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,E,e.buffer.byteLength-E));let T=0;for(let t=y;t<E;t+=188)if(71===e[t]){let s,E=!!(64&e[t+1]),T=r_(e,t);if((48&e[t+3])>>4>1){if((s=t+5+e[t+4])===t+188)continue}else s=t+4;switch(T){case h:E&&(d&&(r=rC(d))&&this.videoParser.parseAVCPES(a,l,r,!1,this._duration),d={data:[],size:0}),d&&(d.data.push(e.subarray(s,t+188)),d.size+=t+188-s);break;case u:if(E){if(f&&(r=rC(f)))switch(n.segmentCodec){case"aac":this.parseAACPES(n,r);break;case"mp3":this.parseMPEGPES(n,r);break;case"ac3":this.parseAC3PES(n,r)}f={data:[],size:0}}f&&(f.data.push(e.subarray(s,t+188)),f.size+=t+188-s);break;case c:E&&(g&&(r=rC(g))&&this.parseID3PES(o,r),g={data:[],size:0}),g&&(g.data.push(e.subarray(s,t+188)),g.size+=t+188-s);break;case 0:var S,R;E&&(s+=e[s]+1),v=this._pmtId=(31&(S=e)[(R=s)+10])<<8|S[R+11];break;case v:{E&&(s+=e[s]+1);let r=function(e,t,r,i,s){let a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},n=(15&e[t+1])<<8|e[t+2],o=t+3+n-4,l=(15&e[t+10])<<8|e[t+11];for(t+=12+l;t<o;){let n=r_(e,t),o=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){rw("ADTS AAC");break}case 15:-1===a.audioPid&&(a.audioPid=n);break;case 21:-1===a.id3Pid&&(a.id3Pid=n);break;case 219:if(!i){rw("H.264");break}case 27:-1===a.videoPid&&(a.videoPid=n,a.segmentVideoCodec="avc");break;case 3:case 4:r.mpeg||r.mp3?-1===a.audioPid&&(a.audioPid=n,a.segmentAudioCodec="mp3"):A.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){rw("AC-3");break}case 129:r.ac3?-1===a.audioPid&&(a.audioPid=n,a.segmentAudioCodec="ac3"):A.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&o>0){let i=t+5,s=o;for(;s>2;){106===e[i]&&(!0!==r.ac3?A.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=n,a.segmentAudioCodec="ac3"));let t=e[i+1]+2;i+=t,s-=t}}break;case 194:case 135:return rk(s,Error("Unsupported EC-3 in M2TS found")),a;case 36:return rk(s,Error("Unsupported HEVC in M2TS found")),a}t+=o+5}return a}(e,s,this.typeSupported,i,this.observer);(h=r.videoPid)>0&&(a.pid=h,a.segmentCodec=r.segmentVideoCodec),(u=r.audioPid)>0&&(n.pid=u,n.segmentCodec=r.segmentAudioCodec),(c=r.id3Pid)>0&&(o.pid=c),null===m||p||(A.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${y} to parse all TS packets.`),m=null,t=y-188),p=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=T}}else T++;T>0&&rk(this.observer,Error(`Found ${T} TS packet/s that do not start with 0x47`)),a.pesData=d,n.pesData=f,o.pesData=g;let L={audioTrack:n,videoTrack:a,id3Track:o,textTrack:l};return s&&this.extractRemainingSamples(L),L}flush(){let e,{remainderData:t}=this;
5return(this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes)?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(e){let t,{audioTrack:r,videoTrack:i,id3Track:s,textTrack:a}=e,n=i.pesData,o=r.pesData,l=s.pesData;if(n&&(t=rC(n))?(this.videoParser.parseAVCPES(i,a,t,!0,this._duration),i.pesData=null):i.pesData=n,o&&(t=rC(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t);break;case"ac3":this.parseAC3PES(r,t)}r.pesData=null}else null!=o&&o.size&&A.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=rC(l))?(this.parseID3PES(s,t),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let i=this.demux(e,r,!0,!this.config.progressive),s=this.sampleAes=new rD(this.observer,this.config,t);return this.decrypt(i,s)}decrypt(e,t){return new Promise(r=>{let{audioTrack:i,videoTrack:s}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{s.samples?t.decryptAvcSamples(s.samples,0,0,()=>{r(e)}):r(e)}):s.samples&&t.decryptAvcSamples(s.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r,i,s,a,n=0,o=this.aacOverFlow,l=t.data;if(o){this.aacOverFlow=null;let t=o.missing,r=o.sample.unit.byteLength;-1===t?l=eT(o.sample.unit,l):(o.sample.unit.set(l.subarray(0,t),r-t),e.samples.push(o.sample),n=o.missing)}for(r=n,i=l.length;r<i-1&&!ro(l,r);r++);if(r!==n){let e,t=r<i-1;if(e=t?`AAC PES did not start with ADTS header,offset:${r}`:"No ADTS header found in AAC PES",rk(this.observer,Error(e),t),!t)return}if(rl(e,this.observer,l,r,this.audioCodec),void 0!==t.pts)s=t.pts;else{if(!o)return void A.warn("[tsdemuxer]: AAC PES unknown PTS");let t=9216e4/e.samplerate;s=o.sample.pts+t}let h=0;for(;r<i;){if(a=rh(e,l,r,s,h),r+=a.length,a.missing){this.aacOverFlow=a;break}for(h++;r<i-1&&!ro(l,r);r++);}}parseMPEGPES(e,t){let r=t.data,i=r.length,s=0,a=0,n=t.pts;if(void 0===n)return void A.warn("[tsdemuxer]: MPEG PES unknown PTS");for(;a<i;)if(rE(r,a)){let t=rm(e,r,a,n,s);if(t)a+=t.length,s++;else break}else a++}parseAC3PES(e,t){{let r,i=t.data,s=t.pts;if(void 0===s)return void A.warn("[tsdemuxer]: AC3 PES unknown PTS");let a=i.length,n=0,o=0;for(;o<a&&(r=rA(e,i,o,s,n++))>0;)o+=r}}parseID3PES(e,t){if(void 0===t.pts)return void A.warn("[tsdemuxer]: ID3 PES unknown PTS");let r=c({},t,{type:this._videoTrack?e7.emsg:e7.audioId3,duration:1/0});e.samples.push(r)}}function r_(e,t){return((31&e[t+1])<<8)+e[t+2]}function rk(e,t,r){A.warn(`parsing error: ${t.message}`),e.emit(p.ERROR,p.ERROR,{type:v.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function rw(e){A.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function rC(e){let t,r,i,s,a,n=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=eT(o[0],o[1]),o.splice(1,1);if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;let l=t[7];192&l&&(s=(14&t[9])*0x20000000+(255&t[10])*4194304+(254&t[11])*16384+(255&t[12])*128+(254&t[13])/2,64&l?s-(a=(14&t[14])*0x20000000+(255&t[15])*4194304+(254&t[16])*16384+(255&t[17])*128+(254&t[18])/2)>54e5&&(A.warn(`${Math.round((s-a)/9e4)}s delta between PTS and DTS, align them`),s=a):a=s);let h=(i=t[8])+9;if(e.size<=h)return null;e.size-=h;let d=new Uint8Array(e.size);for(let e=0,r=o.length;e<r;e++){let r=(t=o[e]).byteLength;if(h)if(h>r){h-=r;continue}else t=t.subarray(h),r-=h,h=0;d.set(t,n),n+=r}return r&&(r-=i+3),{data:d,pts:s,dts:a,len:r}}return null}class rx{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);else if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);else if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}class rP{static init(){let e;for(e in rP.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},rP.types)rP.types.hasOwnProperty(e)&&(rP.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);rP.HDLR_TYPES={video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])};let t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);rP.STTS=rP.STSC=rP.STCO=new Uint8Array([0,0,0,0,0,0,0,0]),rP.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),rP.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),rP.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),rP.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let r=new Uint8Array([105,115,111,109]),i=new Uint8Array([97,118,99,49]),s=new Uint8Array([0,0,0,1]);rP.FTYP=rP.box(rP.types.ftyp,r,s,r,i),rP.DINF=rP.box(rP.types.dinf,rP.box(rP.types.dref,t))}static box(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];let s=8,a=r.length,n=a;for(;a--;)s+=r[a].byteLength;let o=new Uint8Array(s);for(o[0]=s>>24&255,o[1]=s>>16&255,o[2]=s>>8&255,o[3]=255&s,o.set(e,4),a=0,s=8;a<n;a++)o.set(r[a],s),s+=r[a].byteLength;return o}static hdlr(e){return rP.box(rP.types.hdlr,rP.HDLR_TYPES[e])}static mdat(e){return rP.box(rP.types.mdat,e)}static mdhd(e,t){let r=Math.floor((t*=e)/0x100000000),i=Math.floor(t%0x100000000);return rP.box(rP.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return rP.box(rP.types.mdia,rP.mdhd(e.timescale,e.duration),rP.hdlr(e.type),rP.minf(e))}static mfhd(e){return rP.box(rP.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?rP.box(rP.types.minf,rP.box(rP.types.smhd,rP.SMHD),rP.DINF,rP.stbl(e)):rP.box(rP.types.minf,rP.box(rP.types.vmhd,rP.VMHD),rP.DINF,rP.stbl(e))}static moof(e,t,r){return rP.box(rP.types.moof,rP.mfhd(e),rP.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=rP.trak(e[t]);return rP.box.apply(null,[rP.types.moov,rP.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(rP.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=rP.trex(e[t]);return rP.box.apply(null,[rP.types.mvex,...r])}static mvhd(e,t){let r=Math.floor((t*=e)/0x100000000),i=Math.floor(t%0x100000000),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return rP.box(rP.types.mvhd,s)}static sdtp(e){let t,r,i=e.samples||[],s=new Uint8Array(4+i.length);for(t=0;t<i.length;t++)r=i[t].flags,s[t+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return rP.box(rP.types.sdtp,s)}static stbl(e){return rP.box(rP.types.stbl,rP.stsd(e),rP.box(rP.types.stts,rP.STTS),rP.box(rP.types.stsc,rP.STSC),rP.box(rP.types.stsz,rP.STSZ),rP.box(rP.types.stco,rP.STCO))}static avc1(e){let t,r,i,s=[],a=[];for(t=0;t<e.sps.length;t++)i=(r=e.sps[t]).byteLength,s.push(i>
5>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)i=(r=e.pps[t]).byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(r));let n=rP.box(rP.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(a))),o=e.width,l=e.height,h=e.pixelRatio[0],d=e.pixelRatio[1];return rP.box(rP.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n,rP.box(rP.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),rP.box(rP.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){let t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0])}static mp4a(e){return rP.box(rP.types.mp4a,rP.audioStsd(e),rP.box(rP.types.esds,rP.esds(e)))}static mp3(e){return rP.box(rP.types[".mp3"],rP.audioStsd(e))}static ac3(e){return rP.box(rP.types["ac-3"],rP.audioStsd(e),rP.box(rP.types.dac3,e.config))}static stsd(e){return"audio"!==e.type?rP.box(rP.types.stsd,rP.STSD,rP.avc1(e)):"mp3"===e.segmentCodec&&"mp3"===e.codec?rP.box(rP.types.stsd,rP.STSD,rP.mp3(e)):"ac3"===e.segmentCodec?rP.box(rP.types.stsd,rP.STSD,rP.ac3(e)):rP.box(rP.types.stsd,rP.STSD,rP.mp4a(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,i=e.width,s=e.height,a=Math.floor(r/0x100000000),n=Math.floor(r%0x100000000);return rP.box(rP.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,s>>8&255,255&s,0,0]))}static traf(e,t){let r=rP.sdtp(e),i=e.id,s=Math.floor(t/0x100000000),a=Math.floor(t%0x100000000);return rP.box(rP.types.traf,rP.box(rP.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),rP.box(rP.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,a>>24,a>>16&255,a>>8&255,255&a])),rP.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||0xffffffff,rP.box(rP.types.trak,rP.tkhd(e),rP.mdia(e))}static trex(e){let t=e.id;return rP.box(rP.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r,i,s,a,n,o,l=e.samples||[],h=l.length,d=12+16*h,u=new Uint8Array(d);for(t+=8+d,u.set([+("video"===e.type),0,15,1,h>>>24&255,h>>>16&255,h>>>8&255,255&h,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r<h;r++)s=(i=l[r]).duration,a=i.size,n=i.flags,o=i.cts,u.set([s>>>24&255,s>>>16&255,s>>>8&255,255&s,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,o>>>24&255,o>>>16&255,o>>>8&255,255&o],12+16*r);return rP.box(rP.types.trun,u)}static initSegment(e){rP.types||rP.init();let t=rP.moov(e);return eT(rP.FTYP,t)}}function rO(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=e*t*r;return i?Math.round(s):s}function rM(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return rO(e,1e3,11111111111111112e-21,t)}rP.types=void 0,rP.HDLR_TYPES=void 0,rP.STTS=void 0,rP.STSC=void 0,rP.STCO=void 0,rP.STSZ=void 0,rP.VMHD=void 0,rP.SMHD=void 0,rP.STSD=void 0,rP.FTYP=void 0,rP.DINF=void 0;let rF=null,rN=null;class rU{constructor(e,t,r,i=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupp
5orted=r,this.ISGenerated=!1,null===rF){let e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);rF=e?parseInt(e[1]):0}if(null===rN){let e=navigator.userAgent.match(/Safari\/(\d+)/i);rN=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){A.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){A.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){A.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,r=e.reduce((e,r)=>{let i=r.pts-e;return i<-0x100000000?(t=!0,rB(e,r.pts)):i>0?e:r.pts},e[0].pts);return t&&A.debug("PTS rollover detected"),r}remux(e,t,r,i,s,a,n,o){let l,h,d,u,c,f,g=s,m=s,p=e.pid>-1,v=t.pid>-1,E=t.samples.length,y=e.samples.length>0,T=n&&E>0||E>1;if((!p||y)&&(!v||T)||this.ISGenerated||n){let r;if(this.ISGenerated){var S,R,L,b;let e=this.videoTrackConfig;e&&(t.width!==e.width||t.height!==e.height||(null==(S=t.pixelRatio)?void 0:S[0])!==(null==(R=e.pixelRatio)?void 0:R[0])||(null==(L=t.pixelRatio)?void 0:L[1])!==(null==(b=e.pixelRatio)?void 0:b[1]))&&this.resetInitSegment()}else d=this.generateIS(e,t,s,a);let i=this.isVideoContiguous,n=-1;if(T&&(n=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return -1}(t.samples),!i&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,n>0){A.warn(`[mp4-remuxer]: Dropped ${n} out of ${E} video samples due to a missing keyframe`);let e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(n),t.dropped+=n,m+=(t.samples[0].pts-e)/t.inputTimeScale,r=m}else -1===n&&(A.warn(`[mp4-remuxer]: No keyframe found out of ${E} video samples`),f=!1);if(this.ISGenerated){if(y&&T){let r=this.getVideoStartPts(t.samples),i=(rB(e.samples[0].pts,r)-r)/t.inputTimeScale;g+=Math.max(0,i),m+=Math.max(0,-i)}if(y){if(e.samplerate||(A.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,s,a)),h=this.remuxAudio(e,g,this.isAudioContiguous,a,v||T||o===e0.AUDIO?m:void 0),T){let r=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(A.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,s,a)),l=this.remuxVideo(t,m,i,r)}}else T&&(l=this.remuxVideo(t,m,i,0));l&&(l.firstKeyFrame=n,l.independent=-1!==n,l.firstKeyFramePTS=r)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(c=r$(r,s,this._initPTS,this._initDTS)),i.samples.length&&(u=rG(i,s,this._initPTS))),{audio:h,video:l,initSegment:d,independent:f,text:u,id3:c}}generateIS(e,t,r,i){let s,a,n,o=e.samples,l=t.samples,h=this.typeSupported,d={},u=this._initPTS,c=!u||i,f="audio/mp4";if(c&&(s=a=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":h.mpeg?(f="audio/mpeg",e.codec=""):h.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&h.mpeg?new Uint8Array(0):rP.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(n=e.inputTimeScale,u&&n===u.timescale?c=!1:s=a=o[0].pts-Math.round(n*r))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:rP.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(n=t.inputTimeScale,u&&n===u.timescale)c=!1;else{let e=this.getVideoStartPts(l),t=Math.round(n*r);a=Math.min(a,rB(l[0].dts,e)-t),s=Math.min(s,e-t)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:s,timescale:n},this._initDTS={baseTime:a,timescale:n}):s=n=void 0,{tracks:d,initPTS:s,timescale:n}}remuxVideo(e,t,r,i){let s,a,n,o=e.inputTimeScale,l=e.samples,h=[],d=l.length,u=this._initPTS,f=this.nextAvcDts,g=8,m=this.videoSampleDuration,y=1/0,T=-1/0,S=!1;if(!r||null===f){let e=t*o,i=l[0].pts-rB(l[0].dts,l[0].pts);rF&&null!==f&&15e3>Math.abs(e-i-f)?r=!0:f=e-i}let R=u.baseTime*o/u.timescale;for(let e=0;e<d;e++){let t=l[e];t.pts=rB(t.pts-R,f),t.dts=rB(t.dts-R,f),t.dts<l[e>0?e-1:e].dts&&(S=!0)}S&&l.sort(function(e,t){let r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),s=l[0].dts;let L=(a=l[l.length-1].dts)-s,b=L?Math.round(L/(d-1)):m||e.inputTimeScale/30;if(r){let e=s-f,r=e>b,i=e<-1;if((r||i)&&(r?A.warn(`AVC: ${rM(e,!0)} ms (${e}dts) hole between fragments detected at ${t.toFixed(3)}`):A.warn(`AVC: ${rM(-e,!0)} ms (${e}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!i||f>=l[0].pts||rF)){s=f;let t=l[0].pts-e;if(r)l[0].dts=s,l[0].pts=t;else for(let r=0;r<l.length&&!(l[r].dts>t);r++)l[r].dts-=e,l[r].pts-=e;A.log(`Video: Initial PTS/DTS adjusted: ${rM(t,!0)}/${rM(s,!0)}, delta: ${rM(e,!0)} ms`)}}let D=0,I=0,_=s=Math.max(0,s);for(let e=0;e<d;e++){let t=l[e],r=t.units,i=r.length,s=0;for(let e=0;e<i;e++)s+=r[e].data.length;I+=s,D+=i,t.length=s,t.dts<_?(t.dts=_,_+=b/4|0||1):_=t.dts,y=Math.min(t.pts,y),T=Math.max(t.pts,T)}a=l[d-1].dts;let k=I+4*D+8;try{n=new Uint8Array(k)}catch(e){this.observer.emit(p.ERROR,p.ERROR,{type:v.MUX_ERROR,details:E.REMUX_ALLOC_ER
5ROR,fatal:!1,error:e,bytes:k,reason:`fail allocating video mdat ${k}`});return}let w=new DataView(n.buffer);w.setUint32(0,k),n.set(rP.types.mdat,4);let C=!1,x=1/0,P=1/0,O=-1/0,M=-1/0;for(let e=0;e<d;e++){let t,r=l[e],s=r.units,a=0;for(let e=0,t=s.length;e<t;e++){let t=s[e],r=t.data,i=t.data.byteLength;w.setUint32(g,i),g+=4,n.set(r,g),g+=i,a+=4+i}if(e<d-1)m=l[e+1].dts-r.dts,t=l[e+1].pts-r.pts;else{let s=this.config,a=e>0?r.dts-l[e-1].dts:b;if(t=e>0?r.pts-l[e-1].pts:b,s.stretchShortVideoTrack&&null!==this.nextAudioPts){let e=Math.floor(s.maxBufferHole*o),t=(i?y+i*o:this.nextAudioPts)-r.pts;t>e?((m=t-a)<0?m=a:C=!0,A.log(`[mp4-remuxer]: It is approximately ${t/90} ms to the next segment; using duration ${m/90} ms for the last video frame.`)):m=a}else m=a}let u=Math.round(r.pts-r.dts);x=Math.min(x,m),O=Math.max(O,m),P=Math.min(P,t),M=Math.max(M,t),h.push(new rK(r.key,m,a,u))}if(h.length){if(rF){if(rF<70){let e=h[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(rN&&M-P<O-x&&b/O<.025&&0===h[0].cts){A.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=s;for(let t=0,r=h.length;t<r;t++){let i=e+h[t].duration,s=e+h[t].cts;if(t<r-1){let e=i+h[t+1].cts;h[t].duration=e-s}else h[t].duration=t?h[t-1].duration:b;h[t].cts=0,e=i}}}m=C||!m?b:m,this.nextAvcDts=f=a+m,this.videoSampleDuration=m,this.isVideoContiguous=!0;let F={data1:rP.moof(e.sequenceNumber++,s,c({},e,{samples:h})),data2:n,startPTS:y/o,endPTS:(T+m)/o,startDTS:s/o,endDTS:f/o,type:"video",hasAudio:!1,hasVideo:!0,nb:h.length,dropped:e.dropped};return e.samples=[],e.dropped=0,F}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,r,i,s){let a,n=e.inputTimeScale,o=e.samplerate?e.samplerate:n,l=n/o,h=this.getSamplesPerFrame(e),d=h*l,u=this._initPTS,f="mp3"===e.segmentCodec&&this.typeSupported.mpeg,g=[],m=void 0!==s,y=e.samples,T=8*!f,S=this.nextAudioPts||-1,R=t*n,L=u.baseTime*n/u.timescale;if(this.isAudioContiguous=r=r||y.length&&S>0&&(i&&9e3>Math.abs(R-S)||Math.abs(rB(y[0].pts-L,R)-S)<20*d),y.forEach(function(e){e.pts=rB(e.pts-L,R)}),!r||S<0){if(!(y=y.filter(e=>e.pts>=0)).length)return;S=0===s?0:i&&!m?Math.max(0,R):y[0].pts}if("aac"===e.segmentCodec){let t=this.config.maxAudioFramesDrift;for(let r=0,i=S;r<y.length;r++){let s=y[r],a=s.pts,o=a-i,l=Math.abs(1e3*o/n);
5if(o<=-t*d&&m)0===r&&(A.warn(`Audio frame @ ${(a/n).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*o/n)} ms.`),this.nextAudioPts=S=i=a);else if(o>=t*d&&l<1e4&&m){let t=Math.round(o/d);(i=a-t*d)<0&&(t--,i+=d),0===r&&(this.nextAudioPts=S=i),A.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(i/n).toFixed(3)}s due to ${Math.round(1e3*o/n)} ms gap.`);for(let a=0;a<t;a++){let t=Math.max(i,0),a=rx.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);a||(A.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),a=s.unit.subarray()),y.splice(r,0,{unit:a,pts:t}),i+=d,r++}}s.pts=i,i+=d}}let b=null,D=null,I=0,_=y.length;for(;_--;)I+=y[_].unit.byteLength;for(let t=0,i=y.length;t<i;t++){let i=y[t],s=i.unit,n=i.pts;if(null!==D)g[t-1].duration=Math.round((n-D)/l);else{if(r&&"aac"===e.segmentCodec&&(n=S),b=n,!(I>0))return;I+=T;try{a=new Uint8Array(I)}catch(e){this.observer.emit(p.ERROR,p.ERROR,{type:v.MUX_ERROR,details:E.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:I,reason:`fail allocating audio mdat ${I}`});return}f||(new DataView(a.buffer).setUint32(0,I),a.set(rP.types.mdat,4))}a.set(s,T);let o=s.byteLength;T+=o,g.push(new rK(!0,h,o,0)),D=n}let k=g.length;if(!k)return;let w=g[g.length-1];this.nextAudioPts=S=D+l*w.duration;let C=f?new Uint8Array(0):rP.moof(e.sequenceNumber++,b/l,c({},e,{samples:g}));e.samples=[];let x=b/n,P=S/n,O={data1:C,data2:a,startPTS:x,endPTS:P,startDTS:x,endDTS:P,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,O}remuxEmptyAudio(e,t,r,i){let s=e.inputTimeScale,a=e.samplerate?e.samplerate:s,n=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,h=(null!==n?n:i.startDTS*s)+l,d=i.endDTS*s+l,u=s/a*1024,c=Math.ceil((d-h)/u),f=rx.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(A.warn("[mp4-remuxer]: remux empty Audio"),!f)return void A.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");let g=[];for(let e=0;e<c;e++){let t=h+e*u;g.push({unit:f,pts:t,dts:t})}return e.samples=g,this.remuxAudio(e,t,r,!1)}}function rB(e,t){let r;if(null===t)return e;for(r=t<e?-0x200000000:0x200000000;Math.abs(e-t)>0x100000000;)e+=r;return e}function r$(e,t,r,i){let s=e.samples.length;if(!s)return;let a=e.inputTimeScale;for(let n=0;n<s;n++){let s=e.samples[n];s.pts=rB(s.pts-r.baseTime*a/r.timescale,t*a)/a,s.dts=rB(s.dts-i.baseTime*a/i.timescale,t*a)/a}let n=e.samples;return e.samples=[],{samples:n}}function rG(e,t,r){let i=e.samples.length;if(!i)return;let s=e.inputTimeScale;for(let a=0;a<i;a++){let i=e.samples[a];i.pts=rB(i.pts-r.baseTime*s/r.timescale,t*s)/s}e.samples.sort((e,t)=>e.pts-t.pts);let a=e.samples;return e.samples=[],{samples:a}}
5class rK{constructor(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:+!e}}}function rH(e,t){let r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===_.AUDIO){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r)return eB(r,!1);let e="mp4a.40.5";return A.info(`Parsed audio codec "${r}" or audio object type not handled. Using "${e}"`),e}return(A.warn(`Unhandled video codec "${r}"`),"hvc1"===r||"hev1"===r)?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1.42e01e"}try{r=self.performance.now.bind(self.performance)}catch(e){A.debug("Unable to use Performance API on this environment"),r=null==M?void 0:M.Date.now}let rV=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){let s=this.videoTrack=rt("video",1),a=this.audioTrack=rt("audio",1),n=this.txtTrack=rt("text",1);if(this.id3Track=rt("id3",1),this.timeOffset=0,!(null!=e&&e.byteLength))return;let o=em(e);if(o.video){let{id:e,timescale:t,codec:r}=o.video;s.id=e,s.timescale=n.timescale=t,s.codec=r}if(o.audio){let{id:e,timescale:t,codec:r}=o.audio;a.id=e,a.timescale=t,a.codec=r}n.id=eo.text,s.sampleDuration=0,s.duration=a.duration=i}resetContiguity(){this.remainderData=null}static probe(e){let t=e.byteLength;for(let r=0;r<t;){let i=ed(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}demux(e,t){this.timeOffset=t;let r=e,i=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=eT(this.remainderData,e));let t=function(e){let t={valid:null,remainder:null},r=eg(e,["moof"]);if(r.length<2)return t.remainder=e,t;let i=r[r.length-1];return t.valid=H(e,0,i.byteOffset-8),t.remainder=H(e,i.byteOffset-8),t}(r);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=r;let a=this.extractID3Track(i,t);return s.samples=eS(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let i=this.extractID3Track(t,this.timeOffset);
5return r.samples=eS(e,t),{videoTrack:t,audioTrack:rt(),id3Track:i,textTrack:rt()}}extractID3Track(e,t){let r=this.id3Track;return e.samples.length&&eg(e.samples,["emsg"]).forEach(e=>{let i=function(e){let t=e[0],r="",i="",s=0,a=0,n=0,o=0,l=0,h=0;if(0===t){for(;"\0"!==el(e.subarray(h,h+1));)r+=el(e.subarray(h,h+1)),h+=1;for(r+=el(e.subarray(h,h+1)),h+=1;"\0"!==el(e.subarray(h,h+1));)i+=el(e.subarray(h,h+1)),h+=1;i+=el(e.subarray(h,h+1)),h+=1,s=ed(e,12),a=ed(e,16),o=ed(e,20),l=ed(e,24),h=28}else if(1===t){h+=4,s=ed(e,h);let t=ed(e,h+=4),a=ed(e,h+=4);for(h+=4,g(n=0x100000000*t+a)||(n=Number.MAX_SAFE_INTEGER,A.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ed(e,h),h+=4,l=ed(e,h),h+=4;"\0"!==el(e.subarray(h,h+1));)r+=el(e.subarray(h,h+1)),h+=1;for(r+=el(e.subarray(h,h+1)),h+=1;"\0"!==el(e.subarray(h,h+1));)i+=el(e.subarray(h,h+1)),h+=1;i+=el(e.subarray(h,h+1)),h+=1}return{schemeIdUri:r,value:i,timeScale:s,presentationTime:n,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(h,e.byteLength)}}(e);if(rT.test(i.schemeIdUri)){let e=f(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale,s=0xffffffff===i.eventDuration?1/0:i.eventDuration/i.timeScale;s<=.001&&(s=1/0);let a=i.payload;r.samples.push({data:a,len:a.byteLength,dts:e,pts:e,type:e7.emsg,duration:s})}}),r}demuxSampleAes(e,t,r){return Promise.reject(Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(!e||!t)return e;let r=t.keyId;return r&&t.isCommonEncryption&&eg(e,["moov","trak"]).forEach(e=>{let t=eg(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=eg(t,["enca"]),s=i.length>0;
5s||(i=eg(t,["encv"])),i.forEach(e=>{eg(s?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{let t=ey(e);if(t){let e=t.subarray(8,24);e.some(e=>0!==e)||(A.log(`[eme] Patching keyId in 'enc${s?"a":"v"}>sinf>>tenc' box: ${ea.hexDump(e)} -> ${ea.hexDump(r)}`),t.set(r,8))}})})}),e}(e,i)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(null!=e&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let i=this.initData=em(e);i.audio&&(t=rH(i.audio,_.AUDIO)),i.video&&(r=rH(i.video,_.VIDEO));let s={};i.audio&&i.video?s.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?s.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?s.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:A.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s}remux(e,t,r,i,s,a){var n,o,l,h,d;let{initPTS:u,lastEndTime:c}=this,g={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};f(c)||(c=this.lastEndTime=s||0);let m=t.samples;if(!(null!=m&&m.length))return g;let p={initPTS:void 0,timescale:1},v=this.initData;if(null!=(n=v)&&n.length||(this.generateInitSegment(m),v=this.initData),!(null!=(o=v)&&o.length))return A.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),g;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);let E=function(e,t){let r=0,i=0,s=0,a=eg(e,["moof","traf"]);for(let e=0;e<a.length;e++){let n=a[e],o=eg(n,["tfhd"])[0],l=t[ed(o,4)];if(!l)continue;let h=l.default,d=ed(o,0)|(null==h?void 0:h.flags),u=null==h?void 0:h.duration;8&d&&(u=2&d?ed(o,12):ed(o,8));let c=l.timescale||9e4,f=eg(n,["trun"]);for(let e=0;e<f.length;
5e++)(r=function(e){let t=ed(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);let i=0,s=ed(e,4);for(let a=0;a<s;a++)256&t&&(i+=ed(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}(f[e]))||!u||(r=u*ed(f[e],4)),l.type===_.VIDEO?i+=r/c:l.type===_.AUDIO&&(s+=r/c)}if(0===i&&0===s){let t=1/0,r=0,i=0,s=eg(e,["sidx"]);for(let e=0;e<s.length;e++){let a=function(e){let t=[],r=e[0],i=8,s=ed(e,8);i+=4;let a=0,n=0;0===r?(a=ed(e,i),n=ed(e,i+4),i+=8):(a=eu(e,i),n=eu(e,i+8),i+=16),i+=2;let o=e.length+n,l=eh(e,i);i+=2;for(let r=0;r<l;r++){let r=i,a=ed(e,r);r+=4;let n=0x7fffffff&a;if(1==(0x80000000&a)>>>31)return A.warn("SIDX has hierarchical references (not supported)"),null;let l=ed(e,r);r+=4,t.push({referenceSize:n,subsegmentDuration:l,info:{duration:l/s,start:o,end:o+n-1}}),o+=n,r+=4,i=r}return{earliestPresentationTime:a,timescale:s,version:r,referencesCount:l,references:t}}(s[e]);null!=a&&a.references&&(t=Math.min(t,a.earliestPresentationTime/a.timescale),i=(r=Math.max(r,a.references.reduce((e,t)=>e+t.info.duration||0,0)+a.earliestPresentationTime/a.timescale))-t)}if(i&&f(i))return i}return i||s}(m,v),y=(l=v,eg(m,["moof","traf"]).reduce((e,t)=>{let r=eg(t,["tfdt"])[0],i=r[0],s=eg(t,["tfhd"]).reduce((e,t)=>{let s=l[ed(t,4)];if(s){let t=ed(r,4);if(1===i){if(0xffffffff===t)return A.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t*=0x100000000,t+=ed(r,8)}let a=t/(s.timescale||9e4);if(f(a)&&(null===e||a<e))return a}return e},null);return null!==s&&f(s)&&(null===e||s<e)?s:e},null)),T=null===y?s:y;((function(e,t,r,i){if(null===e)return!0;let s=Math.max(i,1);return Math.abs(t-e.baseTime/e.timescale-r)>s})(u,T,s,E)||p.timescale!==u.timescale&&a)&&(p.initPTS=T-s,u&&1===u.timescale&&A.warn(`Adjusting initPTS by ${p.initPTS-u.baseTime}`),this.initPTS=u={baseTime:p.initPTS,timescale:1});let S=e?T-u.baseTime/u.timescale:c,R=S+E;h=v,d=u.baseTime/u.timescale,eg(m,["moof","traf"]).forEach(e=>{eg(e,["tfhd"]).forEach(t=>{let r=h[ed(t,4)];if(!r)return;let i=r.timescale||9e4;eg(e,["tfdt"]).forEach(e=>{let t=e[0],r=d*i;if(r){let i=ed(e,4);if(0===t)i-=r,ef(e,4,i=Math.max(i,0));else{i*=0x100000000,i+=ed(e,8),i-=r;let t=Math.floor((i=Math.max(i,0))/0x100000000),s=Math.floor(i%0x100000000);ef(e,4,t),ef(e,8,s)}}})})}),E>0?this.lastEndTime=R:(A.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let L=!!v.audio,b=!!v.video,D="";L&&(D+="audio"),b&&(D+="video");let I={data1:m,startPTS:S,startDTS:S,endPTS:R,endDTS:R,type:D,hasAudio:L,hasVideo:b,nb:1,dropped:0};return g.audio="audio"===I.type?I:void 0,g.video="audio"!==I.type?I:void 0,g.initSegment=p,g.id3=r$(r,s,u,u),i.samples.length&&(g.text=rG(i,s,u)),g}}},{demux:rI,remux:rU},{demux:class extends rr{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=W(e,0),r=(null==t?void 0:t.length)||0;if(ry(e,r))return!1;for(let t=e.length;r<t;r++)if(function(e,t){if(ro(e,t)){let r=ra(e,t);if(t+r>=e.length)return!1;let i=rn(e,t);if(i<=r)return!1;let s=t+i;return s===e.length||ro(e,s)}return!1}(e,r))return A.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return t+5<e.length&&rs(e,t)&&rn(e,t)<=e.length-t}appendFrame(e,t,r){rl(e,this.observer,t,r,e.manifestCodec);let i=rh(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:rU},{demux:class extends rr{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=W(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==z(t)&&16>=rS(e,r))return!1;for(let t=e.length;r<t;r++)if(ry(e,r))return A.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return rv(e,t)&&4<=e.length-t}appendFrame(e,t,r){if(null!==this.basePTS)return rm(e,t,r,this.basePTS,this.frameIndex)}},remux:rU}];rV.splice(2,0,{demux:class extends rr{constructor(e){super(),this.observer=void 0,this.observer=e}
5resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){let i=rA(e,t,r,this.basePTS,this.frameIndex);if(-1!==i)return{sample:e.samples[e.samples.length-1],length:i,missing:0}}static probe(e){if(!e)return!1;let t=W(e,0);if(!t)return!1;let r=t.length;return!!(11===e[r]&&119===e[r+1]&&void 0!==z(t)&&16>rS(e,r))}},remux:rU});class rj{constructor(e,t,r,i,s){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){var a,n;let o,l=i.transmuxing;l.executeStart=r();let h=new Uint8Array(e),{currentTransmuxState:d,transmuxConfig:u}=this;s&&(this.currentTransmuxState=s);let{contiguous:c,discontinuity:f,trackSwitch:g,accurateTimeOffset:m,timeOffset:y,initSegmentChange:T}=s||d,{audioCodec:S,videoCodec:R,defaultInitPts:L,duration:b,initSegmentData:D}=u,I=(a=h,n=t,o=null,a.byteLength>0&&(null==n?void 0:n.key)!=null&&null!==n.iv&&null!=n.method&&(o=n),o);if(I&&"AES-128"===I.method){let e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(h,I.key.buffer,I.iv.buffer).then(e=>{let t=this.push(e,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise;{let t=e.softwareDecrypt(h,I.key.buffer,I.iv.buffer);if(i.part>-1&&(t=e.flush()),!t)return l.executeEnd=r(),rW(i);h=new Uint8Array(t)}}let _=this.needsProbing(f,g);if(_){let e=this.configureTransmuxer(h);if(e)return A.warn(`[transmuxer] ${e.message}`),this.observer.emit(p.ERROR,p.ERROR,{type:v.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),l.executeEnd=r(),rW(i)}(f||g||T||_)&&this.resetInitSegment(D,S,R,b,t),(f||T||_)&&this.resetInitialTimestamp(L),c||this.resetContiguity();let k=this.transmux(h,I,y,m,i),w=this.currentTransmuxState;return w.contiguous=!0,w.discontinuity=!1,w.trackSwitch=!1,l.executeEnd=r(),k}flush(e){let t=e.transmuxing;t.executeStart=r();let{decrypter:i,currentTransmuxState:s,decryptionPromise:a}=this;if(a)return a.then(()=>this.flush(e));let n=[],{timeOffset:o}=s;if(i){let t=i.flush();t&&n.push(this.push(t,null,e))}let{demuxer:l,remuxer:h}=this;if(!l||!h)return t.executeEnd=r(),[rW(e)];let d=l.flush(o);return rY(d)?d.then(t=>(this.flushRemux(n,t,e),n)):(this.flushRemux(n,d,e),n)}flushRemux(e,t,i){let{audioTrack:s,videoTrack:a,id3Track:n,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:h}=this.currentTransmuxState;A.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);let d=this.remuxer.remux(s,a,n,o,h,l,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=r()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,s){let{demuxer:a,remuxer:n}=this;a&&n&&(a.resetInitSegment(e,t,r,i),n.resetInitSegment(e,t,r,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,s){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,s):this.transmuxUnencrypted(e,r,i,s)}transmuxUnencrypted(e,t,r,i){let{audioTrack:s,videoTrack:a,id3Track:n,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(s,a,n,o,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,s){return this.demuxer.demuxSampleAes(e,t,r).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id),chunkMeta:s}))}
5configureTransmuxer(e){let t,{config:r,observer:i,typeSupported:s,vendor:a}=this;for(let r=0,i=rV.length;r<i;r++){var n;if(null!=(n=rV[r].demux)&&n.probe(e)){t=rV[r];break}}if(!t)return Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,l=this.remuxer,h=t.remux,d=t.demux;l&&l instanceof h||(this.remuxer=new h(i,r,s,a)),o&&o instanceof d||(this.demuxer=new d(i,r,s),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new t5(this.config)),e}}let rW=e=>({remuxResult:{},chunkMeta:e});function rY(e){return"then"in e&&e.then instanceof Function}class rq{constructor(e,t,r,i,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=s||null}}class rz{constructor(e,t,r,i,s,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=s,this.initSegmentChange=a}}var rX={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,n){if("function"!=typeof i)throw TypeError("The listener must be a function");var o=new s(i,a||e,n),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function n(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,a=i.length,n=Array(a);s<a;s++)n[s]=i[s].fn;return n},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,s,a,n){var o=r?r+e:e;if(!this._events[o])return!1;var l,h,d=this._events[o],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,s),!0;case 5:return d.fn.call(d.context,t,i,s,a),!0;case 6:return d.fn.call(d.context,t,i,s,a,n),!0}for(h=1,l=Array(u-1);h<u;h++)l[h-1]=arguments[h];d.fn.apply(d.context,l)}else{var c,f=d.length;for(h=0;h<f;h++)switch(d[h].once&&this.removeListener(e,d[h].fn,void 0,!0),u){case 1:d[h].fn.call(d[h].context);break;case 2:d[h].fn.call(d[h].context,t);break;case 3:d[h].fn.call(d[h].context,t,i);break;case 4:d[h].fn.call(d[h].context,t,i,s);break;default:if(!l)for(c=1,l=Array(u-1);c<u;c++)l[c-1]=arguments[c];d[h].fn.apply(d[h].context,l)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,s){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return n(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||s&&!o.once||i&&o.context!==i||n(this,a);else{for(var l=0,h=[],d=o.length;l<d;l++)(o[l].fn!==t||s&&!o[l].once||i&&o[l].context!==i)&&h.push(o[l]);h.length?this._events[a]=1===h.length?h[0]:h:n(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&n(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(rX);var rJ=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}
5(rX.exports);class rQ{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let s=e.config;this.hls=e,this.id=t,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;let a=(e,t)=>{(t=t||{}).frag=this.frag,t.id=this.id,e===p.ERROR&&(this.error=t.error),this.hls.trigger(e,t)};this.observer=new rJ,this.observer.on(p.FRAG_DECRYPTED,a),this.observer.on(p.ERROR,a);let n=ew(s.preferManagedMediaSource)||{isTypeSupported:()=>!1},o={mpeg:n.isTypeSupported("audio/mpeg"),mp3:n.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:n.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&"undefined"!=typeof Worker&&(s.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__)){try{s.workerPath?(A.log(`loading Web Worker ${s.workerPath} for "${t}"`),this.workerContext=function(e){let t=new self.URL(e,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}(s.workerPath)):(A.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){let e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e);return{worker:new self.Worker(t),objectURL:t}}()),this.onwmsg=e=>this.onWorkerMessage(e);let{worker:e}=this.workerContext;e.addEventListener("message",this.onwmsg),e.onerror=e=>{let r=Error(`${e.message} (${e.filename}:${e.lineno})`);s.enableWorker=!1,A.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(p.ERROR,{type:v.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:r})},e.postMessage({cmd:"init",typeSupported:o,vendor:"",id:t,config:JSON.stringify(s)})}catch(e){A.warn(`Error setting up "${t}" Web Worker, fallback to inline`,e),this.resetWorker(),this.error=null,this.transmuxer=new rj(this.observer,o,s,"",t)}return}this.transmuxer=new rj(this.observer,o,s,"",t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,i,s,a,n,o,l,h){var d,u;l.transmuxing.start=self.performance.now();let{transmuxer:c}=this,f=a?a.start:s.start,g=s.decryptdata,m=this.frag,p=!(m&&s.cc===m.cc),v=!(m&&l.level===m.level),E=m?l.sn-m.sn:-1,y=this.part?l.part-this.part.index:-1,T=0===E&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),S=!v&&(1===E||0===E&&(1===y||T&&y<=0)),R=self.performance.now();(v||E||0===s.stats.parsing.start)&&(s.stats.parsing.start=R),a&&(y||!S)&&(a.stats.parsing.start=R);let L=!(m&&(null==(d=s.initSegment)?void 0:d.url)===(null==(u=m.initSegment)?void 0:u.url)),b=new rz(p,S,o,v,f,L);if(!S||p||L){A.log(`[transmuxer-interface, ${s.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id} 6 discontinuity: ${p} 7 trackSwitch: ${v} 8 contiguous: ${S} 9 accurateTimeOffset: ${o} 10 timeOffset: ${f} 11 initSegmentChange: ${L}`);let e=new rq(r,i,t,n,h);this.configureTransmuxer(e)}if(this.frag=s,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:g,chunkMeta:l,state:b},e instanceof ArrayBuffer?[e]:[]);else if(c){let t=c.push(e,g,l,b);rY(t)?(c.async=!0,t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")})):(c.async=!1,this.handleTransmuxComplete(t))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);rY(r)||t.async?(rY(r)||(r=Promise.resolve(r)),r.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))}
11handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data;if(!(null!=t&&t.event))return void A.warn(`worker message received with no ${t?"event name":"data"}`);let r=this.hls;if(this.hls)switch(t.event){case"init":{var i;let e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":A[t.data.logType]&&A[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}function rZ(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!r0(e[r].attrs,t[r].attrs))return!1;return!0}function r0(e,t,r){let i=e["STABLE-RENDITION-ID"];return i&&!r?i===t["STABLE-RENDITION-ID"]:!(r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>e[r]!==t[r])}function r1(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class r2{constructor(e){this.buffered=void 0;let t=(t,r,i)=>{if((r>>>=0)>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][t]};this.buffered={get length(){return e.length},end:r=>t("end",r,e.length),start:r=>t("start",r,e.length)}}}class r3{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){let i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(e=>{t=e}),i={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(i,e),r}executeNext(e){let t=this.queues[e];if(t.length){let r=t[0];try{r.execute()}catch(i){A.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${i}`),r.onError(i);let t=this.buffers[e];null!=t&&t.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}let r4=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;function r8(e){let t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}let r5={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},r6=e=>String.fromCharCode(r5[e]||e),r9={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},r7={17:2,18:4,21:6,22:8,23:10,19:13,20:15},ie={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},it={25:2,26:4,29:6,30:8,31:10,27:13,28:15},ir=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class ii{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r="function"==typeof t?t():t;A.log(`${this.time} [${e}] ${r}`)}}}let is=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class ia{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class io{constructor(){this.uchar=" ",this.penState=new ia}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class il{constructor(e){this.chars=[],this.pos=0,this.currPenState=new ia,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<100;e++)this.chars.push(new io);this.logger=e}equals(e){for(let t=0;t<100;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<100;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<100;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}
11setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=100)}moveCursor(e){let t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=r6(e);if(this.pos>=100)return void this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<100;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<100;r++){let i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class ih{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<15;t++)this.rows.push(new il(e));this.logger=e}reset(){for(let e=0;e<15;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<15;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<15;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<15;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<15;e++)this.rows[e].clear();let e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){let i=r.rows[e].cueStartTime,s=this.logger.time;if(null!==i&&null!==s&&i<s)for(let i=0;i<this.nrRollUpRows;i++)this.rows[t-this.nrRollUpRows+i+1].copy(r.rows[e+i])}}this.currRow=t;let r=this.rows[this.currRow];if(null!==e.indent){let t=Math.max(e.indent-1,0);r.setCursor(e.indent),e.color=r.chars[t].penState.foreground}let i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",i=-1;for(let r=0;r<15;r++){let s=this.rows[r].getTextString();s&&(i=r+1,e?t.push("Row "+i+": '"+s+"'"):t.push(s.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class id{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new ih(r),this.nonDisplayedMemory=new ih(r),this.lastOutputScreen=new ih(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),("MODE_PAINT-ON"===this.mode||"MODE_ROLL-UP"===this.mode)&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}
11ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};(t.underline=e%2==1,t.italics=e>=46,t.italics)?t.foreground="white":t.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(e/2)-16],this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&!this.displayedMemory.isEmpty()&&(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e)}}class iu{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;let i=this.logger=new ii;this.channels=[null,new id(e,t,i),new id(e+1,r,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){var r,i,s,a,n,o,l,h;let d=127&t[e],u=127&t[e+1],c=!1,f=null;if(0===d&&0===u)continue;this.logger.log(3,()=>"["+is([t[e],t[e+1]])+"] -> ("+is([d,u])+")");let g=this.cmdHistory;if(d>=16&&d<=31){if(r=d,i=u,(s=g).a===r&&s.b===i){(a=g).a=null,a.b=null,this.logger.log(3,()=>"Repeated command ("+is([d,u])+") is dropped");continue}n=d,o=u,(l=this.cmdHistory).a=n,l.b=o,(c=this.parseCmd(d,u))||(c=this.parseMidrow(d,u)),c||(c=this.parsePAC(d,u)),c||(c=this.parseBackgroundAttributes(d,u))}else{(h=g).a=null,h.b=null}if(!c&&(f=this.parseChars(d,u))){let e=this.currentChannel;e&&e>0?this.channels[e].insertChars(f):this.logger.log(2,"No channel found yet. TEXT-MODE?")}c||f||this.logger.log(2,()=>"Couldn't parse cleaned data "+is([d,u])+" orig: "+is([t[e],t[e+1]]))}}parseCmd(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;let r=20===e||21===e||23===e?1:2,i=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+is([e,t])+")"),!0)}return!1}parsePAC(e,t){let r,i=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,s=(16===e||24===e)&&t>=64&&t<=95;if(!(i||s))return!1;let a=e<=23?1:2;r=t>=64&&t<=95?1===a?r9[e]:ie[e]:1===a?r7[e]:it[e];let n=this.channels[a];return!!n&&(n.setPAC(this.interpretPAC(r,t)),this.currentChannel=a,!0)}interpretPAC(e,t){let r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return i.underline=(1&(r=t>95?t-96:t-64))==1,r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}
11parseChars(e,t){let r,i=null,s=null;if(e>=25?(r=2,s=e-8):(r=1,s=e),s>=17&&s<=19){let e;e=17===s?t+80:18===s?t+112:t+144,this.logger.log(2,()=>"Special char '"+r6(e)+"' in channel "+r),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);return i&&this.logger.log(3,()=>"Char codes = "+is(i).join(",")),i}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;let r={};return 16===e||24===e?(r.background=ir[Math.floor((t-32)/2)],t%2==1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0)),this.channels[e<=23?1:2].setBkgData(r),!0}reset(){var e;for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}(e=this.cmdHistory).a=null,e.b=null}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}}class ic{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var ig=function(){if(null!=M&&M.VTTCue)return self.VTTCue;let e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t||!Array.isArray(e))return!1;let r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];let s=1;for(;s<arguments.length;s++){let t=arguments[s];for(let r in t)e[r]=t[r]}return e}function s(s,a,n){let o={enumerable:!0};this.hasBeenReset=!1;let l="",h=!1,d=s,u=a,c=n,f=null,g="",m=!0,p="auto",v="start",E=50,y="middle",T=50,S="middle";Object.defineProperty(this,"id",i({},o,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(this,"pauseOnExit",i({},o,{get:function(){return h},set:function(e){h=!!e}})),Object.defineProperty(this,"startTime",i({},o,{get:function(){return d},set:function(e){if("number"!=typeof e)throw TypeError("Start time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"endTime",i({},o,{get:function(){return u},set:function(e){if("number"!=typeof e)throw TypeError("End time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"text",i({},o,{get:function(){return c},set:function(e){c=""+e,this.hasBeenReset=!0}})),Object.defineProperty(this,"region",i({},o,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"vertical",i({},o,{get:function(){return g},set:function(t){let i=r(e,t);if(!1===i)throw SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(this,"snapToLines",i({},o,{get:function(){return m},set:function(e){m=!!e,this.hasBeenReset=!0}})),Object.defineProperty(this,"line",i({},o,{get:function(){return p},set:function(e){if("number"!=typeof e&&"auto"!==e)throw SyntaxError("An invalid number or illegal string was specified.");p=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"lineAlign",i({},o,{get:function(){return v},set:function(e){let i=r(t,e);if(!i)throw SyntaxError("An invalid or illegal string was specified.");v=i,this.hasBeenReset=!0}})),Object.defineProperty(this,"position",i({},o,{get:function(){return E},set:function(e){if(e<0||e>100)throw Error("Position must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"positionAlign",i({},o,{get:function(){return y},set:function(e){let i=r(t,e);if(!i)throw SyntaxError("An invalid or illegal string was specified.");y=i,this.hasBeenReset=!0}})),Object.defineProperty(this,"size",i({},o,{get:function(){return T},set:function(e){if(e<0||e>100)throw Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"align",i({},o,{get:function(){return S},set:function(e){let i=r(t,e);if(!i)throw SyntaxError("An invalid or illegal string was specified.");S=i,this.hasBeenReset=!0}})),this.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class im{decode(e,t){if(!e)return"";if("string"!=typeof e)throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}
11function ip(e){function t(e,t,r,i){return(0|e)*3600+(0|t)*60+(0|r)+parseFloat(i||0)}let r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}class iv{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function iE(e,t,r,i){let s=i?e.split(i):[e];for(let e in s){if("string"!=typeof s[e])continue;let i=s[e].split(r);if(2===i.length)t(i[0],i[1])}}let iy=new ig(0,0,""),iT="middle"===iy.align?"middle":"center";function iS(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class iA{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new im,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;function r(){let e=t.buffer,r=0;for(e=iS(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;let i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;let i=(e=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!(null!=i&&i[0]))throw Error("Malformed WebVTT signature.");t.state="HEADER"}let s=!1;for(;t.buffer&&/\r\n|\n/.test(t.buffer);)switch(s?s=!1:e=r(),t.state){case"HEADER":if(/:/.test(e)){var i;i=e,iE(i,function(e,t){},/:/)}else e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new ig(0,0,""),t.state="CUE",-1===e.indexOf("-->")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{!function(e,t,r){let i=e;function s(){let t=ip(e);if(null===t)throw Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=s(),a(),"-->"!==e.slice(0,3))throw Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);e=e.slice(3),a(),t.endTime=s(),a();var n=e;let o=new iv;iE(n,function(e,t){let i;switch(e){case"region":for(let i=r.length-1;i>=0;i--)if(r[i].id===t){o.set(e,r[i].region);break}break;case"vertical":o.alt(e,t,["rl","lr"]);break;case"line":i=t.split(","),o.integer(e,i[0]),o.percent(e,i[0])&&o.set("snapToLines",!1),o.alt(e,i[0],["auto"]),2===i.length&&o.alt("lineAlign",i[1],["start",iT,"end"]);break;case"position":i=t.split(","),o.percent(e,i[0]),2===i.length&&o.alt("positionAlign",i[1],["start",iT,"end","line-left","line-right","auto"]);break;case"size":o.percent(e,t);break;case"align":o.alt(e,t,["start",iT,"end","left","right"])}},/:/,/\s/),t.region=o.get("region",null),t.vertical=o.get("vertical","");let l=o.get("line","auto");"auto"===l&&-1===iy.line&&(l=-1),t.line=l,t.lineAlign=o.get("lineAlign","start"),t.snapToLines=o.get("snapToLines",!0),t.size=o.get("size",100),t.align=o.get("align",iT);let h=o.get("position","auto");"auto"===h&&50===iy.position&&(h="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=h}(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let r=-1!==e.indexOf("-->");if(!e||r&&(s=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw Error("Malformed WebVTT signature.")}catch(e){this.onparsingerror&&this.onparsingerror(e)}return this.onflush&&this.onflush(),this}}let iR=/\r\n|\n\r|\n|\r/g,iL=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return e.slice(r,r+t.length)===t},ib=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!f(t)||!f(r)||!f(i)||!f(s))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=6e4*i,t+=36e5*s},iD=function(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()};function iI(e,t,r){return iD(e.toString())+iD(t.toString())+iD(r)}let i_=function(e,t,r){let i=e[t],s=e[i.prevCC];if(!s||!s.new&&i.new){e.ccOffset=e.presentationOffset=i.start,i.new=!1;return}for(;null!=(a=s)&&a.new;){var a;e.ccOffset+=i.start-s.start,i.new=!1,s=e[(i=s).prevCC]}e.presentationOffset=r},ik="stpp.ttml.im1t",iw=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,iC=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,ix={left:"start",center:"center",right:"end",start:"start",end:"end"};
11function iP(e,t,r,i){let s=eg(new Uint8Array(e),["mdat"]);if(0===s.length)return void i(Error("Could not parse IMSC1 mdat"));let a=s.map(e=>es(e)),n=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return rO(e,t,1/r,i)}(t.baseTime,1,t.timescale);try{a.forEach(e=>r(function(e,t){let r=new DOMParser().parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!r)throw Error("Invalid ttml");let i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(i).reduce((e,t)=>(e[t]=r.getAttribute(`ttp:${t}`)||i[t],e),{}),a="preserve"!==r.getAttribute("xml:space"),n=iM(iO(r,"styling","style")),o=iM(iO(r,"layout","region")),l=iO(r,"body","[begin]");return[].map.call(l,e=>{let r=function e(t,r){return[].slice.call(t.childNodes).reduce((t,i,s)=>{var a;return"br"===i.nodeName&&s?t+"\n":null!=(a=i.childNodes)&&a.length?e(i,r):r?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}(e,a);if(!r||!e.hasAttribute("begin"))return null;let i=iU(e.getAttribute("begin"),s),l=iU(e.getAttribute("dur"),s),h=iU(e.getAttribute("end"),s);if(null===i)throw iN(e);if(null===h){if(null===l)throw iN(e);h=i+l}let d=new ig(i-t,h-t,r);d.id=iI(d.startTime,d.endTime,d.text);let u=o[e.getAttribute("region")],f=function(e,t,r){let i="http://www.w3.org/ns/ttml#styling",s=null,a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return a&&r.hasOwnProperty(a)&&(s=r[a]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((r,a)=>{let n=iF(t,i,a)||iF(e,i,a)||iF(s,i,a);return n&&(r[a]=n),r},{})}(u,n[e.getAttribute("style")],n),{textAlign:g}=f;if(g){let e=ix[g];e&&(d.lineAlign=e),d.align=g}return c(d,f),d}).filter(e=>null!==e)}(e,n)))}catch(e){i(e)}}function iO(e,t,r){let i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function iM(e){return e.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function iF(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function iN(e){return Error(`Could not parse ttml timestamp ${e}`)}function iU(e,t){if(!e)return null;let r=ip(e);return null===r&&(iw.test(e)?r=function(e,t){let r=iw.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return(0|r[1])*3600+(0|r[2])*60+(0|r[3])+i/t.frameRate}(e,t):iC.test(e)&&(r=function(e,t){let r=iC.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}function iB(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function i$(e,t){return!!e&&e.kind===iB(t)&&r1(t,e)}function iG(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class iK{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=1/0,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&f(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&A.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return -1;let r=t.filter((t,r)=>this.isLevelAllowed(t)&&r<=e);return this.clientRect=null,iK.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=1/0,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=1/0,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.
11width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,r){if(!(null!=e&&e.length))return -1;let i=(e,t)=>!t||e.width!==t.width||e.height!==t.height,s=e.length-1,a=Math.max(t,r);for(let t=0;t<e.length;t+=1){let r=e[t];if((r.width>=a||r.height>=a)&&i(r,e[t+1])){s=t;break}}return s}}let iH="[eme]";class iV{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=iV.CDMCleanupPromise?[iV.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=A.debug.bind(A,iH),this.log=A.log.bind(A,iH),this.warn=A.warn.bind(A,iH),this.error=A.error.bind(A,iH),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,i=t[e];if(i)return i.licenseUrl;if(e===F.WIDEVINE&&r)return r;throw Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(e,t,r)=>!!e&&r.indexOf(e)===t,i=t.map(e=>e.audioCodec).filter(r),s=t.map(e=>e.videoCodec).filter(r);return i.length+s.length===0&&s.push("avc1.42e01e"),new Promise((t,r)=>{let a=e=>{let n=e.shift();this.getMediaKeysPromise(n,i,s).then(e=>t({keySystem:n,mediaKeys:e})).catch(t=>{e.length?a(e):t instanceof ij?r(t):r(new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};a(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let e=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===K&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(Error(e))}return r(e,t)}getMediaKeysPromise(e,t,r){let i=function(e,t,r,i){var s,a,n,o;let l;switch(e){case F.FAIRPLAY:l=["cenc","sinf"];break;case F.WIDEVINE:case F.PLAYREADY:l=["cenc"];break;case F.CLEARKEY:l=["cenc","keyids"];break;default:throw Error(`Unknown key-system: ${e}`)}return s=l,a=t,n=r,[{initDataTypes:s,persistentState:(o=i).persistentState||"optional",distinctiveIdentifier:o.distinctiveIdentifier||"optional",sessionTypes:o.sessionTypes||[o.sessionType||"temporary"],audioCapabilities:a.map(e=>({contentType:`audio/mp4; codecs="${e}"`,robustness:o.audioRobustness||"",encryptionScheme:o.audioEncryptionScheme||null})),videoCapabilities:n.map(e=>({contentType:`video/mp4; codecs="${e}"`,robustness:o.videoRobustness||"",encryptionScheme:o.videoEncryptionScheme||null}))}]}(e,t,r,this.config.drmSystemOptions),s=this.keySystemAccessPromises[e],a=null==s?void 0:s.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(i)}`),a=this.requestMediaKeySystemAccess(e,i);let t=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),a.then(r=>{this.log(`Access for key-system "${r.keySystem}" obtained`);let i=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),t.mediaKeys=r.createMediaKeys().then(t=>(this.log(`Media-keys created for "${e}"`),i.then(r=>r?this.setMediaKeysServerCertificate(t,e,r):t))),t.mediaKeys.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),t.mediaKeys})}return a.then(()=>s.mediaKeys)}createMediaKeySessionContext(e){let{decryptdata:t,keySystem:r,mediaKeys:i}=e;this.log(`Creating key-system session "${r}" keyId: ${ea.hexDump(t.keyId||[])}`);let s=i.createSession(),a={decryptdata:t,keySystem:r,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw Error("keyId is null");return ea.hexDump(e.keyId)}updateKeySession(e,t){var r;let i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyID ${ea.hexDump((null==(r=e.decryptdata)?void 0:r.keyId)||[])} 12 } (data length: ${t?t.byteLength:t})`),i.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let i=G(this.config),s=e.map(U).filter(e=>!!e&&-1!==i.indexOf(e));return this.getKeySystemSelectionPromise(s).then(e=>{let{keySystem:i}=e,s=$(i);s?t(s):r(Error(`Unable to find format for key-system "${i}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),i=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${i}`);let s=this.keyIdToKeySessionPromise[r];return s||(s=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(r=>{let{keySystem:s,mediaKeys:a}=r;return this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${i}`),this.attemptSetMediaKeys(s,a).then(()=>{this.throwIfDestroyed();let e=this.createMediaKeySessionContext({keySystem:s,mediaKeys:a,decryptdata:t});return this.generateRequestWithPreferredKeySession(e,"cenc",t.pssh,"playlist-key")})})).catch(e=>this.handleError(e)),s}throwIfDestroyed(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0],!this.hls)throw Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof ij?this.hls.trigger(p.ERROR,e.data):this.hls.trigger(p.ERROR,{type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}
12getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let t=U(e.keyFormat),r=t?[t]:G(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=G(this.config)),0===e.length)throw new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let t,r,{initDataType:i,initData:s}=e;if(this.debug(`"${e.type}" event: init data type: "${i}"`),null===s)return;if("sinf"===i&&this.config.drmSystems[F.FAIRPLAY]){let e=el(new Uint8Array(s));try{let i=P(JSON.parse(e).sinf),s=ey(new Uint8Array(i));if(!s)return;t=s.subarray(8,24),r=F.FAIRPLAY}catch(e){this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let e=function(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;let t={version:0,systemId:"",kids:null,data:null},r=new DataView(e),i=r.getUint32(0);if(e.byteLength!==i&&i>44||0x70737368!==r.getUint32(4)||(t.version=r.getUint32(8)>>>24,t.version>1))return null;t.systemId=ea.hexDump(new Uint8Array(e,12,16));let s=r.getUint32(28);if(0===t.version){if(i-32<s)return null;t.data=new Uint8Array(e,32,s)}else if(1===t.version){t.kids=[];for(let r=0;r<s;r++)t.kids.push(new Uint8Array(e,32+16*r,16))}return t}(s);if(null===e)return;0===e.version&&e.systemId===B.WIDEVINE&&e.data&&(t=e.data.subarray(8,24)),r=function(e){if(e===B.WIDEVINE)return F.WIDEVINE}(e.systemId)}if(!r||!t)return;let a=ea.hexDump(t),{keyIdToKeySessionPromise:n,mediaKeySessions:o}=this,l=n[a];for(let e=0;e<o.length;e++){let r=o[e],h=r.decryptdata;if(h.pssh||!h.keyId)continue;let d=ea.hexDump(h.keyId);if(a===d||-1!==h.uri.replace(/-/g,"").indexOf(a)){l=n[d],delete n[d],h.pssh=new Uint8Array(s),h.keyId=t,l=n[a]=l.then(()=>this.generateRequestWithPreferredKeySession(r,i,s,"encrypted-event-key-match"));break}}l||(l=n[a]=this.getKeySystemSelectionPromise([r]).then(e=>{var r;let{keySystem:n,mediaKeys:o}=e;this.throwIfDestroyed();let l=new eb("ISO-23001-7",a,null!=(r=$(n))?r:"");return l.pssh=new Uint8Array(s),l.keyId=t,this.attemptSetMediaKeys(n,o).then(()=>{this.throwIfDestroyed();let e=this.createMediaKeySessionContext({decryptdata:l,keySystem:n,mediaKeys:o});return this.generateRequestWithPreferredKeySession(e,i,s,"encrypted-event-no-match")})})),l.catch(e=>this.handleError(e))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let i=Promise.all(r).then(()=>{if(!this.media)throw Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===r.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,r,i){var s,a,n;let o=null==(s=this.config.drmSystems)||null==(a=s[e.keySystem])?void 0:a.generateRequest;if(o)try{let i=o.call(this.hls,t,r,e);if(!i)throw Error("Invalid response from configured generateRequest filter");t=i.initDataType,r=e.decryptdata.pssh=i.initData?new Uint8Array(i.initData):null}catch(e){if(this.warn(e.message),null!=(n=this.hls)&&n.config.debug)throw e}if(null===r)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);let l=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${i}": ${l} (init data type: ${t} length: ${r?r.byteLength:null})`);let h=new rJ,d=e._onmessage=t=>{let r=e.mediaKeysSession;if(!r)return void h.emit("error",Error("invalid state"));let{messageType:i,message:s}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${s.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,s).catch(e=>{this.handleError(e),h.emit("error",e)}):"license-release"===i?e.keySystem===F.FAIRPLAY&&(this.updateKeySession(e,O("acknowledged")),this.removeSession(e)):this.warn(`unhandled media ke
12y message type "${i}"`)},u=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void h.emit("error",Error("invalid state"));this.onKeyStatusChange(e);let r=e.keyStatus;h.emit("keyStatus",r),"expired"===r&&(this.warn(`${e.keySystem} expired for key ${l}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",d),e.mediaKeysSession.addEventListener("keystatuseschange",u);let c=new Promise((e,t)=>{h.on("error",t),h.on("keyStatus",r=>{r.startsWith("usable")?e():"output-restricted"===r?t(new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${r}"`)):"expired"===r?t(Error("key expired while generating request")):this.warn(`unhandled key status change "${r}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var t;this.log(`Request generated for key-session "${null==(t=e.mediaKeysSession)?void 0:t.sessionId}" keyId: ${l}`)}).catch(e=>{throw new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},`Error generating key-session request: ${e}`)}).then(()=>c).catch(t=>{throw h.removeAllListeners(),this.removeSession(e),t}).then(()=>(h.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${ea.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${ea.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=new t.loader(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((s,a)=>{let n={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};r.load(n,l,{onSuccess:(e,t,r,i)=>{s(e.data)},onError:(t,r,s,o)=>{a(new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:u({url:n.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,s)=>{a(new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:{url:n.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,r)=>{a(Error("aborted"))}})})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,s)=>{e.setServerCertificate(r).then(s=>{this.log(`setServerCertificate ${s?"success":"not supported by CDM"} (${null==r?void 0:r.byteLength}) on "${t}"`),i(e)}).catch(e=>{s(new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(e=>{throw new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}unpackPlayReadyKeyMessage(e,t){let r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let i=new DOMParser().parseFromString(r,"application/xml"),s=i.querySelectorAll("HttpHeader");if(s.length>0){let t;for(let r=0,i=s.length;r<i;r++){var a,n;let i=null==(a=(t=s[r]).querySelector("name"))?void 0:a.textContent,o=null==(n=t.querySelector("value"))?void 0:n.textContent;i&&o&&e.setRequestHeader(i,o)}}let o=i.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw Error("Cannot find <Challenge> in key message");return O(atob(l))}setupLicenseXHR(e,t,r,i){let s=this.config.licenseXhrSetup;return s?Promise.resolve().then(()=>{if(!r.decryptdata)throw Error("Key removed");return s.call(this.hls,e,t,r,i)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),s.call(this.hls,e,t,r,i)}).then(r=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||i})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((i,s)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let n=new XMLHttpRequest;n.responseType="arraybuffer",n.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return s(Error("invalid state"));if(4===n.readyState)if(200===n.status){this._requestLicenseFailureCount=0;let t=n.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);let r=this.config.licenseResponseCallback;if(r)try{t=r.call(this.hls,n,a,e)}catch(e){this.error(e)}i(t)}else{let o=r.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||n.status>=400&&n.status<500)s(new ij({type:v.KEY_SYSTEM_ERROR,details:E.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:a,data:void 0,code:n.status,text:n.statusText}},`License Request XHR failed (${a}). Status: ${n.status} (${n.statusText})`));else{let r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(e,t).then(i,s)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=n,this.setupLicenseXHR(n,a,e,t).then(t=>{let{xhr:r,licenseChallenge:i}=t;e.keySystem==F.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(r,i)),r.send(i)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},eb.clearKeyUriToKeyIdMap();let r=t.length;iV.CDMCleanupPromise=Promise.all(t.map(e=>this.removeSession(e)).concat(null==e?void 0:e.setMediaKeys(null).cat
12ch(e=>{this.log(`Could not clear media keys: ${e}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,t){let{sessionKeys:r}=t;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){let e=r.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let i=this.mediaKeySessions.indexOf(e);return i>-1&&this.mediaKeySessions.splice(i,1),t.remove().catch(e=>{this.log(`Could not remove session: ${e}`)}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`)})}}}iV.CDMCleanupPromise=void 0;
12class ij extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=Error(t)),this.data=e,e.err=e.error}}!function(e){e.MANIFEST="m",e.AUDIO="a",e.VIDEO="v",e.MUXED="av",e.INIT="i",e.CAPTION="c",e.TIMED_TEXT="tt",e.KEY="k",e.OTHER="o"}(s||(s={})),function(e){e.DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o"}(a||(a={})),function(e){e.OBJECT="CMCD-Object",e.REQUEST="CMCD-Request",e.SESSION="CMCD-Session",e.STATUS="CMCD-Status"}(n||(n={}));let iW={[n.OBJECT]:["br","d","ot","tb"],[n.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[n.SESSION]:["cid","pr","sf","sid","st","v"],[n.STATUS]:["bs","rtp"]};class iY{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(e=>e instanceof iY?e:new iY(e))),this.value=e,this.params=t}}class iq{constructor(e){this.description=void 0,this.description=e}}let iz="Bare Item",iX=/[\x00-\x1f\x7f]+/;function iJ(e,t,r){return Error(`failed to serialize "${Array.isArray(e)?JSON.stringify(e):e instanceof Map?"Map{}":e instanceof Set?"Set{}":"object"==typeof e?JSON.stringify(e):String(e)}" as ${t}`,{cause:r})}function iQ(e){if(e<-0x38d7ea4c67fff||0x38d7ea4c67fff<e)throw iJ(e,"Integer");return e.toString()}function iZ(e){let t=e.description||e.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw iJ(t,"Token");return t}function i0(e){switch(typeof e){case"number":if(!f(e))throw iJ(e,iz);if(Number.isInteger(e))return iQ(e);let t=function e(t,r){if(t<0)return-e(-t,r);let i=Math.pow(10,r);if(!(Math.abs(t*i%1-.5)<Number.EPSILON))return Math.round(t*i)/i;{let e=Math.floor(t*i);return(e%2==0?e:e+1)/i}}(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw iJ(e,"Decimal");let r=t.toString();return r.includes(".")?r:`${r}.0`;case"string":if(iX.test(e))throw iJ(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;case"symbol":return iZ(e);case"boolean":if("boolean"!=typeof e)throw iJ(e,"Boolean");return e?"?1":"?0";case"object":if(e instanceof Date)return`@${iQ(e.getTime()/1e3)}`;if(e instanceof Uint8Array){if(!1===ArrayBuffer.isView(e))throw iJ(e,"Byte Sequence");return`:${btoa(String.fromCharCode(...e))}:`}if(e instanceof iq)return iZ(e);default:throw iJ(e,iz)}}function i1(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw iJ(e,"Key");return e}function i2(e){return null==e?"":Object.entries(e).map(e=>{let[t,r]=e;return!0===r?`;${i1(t)}`:`;${i1(t)}=${i0(r)}`}).join("")}function i3(e){return e instanceof iY?`${i0(e.value)}${i2(e.params)}`:i0(e)}let i4=e=>Math.round(e),i8=e=>100*i4(e/100),i5={br:i4,d:i4,bl:i8,dl:i8,mtp:i8,nor:(e,t)=>(null!=t&&t.baseUrl&&(e=function(e,t){let r=new URL(e),i=new URL(t);if(r.origin!==i.origin)return e;let s=r.pathname.split("/").slice(1),a=i.pathname.split("/").slice(1,-1);for(;s[0]===a[0];)s.shift(),a.shift();for(;a.length;)a.shift(),s.unshift("..");return s.join("/")}(e,t.baseUrl)),encodeURIComponent(e)),rtp:i8,tb:i4};function i6(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!=typeof e)throw iJ(e,"Dict");let r=e instanceof Map?e.entries():Object.entries(e),i=null!=t&&t.whitespace?" ":"";return Array.from(r).map(e=>{let[t,r]=e;r instanceof iY==!1&&(r=new iY(r));let i=i1(t);if(!0===r.value)i+=i2(r.params);else if(i+="=",Array.isArray(r.value)){var s;i+=(s=r,`(${s.value.map(i3).join(" ")})${i2(s.params)}`)}else i+=i3(r);return i}).join(`,${i}`)}(function(e,t){let r={};if(null==e||"object"!=typeof e)return r;let i=Object.keys(e).sort(),s=c({},i5,null==t?void 0:t.formatters),a=null==t?void 0:t.filter;return i.forEach(i=>{var n;if(null!=a&&a(i))return;let o=e[i],l=s[i];(l&&(o=l(o,t)),("v"!==i||1!==o)&&("pr"!=i||1!==o))&&("number"==typeof(n=o)?f(n):null!=n&&""!==n&&!1!==n)&&(("ot"===i||"sf"===i||"st"===i)&&"string"==typeof o&&(o=new iq(o)),r[i]=o)}),r}(e,t),c({whitespace:!1},t)):""}let i9=/CMCD=[^&#]+/;function i7(e,t,r,i){e&&Object.keys(t).forEach(s=>{let a=e.filter(e=>e.groupId===s).map(e=>{let a=c({},e);return a.details=void 0,a.attrs=new b(a.attrs),a.url=a.attrs.URI=se(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),a.groupId=a.attrs["GROUP-ID"]=t[s],a.attrs["PATHWAY-ID"]=i,a});e.push(...a)})}
12function se(e,t,r,i){let s,{HOST:a,PARAMS:n,[r]:o}=i;t&&(s=null==o?void 0:o[t])&&(e=s);let l=new self.URL(e);return a&&!s&&(l.host=a),n&&Object.keys(n).sort().forEach(e=>{e&&l.searchParams.set(e,n[e])}),l.href}let st=/^age:\s*[\d.]+\s*$/im;class sr{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new I,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;let s=this.xhrSetup;s?Promise.resolve().then(()=>{if(this.loader===r&&!this.stats.aborted)return s(r,t.url)}).catch(e=>{if(this.loader===r&&!this.stats.aborted)return r.open("GET",t.url,!0),s(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{this.callbacks.onError({code:r.status,text:e.message},t,r,i)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let i=t.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:a}=r.loadPolicy;if(i)for(let t in i)e.setRequestHeader(t,i[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=s&&f(s)?s:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let i=t.readyState,s=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let i=t.status,a="text"!==t.responseType;if(i>=200&&i<300&&(a&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);let s=a?t.response:t.responseText;if(r.loaded=r.total="arraybuffer"===t.responseType?s.byteLength:s.length,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;let n=this.callbacks.onProgress;if(n&&n(r,e,s,t),!this.callbacks)return;let o={url:t.responseURL,data:s,code:i};this.callbacks.onSuccess(o,r,e,t)}else{let a=s.loadPolicy.errorRetry;tL(a,r.retry,!1,{url:e.url,data:void 0,code:i})?this.retry(a):(A.error(`${i} while loading ${e.url}`),this.callbacks.onError({code:i,text:t.statusText},e,t,r))}}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry;if(tL(e,this.stats.retry,!0))this.retry(e);else{var t;A.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);let e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=tA(e,r.retry),r.retry++,A.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&st.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}let si=/(\d+)-(\d+)\/(\d+)/;class ss{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||sa,this.controller=new self.AbortController,this.stats=new I}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let i=this.stats;if(i.loading.start)throw Error("Loader can only be used once.");i.loading.start=self.performance.now();let s=function(e,t){let r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(c({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),a=r.onProgress,n="arraybuffer"===e.responseType,o=n?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:h}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=l&&f(l)?l:h,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(i,e,this.response)},t.timeout),self.fetch(this.request).then(s=>{this.response=this.loader=s;let o=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=h,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(i,e,this.response)},h-(o-i.loading.start)),!s.ok){let{status:e,statusText:t}=s;throw new sn(t||"fetch, bad network response",e,s)}return(i.loading.first=o,i.total=function(e){let t=e.get("Content-Range");if(t){let e=function(e){let t=si.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(f(e))return e}let r=e.get("Content-Length");if(r)return parseInt(r)}(s.headers)||i.total,a&&f(t.highWaterMark))?this.loadProgressively(s,i,e,t.highWaterMark,a):n?s.arrayBuffer():"json"===e.responseType?s.json():s.text()}).then(s=>{let n=this.response;if(!n)throw Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);let l=s[o];l&&(i.loaded=i.total=l);let h={url:n.url,data:s,code:n.status};
12a&&!f(t.highWaterMark)&&a(i,e,s,n),r.onSuccess(h,i,e,n)}).catch(t=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;let s=t&&t.code||0,a=t?t.message:null;r.onError({code:s,text:a},e,t?t.details:null,i)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=new re,n=e.body.getReader(),o=()=>n.read().then(n=>{if(n.done)return a.dataLength&&s(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let l=n.value,h=l.length;return t.loaded+=h,h<i||a.dataLength?(a.push(l),a.dataLength>=i&&s(t,r,a.flush(),e)):s(t,r,l,e),o()}).catch(()=>Promise.reject());return o()}}function sa(e,t){return new self.Request(e.url,t)}class sn extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}let so=/\s/,sl={newCue(e,t,r,i){let s,a,n,o,l,h=[],d=self.VTTCue||self.TextTrackCue;for(let c=0;c<i.rows.length;c++)if(s=i.rows[c],n=!0,o=0,l="",!s.isEmpty()){var u;for(let e=0;e<s.chars.length;e++)so.test(s.chars[e].uchar)&&n?o++:(l+=s.chars[e].uchar,n=!1);s.cueStartTime=t,t===r&&(r+=1e-4),o>=16?o--:o++;let i=iS(l.trim()),f=iI(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||((a=new d(t,r,i)).id=f,a.line=c+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),h.push(a))}return e&&h.length&&(h.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),h.forEach(t=>e8(e,t))),h}},sh=u(u({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:sr,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.co
12decTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{let e,{fragCurrent:t,partCurrent:r,hls:i}=this,{autoLevelEnabled:s,media:a}=i;if(!t||!a)return;let n=performance.now(),o=r?r.stats:t.stats,l=r?r.duration:t.duration,h=n-o.loading.start,d=i.minAutoLevel;if(o.aborted||o.loaded&&o.loaded===o.total||t.level<=d){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||a.paused||!a.playbackRate||!a.readyState)return;let u=i.mainForwardBufferInfo;if(null===u)return;let c=this.bwEstimator.getEstimateTTFB(),g=Math.abs(a.playbackRate);if(h<=Math.max(c,l/(2*g)*1e3))return;let m=u.len/g,v=o.loading.first?o.loading.first-o.loading.start:-1,E=o.loaded&&v>-1,y=this.getBwEstimate(),T=i.levels,S=T[t.level],R=o.total||Math.max(o.loaded,Math.round(l*S.averageBitrate/8)),L=E?h-v:h;L<1&&E&&(L=Math.min(h,8*o.loaded/y));let b=E?1e3*o.loaded/L:0,D=b?(R-o.loaded)/b:8*R/y+c/1e3;if(D<=m)return;let I=b?8*b:y,_=1/0;for(e=t.level-1;e>d;e--){let t=T[e].maxBitrate;if((_=this.getTimeToLoadFrag(c/1e3,I,l*t,!T[e].details))<m)break}if(_>=D||_>10*l)return;i.nextLoadLevel=i.nextAutoLevel=e,E?this.bwEstimator.sample(h-Math.min(c,v),o.loaded):this.bwEstimator.sampleTTFB(h);let k=T[e].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>k&&this.resetEstimator(k),this.clearTimer(),A.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly; 13 Time to underbuffer: ${m.toFixed(3)} s 14 Estimated load time for current fragment: ${D.toFixed(3)} s 15 Estimated load time for down switch fragment: ${_.toFixed(3)} s 16 TTFB estimate: ${0|v} ms 17 Current BW estimate: ${f(y)?0|y:"Unknown"} bps 18 New BW estimate: ${0|this.getBwEstimate()} bps 19 Switching to level ${e} @ ${0|k} bps`),i.trigger(p.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:o})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(A.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){let e=this.hls.config;return new tx(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(p.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){let r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var i;this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case E.BUFFER_ADD_CODEC_ERROR:case E.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case E.FRAG_LOAD_TIMEOUT:{let e=t.frag,{fragCurrent:r,partCurrent:i}=this;if(e&&r&&e.sn===r.sn&&e.level===r.level){let t=performance.now(),r=i?i.stats:e.stats,s=t-r.loading.start,a=r.loading.first?r.loading.first-r.loading.start:-1;if(r.loaded&&a>-1){let e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(e,a),r.loaded)}else this.bwEstimator.sampleTTFB(s)}}}}
19getTimeToLoadFrag(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)}onLevelLoaded(e,t){let r=this.hls.config,{loading:i}=t.stats,s=i.end-i.start;f(s)&&(this.lastLevelLoadSec=s/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,t){let{frag:r,part:i}=t,s=i?i.stats:r.stats;if(r.type===e0.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let e=i?i.duration:r.duration,t=this.hls.levels[r.level],a=(t.loaded?t.loaded.bytes:0)+s.loaded,n=(t.loaded?t.loaded.duration:0)+e;t.loaded={bytes:a,duration:n},t.realBitrate=Math.round(8*a/n)}if(r.bitrateTest){let e={stats:s,frag:r,part:i,id:r.type};this.onFragBuffered(p.FRAG_BUFFERED,e),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}}onFragBuffered(e,t){let{frag:r,part:i}=t,s=null!=i&&i.stats.loaded?i.stats:r.stats;if(s.aborted||this.ignoreFragment(r))return;let a=s.parsing.end-s.loading.start-Math.min(s.loading.first-s.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,s.loaded),s.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==e0.MAIN||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,s=this.findBestLevel(r,t,e,0,i,1,1);if(s>-1)return s;let a=this.hls.firstLevel,n=Math.min(Math.max(a,t),e);return A.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${n}`),n}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(-1!==e&&(!t||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){let t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}
19_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:i,config:s,minAutoLevel:a}=r,n=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),h=s.abrBandWidthFactor,d=s.abrBandWidthUpFactor;if(l){let e=this.findBestLevel(o,a,i,l,0,h,d);if(e>=0)return e}let u=n?Math.min(n,s.maxStarvationDelay):s.maxStarvationDelay;if(!l){let e=this.bitrateTestDelay;e&&(u=(n?Math.min(n,s.maxLoadingDelay):s.maxLoadingDelay)-e,A.info(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),h=d=1)}let c=this.findBestLevel(o,a,i,l,u,h,d);if(A.info(`[abr] ${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${c}`),c>-1)return c;let f=r.levels[a],g=r.levels[r.loadLevel];return(null==f?void 0:f.bitrate)<(null==g?void 0:g.bitrate)?a:r.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,i,s,a,n){var o,l;let h,d=i+s,c=this.lastLoadedFragLevel,g=-1===c?this.hls.firstLevel:c,{fragCurrent:m,partCurrent:p}=this,{levels:v,allAudioTracks:E,loadLevel:y,config:T}=this.hls;if(1===v.length)return 0;let S=v[g],R=!!(null!=S&&null!=(o=S.details)&&o.live),L=-1===y||-1===c,b="SDR",D=(null==S?void 0:S.frameRate)||0,{audioPreference:I,videoPreference:_}=T,k=this.audioTracksByGroup||(this.audioTracksByGroup=E.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);let i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}}));if(L){if(-1!==this.firstSelection)return this.firstSelection;let i=function(e,t,r,i,s){var a;let n,o,l=Object.keys(e),h=null==i?void 0:i.channels,d=null==i?void 0:i.audioCodec,u=h&&2===parseInt(h),c=!0,g=!1,m=1/0,p=1/0,v=1/0,E=0,y=[],{preferHDR:T,allowedVideoRanges:S}=(n=!1,o=[],(a=t)&&(n="SDR"!==a,o=[a]),s&&(o=s.allowedVideoRanges||to.slice(0),o=(n=void 0!==s.preferHDR?s.preferHDR:function(){if("function"==typeof matchMedia){let e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())?o.filter(e=>"SDR"!==e):["SDR"]),{preferHDR:n,allowedVideoRanges:o});for(let t=l.length;t--;){let r=e[l[t]];c=r.channels[2]>0,m=Math.min(m,r.minHeight),p=Math.min(p,r.minFramerate),v=Math.min(v,r.minBitrate);let i=S.filter(e=>r.videoRanges[e]>0);i.length>0&&(g=!0,y=i)}m=f(m)?m:0,p=f(p)?p:0;let A=Math.max(1080,m),R=Math.max(30,p);return r=Math.max(v=f(v)?v:r,r),g||(t=void 0,y=[]),{codecSet:l.reduce((t,i)=>{let s=e[i];if(i===t)return t;if(s.minBitrate>r)return tM(i,`min bitrate of ${s.minBitrate} > current estimate of ${r}`),t;if(!s.hasDefaultAudio)return tM(i,"no renditions with default or auto-select sound found"),t;if(d&&i.indexOf(d.substring(0,4))%5!=0)return tM(i,`audio codec preference "${d}" not found`),t;if(h&&!u){if(!s.channels[h])return tM(i,`no renditions with ${h} channel sound found (channels options: ${Object.keys(s.channels)})`),t}else if((!d||u)&&c&&0===s.channels["2"])return tM(i,"no renditions with stereo sound found"),t;return s.minHeight>A?(tM(i,`min resolution of ${s.minHeight} > maximum of ${A}`),t):s.minFramerate>R?(tM(i,`min framerate of ${s.minFramerate} > maximum of ${R}`),t):y.some(e=>s.videoRanges[e]>0)?s.maxScore<E?(tM(i,`max score of ${s.maxScore} < selected max of ${E}`),t):t&&(eF(i)>=eF(t)||s.fragmentError>e[t].fragmentError)?t:(E=s.maxScore,i):(tM(i,`no variants with VIDEO-RANGE of ${JSON.stringify(y)} found`),t)},void 0),videoRanges:y,preferHDR:T,minFramerate:p,minBitrate:v}}(this.codecTiers||(this.codecTiers=v.slice(t,r+1).reduce((e,t)=>{if(!t.codecSet)return e;let r=t.audioGroups,i=e[t.codecSet];i||(e[t.codecSet]=i={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}
19),i.minBitrate=Math.min(i.minBitrate,t.bitrate);let s=Math.min(t.height,t.width);return i.minHeight=Math.min(i.minHeight,s),i.minFramerate=Math.min(i.minFramerate,t.frameRate),i.maxScore=Math.max(i.maxScore,t.score),i.fragmentError+=t.fragmentError,i.videoRanges[t.videoRange]=(i.videoRanges[t.videoRange]||0)+1,r&&r.forEach(e=>{if(!e)return;let t=k.groups[e];t&&(i.hasDefaultAudio=i.hasDefaultAudio||k.hasDefaultAudio?t.hasDefault:t.hasAutoSelect||!k.hasDefaultAudio&&!k.hasAutoSelectAudio,Object.keys(t.channels).forEach(e=>{i.channels[e]=(i.channels[e]||0)+t.channels[e]}))}),e},{})),b,e,I,_),{codecSet:s,videoRanges:a,minFramerate:n,minBitrate:o,preferHDR:l}=i;h=s,b=l?a[a.length-1]:a[0],D=n,e=Math.max(e,o),A.log(`[abr] picked start tier ${JSON.stringify(i)}`)}else h=null==S?void 0:S.codecSet,b=null==S?void 0:S.videoRange;let w=p?p.duration:m?m.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3,x=[];for(let o=r;o>=t;o--){let t,m=v[o],E=o>g;if(!m)continue;if(T.useMediaCapabilities&&!m.supportedResult&&!m.supportedPromise){let t=navigator.mediaCapabilities;"function"==typeof(null==t?void 0:t.decodingInfo)&&function(e,t,r,i,s,a){let n=e.audioCodec?e.audioGroups:null,o=null==a?void 0:a.audioCodec,l=null==a?void 0:a.channels,h=l?parseInt(l):o?1/0:2,d=null;if(null!=n&&n.length)try{d=1===n.length&&n[0]?t.groups[n[0]].channels:n.reduce((e,r)=>{if(r){let i=t.groups[r];if(!i)throw Error(`Audio track group ${r} not found`);Object.keys(i.channels).forEach(t=>{e[t]=(e[t]||0)+i.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(s,8e6))||!!d&&f(h)&&Object.keys(d).some(e=>parseInt(e)>h)}(m,k,b,D,e,I)?(m.supportedPromise=function(e,t,r){let i=e.videoCodec,s=e.audioCodec;if(!i||!s||!r)return Promise.resolve(tP);let a={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},n=e.videoRange;"SDR"!==n&&(a.transferFunction=n.toLowerCase());let o=i.split(",").map(e=>({type:"media-source",video:u(u({},a),{},{contentType:eO(e,"video")})}));return s&&e.audioGroups&&e.audioGroups.forEach(e=>{var r;e&&(null==(r=t.groups[e])||r.tracks.forEach(t=>{if(t.groupId===e){let e=parseFloat(t.channels||"");f(e)&&e>2&&o.push.apply(o,s.split(",").map(t=>({type:"media-source",audio:{contentType:eO(t,"audio"),channels:""+e}})))}}))}),Promise.all(o.map(e=>{let t=function(e){let{audio:t,video:r}=e,i=r||t;if(i){let e=i.contentType.split('"')[1];if(r)return`r${r.height}x${r.width}f${Math.ceil(r.framerate)}${r.transferFunction||"sd"}_${e}_${Math.ceil(r.bitrate/1e5)}`;if(t)return`c${t.channels}${t.spatialRendering?"s":"n"}_${e}`}return""}(e);return tO[t]||(tO[t]=r.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:o,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:o,decodingInfoResults:[],error:e}))}(m,k,t),m.supportedPromise.then(e=>{if(!this.hls)return;m.supportedResult=e;let t=this.hls.levels,r=t.indexOf(m);e.error?A.warn(`[abr] MediaCapabilities decodingInfo error: "${e.error}" for level ${r} ${JSON.stringify(e)}`):!e.supported&&(A.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${r} ${JSON.stringify(e)}`),r>-1&&t.length>1&&(A.log(`[abr] Removing unsupported level ${r}`),this.hls.removeLevel(r)))})):m.supportedResult=tP}if(h&&m.codecSet!==h||b&&m.videoRange!==b||E&&D>m.frameRate||!E&&D>0&&D<m.frameRate||m.supportedResult&&!(null!=(l=m.supportedResult.decodingInfoResults)&&l[0].smooth)){x.push(o);continue}let _=m.details,P=(p?null==_?void 0:_.partTarget:null==_?void 0:_.averagetargetduration)||w;t=E?n*e:a*e;let O=w&&i>=2*w&&0===s?v[o].averageBitrate:v[o].maxBitrate,M=this.getTimeToLoadFrag(C,t,O*P,void 0===_);if(t>=O&&(o===c||0===m.loadError&&0===m.fragmentError)&&(M<=C||!f(M)||R&&!this.bitrateTestDelay||M<d)){let e=this.forcedAutoLevel;return o!==y&&(-1===e||e!==y)&&(x.length&&A.trace(`[abr] Skipped level(s) ${x.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${v[x[0]].codecs}" ${v[x[0]].videoRange}; not compatible with "${S.codecs}" ${b}`),A.info(`[abr] switch candidate:${g}->${o} adjustedbw(${Math.round(t)})-bitrate=${Math.round(t-O)} ttfb:${C.toFixed(1)} avgDuration:${P.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${M.toFixed(1)}
19 firstSelection:${L} codecSet:${h} videoRange:${b} hls.loadLevel:${y}`)),L&&(this.firstSelection=o),o}}return -1}set nextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:r}=this.hls,i=Math.min(Math.max(e,r),t);this._nextAutoLevel!==i&&(this.nextAutoLevelKey="",this._nextAutoLevel=i)}},bufferController:class{constructor(e){var t;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=e=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{let{media:e,mediaSource:t}=this;this.log("Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(p.MEDIA_ATTACHED,{media:e,mediaSource:t})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:e,_objectUrl:t}=this;e!==t&&A.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e;let r="[buffer-controller]";this.appendSource=(t=ew(e.config.preferManagedMediaSource),"undefined"!=typeof self&&t===self.ManagedMediaSource),this.log=A.log.bind(A,r),this.warn=A.warn.bind(A,r),this.error=A.error.bind(A,r),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.BUFFER_RESET,this.onBufferReset,this),e.on(p.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.BUFFER_EOS,this.onBufferEos,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.FRAG_PARSED,this.onFragParsed,this),e.on(p.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.BUFFER_RESET,this.onBufferReset,this),e.off(p.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.BUFFER_EOS,this.onBufferEos,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.FRAG_PARSED,this.onFragParsed,this),e.off(p.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new r3(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(!t.audio||t.video)&&t.altAudio||(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media,i=ew(this.appendSource);if(r&&i){var s;let e=this.mediaSource=new i;this.log(`created media source: ${null==(s=e.constructor)?void 0:s.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming));let t=this._objectUrl=self.URL.createObjectURL(e);if(this.appendSource)try{r.removeAttribute("src");let i=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||i&&e instanceof i,r8(r),function(e,t){let r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,t),r.load()}catch(e){r.src=t}else r.src=t;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&r8(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.MEDIA_DETACHED,void 0)}
19onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){let t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(t){this.warn(`onBufferReset ${e}`,t)}}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length,i=Object.keys(t);if(i.forEach(e=>{if(r){let r=this.tracks[e];if(r&&"function"==typeof r.buffer.changeType){var i;let{id:s,codec:a,levelCodec:n,container:o,metadata:l}=t[e],h=e$(r.codec,r.levelCodec),d=null==h?void 0:h.replace(r4,"$1"),u=e$(a,n),c=null==(i=u)?void 0:i.replace(r4,"$1");if(u&&d!==c){"audio"===e.slice(0,5)&&(u=eB(u,this.appendSource));let t=`${o};codecs=${u}`;this.appendChangeType(e,t),this.log(`switching codec ${h} to ${u}`),this.tracks[e]={buffer:r.buffer,codec:a,container:o,levelCodec:n,metadata:l,id:s}}}}else this.pendingTracks[e]=t[e]}),r)return;let s=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==s&&(this.log(`${s} bufferCodec event(s) expected ${i.join(",")}`),this.bufferCodecEventsExpected=s),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}appendChangeType(e,t){let{operationQueue:r}=this;r.append({execute:()=>{let i=this.sourceBuffer[e];i&&(this.log(`changing ${e} sourceBuffer type to ${t}`),i.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}},e,!!this.pendingTracks[e])}onBufferAppending(e,t){let{hls:r,operationQueue:i,tracks:s}=this,{data:a,type:n,frag:o,part:l,chunkMeta:h}=t,d=h.buffering[n],u=self.performance.now();d.start=u;let c=o.stats.buffering,f=l?l.stats.buffering:null;0===c.start&&(c.start=u),f&&0===f.start&&(f.start=u);let g=s.audio,m=!1;"audio"===n&&(null==g?void 0:g.container)==="audio/mpeg"&&(m=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);let y=o.start;i.append({execute:()=>{if(d.executeStart=self.performance.now(),m){let e=this.sourceBuffer[n];if(e){let t=y-e.timestampOffset;Math.abs(t)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${y} (delta: ${t}) sn: ${o.sn})`),e.timestampOffset=y)}}this.appendExecutor(a,n)},onStart:()=>{},onComplete:()=>{let e=self.performance.now();d.executeEnd=d.end=e,0===c.first&&(c.first=e),f&&0===f.first&&(f.first=e);let{sourceBuffer:t}=this,r={};for(let e in t)r[e]=tW.getBuffered(t[e]);this.appendErrors[n]=0,"audio"===n||"video"===n?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(p.BUFFER_APPENDED,{type:n,frag:o,part:l,chunkMeta:h,parent:o.type,timeRanges:r})},onError:e=>{let t={type:v.MEDIA_ERROR,parent:o.type,details:E.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:l,chunkMeta:h,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=E.BUFFER_FULL_ERROR;else{let e=++this.appendErrors[n];t.details=E.BUFFER_APPEND_ERROR,this.warn(`Failed ${e}/${r.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer`),e>=r.config.appendErrorMaxRetry&&(t.fatal=!0)}r.trigger(p.ERROR,t)}},n,!!this.pendingTracks[n])}onBufferFlushing(e,t){let{operationQueue:r}=this,i=e=>({execute:this.removeExecutor.bind(this,e,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(p.BUFFER_FLUSHED,{type:e})},onError:t=>{this.warn(`Failed to remove from ${e} SourceBuffer`,t)}});t.type?r.append(i(t.type),t.type):this.getSourceBufferTypes().forEach(e=>{r.append(i(e),e)})}onFragParsed(e,t){let{frag:r,part:i}=t,s=[],a=i?i.elementaryStreams:r.elementaryStreams;a[_.AUDIOVIDEO]?s.push("audiovideo"):(a[_.AUDIO]&&s.push("audio"),a[_.VIDEO]&&s.push("video"));let n=()=>{let e=self.performance.now();r.stats.buffering.end=e,i&&(i.stats.buffering.end=e);let t=i?i.stats:r.stats;this.hls.trigger(p.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})};0===s.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(n,s)}onFragChanged(e,t){this.trimBuffers()}
19onBufferEos(e,t){this.getSourceBufferTypes().reduce((e,r)=>{let i=this.sourceBuffer[r];return i&&(!t.type||t.type===r)&&(i.ending=!0,i.ended||(i.ended=!0,this.log(`${r} sourceBuffer now EOS`))),e&&!!(!i||i.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(e=>{let t=this.sourceBuffer[e];t&&(t.ending=!1)});let{mediaSource:e}=this;if(!e||"open"!==e.readyState){e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),e.endOfStream()}))}onLevelUpdated(e,t){let{details:r}=t;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){let{hls:e,details:t,media:r}=this;if(!r||null===t||!this.getSourceBufferTypes().length)return;let i=e.config,s=r.currentTime,a=t.levelTargetDuration,n=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(f(n)&&n>0){let e=Math.max(n,a),t=Math.floor(s/a)*a-e;this.flushBackBuffer(s,a,t)}if(f(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){let e=Math.max(Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),a),t=Math.floor(s/a)*a+e;this.flushFrontBuffer(s,a,t)}}flushBackBuffer(e,t,r){let{details:i,sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{let n=s[a];if(n){let s=tW.getBuffered(n);if(s.length>0&&r>s.start(0)){if(this.hls.trigger(p.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=i&&i.live)this.hls.trigger(p.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(n.ended&&s.end(s.length-1)-e<2*t)return void this.log(`Cannot flush ${a} back buffer while SourceBuffer is in ended state`);this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:a})}}})}flushFrontBuffer(e,t,r){let{sourceBuffer:i}=this;this.getSourceBufferTypes().forEach(s=>{let a=i[s];if(a){let i=tW.getBuffered(a),n=i.length;if(n<2)return;let o=i.start(n-1),l=i.end(n-1);if(r>o||e>=o&&e<=l)return;if(a.ended&&e-l<2*t)return void this.log(`Cannot flush ${s} front buffer while SourceBuffer is in ended state`);this.hls.trigger(p.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:s})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;let{details:e,hls:t,media:r,mediaSource:i}=this,s=e.fragments[0].start+e.totalduration,a=r.duration,n=f(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(e)):(s>n&&s>a||!f(a))&&(this.log(`Updating Media Source duration to ${s.toFixed(3)}`),i.duration=s)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){let i=Math.max(0,r[0].start),s=Math.max(i,i+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${i}-${s}.`),t.setLiveSeekableRange(i,s)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,i=Object.keys(r).length;if(i&&(!e||2===i||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};let e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(p.BUFFER_CREATED,{tracks:this.tracks}),e.forEach(e=>{t.executeNext(e)});else{let e=Error("could not create source buffer for media codec(s)");this.hls.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let s in e)if(!t[s]){var i;let a=e[s];if(!a)throw Error(`source buffer exists for track ${s}, however track does not`);let n=(null==(i=a.levelCodec)?void 0:i.indexOf(","))===-1?a.levelCodec:a.codec;n&&"audio"===s.slice(0,5)&&(n=eB(n,this.appendSource));let o=`${a.container};codecs=${n}`;this.log(`creating sourceBuffer(${o})`);try{let e=t[s]=r.addSourceBuffer(o);this.addBufferListener(s,"updatestart",this._onSBUpdateStart),this.addBufferListener(s,"updateend",this._onSBUpdateEnd),this.addBufferListener(s,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(s,"bufferedchange",(e,t)=>{let r=t.removedRanges;null!=r&&r.length&&this.hls.trigger(p.BUFFER_FLUSHED,{type:s})}),this.tracks[s]={buffer:e,codec:n,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(e){this.error(`error while trying to add sourceBuffer: ${e.message}`),this.hls.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:o})}}}get mediaSrc(){var e,t;let r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if((null==(t=this.mediaSource)?void 0:t.readyState)==="closed")return void this.resetBuffer(e);let{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;let i=Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(r=this.mediaSource)?void 0:r.readyState}`);this.error(`${i}`,t),this.hls.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});let s=this.operationQueue.current(e);s&&s.onError(i)}removeExecutor(e,t,r){let{media:i,mediaSource:s,operationQueue:a,sourceBuffer:n}=this,o=n[e];if(!i||!s||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let l=f(i.duration)?i.duration:1/0,h=f(s.duration)?s.duration:1/0,d=Math.max(0,t),u=Math.min(r,l,h);u>d&&(!o.ending||o.ended)?(o.ended=!1,this.log(`Removing [${d},${u}] from the ${e} SourceBuffer`),o.remove(d,u)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getSourceBufferTypes();if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this;Promise.all(t.map(e=>r.appendBlocker(e))).then(()=>
19{e(),t.forEach(e=>{let t=this.sourceBuffer[e];null!=t&&t.updating||r.shiftAndExecuteNext(e)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let i=this.sourceBuffer[e];if(!i)return;let s=r.bind(this,e);this.listeners[e].push({event:t,listener:s}),i.addEventListener(t,s)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(e=>{t.removeEventListener(e.event,e.listener)})}},capLevelController:iK,errorController:class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=A.log.bind(A,"[info]:"),this.warn=A.warn.bind(A,"[warning]:"),this.error=A.error.bind(A,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(p.ERROR,this.onError,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(p.ERROR,this.onError,this),e.off(p.ERROR,this.onErrorOut,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===e0.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,i,s,a;if(t.fatal)return;let n=this.hls,o=t.context;switch(t.details){case E.FRAG_LOAD_ERROR:case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_ERROR:case E.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case E.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap){t.errorAction={action:t_.DoNothing,flags:tk.None};return}case E.FRAG_GAP:case E.FRAG_DECRYPT_ERROR:t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=t_.SendAlternateToPenaltyBox;return;case E.LEVEL_EMPTY_ERROR:case E.LEVEL_PARSING_ERROR:{let e=t.parent===e0.MAIN?t.level:n.loadLevel;t.details===E.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(a=s.levelDetails)&&a.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case E.LEVEL_LOAD_ERROR:case E.LEVEL_LOAD_TIMEOUT:"number"==typeof(null==o?void 0:o.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o.level));return;case E.AUDIO_TRACK_LOAD_ERROR:case E.AUDIO_TRACK_LOAD_TIMEOUT:case E.SUBTITLE_LOAD_ERROR:case E.SUBTITLE_TRACK_LOAD_TIMEOUT:if(o){let e=n.levels[n.loadLevel];e&&(o.type===eZ.AUDIO_TRACK&&e.hasAudioGroup(o.groupId)||o.type===eZ.SUBTITLE_TRACK&&e.hasSubtitleGroup(o.groupId))&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=t_.SendAlternateToPenaltyBox,t.errorAction.flags=tk.MoveAllAlternatesMatchingHost)}return;case E.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let e=n.levels[n.loadLevel],r=null==e?void 0:e.attrs["HDCP-LEVEL"];r?t.errorAction={action:t_.SendAlternateToPenaltyBox,flags:tk.MoveAllAlternatesMatchingHDCP,hdcpLevel:r}:this.keySystemError(t)}return;case E.BUFFER_ADD_CODEC_ERROR:case E.REMUX_ALLOC_ERROR:case E.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:n.loadLevel);return;case E.INTERNAL_EXCEPTION:case E.BUFFER_APPENDING_ERROR:case E.BUFFER_FULL_ERROR:case E.LEVEL_SWITCH_ERROR:case E.BUFFER_STALLED_ERROR:case E.BUFFER_SEEK_OVER_HOLE:case E.BUFFER_NUDGE_ON_STALL:t.errorAction={action:t_.DoNothing,flags:tk.None};return}t.type===v.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){let r=tS(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(tL(r,i,tT(e),e.response))return{action:t_.RetryRequest,flags:tk.None,retryConfig:r,retryCount:i};let s=this.getLevelSwitchAction(e,t);return r&&(s.retryConfig=r,s.retryCount=i),s}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:s,keyLoadPolicy:a}=t.config,n=tS(e.details.startsWith("key")?a:s,e),o=t.levels.reduce((e,t)=>
19e+t.fragmentError,0);if(i&&(e.details!==E.FRAG_GAP&&i.fragmentError++,tL(n,o,tT(e),e.response)))return{action:t_.RetryRequest,flags:tk.None,retryConfig:n,retryCount:o};let l=this.getLevelSwitchAction(e,r);return n&&(l.retryConfig=n,l.retryCount=o),l}getLevelSwitchAction(e,t){let r=this.hls;null==t&&(t=r.loadLevel);let i=this.hls.levels[t];if(i){var s,a,n,o;let t=e.details;i.loadError++,t===E.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1,{levels:h,loadLevel:d,minAutoLevel:u,maxAutoLevel:c}=r;r.autoLevelEnabled||(r.loadLevel=-1);let f=null==(s=e.frag)?void 0:s.type,g=(f===e0.AUDIO&&t===E.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===E.BUFFER_ADD_CODEC_ERROR||t===E.BUFFER_APPEND_ERROR))&&h.some(e=>{let{audioCodec:t}=e;return i.audioCodec!==t}),m="video"===e.sourceBufferName&&(t===E.BUFFER_ADD_CODEC_ERROR||t===E.BUFFER_APPEND_ERROR)&&h.some(e=>{let{codecSet:t,audioCodec:r}=e;return i.codecSet!==t&&i.audioCodec===r}),{type:p,groupId:v}=null!=(a=e.context)?a:{};for(let r=h.length;r--;){let s=(r+d)%h.length;if(s!==d&&s>=u&&s<=c&&0===h[s].loadError){let r=h[s];if(t===E.FRAG_GAP&&f===e0.MAIN&&e.frag){let t=h[s].details;if(t){let r=tD(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else if(p===eZ.AUDIO_TRACK&&r.hasAudioGroup(v)||p===eZ.SUBTITLE_TRACK&&r.hasSubtitleGroup(v))continue;else if(f===e0.AUDIO&&null!=(n=i.audioGroups)&&n.some(e=>r.hasAudioGroup(e))||f===e0.SUBTITLE&&null!=(o=i.subtitleGroups)&&o.some(e=>r.hasSubtitleGroup(e))||g&&i.audioCodec===r.audioCodec||!g&&i.audioCodec!==r.audioCodec||m&&i.codecSet===r.codecSet)continue;l=s;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:t_.SendAlternateToPenaltyBox,flags:tk.None,nextAutoLevel:l}}return{action:t_.SendAlternateToPenaltyBox,flags:tk.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case t_.DoNothing:break;case t_.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===E.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0;
19case t_.RetryRequest:}if(t.fatal)return void this.hls.stopLoad()}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:i,hdcpLevel:s,nextAutoLevel:a}=r;switch(i){case tk.None:this.switchLevel(e,a);break;case tk.MoveAllAlternatesMatchingHDCP:s&&(t.maxHdcpLevel=tn[tn.indexOf(s)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let i=performance.now();if(t){if(this.lastTime){let e=i-this.lastTime,s=r-this.lastDroppedFrames,a=t-this.lastDecodedFrames,n=1e3*s/e,o=this.hls;if(o.trigger(p.FPS_DROP,{currentDropped:s,currentDecoded:a,totalDroppedFrames:r}),n>0&&s>o.config.fpsDroppedMonitoringThreshold*a){let e=o.currentLevel;A.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(p.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:K,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:sl,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends t7{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",e0.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;
19e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.ERROR,this.onError,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(p.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.ERROR,this.onError,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(p.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=t9.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let r,{frag:i,success:s}=t;if(this.fragPrevious=i,this.state=t9.IDLE,!s)return;let a=this.tracksBuffered[this.currentTrackId];if(!a)return;let n=i.start;for(let e=0;e<a.length;e++)if(n>=a[e].start&&n<=a[e].end){r=a[e];break}let o=i.start+i.duration;r?r.end=o:(r={start:n,end:o},a.push(r)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null)}onBufferFlushing(e,t){let{startOffset:r,endOffset:i}=t;if(0===r&&i!==1/0){let e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let r=0;r<t.length;){if(t[r].end<=e){t.shift();continue}if(t[r].start<e)t[r].start=e;else break;r++}}),this.fragmentTracker.removeFragmentsInRange(r,e,e0.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===e0.MAIN){var r;null!=(r=this.media)&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(null==r?void 0:r.type)===e0.SUBTITLE&&(t.details===E.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==t9.STOPPED&&(this.state=t9.IDLE))}onSubtitleTracksUpdated(e,t){let{subtitleTracks:r}=t;if(this.levels&&rZ(this.levels,r)){this.levels=r.map(e=>new tu(e));return}this.tracksBuffered=[],this.levels=r.map(e=>{let t=new tu(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,1/0,e0.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!(null!=(r=this.levels)&&r.length)||-1===this.currentTrackId)return void this.clearInterval();let i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var r,i;let{currentTrackId:s,levels:a}=this,{details:n,id:o}=t;if(!a)return void this.warn(`Subtitle tracks were reset while loading level ${o}`);let l=a[o];if(o>=a.length||!l)return;this.log(`Subtitle track ${o} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let h=0;if(n.live||null!=(r=l.details)&&r.live){let e=this.mainDetails;if(n.deltaUpdateFailed||!e)return;let t=e.fragments[0];l.details?0===(h=this.alignPlaylists(n,l.details,null==(i=this.levelLastLoaded)?void 0:i.details))&&t&&tp(n,h=t.start):n.hasProgramDateTime&&e.hasProgramDateTime?(tQ(n,e),h=n.fragments[0].start):t&&tp(n,h=t.start)}l.details=n,this.levelLastLoaded=l,o===s&&(this.startFragRequested||!this.mainDetails&&n.live||this.setStartPosition(this.mainDetails||n,h),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===t9.IDLE&&(tD(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,i=t.decryptdata,s=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&null!=i&&i.key&&i.iv&&"AES-128"===i.method){let e=performance.now();
19this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer).catch(e=>{throw s.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{let i=performance.now();s.trigger(p.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=t9.IDLE})}}doTick(){if(!this.media){this.state=t9.IDLE;return}if(this.state===t9.IDLE){let{currentTrackId:e,levels:t}=this,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;let{config:i}=this,s=this.getLoadPosition(),{end:a,len:n}=tW.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s,i.maxBufferHole),o=this.getFwdBufferInfo(this.media,e0.MAIN),l=r.details;if(n>this.getMaxBufferLength(null==o?void 0:o.len)+l.levelTargetDuration)return;let h=l.fragments,d=h.length,u=l.edge,c=null,f=this.fragPrevious;if(a<u){let e=i.maxFragLookUpTolerance;(c=tD(f,h,Math.max(h[0].start,a),a>u-e?0:e))||!f||!(f.start<h[0].start)||(c=h[0])}else c=h[d-1];if(!c)return;if("initSegment"!==(c=this.mapToInitFragWhenRequired(c)).sn){let e=h[c.sn-l.startSN-1];e&&e.cc===c.cc&&this.fragmentTracker.getState(e)===tG.NOT_LOADED&&(c=e)}this.fragmentTracker.getState(c)===tG.NOT_LOADED&&this.loadFragment(c,r,a)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,"initSegment"===e.sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new r2(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends tw{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null,t=e9(this.media.textTracks);for(let r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}let r=this.findTrackForTextTrack(e);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(p.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),e9(this.media.textTracks).forEac
19h(e=>{e5(e)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,groupId:i,details:s}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==i)return void this.warn(`Subtitle track with id:${r} and group:${i} not found in active group ${null==a?void 0:a.groupId}`);let n=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.subtitleGroups||null,i=this.groupIds,s=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>(null==i?void 0:i.indexOf(e))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;let t=this.hls.config.subtitlePreference;if(!s&&t){this.selectDefaultTrack=!1;let r=tF(t,e);if(r>-1)s=e[r];else{let e=tF(t,this.tracks);s=this.tracks[e]}}let i=this.findTrackId(s);-1===i&&s&&(i=this.findTrackId(null)),this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger(p.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:e}),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){let t=this.tracksInGroup,r=this.selectDefaultTrack;for(let i=0;i<t.length;i++){let s=t[i];if((!r||s.default)&&(r||e)&&(!e||tN(s,e)))return i}if(e){for(let r=0;r<t.length;r++){let i=t[r];if(r0(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){let i=t[r];if(r0(e.attrs,i.attrs,["LANGUAGE"]))return r}}return -1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++)if(r1(t[r],e))return r}return -1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==eZ.SUBTITLE_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let r=this.currentTrack;if(r&&tN(e,r))return r;let i=tF(e,this.tracksInGroup);if(i>-1){let e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}{if(r)return null;let i=tF(e,t);if(i>-1)return t[i]}}}return null}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){let r=t.id,i=t.groupId,s=t.url;if(e)try{s=e.addDirectives(s)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(p.SUBTITLE_TRACK_LOADING,{url:s,id:r,groupId:i,deliveryDirectives:e||null})}}toggleTrackModes(){let e,{media:t}=this;if(!t)return;let r=e9(t.textTracks),i=this.currentTrack;if(i&&((e=r.filter(e=>r1(i,e))[0])||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(r).forEach(t=>{"disabled"!==t.mode&&t!==e&&(t.mode="disabled")}),e){let t=this.subtitleDisplay?"showing":"hidden";e.mode!==t&&(e.mode=t)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!f(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),!i)return void this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:e});let s=!!i.details&&!i.details.live;if(e===this.trackId&&i===r&&s)return;this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));let{id:a,groupId:n="",name:o,type:l,url:h}=i;this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:a,groupId:n,name:o,type:l,url:h});let d=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(d)}},timelineController:class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=iG(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}}
19,e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){let e=new ic(this,"textTrack1"),t=new ic(this,"textTrack2"),r=new ic(this,"textTrack3"),i=new ic(this,"textTrack4");this.cea608Parser1=new iu(1,e,t),this.cea608Parser2=new iu(3,r,i)}}addCues(e,t,r,i,s){let a=!1;for(let e=s.length;e--;){var n,o;let i=s[e],l=(n=i[0],o=i[1],Math.min(o,r)-Math.max(n,t));if(l>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),a=!0,l/(r-t)>.5))return}if(a||s.push([t,r]),this.config.renderTextTracksNatively){let s=this.captionsTracks[e];this.Cues.newCue(s,t,r,i)}else{let s=this.Cues.newCue(null,t,r,i);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:s,track:e})}}onInitPtsFound(e,t){let{frag:r,id:i,initPTS:s,timescale:a}=t,{unparsedVttFrags:n}=this;"main"===i&&(this.initPTS[r.cc]={baseTime:s,timescale:a}),n.length&&(this.unparsedVttFrags=[],n.forEach(e=>{this.onFragLoaded(p.FRAG_LOADED,e)}))}getExistingTrack(e,t){let{media:r}=this;if(r)for(let i=0;i<r.textTracks.length;i++){let s=r.textTracks[i];if(i$(s,{name:e,lang:t,attrs:{}}))return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:i}=this,{label:s,languageCode:a}=t[e],n=this.getExistingTrack(s,a);if(n)r[e]=n,e5(r[e]),e4(r[e],i);else{let t=this.createTextTrack("captions",s,a);t&&(t[e]=!0,r[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,r){let i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{e5(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=iG(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let e=0;e<t.length;e++)e5(t[e])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===ik);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(rZ(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let e=this.media,t=e?e9(e.textTracks):null;if(this.tracks.forEach((e,r)=>{let i;if(t){let r=null;for(let i=0;i<t.length;i++)if(t[i]&&i$(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)e5(i);else{let t=iB(e);(i=this.createTextTrack(t,e.name,e.lang))&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=t&&t.length){let e=t.filter(e=>null!==e).map(e=>e.label);e.length&&A.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}
19}else if(this.tracks.length){let e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{let t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;let r=`textTrack${t[1]}`,i=this.captionsProperties[r];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===e0.MAIN){var r,i;let{cea608Parser1:e,cea608Parser2:s,lastSn:a}=this,{cc:n,sn:o}=t.frag,l=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;e&&s&&(o!==a+1||o===a&&l!==this.lastPartIndex+1||n!==this.lastCc)&&(e.reset(),s.reset()),this.lastCc=n,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){let{frag:r,payload:i}=t;if(r.type===e0.SUBTITLE)if(i.byteLength){let e=r.decryptdata,s="stats"in t;if(null==e||!e.encrypted||s){let e=this.tracks[r.level],s=this.vttCCs;s[r.cc]||(s[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===ik?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;iP(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{A.log(`Failed to parse IMSC1: ${t}`),r.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;let{frag:r,payload:i}=e,{initPTS:s,unparsedVttFrags:a}=this,n=s.length-1;if(!s[r.cc]&&-1===n)return void a.push(e);let o=this.hls;!function(e,t,r,i,s,a,n){let o,l=new iA,h=es(new Uint8Array(e)).trim().replace(iR,"\n").split("\n"),d=[],u=t?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return rO(e,9e4,1/t)}(t.baseTime,t.timescale):0,c="00:00.000",f=0,g=0,m=!0;l.oncue=function(e){let a=r[i],n=r.ccOffset,l=(f-u)/9e4;if(null!=a&&a.new&&(void 0!==g?n=r.ccOffset=a.start:i_(r,i,l)),l){if(!t){o=Error("Missing initPTS for VTT MPEGTS");return}n=l-r.presentationOffset}let h=e.endTime-e.startTime,c=rB((e.startTime+n-g)*9e4,9e4*s)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+h,0);let m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=iI(e.startTime,e.endTime,m)),e.endTime>0&&d.push(e)},l.onparsingerror=function(e){o=e},l.onflush=function(){if(o)return void n(o);a(d)},h.forEach(e=>{if(m)if(iL(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{iL(e,"LOCAL:")?c=e.slice(6):iL(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{g=ib(c)/1e3}catch(e){o=e}return}else""===e&&(m=!1);l.parse(e+"\n")}),l.flush()}(null!=(t=r.initSegment)&&t.data?eT(r.initSegment.data,new Uint8Array(i)):i,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,e=>{this._appendCues(e,r.level),o.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{let s="Missing initPTS for VTT MPEGTS"===t.message;s?a.push(e):this._fallbackToIMSC1(r,i),A.log(`Failed to parse VTT cue: ${t}`),s&&n>r.cc||o.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||iP(t,this.initPTS[e.cc],()=>{r.textCodec=ik,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach(e=>e8(r,e))}else{let i=this.tracks[t];if(!i)return;let s=i.default?"default":"subtitles"+t;r.trigger(p.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===e0.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();let{cea608Parser1:r,cea608Parser2:i}=this;if(!this.enabled||!r||!i)return;let{frag:s,samples:a}=t;if(s.type!==e0.MAIN||"NONE"!==this.closedCaptionsForLevel(s))for(let e=0;e<a.length;e++){let t=a[e].bytes;if(t){let s=this.extractCea608Data(t);r.addData(a[e].pts,s[0]),i.addData(a[e].pts,s[1])}}}onBufferFlushing(e,t){let{startOffset:r,endOffset:i,endOffsetSubtitles:s,type:a}=t,{media:n}=this;
19if(n&&!(n.currentTime<i)){if(!a||"video"===a){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>e6(e[t],r,i))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==s){let{textTracks:e}=this;Object.keys(e).forEach(t=>e6(e[t],r,s))}}}extractCea608Data(e){let t=[[],[]],r=31&e[0],i=2;for(let s=0;s<r;s++){let r=e[i++],s=127&e[i++],a=127&e[i++];if((0!==s||0!==a)&&(4&r)!=0){let e=3&r;(0===e||1===e)&&(t[e].push(s),t[e].push(a))}}return t}},audioStreamController:class extends t7{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",e0.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(p.ERROR,this.onError,this),e.on(p.BUFFER_RESET,this.onBufferReset,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(p.ERROR,this.onError,this),e.off(p.BUFFER_RESET,this.onBufferReset,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,t){let{frag:r,id:i,initPTS:s,timescale:a}=t;if("main"===i){let e=r.cc;this.initPTS[r.cc]={baseTime:s,timescale:a},this.log(`InitPTS for cc: ${e} found from main: ${s}`),this.videoTrackCC=e,this.state===t9.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=t9.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),t>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=t9.IDLE):(this.loadedmetadata=!1,this.state=t9.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){var e,t;switch(this.state){case t9.IDLE:this.doTickIdle();break;case t9.WAITING_TRACK:{let{levels:t,trackId:r}=this,i=null==t||null==(e=t[r])?void 0:e.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=t9.WAITING_INIT_PTS}break}case t9.FRAG_LOADING_WAITING_RETRY:{let e=performance.now(),r=this.retryDate;if(!r||e>=r||null!=(t=this.media)&&t.seeking){let{levels:e,trackId:t}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==e?void 0:e[t])||null),this.state=t9.IDLE}break}case t9.WAITING_INIT_PTS:{let e=this.waitingData;if(e){let{frag:t,part:r,cache:i,complete:s}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=t9.FRAG_LOADING;let e={frag:t,part:r,payload:i.flush(),networkDetails:null};this._handleFragmentLoadProgress(e),s&&super._handleFragmentLoadComplete(e)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${t.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let e=this.getLoadPosition(),r=tW.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole);0>tI(r.end,this.config.maxFragLookUpTolerance,t)&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${r.end} is needed`),this.clearWaitingFragment())}}else this.state=t9.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=t9.IDLE)}
19resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:i}=this,s=e.config;if(!r&&(this.startFragRequested||!s.startFragPrefetch)||!(null!=t&&t[i]))return;let a=t[i],n=a.details;if(!n||n.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(n)){this.state=t9.WAITING_TRACK;return}let o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,_.AUDIO,e0.AUDIO));let l=this.getFwdBufferInfo(o,e0.AUDIO);if(null===l)return;let{bufferedTrack:h,switchingTrack:d}=this;if(!d&&this._streamEnded(l,n)){e.trigger(p.BUFFER_EOS,{type:"audio"}),this.state=t9.ENDED;return}let u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,e0.MAIN),c=l.len,f=this.getMaxBufferLength(null==u?void 0:u.len),g=n.fragments,m=g[0].start,v=this.flushing?this.getLoadPosition():l.end;if(d&&r){let e=this.getLoadPosition();h&&!r0(d.attrs,h.attrs)&&(v=e),n.PTSKnown&&e<m&&(l.end>m||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=m+.05)}if(c>=f&&!d&&v<g[g.length-1].start)return;let E=this.getNextFragment(v,n),y=!1;if(E&&this.isLoopLoading(E,v)&&(y=!!E.gap,E=this.getNextFragmentLoopLoading(E,n,l,e0.MAIN,f)),!E){this.bufferFlushed=!0;return}let T=u&&E.start>u.end+n.targetduration;if(T||!(null!=u&&u.len)&&l.len){let e=this.getAppendedFrag(E.start,e0.MAIN);if(null===e||(y||(y=!!e.gap||!!T&&0===u.len),T&&!y||y&&l.nextStart&&l.nextStart<e.end))return}this.loadFragment(E,a,v)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,t){let{audioTracks:r}=t;this.resetTransmuxer(),this.levels=r.map(e=>new tu(e))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=t9.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=t9.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(p.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r,i;if(null==this.mainDetails){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:a,id:n}=t;if(!s)return void this.warn(`Audio tracks were reset while loading level ${n}`);this.log(`Audio track ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);let o=s[n],l=0;if(a.live||null!=(r=o.details)&&r.live){this.checkLiveUpdate(a);let e=this.mainDetails;if(a.deltaUpdateFailed||!e)return;!o.details&&a.hasProgramDateTime&&e.hasProgramDateTime?(tQ(a,e),l=a.fragments[0].start):l=this.alignPlaylists(a,o.details,null==(i=this.levelLastLoaded)?void 0:i.details)}o.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(this.mainDetails||a,l),this.state!==t9.WAITING_TRACK||this.waitForCdnTuneIn(a)||(this.state=t9.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:i,payload:s}=e,{config:a,trackId:n,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);let l=o[n];if(!l)return void this.warn("Audio track is undefined on fragment load progress");let h=l.details;if(!h){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let d=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",u=this.transmuxer;u||(u=this.transmuxer=new rQ(this.hls,e0.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let c=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==c){let e=i?i.index:-1,t=new tY(r.level,r.sn,r.stats.chunkCount,s.byteLength,e,-1!==e);u.push(s,f,d,"",r,i,h.totalduration,!1,t,c)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${h.startSN} ,${h.endSN}],track ${n}`);let{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new re,complete:!1};e.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=t9.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:i}
19=t;if(r.type!==e0.AUDIO){if(!this.loadedmetadata&&r.type===e0.MAIN){let e=this.videoBuffer||this.media;e&&tW.getBuffered(e).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r))return void this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);if("initSegment"!==r.sn){this.fragPrevious=r;let e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(p.AUDIO_TRACK_SWITCHED,u({},e)))}this.fragBufferedComplete(r,i)}onError(e,t){var r;if(t.fatal){this.state=t9.ERROR;return}switch(t.details){case E.FRAG_GAP:case E.FRAG_PARSING_ERROR:case E.FRAG_DECRYPT_ERROR:case E.FRAG_LOAD_ERROR:case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_ERROR:case E.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(e0.AUDIO,t);break;case E.AUDIO_TRACK_LOAD_ERROR:case E.AUDIO_TRACK_LOAD_TIMEOUT:case E.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==t9.WAITING_TRACK||(null==(r=t.context)?void 0:r.type)!==eZ.AUDIO_TRACK||(this.state=t9.IDLE);break;case E.BUFFER_APPEND_ERROR:case E.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===E.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,1/0,"audio"));break;case E.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,t){let{type:r}=t;r!==_.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,t){let{type:r}=t;if(r!==_.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===t9.ENDED&&(this.state=t9.IDLE);let e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,r,e0.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;let r="audio",{hls:i}=this,{remuxResult:s,chunkMeta:a}=e,n=this.getCurrentContext(a);if(!n)return void this.resetWhenMissingContext(a);let{frag:o,part:l,level:h}=n,{details:d}=h,{audio:u,text:f,id3:g,initSegment:m}=s;if(this.fragContextChanged(o)||!d)return void this.fragmentTracker.removeFragment(o);if(this.state=t9.PARSING,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=m&&m.tracks){let e=o.initSegment||o;this._bufferInitSegment(h,m.tracks,e,a),i.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:m.tracks})}if(u){let{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[_.AUDIO]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(_.AUDIO,e,t,r,i),this.bufferFragmentData(u,o,l,a)}if(null!=g&&null!=(t=g.samples)&&t.length){let e=c({id:r,frag:o,details:d},g);i.trigger(p.FRAG_PARSING_METADATA,e)}if(f){let e=c({id:r,frag:o,details:d},f);i.trigger(p.FRAG_PARSING_USERDATA,e)}}_bufferInitSegment(e,t,r,i){if(this.state!==t9.PARSING)return;t.video&&delete t.video;let s=t.audio;if(!s)return;s.id="audio";let a=e.audioCodec;this.log(`Init audio buffer, container:${s.container}, codecs[level/parsed]=[${a}/${s.codec}]`),a&&1===a.split(",").length&&(s.levelCodec=a),this.hls.trigger(p.BUFFER_CODECS,t);let n=s.initSegment;if(null!=n&&n.byteLength){let e={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:n};this.hls.trigger(p.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){let i=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||i===tG.NOT_LOADED||i===tG.PARTIAL){var s;if("initSegment"===e.sn)this._loadInitSegment(e,t);else if(null!=(s=t.details)&&s.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=t9.WAITING_INIT_PTS;let r=this.mainDetails;r&&r.fragments[0].start!==t.details.fragments[0].start&&tQ(t.details,r)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){let{media:t,bufferedTrack:r}=this,i=null==r?void 0:r.attrs,s=e.attrs;t&&i&&(i.CHANNELS!==s.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,1/0,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(p.AUDIO_TRACK_SWITCHED,u({},e))}}
19,audioTrackController:class extends tw{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(p.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:i,details:s}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==i)return void this.warn(`Audio track with id:${r} and group:${i} not found in active group ${null==a?void 0:a.groupId}`);let n=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.audioGroups||null,i=this.groupIds,s=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>(null==i?void 0:i.indexOf(e))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;let t=this.hls.config.audioPreference;if(!s&&t){let r=tF(t,e,tU);if(r>-1)s=e[r];else{let e=tF(t,this.tracks);s=this.tracks[e]}}let i=this.findTrackId(s);-1===i&&s&&(i=this.findTrackId(null)),this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==r?void 0:r.join(",")}`),this.hls.trigger(p.AUDIO_TRACKS_UPDATED,{audioTracks:e});let n=this.trackId;if(-1!==i&&-1===n)this.setAudioTrack(i);else if(e.length&&-1===n){var a;let t=Error(`No audio track selected for current audio group-ID(s): ${null==(a=this.groupIds)?void 0:a.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}else this.shouldReloadPlaylist(s)&&this.setAudioTrack(this.trackId)}onError(e,t){!t.fatal&&t.context&&(t.context.type!==eZ.AUDIO_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||(this.requestScheduled=-1,this.checkRetry(t)))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let r=this.allAudioTracks;
19if(this.selectDefaultTrack=!1,r.length){let i=this.currentTrack;if(i&&tN(e,i,tU))return i;let s=tF(e,this.tracksInGroup,tU);if(s>-1){let e=this.tracksInGroup[s];return this.setAudioTrack(s),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);let s=function(e,t,r,i,s){let a=t[i],n=t.reduce((e,t,r)=>{let i=t.uri;return(e[i]||(e[i]=[])).push(r),e},{})[a.uri];n.length>1&&(i=Math.max.apply(Math,n));let o=a.videoRange,l=a.frameRate,h=a.codecSet.substring(0,4),d=tB(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==h)return!1;let i=t.audioGroups;return tF(e,r.filter(e=>!i||-1!==i.indexOf(e.groupId)),s)>-1});return d>-1?d:tB(t,i,t=>{let i=t.audioGroups;return tF(e,r.filter(e=>!i||-1!==i.indexOf(e.groupId)),s)>-1})}(e,t.levels,r,i,tU);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){let t=tF(e,r);if(t>-1)return r[t]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,i=t[e],s=i.details&&!i.details.live;if(e===this.trackId&&i===r&&s||(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(p.AUDIO_TRACK_SWITCHING,u({},i)),s))return;let a=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||tN(e,i,tU)))return r}if(e){let{name:r,lang:i,assocLang:s,characteristics:a,audioCodec:n,channels:o}=e;for(let e=0;e<t.length;e++)if(tN({name:r,lang:i,assocLang:s,characteristics:a,audioCodec:n,channels:o},t[e],tU))return e;for(let r=0;r<t.length;r++){let i=t[r];if(r0(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){let i=t[r];if(r0(e.attrs,i.attrs,["LANGUAGE"]))return r}}return -1}loadPlaylist(e){let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();let r=t.id,i=t.groupId,s=t.url;if(e)try{s=e.addDirectives(s)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${i}`),this.clearTimer(),this.hls.trigger(p.AUDIO_TRACK_LOADING,{url:s,id:r,groupId:i,deliveryDirectives:e||null})}}},emeController:iV,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:s.MANIFEST,su:!this.initialized})}catch(e){A.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{let t=e.frag,r=this.hls.levels[t.level],i=this.getObjectType(t),a={d:1e3*t.duration,ot:i};(i===s.VIDEO||i===s.AUDIO||i==s.MUXED)&&(a.br=r.bitrate/1e3,a.tb=this.getTopBandwidth(i)/1e3,a.bl=this.getBufferLength(i)),this.apply(e,a)}catch(e){A.warn("Could not generate segment CMCD data.",e)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;null!=r&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||function(){try{return crypto.randomUUID()}catch(e){try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(t){let e=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)})}}}(),this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;
19e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:a.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c(t,this.createData());let r=t.ot===s.INIT||t.ot===s.VIDEO||t.ot===s.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);let{includeKeys:i}=this;if(i&&(t=Object.keys(t).reduce((e,r)=>(i.includes(r)&&(e[r]=t[r]),e),{})),this.useHeaders){var a;e.headers||(e.headers={}),a=e.headers,c(a,function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return{};let r=Object.entries(e),i=Object.entries(iW).concat(Object.entries((null==t?void 0:t.customHeaderMap)||{}));return Object.entries(r.reduce((e,t)=>{var r;let[s,a]=t,o=(null==(r=i.find(e=>e[1].includes(s)))?void 0:r[0])||n.REQUEST;return null!=e[o]||(e[o]={}),e[o][s]=a,e},{})).reduce((e,r)=>{let[i,s]=r;return e[i]=i6(s,t),e},{})}(t,void 0))}else e.url=function(e,t,r){let i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return"";let r=i6(e,t);return`CMCD=${encodeURIComponent(r)}`}(t,void 0);if(!i)return e;if(i9.test(e))return e.replace(i9,i);let s=e.includes("?")?"&":"?";return`${e}${s}${i}`}(e.url,t)}getObjectType(e){let{type:t}=e;return"subtitle"===t?s.TIMED_TEXT:"initSegment"===e.sn?s.INIT:"audio"===t?s.AUDIO:"main"===t?this.hls.audioTracks.length?s.VIDEO:s.MUXED:void 0}getTopBandwidth(e){let t,r=0,i=this.hls;if(e===s.AUDIO)t=i.audioTracks;else{let e=i.maxAutoLevel,r=e>-1?e+1:i.levels.length;t=i.levels.slice(0,r)}for(let e of t)e.bitrate>r&&(r=e.bitrate);return r>0?r:NaN}getBufferLength(e){let t=this.hls.media,r=e===s.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*tW.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}},contentSteeringController:class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=A.log.bind(A,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.ERROR,this.onError,this))}
19startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((null==r?void 0:r.action)===t_.SendAlternateToPenaltyBox&&r.flags===tk.MoveAllAlternatesMatchingHost){let e=this.levels,i=this.pathwayPriority,s=this.pathwayId;if(t.context){let{groupId:r,pathwayId:i,type:a}=t.context;r&&e?s=this.getPathwayForGroupId(r,a,s):i&&(s=i)}s in this.penalizedPathways||(this.penalizedPathways[s]=performance.now()),!i&&e&&(i=e.reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==s),r.resolved||A.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${s} levels: ${e?e.length:e} priorities: ${JSON.stringify(i)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this.pathwayPriority=e;let r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{i-r[e]>3e5&&delete r[e]});for(let i=0;i<e.length;i++){let s=e[i];if(s in r)continue;if(s===this.pathwayId)return;let a=this.hls.nextLoadLevel,n=this.hls.levels[a];if((t=this.getLevelsForPathway(s)).length>0){this.log(`Setting Pathway to "${s}"`),this.pathwayId=s,ty(t),this.hls.trigger(p.LEVELS_UPDATED,{levels:t});let e=this.hls.levels[a];n&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==n.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==n.bitrate&&this.log(`Unstable Pathways change from bitrate ${n.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=a);break}}}getPathwayForGroupId(e,t,r){let i=this.getLevelsForPathway(r).concat(this.levels||[]);for(let r=0;r<i.length;r++)if(t===eZ.AUDIO_TRACK&&i[r].hasAudioGroup(e)||t===eZ.SUBTITLE_TRACK&&i[r].hasSubtitleGroup(e))return i[r].pathwayId;return r}clonePathways(e){let t=this.levels;if(!t)return;let r={},i={};e.forEach(e=>{let{ID:s,"BASE-ID":a,"URI-REPLACEMENT":n}=e;if(t.some(e=>e.pathwayId===s))return;let o=this.getLevelsForPathway(a).map(e=>{let t=new b(e.attrs);t["PATHWAY-ID"]=s;let a=t.AUDIO&&`${t.AUDIO}_clone_${s}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${s}`;a&&(r[t.AUDIO]=a,t.AUDIO=a),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);let l=se(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",n),h=new tu({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)h.addGroupId("audio",`${e.audioGroups[t]}_clone_${s}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)h.addGroupId("text",`${e.subtitleGroups[t]}_clone_${s}`);return h});t.push(...o),i7(this.audioTracks,r,n,s),i7(this.subtitleTracks,i,n,s)})}loadSteeringManifest(e){let t,r=this.hls.config,i=r.loader;this.loader&&this.loader.destroy(),this.loader=new i(r);try{t=new self.URL(e)}catch(t){this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if("data:"!==t.protocol){let e=0|(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+e)}let s={responseType:"json",url:t.href},a=r.steeringManifestLoadPolicy.default,n=a.errorRetry||a.timeoutRetry||{},o={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0};this.log(`Requesting steering manifest: ${t}`),this.loader.load(s,o,{onSuccess:(e,r,i,s)=>{this.log(`Loaded steering manifest: "${t}"`);let a=e.data;if(1!==a.VERSION)return void this.log(`Steering VERSION ${a.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=a.TTL;let{"RELOAD-URI":n,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=a;if(n)try{this.uri=new self.URL(n,t).href}catch(e){this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${n}`);return}this.scheduleRefresh(this.uri||i.url),o&&this.clonePathways(o);let h={steeringManifest:a,url:t.toString()};this.hls.trigger(p.STEERING_MANIFEST_LOADED,h),l&&this.updatePathwayPriority(l)},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code){this.enabled=!1,this.log(`Steering manifest ${t.url} no longer available`);return}let s=1e3*this.timeToLoad;if(429===e.code){let e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){let t=e.getResponseHeader("Retry-After");t&&(s=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`);return}this.scheduleRefresh(this.uri||t.url,s)},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}})}scheduleRefresh(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3*this.timeToLoad;this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;let r=null==(t=this.hls)?void 0:t.media;if(r&&!r.ended)return void this.loadSteeringManifest(e);this.scheduleRefresh(e,1e3*this.timeToLoad)},t)}}});
19class sd extends tw{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=this.hls.config.preferManagedMediaSource,s=[],a={},n={},o=!1,l=!1,h=!1;t.levels.forEach(e=>{var t,d;let u=e.attrs,{audioCodec:c,videoCodec:f}=e;(null==(t=c)?void 0:t.indexOf("mp4a.40.34"))!==-1&&(i||(i=/chrome|firefox/i.test(navigator.userAgent)),i&&(e.audioCodec=c=void 0)),c&&(e.audioCodec=c=eB(c,r)),(null==(d=f)?void 0:d.indexOf("avc1"))===0&&(f=e.videoCodec=function(e){let t=e.split(",");for(let e=0;e<t.length;e++){let r=t[e].split(".");if(r.length>2){let i=r.shift()+".";i+=parseInt(r.shift()).toString(16),i+=("000"+parseInt(r.shift()).toString(16)).slice(-4),t[e]=i}}return t.join(",")}(f));let{width:g,height:m,unknownCodecs:p}=e;if(o||(o=!!(g&&m)),l||(l=!!f),h||(h=!!c),null!=p&&p.length||c&&!ex(c,"audio",r)||f&&!ex(f,"video",r))return;let{CODECS:v,"FRAME-RATE":E,"HDCP-LEVEL":y,"PATHWAY-ID":T,RESOLUTION:S,"VIDEO-RANGE":A}=u,R=`${T||"."}-`,L=`${R}${e.bitrate}-${S}-${E}-${v}-${A}-${y}`;if(a[L])if(a[L].uri===e.url||e.attrs["PATHWAY-ID"])a[L].addGroupId("audio",u.AUDIO),a[L].addGroupId("text",u.SUBTITLES);else{let t=n[L]+=1;e.attrs["PATHWAY-ID"]=Array(t+1).join(".");let r=new tu(e);a[L]=r,s.push(r)}else{let t=new tu(e);a[L]=t,n[L]=1,s.push(t)}}),this.filterAndSortMediaOptions(s,t,o,l,h)}filterAndSortMediaOptions(e,t,r,i,s){let a=[],n=[],o=e;if((r||i)&&s&&(o=o.filter(e=>{var t;let{videoCodec:r,videoRange:i,width:s,height:a}=e;return(!!r||!!(s&&a))&&!!(t=i)&&to.indexOf(t)>-1})),0===o.length)return void Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);let e=Error("no level with compatible codecs found in manifest");this.hls.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}});if(t.audioTracks){let{preferManagedMediaSource:e}=this.hls.config;su(a=t.audioTracks.filter(t=>!t.audioCodec||ex(t.audioCodec,"audio",e)))}t.subtitles&&su(n=t.subtitles);let l=o.slice(0);o.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return to.indexOf(e.videoRange)-to.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){let r=eM(e.videoCodec),i=eM(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){let r=eF(e.codecSet),i=eF(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let h=l[0];if(this.steering&&(o=this.steering.filterParsedLevels(o)).length!==l.length){for(let e=0;e<l.length;e++)if(l[e].pathwayId===o[0].pathwayId){h=l[e];break}}this._levels=o;for(let e=0;e<o.length;e++)if(o[e]===h){var d;this._firstLevel=e;let t=h.bitrate,r=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${o.length} level(s) found, first bitrate: ${t}`),(null==(d=this.hls.userConfig)?void 0:d.abrEwmaDefaultEstimate)===void 0){let e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>r&&r===sh.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}let u=s&&!i,c={levels:o,audioTracks:a,subtitleTracks:n,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:s,video:i,altAudio:!u&&a.some(e=>!!e.url)};this.hls.trigger(p.MANIFEST_PARSED,c),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){let r=Error("invalid level idx"),i=e<0;if(this.hls.trigger(p.ERROR,{type:v.OTHER_ERROR,details:E.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,i=this.currentLevel,s=i?i.attrs["PATHWAY-ID"]:void 0,a=t[e],n=a.attrs["PATHWAY-ID"];
19if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&i&&s===n)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${n?" with Pathway "+n:""} from level ${r}${s?" with Pathway "+s:""}`);let o={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(p.LEVEL_SWITCHING,o);let l=a.details;if(!l||l.live){let e=this.switchParams(a.uri,null==i?void 0:i.details,l);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){let e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===eZ.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,t){let{frag:r}=t;if(void 0!==r&&r.type===e0.MAIN){let e=r.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return;let t=this._levels[r.level];null!=t&&t.loadError&&(this.log(`Resetting level error count of ${t.loadError} on frag buffered`),t.loadError=0)}}onLevelLoaded(e,t){var r,i;let{level:s,details:a}=t,n=this._levels[s];if(!n){this.warn(`Invalid level index ${s}`),null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(0===n.fragmentError&&(n.loadError=0),this.playlistLoaded(s,t,n.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let i=r.uri;if(e)try{i=e.addDirectives(i)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}let s=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(null==e?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${s?" Pathway "+s:""} ${i}`),this.clearTimer(),this.hls.trigger(p.LEVEL_LOADING,{url:i,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return -1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;let r=this._levels.filter((t,r)=>r!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));ty(r),this._levels=r,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(p.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,t){let{levels:r}=t;this._levels=r}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(p.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function su(e){let t={};e.forEach(e=>{let r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}class sc{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let r in this.keyUriToKeyInfo){let i=this.keyUriToKeyInfo[r].loader;if(i){var t;if(e&&e!==(null==(t=i.context)?void 0:t.frag.type))return;i.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){for(let e in this.detach(),this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E.KEY_LOAD_ERROR,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;
19return new t2({type:v.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:s,error:r,networkDetails:i})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:i}=e;for(let e=0;e<t.length;e++){let s=t[e];if(i<=s.cc&&("initSegment"===r||"initSegment"===s.sn||r<s.sn)){this.emeController.selectKeySystemFormat(s).then(e=>{s.setKeyFormat(e)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,i,s;t&&e.setKeyFormat(t);let a=e.decryptdata;if(!a){let r=Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,r))}let n=a.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,Error(`Invalid key URI: "${n}"`)));let o=this.keyUriToKeyInfo[n];if(null!=(r=o)&&r.decryptdata.key)return a.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if(null!=(i=o)&&i.keyLoadPromise)switch(null==(s=o.mediaKeySessionContext)?void 0:s.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(t=>(a.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}switch(o=this.keyUriToKeyInfo[n]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if("identity"===a.keyFormat)return this.loadKeyHTTP(o,e);return this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let t=this.emeController.loadKey(r);if(t)return(e.keyLoadPromise=t.then(t=>(e.mediaKeySessionContext=t,r))).catch(t=>{throw e.keyLoadPromise=null,t})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,i=new r.loader(r);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((s,a)=>{let n={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},o=r.keyLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};i.load(n,l,{onSuccess:(e,t,r,i)=>{let{frag:n,keyInfo:o,url:l}=r;if(!n.decryptdata||o!==this.keyUriToKeyInfo[l])return a(this.createKeyLoadError(n,E.KEY_LOAD_ERROR,Error("after key load, decryptdata unset or changed"),i));o.decryptdata.key=n.decryptdata.key=new Uint8Array(e.data),n.keyLoader=null,o.loader=null,s({frag:n,keyInfo:o})},onError:(e,r,i,s)=>{this.resetLoader(r),a(this.createKeyLoadError(t,E.KEY_LOAD_ERROR,Error(`HTTP Error ${e.code} loading key ${e.text}`),i,u({url:n.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),a(this.createKeyLoadError(t,E.KEY_LOAD_TIMEOUT,Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),a(this.createKeyLoadError(t,E.INTERNAL_ABORTED,Error("key loading aborted"),i))}})})}resetLoader(e){let{frag:t,keyInfo:r,url:i}=e,s=r.loader;t.keyLoader===s&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],s&&s.destroy()}}function sf(){return self.SourceBuffer||self.WebKitSourceBuffer}function sg(){if(!ew())return!1;let e=sf();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}
19class sm{constructor(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:i,stalled:s}=this;if(null===i)return;let{currentTime:a,seeking:n}=i,o=this.seeking&&!n,l=!this.seeking&&n;if(this.seeking=n,a!==e){if(this.moved=!0,n||(this.nudgeRetry=0),null!==s){if(this.stallReported){let e=self.performance.now()-s;A.warn(`playback not stuck anymore @${a}, after ${Math.round(e)}ms`),this.stallReported=!1}this.stalled=null}return}if(l||o){this.stalled=null;return}if(i.paused&&!n||i.ended||0===i.playbackRate||!tW.getBuffered(i).length){this.nudgeRetry=0;return}let h=tW.bufferInfo(i,a,0),d=h.nextStart||0;if(n){let e=h.len>2,r=!d||t&&t.start<=a||d-a>2&&!this.fragmentTracker.getPartialFragment(a);if(e||r)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var u;if(!(h.len>0)&&!d)return;let e=Math.max(d,h.start||0)-a,t=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,r=(null==t||null==(u=t.details)?void 0:u.live)?2*t.details.targetduration:2,s=this.fragmentTracker.getPartialFragment(a);if(e>0&&(e<=r||s)){i.paused||this._trySkipBufferHole(s);return}}let c=self.performance.now();if(null===s){this.stalled=c;return}let f=c-s;if(!n&&f>=250&&(this._reportStall(h),!this.media))return;let g=tW.bufferInfo(i,a,r.maxBufferHole);this._tryFixBufferStall(g,f)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:i,media:s}=this;if(null===s)return;let a=s.currentTime,n=i.getPartialFragment(a);!(n&&(this._trySkipBufferHole(n)||!this.media))&&(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(A.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:i}=this;if(!i&&r){this.stallReported=!0;let i=Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);A.warn(i.message),t.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}}
19_trySkipBufferHole(e){let{config:t,hls:r,media:i}=this;if(null===i)return 0;let s=i.currentTime,a=tW.bufferInfo(i,s,0),n=s<a.start?a.start:a.nextStart;if(n){let o=a.len<=t.maxBufferHole,l=a.len>0&&a.len<1&&i.readyState<3,h=n-s;if(h>0&&(o||l)){if(h>t.maxBufferHole){let{fragmentTracker:t}=this,r=!1;if(0===s){let e=t.getAppendedFrag(0,e0.MAIN);e&&n<e.end&&(r=!0)}if(!r){let r=e||t.getAppendedFrag(s,e0.MAIN);if(r){let e=!1,i=r.end;for(;i<n;){let r=t.getPartialFragment(i);if(r)i+=r.duration;else{e=!0;break}}if(e)return 0}}}let a=Math.max(n+.05,s+.1);if(A.warn(`skipping hole, adjusting currentTime from ${s} to ${a}`),this.moved=!0,this.stalled=null,i.currentTime=a,e&&!e.gap){let t=Error(`fragment loaded with buffer holes, seeking from ${s} to ${a}`);r.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:t,reason:t.message,frag:e})}return a}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:i}=this;if(null===r)return;let s=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){let a=s+(i+1)*e.nudgeOffset,n=Error(`Nudging 'currentTime' from ${s} to ${a}`);A.warn(n.message),r.currentTime=a,t.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.BUFFER_NUDGE_ON_STALL,error:n,fatal:!1})}else{let r=Error(`Playhead still not moving while enough data buffered @${s} after ${e.nudgeMaxRetry} nudges`);A.error(r.message),t.trigger(p.ERROR,{type:v.MEDIA_ERROR,details:E.BUFFER_STALLED_ERROR,error:r,fatal:!0})}}}class sp extends t7{constructor(e,t,r){super(e,t,r,"[stream-controller]",e0.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(p.ERROR,this.onError,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(p.ERROR,this.onError,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=r.startLevel;-1===e&&(r.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=r.firstAutoLevel),r.nextLoadLevel=e,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=t9.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=t9.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case t9.WAITING_LEVEL:{let{levels:e,level:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=t9.IDLE}else this.hls.nextLoadLevel!==this.level&&(this.state=t9.IDLE);break}case t9.FRAG_LOADING_WAITING_RETRY:{var e;let t=self.performance.now(),r=this.retryDate;if(!r||t>=r||null!=(e=this.media)&&e.seeking){let{levels:e,level:t}=this,r=null==e?void 0:e[t];this.resetStartWhenNotLoaded(r||null),this.state=t9.IDLE}}}this.state===t9.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:i}=this;if(null===t||!i&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let s=e.nextLoadLevel;if(!(null!=r&&r[s]))return;let a=r[s],n=this.getMainFwdBufferInfo();if(null===n)return;let o=this.getLevelDetails();if(o&&this._streamEnded(n,o)){let e={};this.altAudio&&(e.type="video"),this.hls.trigger(p.BUFFER_EOS,e),this.state=t9.ENDED;return}e.loadLevel!==s&&-1===e.manualLevel&&this.log(`Adapting to level ${s} from level ${this.level}`),this.level=e.nextLoadLevel=s;let l=a.details;if(!l||this.state===t9.WAITING_LEVEL||l.live&&this.levelLastLoaded!==a){this.level=s,this.state=t9.WAITING_LEVEL;return}let h=n.len,d=this.getMaxBufferLength(a.maxBitrate);
19if(h>=d)return;this.backtrackFragment&&this.backtrackFragment.start>n.end&&(this.backtrackFragment=null);let u=this.backtrackFragment?this.backtrackFragment.start:n.end,c=this.getNextFragment(u,l);if(this.couldBacktrack&&!this.fragPrevious&&c&&"initSegment"!==c.sn&&this.fragmentTracker.getState(c)!==tG.OK){var f;let e=(null!=(f=this.backtrackFragment)?f:c).sn-l.startSN,t=l.fragments[e-1];t&&c.cc===t.cc&&(c=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&n.len&&(this.backtrackFragment=null);if(c&&this.isLoopLoading(c,u)){if(!c.gap){let e=this.audioOnly&&!this.altAudio?_.AUDIO:_.VIDEO,t=(e===_.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,e0.MAIN)}c=this.getNextFragmentLoopLoading(c,l,n,e0.MAIN,d)}c&&(!c.initSegment||c.initSegment.data||this.bitrateTest||(c=c.initSegment),this.loadFragment(c,a,u))}loadFragment(e,t,r){let i=this.fragmentTracker.getState(e);this.fragCurrent=e,i===tG.NOT_LOADED||i===tG.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,e0.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,1/0)}nextLevelSwitch(){let{levels:e,media:t}=this;if(null!=t&&t.readyState){let r,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);let s=this.getLevelDetails();if(null!=s&&s.live){let e=this.getMainFwdBufferInfo();if(!e||e.len<2*s.targetduration)return}if(!t.paused&&e){let t=e[this.hls.nextLoadLevel],i=this.fragLastKbps;r=i&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*i)+1:0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let e=this.followingBufferedFrag(a);if(e){this.abortCurrentFrag();let t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(a.end,t+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,r*(this.couldBacktrack?.5:.125)),r*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(i,1/0)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case t9.KEY_LOADING:case t9.FRAG_LOADING:case t9.FRAG_LOADING_WAITING_RETRY:case t9.PARSING:case t9.PARSED:this.state=t9.IDLE}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new sm(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;f(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(null===r||0===r.len)return void this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,i=!1;t.levels.forEach(e=>{let t=e.audioCodec;t&&(r=r||-1!==t.indexOf("mp4a.40.2"),i=i||-1!==t.indexOf("mp4a.40.5"))}),this.audioCodecSwitch=r&&i&&!function(){var e;let t=sf();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==t9.IDLE)return;let i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(i.details))&&(this.state=t9.WAITING_LEVEL)}onLevelLoaded(e,t){var r,i;let{levels:s}=this,a=t.level,n=t.details,o=n.totalduration;if(!s)return void this.warn(`Levels were reset while loading level ${a}`);this.log(`Level ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""}, cc [${n.startCC}, ${n.endCC}] duration:${o}`);let l=s[a],h=this.fragCurrent;h&&(this.state===t9.FRAG_LOADING||this.state===t9.FRAG_LOADING_WAITING_RETRY)&&h.level!==t.level&&h.loader&&this.abortCurrentFrag();let d=0;if(n.live||null!=(r=l.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;d=this.alignPlaylists(n,l.details,null==(i=this.levelLastLoaded)?void 0:i.details)}if(l.details=n,this.levelLastLoaded=l,this.hls.trigger(p.LEVEL_UPDATED,{details:n,level:a}),this.state===t9.WAITING_LEVEL){if(this.waitForCdnTuneIn(n))return;this.state=t9.IDLE}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,d),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:i,payload:s}=e,{levels:a}=this;if(!a)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);let n=a[r.level],o=n.details;if(!o){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let l=n.videoCodec,h=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(n),c=this.transmuxer=this.transmuxer||new rQ(this.hls,e0.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,g=new tY(r.level,r.sn,r.stats.chunkCount,s.byteLength,f,-1!==f),m=this.initPTS[r.cc];c.push(s,d,u,l,r,i,o.totalduration,h,g,m)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();let e=this.hls;r&&(e.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:1/0,type:null}),this.fragmentTracker.removeAllFragments()),e.trigger(p.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,i=!!this.hls.audioTracks[r].url;if(i){let e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=i,this.tick()}onBufferCreated(e,t){let r,i,s=t.tracks,a=!1;for(let e in s){let t=s[e];if("main"===t.id){if(i=e,r=t,"video"===e){let t=s[e];t&&(this.videoBuffer=t.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:i}
19=t;if(r&&r.type!==e0.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===t9.PARSED&&(this.state=t9.IDLE);return}let s=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}onError(e,t){var r;if(t.fatal){this.state=t9.ERROR;return}switch(t.details){case E.FRAG_GAP:case E.FRAG_PARSING_ERROR:case E.FRAG_DECRYPT_ERROR:case E.FRAG_LOAD_ERROR:case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_ERROR:case E.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(e0.MAIN,t);break;case E.LEVEL_LOAD_ERROR:case E.LEVEL_LOAD_TIMEOUT:case E.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==t9.WAITING_LEVEL||(null==(r=t.context)?void 0:r.type)!==eZ.LEVEL||(this.state=t9.IDLE);break;case E.BUFFER_APPEND_ERROR:case E.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===E.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,1/0);break;case E.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}
19checkBuffer(){let{media:e,gapController:t}=this;if(e&&t&&e.readyState){if(this.loadedmetadata||!tW.getBuffered(e).length){let e=this.state!==t9.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,e)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=t9.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,t){let{type:r}=t;if(r!==_.AUDIO||this.audioOnly&&!this.altAudio){let e=(r===_.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(e,r,e0.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log(`could not seek to ${r}, already seeking at ${t}`);let i=tW.getBuffered(e),s=(i.length?i.start(0):0)-r;s>0&&(s<this.config.maxBufferHole||s<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${s} to match buffer start`),r+=s,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:i}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=t9.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let s=e.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),i.trigger(p.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:i}=this,{remuxResult:s,chunkMeta:a}=e,n=this.getCurrentContext(a);if(!n)return void this.resetWhenMissingContext(a);let{frag:o,part:l,level:h}=n,{video:d,text:u,id3:c,initSegment:g}=s,{details:m}=h,v=this.altAudio?void 0:s.audio;if(this.fragContextChanged(o))return void this.fragmentTracker.removeFragment(o);if(this.state=t9.PARSING,g){if(null!=g&&g.tracks){let e=o.initSegment||o;this._bufferInitSegment(h,g.tracks,e,a),i.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:g.tracks})}let e=g.initPTS,t=g.timescale;f(e)&&(this.initPTS[o.cc]={baseTime:e,timescale:t},i.trigger(p.INIT_PTS_FOUND,{frag:o,id:r,initPTS:e,timescale:t}))}if(d&&m&&"initSegment"!==o.sn){let e=m.fragments[o.sn-1-m.startSN],t=o.sn===m.startSN,r=!e||o.cc>e.cc;if(!1!==s.independent){let{startPTS:e,endPTS:i,startDTS:s,endDTS:n}=d;if(l)l.elementaryStreams[d.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:n};else if(d.firstKeyFrame&&d.independent&&1===a.id&&!r&&(this.couldBacktrack=!0),d.dropped&&d.independent){let s=this.getMainFwdBufferInfo(),a=(s?s.end:this.getLoadPosition())+this.config.maxBufferHole,l=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&a<l-this.config.maxBufferHole&&!r)return void this.backtrack(o);r&&(o.gap=!0),o.setElementaryStreamInfo(d.type,o.start,i,o.start,n,!0)}else t&&e>2&&(o.gap=!0);o.setElementaryStreamInfo(d.type,e,i,s,n),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,l,a,t||r)}else{if(!t&&!r)return void this.backtrack(o);o.gap=!0}}if(v){let{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=v;l&&(l.elementaryStreams[_.AUDIO]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(_.AUDIO,e,t,r,i),this.bufferFragmentData(v,o,l,a)}if(m&&null!=c&&null!=(t=c.samples)&&t.length){let e={id:r,frag:o,details:m,samples:c.samples};i.trigger(p.FRAG_PARSING_METADATA,e)}if(m&&u){let e={id:r,frag:o,details:m,samples:u.samples};i.trigger(p.FRAG_PARSING_USERDATA,e)}}_bufferInitSegment(e,t,r,i){if(this.state!==t9.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:s,video:a,audiovideo:n}=t;if(s){let t=e.audioCodec,r=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");let e=s.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===r.indexOf("firefox")&&(t="mp4a.40.5")}t&&-1!==t.indexOf("mp4a.40.5")&&-1!==r.indexOf("android")&&"audio/mpeg"!==s.container&&(t="mp4a.40.2",this.log(`Android: force audio codec to ${t}`)),e.audioCodec&&e.audioCodec!==t&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${t}"`),s.levelCodec=t,s.id="main",this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${t||""}/${e.audioCodec||""}/${s.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),n&&this.log(`Init audiovideo buffer, container:${n.container}, codecs[level/parsed]=[${e.codecs}/${n.codec}]`),this.hls.trigger(p.BUFFER_CODECS,t),Object.keys(t).forEach(e
19=>{let s=t[e].initSegment;null!=s&&s.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:e,data:s,frag:r,part:null,chunkMeta:i,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,e0.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=t9.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){let r=e.currentTime;if(tW.isBuffered(e,r)?t=this.getAppendedFrag(r):tW.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let e=this.fragPlaying,r=t.level;(!e||t.sn!==e.sn||e.level!==r)&&(this.fragPlaying=t,this.hls.trigger(p.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(p.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&f(t)&&f(r.programDateTime))return new Date(r.programDateTime+(t-r.start)*1e3)}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class sv{static get version(){return"1.5.14"}static isMSESupported(){return sg()}static isSupported(){if(!sg())return!1;let e=ew();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(eO(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(eO(t,"audio"))))}static getMediaSource(){return ew()}static get Events(){return p}static get ErrorTypes(){return v}static get ErrorDetails(){return E}static get DefaultConfig(){return sv.defaultConfig?sv.defaultConfig:sh}static set DefaultConfig(e){sv.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new rJ,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,function(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach(function(t){S[t]=e[t]?e[t].bind(e):function(e){let t=self.console[e];return t?t.bind(self.console,`[${e}] >`):y}(t)})}(e,"debug","log","info","warn","error");try{S.log(`Debug logs enabled for "${t}" in hls.js version 1.5.14`)}catch(e){S=T}}else S=T}(e.debug||!1,"Hls instance");let t=this.config=function(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let r=function e(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(e):Object.keys(t).reduce((r,i)=>(r[i]=e(t[i]),r),{}):t}(e),i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{let s=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[s],n=[];
19i.forEach(i=>{let o=`${e}Loading${i}`,l=t[o];if(void 0!==l&&a){n.push(o);let e=r[s].default;switch(t[s]={default:e},i){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}}),n.length&&A.warn(`hls.js config: "${n.join('", "')}" setting(s) are deprecated, use "${s}": ${JSON.stringify(t[s])}`)}),u(u({},r),t)}(sv.DefaultConfig,e);this.userConfig=e,t.progressive&&function(e){let t=e.loader;t!==ss&&t!==sr?(A.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=ss,e.progressive=!0,e.enableSoftwareAES=!0,A.log("[config]: Progressive streaming enabled, using FetchLoader"))}(t);let{abrController:r,bufferController:i,capLevelController:s,errorController:a,fpsController:n}=t,o=new a(this),l=this.abrController=new r(this),h=this.bufferController=new i(this),d=this.capLevelController=new s(this),c=new n(this),f=new e3(this),g=new ts(this),m=t.contentSteeringController,v=m?new m(this):null,E=this.levelController=new sd(this,v),R=new tK(this),L=new sc(this.config),b=this.streamController=new sp(this,R,L);d.setStreamController(b),c.setStreamController(b);let D=[f,E,b];v&&D.splice(1,0,v),this.networkControllers=D;let I=[l,h,d,c,g,R];this.audioTrackController=this.createController(t.audioTrackController,D);let _=t.audioStreamController;_&&D.push(new _(this,R,L)),this.subtitleTrackController=this.createController(t.subtitleTrackController,D);let k=t.subtitleStreamController;k&&D.push(new k(this,R,L)),this.createController(t.timelineController,I),L.emeController=this.emeController=this.createController(t.emeController,I),this.cmcdController=this.createController(t.cmcdController,I),this.latencyController=this.createController(ta,I),this.coreComponents=I,D.push(o);let w=o.onErrorOut;"function"==typeof w&&this.on(p.ERROR,w,o)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.on(e,t,r)}once(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,i=arguments.length>3?arguments[3]:void 0;this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(A.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;let r=e===p.ERROR;this.trigger(p.ERROR,{type:v.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){A.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){A.log("attachMedia"),this._media=e,this.trigger(p.MEDIA_ATTACHING,{media:e})}detachMedia(){A.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,i=this.url=h.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,A.log(`loadSource:${i}`),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e})}
19startLoad(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;A.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){A.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){A.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){A.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){A.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){A.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){A.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){A.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){let e=this.levelController.startLevel;return -1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){A.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(A.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){tn.indexOf(e)>-1&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return -1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){let e,{levels:t,autoLevelCapping:r,maxHdcpLevel:i}=this;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(let r=e;r--;){let e=t[r].attrs["HDCP-LEVEL"];if(e&&e<=i)return r}return e}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}sv.defaultConfig=void 0;var sE=e.i(271645);e.i(50019);var sy=e.i(917796),sT=e.i(54479),sS=e.i(119773),sA=e.i(618566);let sR=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=(0,sA.usePathname)();(0,sE.useEffect)(()=>{t&&e()},[]),(0,sE.useEffect)(()=>{e()},[i,...r])};var sL=e.i(206359),sb=e.i(519448),sD=e.i(67405),sI=e.i(337451);let s_=e=>{let{intlMessages:t,navTranslations:r,pageData:i}=e,{setContextTranslationsAndPageId:s}=(0,sI.useLanguageTranslationsContext)(),a=(0,sA.usePathname)(),[n,l,h]=(0,sD.useMediaContextV2)(),d=(0,sE.useRef)(void 0),{content:u,routeMeta:c}=i,{languageCode:f}=c,{contentType:g}=c??{},m=c?.site;return(0,sE.useEffect)(()=>{c?.permalink!==d.current&&(d.current=c?.permalink,h(i,t))},[i,h,t]),(0,sE.useEffect)(()=>{s(r??[],u?.id??"",g)},[s,r,u?.id,g]),window.Hls=sv,(()=>{let{setCookie:e}=(0,sy.useCookie)();(0,sE.useEffect)(()=>{let t=(0,sT.default)(()=>{e(sS.BROWSER_WIDTH_COOKIE_KEY,window.innerWidth,2592e3)},500,{trailing:!0});return t(),window.addEventListener("resize",t,{passive:!0}),()=>window.removeEventListener("resize",t)},[e])})(),(0,sE.useEffect)(()=>
19{"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.getRegistrations().then(e=>{e.map(e=>e.unregister())})})},[]),sR(()=>(e=>{let t=JSON.parse(localStorage.getItem("userLanguages")||"[]");if(!e||e?.includes(sb.EN))return;let{updatedUserLanguages:r,favouriteLanguage:i}=((e,t)=>{if(!t)return{updatedUserLanguages:e};let r=[...e],i=r.findIndex(e=>e.languageCode===t);return -1!==i?r[i].views+=1:r.push({languageCode:t,views:1}),r.sort((e,t)=>t.views-e.views),{updatedUserLanguages:r,favouriteLanguage:r?.[0]?.languageCode}})(t,e);if(localStorage.setItem("userLanguages",JSON.stringify(r)),i){let e=new Date;e.setTime(e.getTime()+sL.default.YEAR),document.cookie=`${sS.USER_FAVOURITE_LANGUAGE}=${i}; expires=${e.toUTCString()}; path=/`}})(f),!0,[f]),(0,o.jsx)("script",{id:"route-data",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify({languageCode:f,pathOrId:a,site:m,contentType:g})}})}},450451,e=>{"use strict";e.s(["default",()=>o],450451);var t=e.i(857727),r=e.i(271645),i=e.i(174080),s=e.i(618566),a=e.i(637149),n=e.i(882183);function o(e){let{showAd:o}=e,l=(0,s.usePathname)(),{pageContent:h}=(0,a.usePageContext)(),d=h?.pageType==="HOMEPAGE",[u,c]=(0,r.useState)(null);return((0,r.useLayoutEffect)(()=>{c(document.getElementById("slot1-leaderboard-portal"))},[]),(0,r.useLayoutEffect)(()=>{if(u)return u.setAttribute("data-hydrated",""),o?(u.style.removeProperty("display"),u.setAttribute("data-ad-visible",""),d?u.setAttribute("data-ad-homepage",""):u.removeAttribute("data-ad-homepage")):(u.style.display="none",u.removeAttribute("data-ad-visible"),u.removeAttribute("data-ad-homepage")),()=>{u.style.display="none",u.removeAttribute("data-ad-visible"),u.removeAttribute("data-ad-homepage")}},[u,o,d]),u&&o)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{id:"slot1-leaderboard",style:{display:"none"}}),(0,i.createPortal)((0,t.jsx)(n.default,{id:"slot1-leaderboard-ad",changeToMrec:!1,isHomePage:d,variant:"light"},l),u)]}):null}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.